fix(core): treat export-seed --with-content=all as all collections (#1329)#1571
Conversation
…mdash-cms#1329) `export-seed`'s `--with-content` help documents `all` as a valid value, but only `""` and `"true"` were treated as the all-collections sentinel. Passing `all` produced `["all"]`, an allowlist of one collection named "all"; since no collection has that slug, every collection was skipped and nothing exported. Add `"all"` to the sentinel so it behaves as documented. Comma-separated collection names still work as an explicit allowlist. Adds a regression test exporting two collections with `withContent: "all"`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ca11784 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Approve. This is the right change solving the right problem.
Approach. emdash export-seed --with-content=all exported no content because exportSeed treated withContent purely as a comma-separated allowlist of collection slugs, so the literal all matched no collection and seed.content came back empty. Both the CLI arg help ("Include content (all or comma-separated collection names)") and docs/src/content/docs/reference/cli.mdx document all as a valid value meaning "every collection". Adding all to the existing ""/"true" sentinel set is the correct, minimal, idiomatic fix — it matches the documented contract and is consistent with how the bare --with-content flag is already handled. Closes #1329.
Implementation. The diff is a single conditional addition (|| withContent === "all") in exportSeed, with an explanatory comment. Tracing exportContent: when collections is null every collection is exported; the allowlist branch is unchanged. No SQL interpolation, no route/auth/locale concerns — this is a CLI export path.
Test. The new export-seed-with-content-all.test.ts is a genuine regression test: it seeds posts + pages with content, calls exportSeed(db, "all"), and asserts both collections' entries appear. Without the fix, "all" falls into the split branch → ["all"] allowlist → both collections skipped → seed.content is {} → seed.content?.posts?.map(...) is undefined → the toEqual(["hello"]) assertion fails. With the fix it passes. Setup mirrors the established seed-test pattern (setupTestDatabase + SchemaRegistry, setI18nConfig(null) to mirror the CLI), and the ContentRepository.create / createField calls match their signatures.
Changeset. .changeset/export-seed-with-content-all.md is well-formed: "emdash": patch (correct package name), leads with "Fixes", describes the observable effect for an upgrader.
Edge cases considered and dismissed. all is not in RESERVED_COLLECTION_SLUGS, so a collection literally named all would now be swept into an --with-content=all export rather than exported alone — but all is the documented sentinel, so this is correct behavior, and the collision is an extreme edge case. all,posts (mixed) exports only posts; undocumented and defensible. Case-sensitivity (ALL) is consistent with the existing exact-match sentinels and the lowercase docs.
Clean, well-scoped bug fix with a proper regression test and changeset. No findings.
What does this PR do?
Fixes
emdash export-seed --with-content=allexporting no content.exportSeedtreated thewithContentvalue as a comma-separated allowlist of collection names. The documentedallvalue matched no collection, so the seed'scontentcame back empty. (""and"true", produced by the bare--with-contentflag, already meant "every collection".)Fix: treat
"","true", and"all"as "all collections"; anything else stays a comma-separated allowlist.Closes #1329.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
New test
packages/core/tests/unit/seed/export-seed-with-content-all.test.ts: seeds posts + pages with content, callsexportSeed(db, "all"), asserts both collections' entries are exported.