Skip to content

Commit 1eaef1c

Browse files
Kamiruscursoragent
andcommitted
chore(cli): extend dfx replica deprecation to test + watch; track removal in NEXT-MAJOR
- Extract the warning into a shared `helpers/deprecate-dfx-replica.ts` and wire it through `mops bench`, `mops test --mode replica`, and `mops watch` (one-shot per watch session). - Recommend `mops toolchain use pocket-ic` in the warning text and docs, matching the existing wasmtime hint pattern in `test.ts`. - Annotate `mops test --replica`'s `--help` with the deprecation note, mirroring what `mops bench --replica` already says. - Add a NEXT-MAJOR.md item under "Drop dfx coupling" to remove the dfx replica paths entirely and flip the default to a mops-pinned PocketIC version. Calls out the bench-baseline drift for release notes. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f142b40 commit 1eaef1c

9 files changed

Lines changed: 53 additions & 22 deletions

File tree

NEXT-MAJOR.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Close the gap between update path and resolve path.
3939

4040
### Drop `dfx` coupling
4141
- Remove `dfx`-bundled `moc` fallback in `toolchain bin --fallback`, `test`, `bench`, `bench-replica`, `docs`. (`cli/helpers/get-dfx-version.ts`, `cli/commands/toolchain/index.ts:359,387`, `cli/commands/docs.ts:44-54`)
42+
- Remove the `dfx` and `dfx-pocket-ic` replica paths from `mops bench`, `mops test --mode replica`, and `mops watch`. Drop the `dfx` choice from `--replica`; drop the implicit `dfx`/`dfx-pocket-ic` fallback when `[toolchain.pocket-ic]` is unset. Flip the default so an unpinned `pocket-ic` auto-resolves to a mops-controlled `DEFAULT_POCKET_IC_VERSION` (download-on-demand via `toolchain.download("pocket-ic", ...)`), so users never need to know dfx exists. Document the version bump policy. Deprecated with warnings in 2.x via `cli/helpers/deprecate-dfx-replica.ts` (PR #555). **User-visible break**: implicit-dfx benchmark baselines drift on first run because PocketIC and dfx-replica report different instruction/heap counts; call out in release notes and recommend re-recording with `--save`.
4243
- `mops init` stops fetching "default packages for dfx" — mops manages its own toolchain. (LIN: Doctor overhaul)
4344
- Drop `mops toolchain init` requirement; env-var setup becomes a hint when `dfx.json` is present. (LIN)
4445
- Reject `dfx` field in `[package]` (deprecated since 2.7).

cli/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Mops CLI Changelog
22

33
## Next
4-
- Deprecate the `dfx` replica in `mops bench`. Behavior is unchanged for now — `--replica dfx` still works, and `mops bench` still falls back to `dfx` (or dfx-bundled PocketIC) when no `pocket-ic` version is set in `[toolchain]` — but a warning is printed in those paths, and the `dfx` replica will be removed in a future release. To silence the warning, pin a `pocket-ic` version in `[toolchain]` (e.g. `pocket-ic = "12.0.0"`); `mops bench` already prefers it over `dfx` when both are available. Motivation: `dfx` itself is being deprecated, and PocketIC is the better fit for benchmarks anyway — deterministic, in-process, and no separate background daemon to manage.
4+
- Deprecate the `dfx` replica in `mops bench`, `mops test --mode replica`, and `mops watch`. Behavior is unchanged for now — `--replica dfx` still works, and the implicit fallback to `dfx` (or dfx-bundled PocketIC) when no `pocket-ic` version is set in `[toolchain]` still works — but a warning is printed in those paths. To silence the warning, run `mops toolchain use pocket-ic` to pin a PocketIC version; the replica resolver already prefers it over `dfx` when both are available. The `dfx` replica (and the `dfx-pocket-ic` fallback) will be removed and the default flipped to PocketIC in mops v3. Motivation: `dfx` itself is being deprecated upstream, and PocketIC is the better fit for benchmarks and replica tests anyway — deterministic, in-process, and no separate background daemon to manage.
55

66
- Add `--patch` to `mops update` and `mops outdated` to restrict updates to patch versions only (e.g. `1.2.3 -> 1.2.4`, never `1.2.3 -> 1.3.0`). Mutually exclusive with `--major`. For pre-1.0 packages this matches the default — caret already restricts `0.x.y` to patch updates. Useful for risk-averse upgrades on packages that have hit 1.0+.
77

cli/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ program
413413
.addOption(
414414
new Option(
415415
"--replica <replica>",
416-
"Which replica to use to run tests in replica mode",
416+
"Which replica to use to run tests in replica mode (`dfx` is deprecated; prefer `pocket-ic`)",
417417
).choices(["dfx", "pocket-ic"]),
418418
)
419419
.option("-w, --watch", "Enable watch mode")

cli/commands/bench.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { parallel } from "../parallel.js";
2222
import { absToRel } from "./test/utils.js";
2323
import { getMocVersion } from "../helpers/get-moc-version.js";
2424
import { getDfxVersion } from "../helpers/get-dfx-version.js";
25+
import { warnIfDfxReplica } from "../helpers/deprecate-dfx-replica.js";
2526
import { getMocPath } from "../helpers/get-moc-path.js";
2627
import { sources } from "./sources.js";
2728
import { MOTOKO_GLOB_CONFIG } from "../constants.js";
@@ -98,20 +99,7 @@ export async function bench(
9899
options.replicaVersion = config.toolchain?.["pocket-ic"] || "";
99100
}
100101

101-
if (replicaType === "dfx" || replicaType === "dfx-pocket-ic") {
102-
let explicitDfx = optionsArg.replica === "dfx";
103-
let usedFallback = replicaType === "dfx-pocket-ic";
104-
let lead = explicitDfx
105-
? "`--replica dfx` is deprecated and will be removed in a future release."
106-
: usedFallback
107-
? "Falling back to dfx-bundled PocketIC because no `pocket-ic` version is set in `[toolchain]`. This fallback is deprecated and will be removed in a future release."
108-
: "`mops bench` is using `dfx` because no `pocket-ic` version is set in `[toolchain]`. The `dfx` replica is deprecated and will be removed in a future release.";
109-
console.log(
110-
chalk.yellow(
111-
`${lead}\nAdd a \`pocket-ic\` version to \`[toolchain]\` in mops.toml (e.g. \`pocket-ic = "12.0.0"\`) to silence this warning.`,
112-
),
113-
);
114-
}
102+
warnIfDfxReplica(replicaType, optionsArg.replica === "dfx");
115103

116104
options.verbose && console.log(options);
117105

cli/commands/test/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { toolchain } from "../toolchain/index.js";
3232
import { Replica } from "../replica.js";
3333
import { TestMode } from "../../types.js";
3434
import { getDfxVersion } from "../../helpers/get-dfx-version.js";
35+
import { warnIfDfxReplica } from "../../helpers/deprecate-dfx-replica.js";
3536
import { MOTOKO_GLOB_CONFIG, MOTOKO_IGNORE_PATTERNS } from "../../constants.js";
3637

3738
type ReporterName = "verbose" | "files" | "compact" | "silent";
@@ -79,6 +80,8 @@ export async function test(filter = "", options: Partial<TestOptions> = {}) {
7980
}
8081
}
8182

83+
warnIfDfxReplica(replicaType, options.replica === "dfx");
84+
8285
replica.type = replicaType;
8386
replica.verbose = !!options.verbose;
8487

cli/commands/watch/tester.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { readConfig } from "../../mops.js";
33
import { ErrorChecker } from "./error-checker.js";
44
import { testWithReporter } from "../test/test.js";
55
import { SilentReporter } from "../test/reporters/silent-reporter.js";
6+
import {
7+
warnIfDfxReplica,
8+
type ReplicaName,
9+
} from "../../helpers/deprecate-dfx-replica.js";
610

711
export class Tester {
812
verbose = false;
@@ -13,6 +17,7 @@ export class Tester {
1317
aborted = false;
1418
controller = new AbortController();
1519
currentRun: Promise<any> | undefined;
20+
warnedDfx = false;
1621

1722
constructor({
1823
verbose,
@@ -53,12 +58,20 @@ export class Tester {
5358
this.controller = new AbortController();
5459

5560
let config = readConfig();
61+
let replicaType: ReplicaName = config.toolchain?.["pocket-ic"]
62+
? "pocket-ic"
63+
: "dfx";
64+
65+
if (!this.warnedDfx) {
66+
warnIfDfxReplica(replicaType, false);
67+
this.warnedDfx = true;
68+
}
5669

5770
this.currentRun = testWithReporter(
5871
this.reporter,
5972
"",
6073
"interpreter",
61-
config.toolchain?.["pocket-ic"] ? "pocket-ic" : "dfx",
74+
replicaType,
6275
true,
6376
this.controller.signal,
6477
);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import chalk from "chalk";
2+
3+
export type ReplicaName = "dfx" | "pocket-ic" | "dfx-pocket-ic";
4+
5+
// Prints a deprecation warning when `mops bench`/`mops test`/`mops watch`
6+
// resolves to a dfx-backed replica. Removal is tracked in NEXT-MAJOR.md
7+
// under "Drop dfx coupling".
8+
export function warnIfDfxReplica(
9+
replicaType: ReplicaName,
10+
explicit: boolean,
11+
): void {
12+
if (replicaType !== "dfx" && replicaType !== "dfx-pocket-ic") {
13+
return;
14+
}
15+
let lead =
16+
explicit && replicaType === "dfx"
17+
? "`--replica dfx` is deprecated and will be removed in a future release."
18+
: replicaType === "dfx-pocket-ic"
19+
? "Falling back to dfx-bundled PocketIC because no `pocket-ic` version is set in `[toolchain]`. This fallback is deprecated and will be removed in a future release."
20+
: "Using `dfx` replica because no `pocket-ic` version is set in `[toolchain]`. The `dfx` replica is deprecated and will be removed in a future release.";
21+
console.log(
22+
chalk.yellow(
23+
`${lead}\nRun \`mops toolchain use pocket-ic\` to pin a PocketIC version and silence this warning.`,
24+
),
25+
);
26+
}

docs/docs/cli/4-dev/01-mops-test.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ You can also specify `wasi` mode for a specific test file by adding the line bel
7171

7272
Which replica to use to run actor tests.
7373

74-
Default `pocket-ic` if `pocket-ic` is specified in `mops.toml` in `[toolchain]` section, otherwise `dfx`.
74+
Default `pocket-ic` if `pocket-ic` is specified in `mops.toml` in `[toolchain]` section, otherwise `dfx` (deprecated, see below).
7575

7676
Possible values:
77-
- `dfx` - use `dfx` local replica
78-
- `pocket-ic` - use [PocketIC](https://pypi.org/project/pocket-ic/) light replica via [pic.js](https://www.npmjs.com/package/@hadronous/pic) wrapper
77+
- `pocket-ic` - use [PocketIC](https://github.com/dfinity/pocketic) light replica via [pic.js](https://github.com/dfinity/pic-js). Recommended.
78+
- `dfx` - **deprecated**. Uses `dfx` local replica. Will be removed in a future release. Run `mops toolchain use pocket-ic` to pin a PocketIC version and `mops test` will use it directly.
7979

8080
:::info
81-
If you run `mops test --replica pocket-ic` AND `pocket-ic` is not specified in `mops.toml` in `[toolchain]` section, Mops will use pocket-ic replica that comes with dfx (`dfx start --pocketic`).
81+
If you run `mops test --replica pocket-ic` AND `pocket-ic` is not specified in `mops.toml` in `[toolchain]` section, Mops will use pocket-ic replica that comes with dfx (`dfx start --pocketic`). This fallback path is also deprecated.
8282
:::
8383

8484
### `--verbose`

docs/docs/cli/4-dev/02-mops-bench.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Default `pocket-ic` if `pocket-ic` is specified in `mops.toml` in `[toolchain]`
3636

3737
Possible values:
3838
- `pocket-ic` - use [PocketIC](https://github.com/dfinity/pocketic) light replica via [pic.js](https://github.com/dfinity/pic-js). Recommended.
39-
- `dfx` - **deprecated**. Uses `dfx` local replica. Will be removed in a future release. Pin a `pocket-ic` version in `[toolchain]` (e.g. `pocket-ic = "12.0.0"`) and `mops bench` will use it directly.
39+
- `dfx` - **deprecated**. Uses `dfx` local replica. Will be removed in a future release. Run `mops toolchain use pocket-ic` to pin a PocketIC version and `mops bench` will use it directly.
4040

4141
### `--gc`
4242

0 commit comments

Comments
 (0)