fix(cli/export-seed): include bylines in exported seed#1328
Conversation
`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 detectedLatest commit: 66c87f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 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 |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
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.tsround-trip logic for bylines and credits.BylineRepositoryto confirm_emdash_content_bylines.byline_idstorestranslation_group.validateSeedto confirm byline/bylines credit validation already existed.- Existing tests that call
exportSeedto 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.
|
@MA2153 there's a conflict. COuld you resolve it? |
# Conflicts: # packages/core/src/cli/commands/export-seed.ts
|
@ascorbic Done! Thanks for the ping. |
What does this PR do?
emdash export-seedexported settings, collections, taxonomies, menus, widget areas, and content — but never bylines. The seed format and theapplySeedimport side both fully support bylines (rootSeedByline[]profiles and per-entrySeedBylineCredit[]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 bytranslation_group(becauseSeedBylinehas no locale axis), and returns agroup → seed-idmap.exportContent()via a newgetBylineCredits()helper. It reads_emdash_content_bylinesdirectly —byline_idthere 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
Checklist
pnpm typecheckpasses (theemdashcore package typechecks clean)pnpm lintpasses (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 testpasses (targeted:tests/unit/seed/*+tests/unit/cli/seed-commands.test.ts, 118/118)pnpm formathas been runemdashpatchAI-generated code disclosure
Screenshots / test output
🤖 Generated with Claude Code