Skip to content

Commit e3903e5

Browse files
authored
Upgrade emdash 0.6 (#12)
## Summary - Bumps `emdash` + `@emdash-cms/cloudflare` to `^0.6.0` - Widens core's `emdash` peer range to `>=0.5.0 <0.7.0` - Regenerates the Stripe webhook body-clone patch for 0.6 - Changeset: core patch, starter minor
2 parents b15c0e8 + 321e810 commit e3903e5

9 files changed

Lines changed: 277 additions & 32 deletions

File tree

.changeset/upgrade-emdash-0.6.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@dashcommerce/core": patch
3+
"@dashcommerce/starter": minor
4+
---
5+
6+
Upgrade to emdash 0.6.0.
7+
8+
- `@dashcommerce/core`: widen `emdash` peer range to `>=0.5.0 <0.7.0`. Bump the bundled devDeps (`emdash`, `@emdash-cms/admin`) to `^0.6.0` so the package builds against current types. No public API changes.
9+
- `@dashcommerce/starter`: bump `emdash` and `@emdash-cms/cloudflare` to `^0.6.0`. 0.6's [release fix for `syncSearchState` FTS-during-field-creation](https://github.com/emdash-cms/emdash/pull/595) eliminates the partial-DDL issue that was truncating collection schemas on Cloudflare D1 setup and throwing mid-seed on Postgres. Storefront surfaced zero typecheck errors on the upgrade — no porting required.
10+
11+
Stripe webhook body-clone patch regenerated for 0.6 (`patches/emdash@0.6.0.patch`) since the upstream `request.clone().json()` fix still isn't in place.

bun.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"bun": ">=1.1.0"
2929
},
3030
"patchedDependencies": {
31-
"emdash@0.5.0": "patches/emdash@0.5.0.patch"
31+
"emdash@0.6.0": "patches/emdash@0.6.0.patch"
3232
}
3333
}

packages/core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"test": "bun test"
6666
},
6767
"peerDependencies": {
68-
"emdash": ">=0.4.0 <0.6.0",
68+
"emdash": ">=0.5.0 <0.7.0",
6969
"react": "^18.0.0 || ^19.0.0",
7070
"react-dom": "^18.0.0 || ^19.0.0"
7171
},
@@ -78,12 +78,12 @@
7878
}
7979
},
8080
"devDependencies": {
81-
"@emdash-cms/admin": "0.5.0",
81+
"@emdash-cms/admin": "^0.6.0",
8282
"@stripe/react-stripe-js": "^3.0.0",
8383
"@stripe/stripe-js": "^5.0.0",
8484
"@types/react": "^19.0.0",
8585
"@types/react-dom": "^19.0.0",
86-
"emdash": "^0.5.0",
86+
"emdash": "^0.6.0",
8787
"react": "^19.0.0",
8888
"react-dom": "^19.0.0",
8989
"tsdown": "^0.20.0",

packages/starter/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"cf:deploy": "bun run build:cf && wrangler deploy --config dist/server/wrangler.json",
1717
"cf:dev": "bun run build:cf && wrangler dev --config dist/server/wrangler.json",
1818
"cf:d1:create": "wrangler d1 create dashcommerce-demo",
19-
"cf:d1:seed": "bun run bootstrap && sqlite3 data.db .dump | grep -v -E '^(PRAGMA|BEGIN|COMMIT|CREATE TABLE sqlite_)' > .emdash/d1-seed.sql && wrangler d1 execute dashcommerce-demo --remote --file=.emdash/d1-seed.sql",
19+
"cf:d1:seed": "node scripts/cf-d1-seed.mjs",
2020
"typecheck": "astro check"
2121
},
2222
"emdash": {
@@ -31,11 +31,11 @@
3131
"@astrojs/react": "^5.0.0",
3232
"@astrojs/sitemap": "^3.4.0",
3333
"@dashcommerce/core": "workspace:*",
34-
"@emdash-cms/cloudflare": "^0.5.0",
34+
"@emdash-cms/cloudflare": "^0.6.0",
3535
"@stripe/react-stripe-js": "^6.0.0",
3636
"@stripe/stripe-js": "^9.0.0",
3737
"astro": "^6.0.0",
38-
"emdash": "^0.5.0",
38+
"emdash": "^0.6.0",
3939
"react": "^19.0.0",
4040
"react-dom": "^19.0.0"
4141
},
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Produce a D1-safe SQL dump from local data.db.
4+
*
5+
* Why a dedicated script (not just sqlite3 .dump | grep):
6+
* - SQLite's `.dump` represents FTS5 virtual tables as INSERT INTO sqlite_schema(...).
7+
* D1 rejects any write to sqlite_schema/sqlite_master with "table sqlite_master
8+
* may not be modified", so those statements must go.
9+
* - FTS5 triggers that live on the host tables (e.g. _emdash_fts_products_insert)
10+
* also write into the virtual tables' shadow storage. Once we drop the FTS5
11+
* tables, those triggers become broken — cleanest to drop them too.
12+
* - We do all of this on a *copy* of data.db so local dev + search keep working.
13+
*
14+
* Trade-off: full-text search won't work on the D1 deploy until emdash's D1
15+
* adapter learns to materialize FTS5 indexes itself. Everything else (products,
16+
* checkout, admin, blog) lands intact.
17+
*/
18+
19+
import {
20+
copyFileSync,
21+
existsSync,
22+
unlinkSync,
23+
writeFileSync,
24+
} from "node:fs";
25+
import { execFileSync } from "node:child_process";
26+
27+
const SRC = "data.db";
28+
const COPY = "/tmp/dashcommerce-d1-export.db";
29+
const OUT = ".emdash/d1-seed.sql";
30+
31+
if (!existsSync(SRC)) {
32+
console.error(
33+
`[cf-d1-dump] ${SRC} not found. Run \`bun run bootstrap\` first.`,
34+
);
35+
process.exit(1);
36+
}
37+
38+
if (existsSync(COPY)) unlinkSync(COPY);
39+
copyFileSync(SRC, COPY);
40+
41+
function sqlite(cmd) {
42+
return execFileSync("sqlite3", [COPY, cmd]).toString();
43+
}
44+
45+
const ftsTables = sqlite(
46+
"SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '_emdash_fts%' ORDER BY name",
47+
)
48+
.trim()
49+
.split(/\r?\n/)
50+
.filter(Boolean);
51+
52+
for (const t of ftsTables) {
53+
sqlite(`DROP TABLE IF EXISTS "${t}"`);
54+
}
55+
56+
const ftsTriggers = sqlite(
57+
"SELECT name FROM sqlite_master WHERE type='trigger' AND name LIKE '_emdash_fts%' ORDER BY name",
58+
)
59+
.trim()
60+
.split(/\r?\n/)
61+
.filter(Boolean);
62+
63+
for (const t of ftsTriggers) {
64+
sqlite(`DROP TRIGGER IF EXISTS "${t}"`);
65+
}
66+
67+
const raw = execFileSync("sqlite3", [COPY, ".dump"]).toString();
68+
69+
// D1 rejects: header PRAGMAs, explicit transactions, CREATE TABLE on sqlite_*,
70+
// any INSERT into sqlite_schema (the dump's representation of virtual tables).
71+
const safe = raw
72+
.split("\n")
73+
.filter((line) => !/^(PRAGMA|BEGIN|COMMIT|ROLLBACK)\b/.test(line))
74+
.filter((line) => !/^CREATE TABLE\s+"?sqlite_/.test(line))
75+
.filter((line) => !/^INSERT INTO\s+"?sqlite_/.test(line))
76+
.join("\n");
77+
78+
writeFileSync(OUT, safe);
79+
unlinkSync(COPY);
80+
81+
console.log(
82+
`[cf-d1-dump] wrote ${OUT} — stripped ${ftsTables.length} FTS5 tables, ${ftsTriggers.length} FTS5 triggers`,
83+
);

0 commit comments

Comments
 (0)