Skip to content

Commit dc66a27

Browse files
Kamiruscursoragent
andauthored
cli: drop mops migrate recommendations from check/build (#531)
Follow-up to #530, which marked `mops migrate` as experimental in the docs but missed a few CLI hints that still pushed users at it. ## What users will see **Before:** `mops check` / `mops check-stable` failing on a stable-compatibility regression printed an extra hint: > Hint: You may need a migration. Run `mops migrate new <Name>` to create one. **After:** that hint is gone. `moc`'s underlying compatibility error already links to the migration docs, and the hint guessed at the cause — it could equally be a missing new migration or a bug in an existing one. **Before:** `mops check`/`build`/`check-stable` failing because the chain dir doesn't exist: > Migration chain directory not found: migrations > Run `mops migrate new <Name>` to initialize the migration chain. **After:** points at the recommended workflow instead: > Migration chain directory not found: migrations > Create the directory and add a `.mo` migration file to initialize the chain. Also dropped the matching "a hint is shown suggesting to create a new migration" sentence from the `mops check-stable` docs page, which is no longer accurate. ## Why #530's PR description called this out as a follow-up: with `mops migrate` flagged experimental, the CLI shouldn't keep nudging users toward it. The `mops migrate` command itself still exists and works for those who want it. ## Test plan - [x] `npm test -- migrate.test.ts` (19 tests, 12 snapshots, all green) - [x] `npm run check` (TypeScript + svelte-check, pre-commit hook clean) Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent aa90dd8 commit dc66a27

7 files changed

Lines changed: 7 additions & 17 deletions

File tree

cli/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Next
44
- Deprecate `skipIfMissing` in `[canisters.<name>.check-stable]`. Behavior is unchanged for now, but `mops check`/`check-stable` print a warning when it is set. For initial deployments, commit a `.most` file at the configured `path` containing an empty actor (`// Version: 1.0.0\nactor { };`) instead — the stable check then runs against an empty baseline.
5+
- Drop the "you may need a migration" hint after a failed stable compatibility check in `mops check`/`check-stable`. The hint guessed at whether the user needed a new migration or a fix to an existing one, and `moc`'s underlying compatibility error already links to the migration docs.
6+
- The missing-chain-directory error from `mops check`/`build`/`check-stable` now points at adding a `.mo` file to the `chain` directory instead of running the experimental `mops migrate new <Name>` command.
57

68
## 2.13.1
79
- `mops lint` now honors `[canisters.<name>.migrations].check-limit`, skipping trimmed chain migrations so projects with large migration histories lint as fast as they type-check. Pass an explicit filter (`mops lint <name>`) to opt back in for a one-off lint of a trimmed file.

cli/commands/check-stable.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ export async function checkStable(
9898
globalMocArgs,
9999
canisterArgs: [...migration.migrationArgs, ...(canister.args ?? [])],
100100
options,
101-
hasMigrations: !!canister.migrations,
102101
});
103102
} finally {
104103
await migration.cleanup();
@@ -141,7 +140,6 @@ export async function checkStable(
141140
canisterArgs: [...migration.migrationArgs, ...(canister.args ?? [])],
142141
sources,
143142
options,
144-
hasMigrations: !!canister.migrations,
145143
});
146144
} finally {
147145
await migration.cleanup();
@@ -169,7 +167,6 @@ export interface RunStableCheckParams {
169167
canisterArgs: string[];
170168
sources?: string[];
171169
options?: Partial<CheckStableOptions>;
172-
hasMigrations?: boolean;
173170
}
174171

175172
export async function runStableCheck(
@@ -238,13 +235,6 @@ export async function runStableCheck(
238235
if (result.stderr) {
239236
console.error(result.stderr);
240237
}
241-
if (params.hasMigrations) {
242-
console.error(
243-
chalk.yellow(
244-
"Hint: You may need a migration. Run `mops migrate new <Name>` to create one.",
245-
),
246-
);
247-
}
248238
cliError(
249239
`✗ Stable compatibility check failed for canister '${canisterName}'`,
250240
);

cli/commands/check.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ async function checkCanisters(
216216
canisterArgs: [...migration.migrationArgs, ...(canister.args ?? [])],
217217
sources,
218218
options: { verbose: options.verbose, extraArgs: options.extraArgs },
219-
hasMigrations: !!canister.migrations,
220219
});
221220
}
222221
} finally {

cli/helpers/migrations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function resolveMigrationChain(
130130
if (!existsSync(chainDir) && !nextFile) {
131131
cliError(
132132
`Migration chain directory not found: ${chainDir}\n` +
133-
"Run `mops migrate new <Name>` to initialize the migration chain.",
133+
"Create the directory and add a `.mo` migration file to initialize the chain.",
134134
);
135135
}
136136

cli/tests/__snapshots__/migrate.test.ts.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,11 @@ exports[`migrate migrate new creates a migration file with timestamp and templat
143143
}
144144
`;
145145
146-
exports[`migrate stable check hint stable check fails with hint when deployed.most is incompatible 1`] = `
146+
exports[`migrate stable check stable check fails when deployed.most is incompatible 1`] = `
147147
{
148148
"exitCode": 1,
149149
"stderr": "(unknown location): Compatibility error [M0169], the stable variable \`a\` of the previous version cannot be implicitly discarded. The variable can only be dropped by an explicit migration function, please see https://internetcomputer.org/docs/motoko/fundamentals/actors/compatibility#explicit-migration-using-a-migration-function
150150
(unknown location): Compatibility error [M0169], the stable variable \`name\` of the previous version cannot be implicitly discarded. The variable can only be dropped by an explicit migration function, please see https://internetcomputer.org/docs/motoko/fundamentals/actors/compatibility#explicit-migration-using-a-migration-function
151-
Hint: You may need a migration. Run \`mops migrate new <Name>\` to create one.
152151
✗ Stable compatibility check failed for canister 'backend'",
153152
"stdout": "✓ backend",
154153
}

cli/tests/migrate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ describe("migrate", () => {
241241
});
242242
});
243243

244-
describe("stable check hint", () => {
245-
test("stable check fails with hint when deployed.most is incompatible", async () => {
244+
describe("stable check", () => {
245+
test("stable check fails when deployed.most is incompatible", async () => {
246246
const cwd = await makeTempFixture("basic");
247247
await writeFile(
248248
path.join(cwd, "deployed.most"),

docs/docs/cli/4-dev/05-mops-check-stable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Show detailed output including the `moc` commands being run and the intermediate
8787

8888
## Enhanced migration support
8989

90-
When a canister has a `[canisters.<name>.migrations]` section in `mops.toml`, `mops check-stable` automatically injects the `--enhanced-migration` flag when generating stable type signatures. If the stable check fails and `[migrations]` is configured, a hint is shown suggesting to create a new migration.
90+
When a canister has a `[canisters.<name>.migrations]` section in `mops.toml`, `mops check-stable` automatically injects the `--enhanced-migration` flag when generating stable type signatures.
9191

9292
## Passing flags to the Motoko compiler
9393

0 commit comments

Comments
 (0)