Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/upgrade-emdash-0.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@dashcommerce/core": patch
"@dashcommerce/starter": minor
---

Upgrade to emdash 0.6.0.

- `@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.
- `@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.

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.
24 changes: 12 additions & 12 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"bun": ">=1.1.0"
},
"patchedDependencies": {
"emdash@0.5.0": "patches/emdash@0.5.0.patch"
"emdash@0.6.0": "patches/emdash@0.6.0.patch"
}
}
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"test": "bun test"
},
"peerDependencies": {
"emdash": ">=0.4.0 <0.6.0",
"emdash": ">=0.5.0 <0.7.0",
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0"
},
Expand All @@ -78,12 +78,12 @@
}
},
"devDependencies": {
"@emdash-cms/admin": "0.5.0",
"@emdash-cms/admin": "^0.6.0",
"@stripe/react-stripe-js": "^3.0.0",
"@stripe/stripe-js": "^5.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"emdash": "^0.5.0",
"emdash": "^0.6.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tsdown": "^0.20.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"cf:deploy": "bun run build:cf && wrangler deploy --config dist/server/wrangler.json",
"cf:dev": "bun run build:cf && wrangler dev --config dist/server/wrangler.json",
"cf:d1:create": "wrangler d1 create dashcommerce-demo",
"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",
"cf:d1:seed": "node scripts/cf-d1-seed.mjs",
"typecheck": "astro check"
},
"emdash": {
Expand All @@ -31,11 +31,11 @@
"@astrojs/react": "^5.0.0",
"@astrojs/sitemap": "^3.4.0",
"@dashcommerce/core": "workspace:*",
"@emdash-cms/cloudflare": "^0.5.0",
"@emdash-cms/cloudflare": "^0.6.0",
"@stripe/react-stripe-js": "^6.0.0",
"@stripe/stripe-js": "^9.0.0",
"astro": "^6.0.0",
"emdash": "^0.5.0",
"emdash": "^0.6.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
83 changes: 83 additions & 0 deletions packages/starter/scripts/cf-d1-dump.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env node
/**
* Produce a D1-safe SQL dump from local data.db.
*
* Why a dedicated script (not just sqlite3 .dump | grep):
* - SQLite's `.dump` represents FTS5 virtual tables as INSERT INTO sqlite_schema(...).
* D1 rejects any write to sqlite_schema/sqlite_master with "table sqlite_master
* may not be modified", so those statements must go.
* - FTS5 triggers that live on the host tables (e.g. _emdash_fts_products_insert)
* also write into the virtual tables' shadow storage. Once we drop the FTS5
* tables, those triggers become broken — cleanest to drop them too.
* - We do all of this on a *copy* of data.db so local dev + search keep working.
*
* Trade-off: full-text search won't work on the D1 deploy until emdash's D1
* adapter learns to materialize FTS5 indexes itself. Everything else (products,
* checkout, admin, blog) lands intact.
*/

import {
copyFileSync,
existsSync,
unlinkSync,
writeFileSync,
} from "node:fs";
import { execFileSync } from "node:child_process";

const SRC = "data.db";
const COPY = "/tmp/dashcommerce-d1-export.db";
const OUT = ".emdash/d1-seed.sql";

if (!existsSync(SRC)) {
console.error(
`[cf-d1-dump] ${SRC} not found. Run \`bun run bootstrap\` first.`,
);
process.exit(1);
}

if (existsSync(COPY)) unlinkSync(COPY);
copyFileSync(SRC, COPY);

function sqlite(cmd) {
return execFileSync("sqlite3", [COPY, cmd]).toString();
}

const ftsTables = sqlite(
"SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '_emdash_fts%' ORDER BY name",
)
.trim()
.split(/\r?\n/)
.filter(Boolean);

for (const t of ftsTables) {
sqlite(`DROP TABLE IF EXISTS "${t}"`);
}

const ftsTriggers = sqlite(
"SELECT name FROM sqlite_master WHERE type='trigger' AND name LIKE '_emdash_fts%' ORDER BY name",
)
.trim()
.split(/\r?\n/)
.filter(Boolean);

for (const t of ftsTriggers) {
sqlite(`DROP TRIGGER IF EXISTS "${t}"`);
}

const raw = execFileSync("sqlite3", [COPY, ".dump"]).toString();

// D1 rejects: header PRAGMAs, explicit transactions, CREATE TABLE on sqlite_*,
// any INSERT into sqlite_schema (the dump's representation of virtual tables).
const safe = raw
.split("\n")
.filter((line) => !/^(PRAGMA|BEGIN|COMMIT|ROLLBACK)\b/.test(line))
.filter((line) => !/^CREATE TABLE\s+"?sqlite_/.test(line))
.filter((line) => !/^INSERT INTO\s+"?sqlite_/.test(line))
.join("\n");

writeFileSync(OUT, safe);
unlinkSync(COPY);

console.log(
`[cf-d1-dump] wrote ${OUT} — stripped ${ftsTables.length} FTS5 tables, ${ftsTriggers.length} FTS5 triggers`,
);
Loading
Loading