ic-mops 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/bundle/cli.tgz +0 -0
- package/commands/check-stable.ts +9 -10
- package/dist/commands/check-stable.js +9 -10
- package/dist/package.json +1 -1
- package/dist/tests/check-stable.test.js +11 -0
- package/package.json +1 -1
- package/tests/check-stable/actor-idl/mops.toml +8 -0
- package/tests/check-stable/actor-idl/new.mo +6 -0
- package/tests/check-stable/actor-idl/old.mo +5 -0
- package/tests/check-stable/actor-idl/system-idl/aaaaa-aa.did +3 -0
- package/tests/check-stable.test.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Next
|
|
4
4
|
|
|
5
|
+
## 2.8.1
|
|
6
|
+
|
|
7
|
+
- Fix `mops check-stable` failing when `[moc] args` contains flags with relative paths (e.g. `--actor-idl=system-idl`)
|
|
8
|
+
|
|
5
9
|
## 2.8.0
|
|
6
10
|
|
|
7
11
|
- `mops build` now generates a `.most` (Motoko stable types) file alongside `.wasm` and `.did` for each canister; the `.most` file can be passed directly to `mops check-stable` to verify upgrade compatibility
|
package/bundle/cli.tgz
CHANGED
|
Binary file
|
package/commands/check-stable.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { basename, join
|
|
1
|
+
import { basename, join } from "node:path";
|
|
2
2
|
import { existsSync, mkdirSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { execa } from "execa";
|
|
6
6
|
import { cliError } from "../error.js";
|
|
@@ -62,8 +62,7 @@ export async function runStableCheck(
|
|
|
62
62
|
options = {},
|
|
63
63
|
} = params;
|
|
64
64
|
|
|
65
|
-
const
|
|
66
|
-
const sources = (await sourcesArgs({ cwd: checkStableDir })).flat();
|
|
65
|
+
const sources = (await sourcesArgs()).flat();
|
|
67
66
|
const isOldMostFile = oldFile.endsWith(".most");
|
|
68
67
|
|
|
69
68
|
if (!existsSync(oldFile)) {
|
|
@@ -137,10 +136,13 @@ async function generateStableTypes(
|
|
|
137
136
|
globalMocArgs: string[],
|
|
138
137
|
options: Partial<CheckStableOptions>,
|
|
139
138
|
): Promise<string> {
|
|
140
|
-
const
|
|
139
|
+
const base = basename(outputPath, ".most");
|
|
140
|
+
const wasmPath = join(CHECK_STABLE_DIR, base + ".wasm");
|
|
141
141
|
const args = [
|
|
142
142
|
"--stable-types",
|
|
143
|
-
|
|
143
|
+
"-o",
|
|
144
|
+
wasmPath,
|
|
145
|
+
moFile,
|
|
144
146
|
...sources,
|
|
145
147
|
...globalMocArgs,
|
|
146
148
|
...(options.extraArgs ?? []),
|
|
@@ -155,7 +157,6 @@ async function generateStableTypes(
|
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
const result = await execa(mocPath, args, {
|
|
158
|
-
cwd: CHECK_STABLE_DIR,
|
|
159
160
|
stdio: "pipe",
|
|
160
161
|
reject: false,
|
|
161
162
|
});
|
|
@@ -169,9 +170,7 @@ async function generateStableTypes(
|
|
|
169
170
|
);
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
|
|
173
|
-
await rename(join(CHECK_STABLE_DIR, base + ".most"), outputPath);
|
|
174
|
-
await rm(join(CHECK_STABLE_DIR, base + ".wasm"), { force: true });
|
|
173
|
+
await rm(wasmPath, { force: true });
|
|
175
174
|
|
|
176
175
|
return outputPath;
|
|
177
176
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { basename, join
|
|
1
|
+
import { basename, join } from "node:path";
|
|
2
2
|
import { existsSync, mkdirSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { execa } from "execa";
|
|
6
6
|
import { cliError } from "../error.js";
|
|
@@ -28,8 +28,7 @@ export async function checkStable(oldFile, canisterName, options = {}) {
|
|
|
28
28
|
}
|
|
29
29
|
export async function runStableCheck(params) {
|
|
30
30
|
const { oldFile, canisterMain, canisterName, mocPath, globalMocArgs, options = {}, } = params;
|
|
31
|
-
const
|
|
32
|
-
const sources = (await sourcesArgs({ cwd: checkStableDir })).flat();
|
|
31
|
+
const sources = (await sourcesArgs()).flat();
|
|
33
32
|
const isOldMostFile = oldFile.endsWith(".most");
|
|
34
33
|
if (!existsSync(oldFile)) {
|
|
35
34
|
cliError(`File not found: ${oldFile}`);
|
|
@@ -65,10 +64,13 @@ export async function runStableCheck(params) {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
async function generateStableTypes(mocPath, moFile, outputPath, sources, globalMocArgs, options) {
|
|
68
|
-
const
|
|
67
|
+
const base = basename(outputPath, ".most");
|
|
68
|
+
const wasmPath = join(CHECK_STABLE_DIR, base + ".wasm");
|
|
69
69
|
const args = [
|
|
70
70
|
"--stable-types",
|
|
71
|
-
|
|
71
|
+
"-o",
|
|
72
|
+
wasmPath,
|
|
73
|
+
moFile,
|
|
72
74
|
...sources,
|
|
73
75
|
...globalMocArgs,
|
|
74
76
|
...(options.extraArgs ?? []),
|
|
@@ -78,7 +80,6 @@ async function generateStableTypes(mocPath, moFile, outputPath, sources, globalM
|
|
|
78
80
|
console.log(chalk.gray(mocPath, JSON.stringify(args)));
|
|
79
81
|
}
|
|
80
82
|
const result = await execa(mocPath, args, {
|
|
81
|
-
cwd: CHECK_STABLE_DIR,
|
|
82
83
|
stdio: "pipe",
|
|
83
84
|
reject: false,
|
|
84
85
|
});
|
|
@@ -88,8 +89,6 @@ async function generateStableTypes(mocPath, moFile, outputPath, sources, globalM
|
|
|
88
89
|
}
|
|
89
90
|
cliError(`Failed to generate stable types for ${moFile} (exit code: ${result.exitCode})`);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
await rename(join(CHECK_STABLE_DIR, base + ".most"), outputPath);
|
|
93
|
-
await rm(join(CHECK_STABLE_DIR, base + ".wasm"), { force: true });
|
|
92
|
+
await rm(wasmPath, { force: true });
|
|
94
93
|
return outputPath;
|
|
95
94
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import path from "path";
|
|
@@ -42,6 +43,16 @@ describe("check-stable", () => {
|
|
|
42
43
|
await rm(tempDir, { recursive: true, force: true });
|
|
43
44
|
}
|
|
44
45
|
});
|
|
46
|
+
test("works with relative paths in moc args (e.g. --actor-idl)", async () => {
|
|
47
|
+
const cwd = path.join(import.meta.dirname, "check-stable/actor-idl");
|
|
48
|
+
const result = await cli(["check-stable", "old.mo"], { cwd });
|
|
49
|
+
expect(result.exitCode).toBe(0);
|
|
50
|
+
expect(result.stdout).toMatch(/Stable compatibility check passed/);
|
|
51
|
+
expect(existsSync(path.join(cwd, "old.most"))).toBe(false);
|
|
52
|
+
expect(existsSync(path.join(cwd, "old.wasm"))).toBe(false);
|
|
53
|
+
expect(existsSync(path.join(cwd, "new.most"))).toBe(false);
|
|
54
|
+
expect(existsSync(path.join(cwd, "new.wasm"))).toBe(false);
|
|
55
|
+
});
|
|
45
56
|
test("errors when old file does not exist", async () => {
|
|
46
57
|
const cwd = path.join(import.meta.dirname, "check-stable/compatible");
|
|
47
58
|
const result = await cli(["check-stable", "nonexistent.mo"], { cwd });
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import path from "path";
|
|
@@ -47,6 +48,17 @@ describe("check-stable", () => {
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
|
|
51
|
+
test("works with relative paths in moc args (e.g. --actor-idl)", async () => {
|
|
52
|
+
const cwd = path.join(import.meta.dirname, "check-stable/actor-idl");
|
|
53
|
+
const result = await cli(["check-stable", "old.mo"], { cwd });
|
|
54
|
+
expect(result.exitCode).toBe(0);
|
|
55
|
+
expect(result.stdout).toMatch(/Stable compatibility check passed/);
|
|
56
|
+
expect(existsSync(path.join(cwd, "old.most"))).toBe(false);
|
|
57
|
+
expect(existsSync(path.join(cwd, "old.wasm"))).toBe(false);
|
|
58
|
+
expect(existsSync(path.join(cwd, "new.most"))).toBe(false);
|
|
59
|
+
expect(existsSync(path.join(cwd, "new.wasm"))).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
50
62
|
test("errors when old file does not exist", async () => {
|
|
51
63
|
const cwd = path.join(import.meta.dirname, "check-stable/compatible");
|
|
52
64
|
const result = await cli(["check-stable", "nonexistent.mo"], { cwd });
|