Skip to content

fix(cli/export-seed): include bylines in exported seed#1328

Merged
ascorbic merged 2 commits into
emdash-cms:mainfrom
MA2153:fix/export-seed-bylines
Jun 4, 2026
Merged

fix(cli/export-seed): include bylines in exported seed#1328
ascorbic merged 2 commits into
emdash-cms:mainfrom
MA2153:fix/export-seed-bylines

Conversation

@MA2153
Copy link
Copy Markdown
Contributor

@MA2153 MA2153 commented Jun 4, 2026

What does this PR do?

emdash export-seed exported settings, collections, taxonomies, menus, widget areas, and content — but never bylines. The seed format and the applySeed import side both fully support bylines (root SeedByline[] profiles and per-entry SeedBylineCredit[] credits), so an exported seed silently dropped every author credit and could never round-trip.

This adds:

  • exportBylines() — emits one root profile per byline, deduped by translation_group (because SeedByline has no locale axis), and returns a group → seed-id map.
  • Byline credits in exportContent() via a new getBylineCredits() helper. It reads _emdash_content_bylines directly — byline_id there already stores the translation group, so it maps straight to seed ids, stays locale-agnostic, and avoids the locale-sibling fan-out a hydrated read would cause.

Developed with TDD: failing tests first (profiles, ordered credits + roleLabel, empty-omission, and a full export → applySeed → verify round-trip), then the implementation. New tests 4/4 pass; the broader seed + CLI suites stay green (118/118).

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes (the emdash core package typechecks clean)
  • pnpm lint passes (changed files are lint-clean; the only repo-wide lint/typecheck failures are pre-existing and live in unrelated plugin/registry packages with unbuilt dist outputs)
  • pnpm test passes (targeted: tests/unit/seed/* + tests/unit/cli/seed-commands.test.ts, 118/118)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable) — n/a, CLI-only change, no admin strings
  • I have added a changeset (if this PR changes a published package) — emdash patch
  • New features link to an approved Discussion — n/a, bug fix

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.8 (Claude Code)

Screenshots / test output

 Test Files  1 passed (1)
      Tests  4 passed (4)   tests/unit/seed/export-bylines.test.ts

 Test Files  7 passed (7)
      Tests  118 passed (118)   seed + CLI suites

🤖 Generated with Claude Code

`emdash export-seed` exported settings, collections, taxonomies, menus,
widget areas, and content, but never bylines — even though the seed
format and `applySeed` fully support them. Exported seeds silently
dropped every author credit and could not round-trip.

Add `exportBylines()` to emit byline profiles as the root `bylines[]`
array (one entry per translation group, since `SeedByline` has no locale
axis), returning a translation_group -> seed-id map. Thread that map into
`exportContent()`, which now attaches each entry's ordered byline credits
via `getBylineCredits()`. Credits are read directly from
`_emdash_content_bylines` — whose `byline_id` already stores the
translation group — so the result is locale-agnostic and round-trips
back through `applySeed` with profiles and credits intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

🦋 Changeset detected

Latest commit: 66c87f6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 4, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1328

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1328

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1328

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1328

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1328

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1328

emdash

npm i https://pkg.pr.new/emdash@1328

create-emdash

npm i https://pkg.pr.new/create-emdash@1328

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1328

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1328

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1328

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1328

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1328

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1328

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1328

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1328

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1328

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1328

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1328

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1328

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1328

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1328

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1328

commit: 66c87f6

Copy link
Copy Markdown
Contributor

@emdashbot emdashbot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a focused, well-scoped bug fix: emdash export-seed never exported byline profiles or per-entry credits, despite both the seed format and applySeed supporting them. The PR adds exportBylines() and getBylineCredits() to the exporter, wired before content export so the emitted root bylines[] can be referenced by each entry's bylines[] array.

Approach judgment: Correct and idiomatic. It mirrors the existing export patterns (taxonomy, menus, widget areas), uses the same cursor-pagination + locale-agnostic junction read the codebase already relies on, and keeps the deterministic seed-local id generation style (byline:${slug} with a group-based disambiguation fallback). The implementation is aware of the i18n model: SeedByline has no locale axis, so one profile is emitted per translation_group; the content credits read byline_id straight from _emdash_content_bylines (which stores the translation group, not a row id), avoiding locale-sibling fan-out.

What I checked:

  • Diff against origin/main.
  • Full changed files (export-seed.ts, export-bylines.test.ts, changeset).
  • applySeed.ts round-trip logic for bylines and credits.
  • BylineRepository to confirm _emdash_content_bylines.byline_id stores translation_group.
  • validateSeed to confirm byline/bylines credit validation already existed.
  • Existing tests that call exportSeed to ensure nothing is broken by the new output key.

Conclusion: No issues found. The implementation is clean, SQL is parameterized via Kysely, tests cover profiles, ordered credits with roleLabel, empty-omission, and a full export → applySeed → verify round-trip. The changeset is present and correctly describes a patch bump for emdash. LGTM.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jun 4, 2026
Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ascorbic
Copy link
Copy Markdown
Collaborator

ascorbic commented Jun 4, 2026

@MA2153 there's a conflict. COuld you resolve it?

# Conflicts:
#	packages/core/src/cli/commands/export-seed.ts
@MA2153
Copy link
Copy Markdown
Contributor Author

MA2153 commented Jun 4, 2026

@ascorbic Done! Thanks for the ping.

@ascorbic ascorbic merged commit 149fc49 into emdash-cms:main Jun 4, 2026
42 checks passed
@emdashbot emdashbot Bot mentioned this pull request Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/approved Approved; no new commits since size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants