Skip to content

fix(cli): send --force through to the API when deleting a collection - #3016

Open
jakevis wants to merge 2 commits into
emdash-cms:mainfrom
jakevis:fix/cli-schema-delete-force
Open

fix(cli): send --force through to the API when deleting a collection#3016
jakevis wants to merge 2 commits into
emdash-cms:mainfrom
jakevis:fix/cli-schema-delete-force

Conversation

@jakevis

@jakevis jakevis commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

emdash schema delete --force consumed the flag to skip its own confirmation prompt and then called the client without it, so the API refused any collection that still had content — with an error naming the very option the user had just passed. There was no other CLI path through.

EmDashClient.deleteCollection now takes { force?: boolean } and sends it as ?force=true, the way the route already reads it; the command passes its flag along. The flag keeps a single meaning — "don't ask, just delete" — since the prompt existed to guard exactly the destructive case. Test added for the client's query string; changeset included.

Closes #2994

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)
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion
  • I have included screenshots below if this PR changes the UI

AI-generated code disclosure

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

Screenshots / test output

tests/unit/client/client.test.ts  44 passed

`emdash schema delete --force` consumed the flag to skip its own prompt and
then called the client without it, so the API refused any collection that
still had content — with an error naming the very option the user had just
passed. There was no other CLI path through, so scripted cleanup had to
hand-roll the DELETE request and its auth.

The client method now takes `{ force }` and sends it the way the route
already reads it, and the command passes its flag along. The flag keeps its
single meaning — "don't ask, just delete" — since the prompt existed to
guard exactly the destructive case.

Fixes emdash-cms#2994
@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 911c93f

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

This PR includes changesets to release 17 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/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/release-service 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 github-actions Bot added review/needs-review No maintainer or bot review yet area/core size/S labels Sep 10, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

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

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@3016

@emdash-cms/registry-verification

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

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 911c93f

@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 is a small, targeted fix for the right problem: emdash schema delete --force was swallowing the flag after using it only to skip the local confirmation prompt. The change threads the flag through EmDashClient.deleteCollection as ?force=true, which matches the existing API route (packages/core/src/astro/routes/api/schema/collections/[slug]/index.ts reads url.searchParams.get("force") === "true"). The signature change is backwards-compatible, the new client unit test covers all three states (no options, force: false, force: true), and the updated help text now describes the combined behavior accurately.

I reviewed the CLI command, client implementation, API route, registry handler, related tests, and the changeset. No logic bugs or regressions found. One AGENTS.md convention issue remains: the inline comment in packages/core/src/cli/commands/schema.ts narrates the pre-fix bug / PR context rather than serving as evergreen code explanation, and should be removed.

Comment thread packages/core/src/cli/commands/schema.ts Outdated
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/needs-review No maintainer or bot review yet labels Sep 10, 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/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

schema delete --force never sends force to the API, so a collection with content cannot be deleted from the CLI

1 participant