Skip to content

Add emdash migrate command - #2438

Merged
ascorbic merged 3 commits into
codex/issue-2276-migrations-corefrom
codex/issue-2276-migrations-cli
Aug 18, 2026
Merged

Add emdash migrate command#2438
ascorbic merged 3 commits into
codex/issue-2276-migrations-corefrom
codex/issue-2276-migrations-cli

Conversation

@ascorbic

@ascorbic ascorbic commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds the emdash migrate deployment command, including manifest/config resolution, target selection, confirmation and non-interactive modes, JSON output, error handling, and SQLite integration coverage.

Part of #2276

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
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • 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). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: RFC: Deployment-managed core migrations #2418

Approved design discussion: #2418. Package typechecking, quick lint, and targeted formatting pass.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: GPT-5 Codex

Screenshots / test output

Non-visual change. The CLI unit suite and SQLite migration integration coverage pass.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-do 05bc7da Aug 18 2026, 02:35 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
emdash-playground ea0bb74 Aug 13 2026, 09:00 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 05bc7da Aug 18 2026, 02:36 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 05bc7da Aug 18 2026, 02:32 PM

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 05bc7da

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

This PR includes changesets to release 17 packages
Name Type
emdash Minor
@emdash-cms/cloudflare Minor
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Major
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Minor
@emdash-cms/auth Minor
@emdash-cms/blocks Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
create-emdash Minor
@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

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 1,235 lines across 5 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@ascorbic
ascorbic marked this pull request as ready for review August 12, 2026 16:32
Copilot AI lite review requested due to automatic review settings August 12, 2026 16:32
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Aug 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new deployment-oriented emdash migrate CLI subcommand to explicitly check/status/apply core migrations recorded at build time, aligning with the goal of avoiding runtime auto-migrations in production-like environments.

Changes:

  • Introduces emdash migrate with manifest/config loading, target display + fingerprint confirmation, JSON/human reporting, and bounded cleanup on signals.
  • Adds unit + integration coverage for CLI behavior and SQLite execution (including idempotency and signal cleanup).
  • Registers the new subcommand in the CLI entrypoint and adds a minor-version changeset.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/cli/commands/migrate.ts Implements the migrate command (options validation, manifest loading, executor wiring, reporting, confirmation, signal handling, redaction).
packages/core/src/cli/index.ts Wires migrate into the top-level CLI command map.
packages/core/tests/unit/cli/migrate.test.ts Unit coverage for command flow, option conflicts, confirmation gating, JSON output stability, and redaction/cleanup behaviors.
packages/core/tests/integration/cli/migrate-sqlite.test.ts Integration coverage against the built CLI for SQLite apply/check idempotency and real SIGTERM cleanup behavior.
.changeset/add-deployment-migrate-cli.md Announces the new emdash migrate command as a minor release.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/core/src/cli/commands/migrate.ts

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The approach is sound: this adds the deployment-side emdash migrate command on top of the migration identity/manifest/executor protocol already landed in the base branch, and it links to the approved design discussion (#2418). The implementation is dependency-injected for testing, handles interactive vs non-interactive apply, redacts secrets from executor errors, and includes both unit and SQLite integration coverage. Code is generally clean against AGENTS.md conventions (proper changeset, no SQL interpolation, no admin UI/i18n concerns, sensible CLI patterns).

There is one real logic bug: the isRecord helper currently accepts arrays, so if a migration executor returns an array instead of a MigrationReport object, safeReport treats it as a valid record with all-undefined fields and reports an empty success. For emdash migrate --check this would incorrectly exit 0 and hide pending/unknown migrations. The fix is to make isRecord reject arrays, and a regression test for non-object reports should be added.

Comment thread packages/core/src/cli/commands/migrate.ts Outdated
@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Aug 12, 2026
@ascorbic
ascorbic force-pushed the codex/issue-2276-migrations-cli branch from a305b32 to 124025b Compare August 13, 2026 08:20
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Aug 13, 2026
Comment thread packages/core/tests/unit/cli/migrate.test.ts Dismissed
@pkg-pr-new

pkg-pr-new Bot commented Aug 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

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

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2438

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 05bc7da

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-rereview Author pushed changes since the last review labels Aug 13, 2026
@ascorbic
ascorbic force-pushed the codex/issue-2276-migrations-cli branch from 124025b to 2334fc5 Compare August 13, 2026 08:46
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Aug 13, 2026
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This re-review looks good overall. The approach is sound: emdash migrate plugs cleanly into the existing migration identity / manifest / executor protocol from the base branch and links to the approved design discussion (#2418). The only prior finding — isRecord accepting arrays, which let an executor array report slip through safeReport and hide pending/unknown migrations on --check — is fixed, and a regression test for array-shaped reports was added.

I re-read packages/core/src/cli/commands/migrate.ts, the CLI wiring in packages/core/src/cli/index.ts, the new unit coverage, and the SQLite integration test. The fix is correct (!Array.isArray(value)), tests fail on arrays, secret redaction is preserved, signal cleanup is bounded, and the changeset is present and well-written.

One small non-blocking note: the header comment in packages/core/src/cli/index.ts that inventories CLI commands no longer matches the actual subCommands map now that migrate has been added.

Comment thread packages/core/src/cli/index.ts
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review of #2438 confirms the prior finding is fixed and the non-blocking note is addressed.

  • Prior isRecord bug: Fixed. isRecord now rejects arrays (!Array.isArray(value)), so an executor array-shaped report cannot slip through safeReport and hide pending/unknown migrations on --check.
  • Outdated header comment: Removed entirely from packages/core/src/cli/index.ts, which is consistent with the comment-discipline guidance (no command inventories in comments).

I re-read packages/core/src/cli/commands/migrate.ts, the CLI wiring, the unit tests, and the SQLite integration test. The approach remains sound: emdash migrate plugs cleanly into the existing migration identity / manifest / executor protocol, supports manifest/config resolution, target selection, interactive and non-interactive modes, JSON output, secret redaction, bounded signal cleanup, and stable check/apply/status semantics. The new tests cover array-shaped reports, target mismatch, secret redaction, signal cleanup, idempotent apply, and option validation.

I found no new issues against AGENTS.md conventions (imports, SQL safety, API envelope shape, localization/RTL, locale filtering, index discipline, comment discipline, changesets) and no logic regressions. The changeset is present and well-written.

LGTM.

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-rereview Author pushed changes since the last review labels Aug 13, 2026
@ascorbic
ascorbic force-pushed the codex/issue-2276-migrations-cli branch from 8b9e1f5 to d229512 Compare August 13, 2026 09:17
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review of #2438 after the prior approved pass. I re-read the full diff and the changed files, traced the migration CLI against the existing migration identity/manifest/executor protocol, and checked the new unit and SQLite integration tests against AGENTS.md conventions.

  • Approach: the change is the right follow-up to the migration-core work (#2276). emdash migrate wires cleanly into the existing manifest/config-loader/protocol layer, supports the requested discovery modes (manifest default, --manifest, --from-config), target overrides, interactive and non-interactive apply, JSON output, and bounded signal cleanup. The linked approved Discussion (#2418) is present, and the changeset is user-facing and concise.
  • Prior isRecord issue: still fixed — isRecord rejects arrays, so an array-shaped executor report cannot masquerade as a valid report in safeReport.
  • Comment discipline: the command inventory header was removed from packages/core/src/cli/index.ts; the new migrate.ts has no narrative/justification comments.
  • Conventions: imports use .js extensions, type-only imports are separate, SQL is not touched by the CLI, no user-visible admin UI strings are introduced, and no content-table/locale queries are involved.
  • Tests cover array-shaped reports, target mismatch, secret redaction, signal cleanup, idempotent apply, option validation, D1 warnings, and the real built CLI against SQLite.

I found no new logic bugs, regressions, or AGENTS.md violations in the current head. LGTM.

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026
@ascorbic
ascorbic force-pushed the codex/issue-2276-migrations-cli branch from d229512 to d3a185a Compare August 13, 2026 11:23
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/approved Approved; no new commits since labels Aug 13, 2026
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review of #2438 after the prior approved pass. I re-read the full diff and the changed files, traced the new emdash migrate command against the existing migration identity/manifest/executor protocol, and checked the unit and SQLite integration tests against AGENTS.md conventions.

The current head remains clean:

  • The approach is sound and follows the approved Discussion (#2418): emdash migrate wires into the existing manifest/config-loader/protocol layer, supports manifest/config discovery, target overrides, interactive and noninteractive apply, JSON output, stable exit codes, and bounded signal cleanup.
  • No AGENTS.md violations: internal imports use .js extensions, type-only imports are separate, the CLI does not touch SQL or content tables, there are no new user-visible admin UI strings, no logged-out route queries, no new indexes, and no narrative/justification comments.
  • The changeset is user-facing and concise.
  • Tests cover array-shaped reports, target mismatch, secret redaction, signal cleanup, idempotent apply, option validation, D1 warnings, and the real built CLI against SQLite.

I found no new logic bugs, regressions, or convention violations. The prior approval stands. LGTM.

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Aug 13, 2026
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-rereview Author pushed changes since the last review labels Aug 13, 2026
@ascorbic
ascorbic force-pushed the codex/issue-2276-migrations-cli branch from d3a185a to 8cda7b2 Compare August 18, 2026 13:08
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/approved Approved; no new commits since labels Aug 18, 2026
@ascorbic
ascorbic force-pushed the codex/issue-2276-migrations-cli branch from 8cda7b2 to 05bc7da Compare August 18, 2026 14:20
@ascorbic
ascorbic merged commit 0aa1bc8 into main Aug 18, 2026
61 of 88 checks passed
@ascorbic
ascorbic deleted the codex/issue-2276-migrations-cli branch August 18, 2026 15:16
@emdashbot emdashbot Bot mentioned this pull request Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core cla: signed review/needs-rereview Author pushed changes since the last review size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants