ic-mops 2.15.0 → 2.15.2
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 +12 -0
- package/bundle/cli.tgz +0 -0
- package/cli.ts +31 -11
- package/commands/bench-replica.ts +2 -1
- package/commands/bench.ts +32 -9
- package/commands/check-stable.ts +20 -3
- package/commands/check.ts +6 -1
- package/dist/cli.js +18 -10
- package/dist/commands/bench-replica.js +3 -1
- package/dist/commands/bench.js +21 -4
- package/dist/commands/check-stable.d.ts +2 -1
- package/dist/commands/check-stable.js +8 -2
- package/dist/commands/check.js +6 -1
- package/dist/helpers/autofix-motoko.js +19 -2
- package/dist/helpers/migrations.d.ts +16 -0
- package/dist/helpers/migrations.js +71 -1
- package/dist/helpers/parse-most.d.ts +5 -0
- package/dist/helpers/parse-most.js +28 -0
- package/dist/helpers/pocket-ic-client.d.ts +2 -2
- package/dist/helpers/pocket-ic-client.js +8 -4
- package/dist/package.json +1 -1
- package/dist/tests/check-fix.test.js +14 -2
- package/dist/tests/check-stable.test.js +15 -0
- package/dist/tests/check.test.js +5 -0
- package/dist/tests/lint.test.js +1 -1
- package/dist/tests/migrations-most.test.d.ts +1 -0
- package/dist/tests/migrations-most.test.js +47 -0
- package/helpers/autofix-motoko.ts +23 -2
- package/helpers/migrations.ts +117 -0
- package/helpers/parse-most.ts +32 -0
- package/helpers/pocket-ic-client.ts +11 -5
- package/package.json +1 -1
- package/tests/__snapshots__/check-stable.test.ts.snap +11 -0
- package/tests/__snapshots__/lint.test.ts.snap +29 -1
- package/tests/check-fix.test.ts +26 -2
- package/tests/check-stable/check-limit-warning/deployed.most +8 -0
- package/tests/check-stable/check-limit-warning/migrations/20250101_000000_Init.mo +5 -0
- package/tests/check-stable/check-limit-warning/migrations/20250201_000000_AddField.mo +9 -0
- package/tests/check-stable/check-limit-warning/migrations/20250301_000000_AddD.mo +10 -0
- package/tests/check-stable/check-limit-warning/mops.toml +15 -0
- package/tests/check-stable/check-limit-warning/src/main.mo +12 -0
- package/tests/check-stable.test.ts +24 -0
- package/tests/check.test.ts +9 -0
- package/tests/lint-extra-example-rules/lint/migration-self-contained/migration-self-contained.toml +7 -0
- package/tests/lint-extra-example-rules/migrations/20250101_000000_Init.mo +11 -0
- package/tests/lint-extra-example-rules/mops.toml +1 -0
- package/tests/lint.test.ts +1 -1
- package/tests/migrations-most.test.ts +64 -0
package/tests/lint.test.ts
CHANGED
|
@@ -83,7 +83,7 @@ describe("lint", () => {
|
|
|
83
83
|
);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
test("example rules: no-types, types-only, migration-only", async () => {
|
|
86
|
+
test("example rules: no-types, types-only, migration-only, migration-self-contained", async () => {
|
|
87
87
|
const cwd = path.join(import.meta.dirname, "lint-extra-example-rules");
|
|
88
88
|
await cliSnapshot(["lint"], { cwd }, 1);
|
|
89
89
|
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import {
|
|
3
|
+
latestAppliedMigrationName,
|
|
4
|
+
parseMostAppliedMigrationNames,
|
|
5
|
+
} from "../helpers/parse-most";
|
|
6
|
+
|
|
7
|
+
describe("parseMostAppliedMigrationNames", () => {
|
|
8
|
+
test("parses Version 4.0.0 enhanced-migration chain", () => {
|
|
9
|
+
const content = `// Version: 4.0.0
|
|
10
|
+
{
|
|
11
|
+
"20250101_000000_Init" : {} -> {a : Nat; b : Text};
|
|
12
|
+
"20250201_000000_AddField" : (old : {a : Nat; b : Text}) -> {a : Nat; b : Text; c : Bool};
|
|
13
|
+
}
|
|
14
|
+
actor {
|
|
15
|
+
stable a : Nat;
|
|
16
|
+
stable b : Text;
|
|
17
|
+
stable c : Bool
|
|
18
|
+
};
|
|
19
|
+
`;
|
|
20
|
+
expect(parseMostAppliedMigrationNames(content)).toEqual([
|
|
21
|
+
"20250101_000000_Init",
|
|
22
|
+
"20250201_000000_AddField",
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("returns empty array for Version 1.0.0 (no EM chain)", () => {
|
|
27
|
+
expect(
|
|
28
|
+
parseMostAppliedMigrationNames("// Version: 1.0.0\nactor { };\n"),
|
|
29
|
+
).toEqual([]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("returns empty array for Version 3.0.0 (legacy migration)", () => {
|
|
33
|
+
const content = `// Version: 3.0.0
|
|
34
|
+
actor ({
|
|
35
|
+
}, {
|
|
36
|
+
stable var field1 : Nat;
|
|
37
|
+
stable var field2 : Text
|
|
38
|
+
});
|
|
39
|
+
`;
|
|
40
|
+
expect(parseMostAppliedMigrationNames(content)).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("returns null when version header is missing", () => {
|
|
44
|
+
expect(parseMostAppliedMigrationNames("actor { };\n")).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("returns null when Version 4.0.0 has no actor block", () => {
|
|
48
|
+
expect(
|
|
49
|
+
parseMostAppliedMigrationNames(
|
|
50
|
+
'// Version: 4.0.0\n{ "Init" : {} -> {} }',
|
|
51
|
+
),
|
|
52
|
+
).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("latestAppliedMigrationName picks lexicographic max", () => {
|
|
56
|
+
expect(
|
|
57
|
+
latestAppliedMigrationName([
|
|
58
|
+
"20250101_000000_Init",
|
|
59
|
+
"20250301_000000_AddD",
|
|
60
|
+
"20250201_000000_AddField",
|
|
61
|
+
]),
|
|
62
|
+
).toBe("20250301_000000_AddD");
|
|
63
|
+
});
|
|
64
|
+
});
|