mmwaa 0.1.7 → 0.1.9

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.
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Decision 0012 couples the release target matrix across THREE files that must
4
+ // move together: scripts/cross-cc.sh (WAA_TARGETS_DEFAULT — the canonical
5
+ // GOOS/GOARCH build matrix), scripts/prepare-npm-package.sh (the artifacts it
6
+ // vendors into this package), and bin/targets.js (the launcher's
7
+ // platform->binary map). Nothing made them agree, so adding a target to the
8
+ // build matrix while forgetting targets.js shipped a release that built and
9
+ // vendored a binary the launcher could never select — that platform's users
10
+ // got "unsupported" from a release that looked complete. This guard derives the
11
+ // expected artifact + launcher entries from the canonical matrix and fails the
12
+ // release if either of the other two files disagrees. Treats cross-cc.sh as the
13
+ // single source of truth (it is sh-native and sourced by the build scripts, so
14
+ // it cannot be derived from node without making the build depend on node).
15
+
16
+ const { readFileSync } = require("node:fs");
17
+ const { join } = require("node:path");
18
+
19
+ const { targets, requiredArtifacts } = require("./targets");
20
+
21
+ const repoRoot = join(__dirname, "..", "..", "..");
22
+ const crossCcPath = join(repoRoot, "scripts", "cross-cc.sh");
23
+ const prepareNpmPath = join(repoRoot, "scripts", "prepare-npm-package.sh");
24
+
25
+ // GOOS/GOARCH -> Node process.platform/process.arch. These are the only values
26
+ // the build matrix can contain; an unmapped one means the matrix grew a target
27
+ // this guard (and the launcher) has no mapping for, which is itself the drift
28
+ // we want to catch loudly rather than guess past.
29
+ const platformForGoos = { darwin: "darwin", linux: "linux", windows: "win32" };
30
+ const archForGoarch = { amd64: "x64", arm64: "arm64" };
31
+
32
+ const errors = [];
33
+
34
+ // Parse the canonical matrix: WAA_TARGETS_DEFAULT="os/arch os/arch ...".
35
+ const crossCc = readFileSync(crossCcPath, "utf8");
36
+ const matrixMatch = crossCc.match(/WAA_TARGETS_DEFAULT="([^"]*)"/);
37
+ if (!matrixMatch) {
38
+ console.error(`check-targets: could not find WAA_TARGETS_DEFAULT in ${crossCcPath}`);
39
+ process.exit(1);
40
+ }
41
+ const matrix = matrixMatch[1].trim().split(/\s+/).filter(Boolean);
42
+
43
+ // Derive the expected artifact names and launcher map from the canonical matrix,
44
+ // using the SAME name shape as scripts/build-release.sh (waa-<os>-<arch>[.exe]).
45
+ const expectedBinaries = [];
46
+ const expectedTargets = {};
47
+ for (const entry of matrix) {
48
+ const [goos, goarch] = entry.split("/");
49
+ const platform = platformForGoos[goos];
50
+ const arch = archForGoarch[goarch];
51
+ if (!platform || !arch) {
52
+ errors.push(`cross-cc.sh matrix entry ${entry} has no Node platform/arch mapping in check-targets.js`);
53
+ continue;
54
+ }
55
+ const binary = `waa-${goos}-${goarch}${goos === "windows" ? ".exe" : ""}`;
56
+ expectedBinaries.push(binary);
57
+ expectedTargets[`${platform}-${arch}`] = binary;
58
+ }
59
+
60
+ const sortedJoin = (values) => [...new Set(values)].sort().join(", ");
61
+ const setEqual = (a, b) => sortedJoin(a) === sortedJoin(b);
62
+
63
+ // 1. targets.js launcher map must match the matrix exactly (keys and binaries).
64
+ const targetEntries = Object.entries(targets);
65
+ const expectedEntries = Object.entries(expectedTargets);
66
+ if (
67
+ !setEqual(Object.keys(targets), Object.keys(expectedTargets)) ||
68
+ targetEntries.some(([key, binary]) => expectedTargets[key] !== binary) ||
69
+ targetEntries.length !== expectedEntries.length
70
+ ) {
71
+ errors.push(
72
+ `bin/targets.js map [${sortedJoin(targetEntries.map(([k, v]) => `${k}=>${v}`))}] ` +
73
+ `does not match the cross-cc.sh matrix [${sortedJoin(expectedEntries.map(([k, v]) => `${k}=>${v}`))}]`
74
+ );
75
+ }
76
+
77
+ // 2. targets.js requiredArtifacts must be every expected binary plus SHA256SUMS.
78
+ const expectedArtifacts = [...expectedBinaries, "SHA256SUMS"];
79
+ if (!setEqual(requiredArtifacts, expectedArtifacts)) {
80
+ errors.push(
81
+ `bin/targets.js requiredArtifacts [${sortedJoin(requiredArtifacts)}] ` +
82
+ `does not match the expected set [${sortedJoin(expectedArtifacts)}]`
83
+ );
84
+ }
85
+
86
+ // 3. prepare-npm-package.sh must vendor exactly the expected binaries (it lists
87
+ // them as literal waa-<os>-<arch> tokens in its artifact/copy block).
88
+ const prepareNpm = readFileSync(prepareNpmPath, "utf8");
89
+ const vendoredBinaries = prepareNpm.match(/waa-[a-z0-9]+-[a-z0-9]+(?:\.exe)?/g) || [];
90
+ if (!setEqual(vendoredBinaries, expectedBinaries)) {
91
+ errors.push(
92
+ `scripts/prepare-npm-package.sh vendors [${sortedJoin(vendoredBinaries)}] ` +
93
+ `but the cross-cc.sh matrix expects [${sortedJoin(expectedBinaries)}]`
94
+ );
95
+ }
96
+ if (!prepareNpm.includes("SHA256SUMS")) {
97
+ errors.push("scripts/prepare-npm-package.sh does not reference SHA256SUMS");
98
+ }
99
+
100
+ if (errors.length > 0) {
101
+ console.error("waa: release target matrix is out of sync across the three files coupled by decision 0012:");
102
+ for (const error of errors) {
103
+ console.error(` - ${error}`);
104
+ }
105
+ console.error("Update scripts/cross-cc.sh, scripts/prepare-npm-package.sh, and bin/targets.js together.");
106
+ process.exit(1);
107
+ }
108
+
109
+ console.log(`check-targets: release target matrix consistent across cross-cc.sh, prepare-npm-package.sh, targets.js (${matrix.join(" ")})`);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "mmwaa",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Zero-config launcher for the waa WhatsApp automation CLI + MCP server",
5
5
  "bin": {
6
6
  "waa": "bin/waa.js"
7
7
  },
8
8
  "scripts": {
9
- "prepublishOnly": "node bin/check-package.js"
9
+ "prepublishOnly": "node bin/check-targets.js && node bin/check-package.js"
10
10
  },
11
11
  "files": [
12
12
  "bin/",
package/vendor/SHA256SUMS CHANGED
@@ -1,5 +1,5 @@
1
- 87140b040650436348c198ed5550a7db8febc0a35c4d946e85f09ae7b661e168 waa-darwin-amd64
2
- 9ef893c81cb643c41314651320afb537be36c4cd4ac6e8ce2dfc091a3dbfce3d waa-darwin-arm64
3
- 7946785b202ae5a3773c36033c695c145ff87f8ea0d9b01957ca56bd957174c7 waa-linux-amd64
4
- 78200bca17ad2e2274572fc31a800b33058cd8ead59ad9f56fdc0564cbe9fb02 waa-linux-arm64
5
- 56974a2a07695aadf4a273ee66365819d02cf97297c1112ff07ca10557d97d4a waa-windows-amd64.exe
1
+ bb8c8460c8395c1a312cdf2a573d5530b67f63dc510e2de66a048d479b575996 waa-darwin-amd64
2
+ 0aded63e1d39bced0de7f5e61cd8baad2973aa6a76e80fdb0cb573aea01b6150 waa-darwin-arm64
3
+ f190b991be05c805b02f7ce5eea64b7c80d495fc7d234e4eb2ccadd149313509 waa-linux-amd64
4
+ c26446d66640a5fb263a9b25742b1c0b2ce2b6f2a5812fb1e556c2b20c377125 waa-linux-arm64
5
+ 8387c9dc327f959b2f8656bfbd8706e2d6a9aa4e194e98f07e3f5d9cdc20e3e2 waa-windows-amd64.exe
Binary file
Binary file
Binary file
Binary file
Binary file