Skip to content

Commit 58d0be8

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/issue-24882-settings-format-refusal
2 parents b3d83aa + 62bc129 commit 58d0be8

3 files changed

Lines changed: 434 additions & 1 deletion

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/cli': minor
3+
---
4+
5+
fix(cli)!: `os migrate apply` exits `1` when the confirmation it needs is not given, as every other `os migrate` subcommand with a `--yes` gate already does
6+
7+
In a non-interactive shell (stdin is not a terminal) or under `--json`, `os migrate apply` without `--yes` applies nothing and prints `⚠ Confirmation required. Re-run with --yes to apply, or use "os migrate plan" to preview.` (under `--json`, its `confirmation_required` document). It exited `0` there, so a deploy script or an agent reading the exit status took a run that applied nothing for an applied one, and the next boot still reported the drift. Every other `os migrate` subcommand that writes behind `--yes` — `comment-reactions --apply`, `meta --stored --apply`, `recorded-by --apply`, `resume --run` and the rest — already exits `1` in that situation, as `organization-ownership --apply` does without `--backup-taken`. `apply` now answers the same way, in both faces. The warning and the `--json` document are unchanged.
8+
9+
Clause-②: no (narrowing)
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No metadata moves: no spec key, authorable spelling, object definition or stored shape is added, removed, renamed or re-shaped, and no exported declaration is removed or narrowed, so there is nothing for `objectstack migrate meta` to rewrite. What changes is the exit status one CLI command returns when it applied nothing because the confirmation it asks for was not given; the remedy is a flag on the caller's command line (`--yes`), never a rewrite of a package source or a stored row. The other categories are closed on facts: the package publishes (not unpublished); no ADR-0087 id is named or touched (not registered or already-registered); and nothing exported is removed or narrowed (not runtime-interface-only, type-surface-only or runtime-export-retired). -->
12+
13+
**BREAKING** (an exit status narrows), shipped as `minor` under the launch-window convention for breaking changes.
14+
15+
- **FROM:** `os migrate apply` (with or without `--allow-destructive`) on a database with changes to apply, without `--yes`, with stdin not a terminal or with `--json`: nothing applied, exit `0`.
16+
- **TO:** nothing applied, exit `1`. The printed warning and the `--json` document (`message: 'confirmation_required'`, `hint: 'pass --yes'`) are unchanged.
17+
- **Unchanged:** answering `n` at the `[y/N]` prompt in a terminal still prints `Aborted — no changes made.` and exits `0`; a run with `--yes` applies and exits `0`; a database with nothing to apply exits `0` without asking.
18+
- **The fix for a script:** a script that means to apply passes `--yes` (`os migrate apply --yes`, or `os migrate apply --allow-destructive --yes`); one that only wants to know what would change runs `os migrate plan`.

‎packages/cli/src/commands/migrate/apply.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,19 @@ export default class MigrateApply extends Command {
612612
}
613613

614614
// Confirmation gate. Nothing above this line has touched the database.
615+
//
616+
// [#24949] A confirmation the run needs and did not get — a non-TTY
617+
// stdin, or `--json`, without `--yes` — applies nothing and exits 1, in
618+
// both faces, as every other `os migrate` subcommand with a `--yes` gate
619+
// does (`test/migrate-confirmation-exit.pin.test.ts` holds the family to
620+
// it). It used to exit 0, so a deploy script reading `$?` took a run
621+
// that applied nothing for an applied one. An operator who answers `n`
622+
// at the prompt below declined on purpose: that path keeps exit 0.
615623
if (!flags.yes) {
616624
if (flags.json || !process.stdin.isTTY) {
617-
if (flags.json) { await emitJson({ ...target, applied: [], skipped: drift, pending, message: 'confirmation_required', hint: 'pass --yes' }, 0, { compact: true }); return; }
625+
if (flags.json) { await emitJson({ ...target, applied: [], skipped: drift, pending, message: 'confirmation_required', hint: 'pass --yes' }, 1, { compact: true }); return; }
618626
printWarning('Confirmation required. Re-run with --yes to apply, or use "os migrate plan" to preview.');
627+
this.exit(1);
619628
return;
620629
}
621630
const targets = stack.telemetryDatabase !== null

0 commit comments

Comments
 (0)