ic-mops 2.3.0 → 2.3.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 CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Next
4
4
 
5
+ ## 2.3.1
6
+ - Fix `mops build` and `mops check-candid` failing with "Wasm bindings have not been set" when installed via `npm i -g ic-mops`
7
+
5
8
  ## 2.3.0
6
9
  - Add `mops check-stable` command for stable variable compatibility checking
7
10
  - `mops check` now falls back to canister entrypoints from `mops.toml` when no files are specified
package/dist/bin/mops.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import "../cli.js";
3
+ import "../environments/nodejs/cli.js";
package/dist/fix-dist.js CHANGED
@@ -7,3 +7,8 @@ delete json.scripts;
7
7
  json.bin.mops = "bin/mops.js";
8
8
  json.bin["ic-mops"] = "bin/mops.js";
9
9
  writeFileSync("dist/package.json", JSON.stringify(json, null, 2));
10
+ // Route the npm entry point through the Node.js environment wrapper
11
+ // so setWasmBindings() is called before the CLI runs.
12
+ // The source bin/mops.js imports ../cli.js (needed for the single-file bundle),
13
+ // but dist/ has the full directory structure with environments/nodejs/cli.js.
14
+ writeFileSync("dist/bin/mops.js", '#!/usr/bin/env node\n\nimport "../environments/nodejs/cli.js";\n');
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
@@ -1,6 +1,9 @@
1
1
  import { describe, expect, test } from "@jest/globals";
2
+ import { execa } from "execa";
3
+ import { existsSync } from "node:fs";
2
4
  import path from "path";
3
5
  import { cliSnapshot } from "./helpers";
6
+ const distBin = path.resolve(import.meta.dirname, "../dist/bin/mops.js");
4
7
  describe("build", () => {
5
8
  test("ok", async () => {
6
9
  const cwd = path.join(import.meta.dirname, "build/success");
@@ -15,4 +18,19 @@ describe("build", () => {
15
18
  expect((await cliSnapshot(["build", "bar"], { cwd }, 1)).stderr).toMatch("Candid compatibility check failed for canister bar");
16
19
  expect((await cliSnapshot(["build", "foo", "bar"], { cwd }, 1)).stderr).toMatch("Candid compatibility check failed for canister bar");
17
20
  });
21
+ // Regression: bin/mops.js must route through environments/nodejs/cli.js
22
+ // so that setWasmBindings() is called before any command runs.
23
+ // The dev entry point (npm run mops) uses tsx and always worked;
24
+ // this test exercises the compiled dist binary (same path as npm i -g ic-mops).
25
+ const hasDistBin = existsSync(distBin);
26
+ (hasDistBin ? test : test.skip)("wasm bindings initialized via dist entry point", async () => {
27
+ const cwd = path.join(import.meta.dirname, "build/success");
28
+ const result = await execa("node", [distBin, "build", "foo"], {
29
+ cwd,
30
+ stdio: "pipe",
31
+ reject: false,
32
+ });
33
+ expect(result.stderr).not.toContain("Wasm bindings have not been set");
34
+ expect(result.exitCode).toBe(0);
35
+ });
18
36
  });
Binary file
Binary file
package/fix-dist.ts CHANGED
@@ -10,3 +10,12 @@ json.bin.mops = "bin/mops.js";
10
10
  json.bin["ic-mops"] = "bin/mops.js";
11
11
 
12
12
  writeFileSync("dist/package.json", JSON.stringify(json, null, 2));
13
+
14
+ // Route the npm entry point through the Node.js environment wrapper
15
+ // so setWasmBindings() is called before the CLI runs.
16
+ // The source bin/mops.js imports ../cli.js (needed for the single-file bundle),
17
+ // but dist/ has the full directory structure with environments/nodejs/cli.js.
18
+ writeFileSync(
19
+ "dist/bin/mops.js",
20
+ '#!/usr/bin/env node\n\nimport "../environments/nodejs/cli.js";\n',
21
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/bin/mops.js",
@@ -1,7 +1,11 @@
1
1
  import { describe, expect, test } from "@jest/globals";
2
+ import { execa } from "execa";
3
+ import { existsSync } from "node:fs";
2
4
  import path from "path";
3
5
  import { cliSnapshot } from "./helpers";
4
6
 
7
+ const distBin = path.resolve(import.meta.dirname, "../dist/bin/mops.js");
8
+
5
9
  describe("build", () => {
6
10
  test("ok", async () => {
7
11
  const cwd = path.join(import.meta.dirname, "build/success");
@@ -21,4 +25,24 @@ describe("build", () => {
21
25
  (await cliSnapshot(["build", "foo", "bar"], { cwd }, 1)).stderr,
22
26
  ).toMatch("Candid compatibility check failed for canister bar");
23
27
  });
28
+
29
+ // Regression: bin/mops.js must route through environments/nodejs/cli.js
30
+ // so that setWasmBindings() is called before any command runs.
31
+ // The dev entry point (npm run mops) uses tsx and always worked;
32
+ // this test exercises the compiled dist binary (same path as npm i -g ic-mops).
33
+ const hasDistBin = existsSync(distBin);
34
+ (hasDistBin ? test : test.skip)(
35
+ "wasm bindings initialized via dist entry point",
36
+ async () => {
37
+ const cwd = path.join(import.meta.dirname, "build/success");
38
+ const result = await execa("node", [distBin, "build", "foo"], {
39
+ cwd,
40
+ stdio: "pipe",
41
+ reject: false,
42
+ });
43
+
44
+ expect(result.stderr).not.toContain("Wasm bindings have not been set");
45
+ expect(result.exitCode).toBe(0);
46
+ },
47
+ );
24
48
  });
Binary file
Binary file
package/bundle/cli.tgz DELETED
Binary file