-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(cli): treat --with-content=all as include-all sentinel
#1389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ascorbic
merged 1 commit into
emdash-cms:main
from
nanangdev:fix/export-seed-with-content-all-1329
Jun 24, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "emdash": patch | ||
| --- | ||
|
|
||
| Fixes `emdash export-seed --with-content=all` so it exports content from every collection, matching the documented behaviour. Previously the literal string `"all"` was treated as a collection name and matched none, producing an empty `content` block. The bare flag and `--with-content=true` were the only sentinels honoured. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/core/tests/unit/seed/export-seed-with-content-all.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import type { Kysely } from "kysely"; | ||
| import { afterEach, beforeEach, describe, expect, it } from "vitest"; | ||
|
|
||
| import { exportSeed } from "../../../src/cli/commands/export-seed.js"; | ||
| import { ContentRepository } from "../../../src/database/repositories/content.js"; | ||
| import type { Database } from "../../../src/database/types.js"; | ||
| import { setI18nConfig } from "../../../src/i18n/config.js"; | ||
| import { SchemaRegistry } from "../../../src/schema/registry.js"; | ||
| import { setupTestDatabase, teardownTestDatabase } from "../../utils/test-db.js"; | ||
|
|
||
| /** | ||
| * Regression for #1329: `emdash export-seed --with-content all` exported | ||
| * nothing because the literal string "all" was treated as a collection name. | ||
| * Only the bare flag and `--with-content=true` were honoured as the | ||
| * "include every collection" sentinel, contradicting the args help text: | ||
| * | ||
| * "with-content": { | ||
| * description: "Include content (all or comma-separated collection names)", | ||
| * } | ||
| */ | ||
| describe("exportSeed: --with-content sentinel handling", () => { | ||
| let db: Kysely<Database>; | ||
|
|
||
| beforeEach(async () => { | ||
| setI18nConfig(null); | ||
| db = await setupTestDatabase(); | ||
|
|
||
| const registry = new SchemaRegistry(db); | ||
| await registry.createCollection({ slug: "posts", label: "Posts" }); | ||
| await registry.createField("posts", { slug: "title", label: "Title", type: "string" }); | ||
| await registry.createCollection({ slug: "pages", label: "Pages" }); | ||
| await registry.createField("pages", { slug: "title", label: "Title", type: "string" }); | ||
|
|
||
| const contentRepo = new ContentRepository(db); | ||
| await contentRepo.create({ | ||
| type: "posts", | ||
| slug: "hello-post", | ||
| status: "published", | ||
| data: { title: "Hello Post" }, | ||
| }); | ||
| await contentRepo.create({ | ||
| type: "pages", | ||
| slug: "hello-page", | ||
| status: "published", | ||
| data: { title: "Hello Page" }, | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(async () => { | ||
| await teardownTestDatabase(db); | ||
| setI18nConfig(null); | ||
| }); | ||
|
|
||
| it("treats `all` as a synonym for include-every-collection", async () => { | ||
| const seed = await exportSeed(db, "all"); | ||
|
|
||
| expect(seed.content).toBeDefined(); | ||
| expect(Object.keys(seed.content ?? {}).toSorted()).toEqual(["pages", "posts"]); | ||
| expect(seed.content?.posts?.[0]?.slug).toBe("hello-post"); | ||
| expect(seed.content?.pages?.[0]?.slug).toBe("hello-page"); | ||
| }); | ||
|
|
||
| it("matches the bare flag's behaviour (empty string)", async () => { | ||
| const seedAll = await exportSeed(db, "all"); | ||
| const seedBare = await exportSeed(db, ""); | ||
|
|
||
| expect(Object.keys(seedAll.content ?? {}).toSorted()).toEqual( | ||
| Object.keys(seedBare.content ?? {}).toSorted(), | ||
| ); | ||
| }); | ||
|
|
||
| it("matches the explicit `true` sentinel's behaviour", async () => { | ||
| const seedAll = await exportSeed(db, "all"); | ||
| const seedTrue = await exportSeed(db, "true"); | ||
|
|
||
| expect(Object.keys(seedAll.content ?? {}).toSorted()).toEqual( | ||
| Object.keys(seedTrue.content ?? {}).toSorted(), | ||
| ); | ||
| }); | ||
|
|
||
| it("still treats a comma-separated list as a collection-name filter", async () => { | ||
| const seed = await exportSeed(db, "posts"); | ||
|
|
||
| expect(seed.content).toBeDefined(); | ||
| expect(Object.keys(seed.content ?? {})).toEqual(["posts"]); | ||
| expect(seed.content?.posts?.[0]?.slug).toBe("hello-post"); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] The test description says "comma-separated list", but the value passed is
"posts"(a single collection name, no comma). Consider updating the description to match the data, or passing an actual comma-separated value like"posts,pages"to exercise the.split(",")path.