qa 0.20.1-node → 0.20.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/cli.cjs +193 -0
- package/package.json +14 -16
- package/mo.mjs +0 -1926
package/cli.cjs
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync, spawn } = require("node:child_process");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
const os = process.platform === "win32" ? "windows" : process.platform;
|
|
8
|
+
const report = os === "linux" ? process.report.getReport() : undefined;
|
|
9
|
+
const header =
|
|
10
|
+
typeof report === "object" && report && "header" in report
|
|
11
|
+
? report.header
|
|
12
|
+
: undefined;
|
|
13
|
+
const libc =
|
|
14
|
+
os === "linux" &&
|
|
15
|
+
!(typeof header === "object" && header && "glibcVersionRuntime" in header)
|
|
16
|
+
? "-musl"
|
|
17
|
+
: "";
|
|
18
|
+
const target = `${os}-${process.arch}${libc}`;
|
|
19
|
+
|
|
20
|
+
const ALL_TARGETS = [
|
|
21
|
+
"darwin-arm64",
|
|
22
|
+
"darwin-x64",
|
|
23
|
+
"linux-arm64",
|
|
24
|
+
"linux-arm64-musl",
|
|
25
|
+
"linux-x64",
|
|
26
|
+
"linux-x64-musl",
|
|
27
|
+
"windows-x64",
|
|
28
|
+
];
|
|
29
|
+
const DOCS_URL = "https://docs.momentic.ai/cli-reference/mo/overview";
|
|
30
|
+
|
|
31
|
+
/** @param {string} t */
|
|
32
|
+
const binaryEntry = (t) =>
|
|
33
|
+
`@momentic/qa-${t}/bin/${t.startsWith("windows") ? "qa.exe" : "qa"}`;
|
|
34
|
+
|
|
35
|
+
/** @param {string} entry */
|
|
36
|
+
function tryResolve(entry) {
|
|
37
|
+
try {
|
|
38
|
+
return require.resolve(entry);
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Windows and macOS arm64 hosts can run the x64 build under emulation.
|
|
45
|
+
const emulatedTargets =
|
|
46
|
+
process.arch === "arm64" && (os === "darwin" || os === "windows")
|
|
47
|
+
? [`${os}-x64`]
|
|
48
|
+
: [];
|
|
49
|
+
|
|
50
|
+
// The package manager that ran us identifies itself in npm_config_user_agent,
|
|
51
|
+
// e.g. "pnpm/9.1.0 npm/? node/v20.11.0 darwin arm64".
|
|
52
|
+
function detectPackageManager() {
|
|
53
|
+
const match = process.env.npm_config_user_agent?.match(/^(\S+)\/(\d+)/);
|
|
54
|
+
return match ? { name: match[1], major: Number(match[2]) } : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @param {{ name: string; major: number } | null} pm */
|
|
58
|
+
function repairCommand(pm) {
|
|
59
|
+
switch (pm?.name) {
|
|
60
|
+
case "pnpm":
|
|
61
|
+
return "pnpm install --force";
|
|
62
|
+
case "bun":
|
|
63
|
+
return "bun install --force";
|
|
64
|
+
case "yarn":
|
|
65
|
+
return pm.major === 1 ? "yarn install --check-files" : "yarn install";
|
|
66
|
+
default:
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Optional dependencies can be skipped (--omit=optional, broken lockfiles, or
|
|
72
|
+
// node_modules copied across platforms). Try a just-in-time install from the
|
|
73
|
+
// qa package directory before giving up.
|
|
74
|
+
function installMissingBinary() {
|
|
75
|
+
let qaDir;
|
|
76
|
+
try {
|
|
77
|
+
qaDir = path.dirname(require.resolve("qa/package"));
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
console.warn(
|
|
82
|
+
`The qa binary for ${target} is missing; attempting to install it now.`,
|
|
83
|
+
);
|
|
84
|
+
try {
|
|
85
|
+
// Erase npm_config_global so a global `npm i -g qa` invocation does not
|
|
86
|
+
// deadlock on the global install lock when this runs nested.
|
|
87
|
+
execSync(
|
|
88
|
+
"npm install --loglevel=error --prefer-offline --no-audit --no-save --no-package-lock --progress=false",
|
|
89
|
+
{
|
|
90
|
+
cwd: qaDir,
|
|
91
|
+
stdio: "pipe",
|
|
92
|
+
env: { ...process.env, npm_config_global: undefined },
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
return true;
|
|
96
|
+
} catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function reportMissingBinary() {
|
|
102
|
+
console.error();
|
|
103
|
+
console.error(`Cannot find the qa binary for ${target}.`);
|
|
104
|
+
const otherPlatforms = ALL_TARGETS.filter(
|
|
105
|
+
(t) => t !== target && tryResolve(binaryEntry(t)),
|
|
106
|
+
);
|
|
107
|
+
if (otherPlatforms.length > 0) {
|
|
108
|
+
console.error(
|
|
109
|
+
`Found binaries for other platforms: ${otherPlatforms.join(", ")}.`,
|
|
110
|
+
);
|
|
111
|
+
console.error(
|
|
112
|
+
"This usually means node_modules was copied between different operating systems or architectures (for example into a Docker image or a shared volume). Reinstall dependencies in the environment where you run qa.",
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
console.error(
|
|
116
|
+
"No platform binaries are installed. This can happen when optional dependencies are skipped (npm install --omit=optional).",
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
const pm = detectPackageManager();
|
|
120
|
+
const repair = repairCommand(pm);
|
|
121
|
+
console.error(
|
|
122
|
+
`Reinstall qa with optional dependencies enabled: npm install --include=optional qa` +
|
|
123
|
+
(pm && repair ? ` — with ${pm.name}, run \`${repair}\`.` : "."),
|
|
124
|
+
);
|
|
125
|
+
console.error(`Supported platforms: ${ALL_TARGETS.join(", ")}.`);
|
|
126
|
+
console.error(`See ${DOCS_URL} for supported platforms and install options.`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function resolveBinary() {
|
|
130
|
+
const override = process.env.MO_BINARY_PATH;
|
|
131
|
+
if (override) {
|
|
132
|
+
if (fs.existsSync(override)) {
|
|
133
|
+
return override;
|
|
134
|
+
}
|
|
135
|
+
console.error(`MO_BINARY_PATH points to a file that does not exist:`);
|
|
136
|
+
console.error(override);
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let binary = tryResolve(binaryEntry(target));
|
|
141
|
+
if (binary) {
|
|
142
|
+
return binary;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (installMissingBinary()) {
|
|
146
|
+
binary = tryResolve(binaryEntry(target));
|
|
147
|
+
if (binary) {
|
|
148
|
+
console.warn("Installation succeeded.");
|
|
149
|
+
return binary;
|
|
150
|
+
}
|
|
151
|
+
console.warn(
|
|
152
|
+
"npm reported success, but the binary is still missing. npm skips failed optional dependencies without reporting an error.",
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
for (const t of emulatedTargets) {
|
|
157
|
+
binary = tryResolve(binaryEntry(t));
|
|
158
|
+
if (binary) {
|
|
159
|
+
console.warn(
|
|
160
|
+
`No qa binary for ${target}; running the ${t} build under emulation.`,
|
|
161
|
+
);
|
|
162
|
+
return binary;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
reportMissingBinary();
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const binary = resolveBinary();
|
|
171
|
+
const child = spawn(binary, process.argv.slice(2), {
|
|
172
|
+
stdio: "inherit",
|
|
173
|
+
env: { ...process.env, MOMENTIC_MO_INSTALL_METHOD: "npm" },
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
/** @type {NodeJS.Signals[]} */
|
|
177
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
178
|
+
for (const signal of signals) {
|
|
179
|
+
process.on(signal, () => child.kill(signal));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
child.on("error", (err) => {
|
|
183
|
+
console.error(`Could not start qa: ${err.message}`);
|
|
184
|
+
process.exitCode = 1;
|
|
185
|
+
});
|
|
186
|
+
child.on("exit", (code, signal) => {
|
|
187
|
+
if (signal) {
|
|
188
|
+
process.removeAllListeners(signal);
|
|
189
|
+
process.kill(process.pid, signal);
|
|
190
|
+
} else {
|
|
191
|
+
process.exitCode = code ?? 1;
|
|
192
|
+
}
|
|
193
|
+
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qa",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "The CLI for Mo, Momentic's autonomous QA agent.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"bin": {
|
|
7
|
-
"qa": "./
|
|
7
|
+
"qa": "./cli.cjs"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
10
|
+
"cli.cjs"
|
|
11
11
|
],
|
|
12
|
-
"repository":
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/momentic-ai/monorepo.git",
|
|
15
|
-
"directory": "packages/mo-cli"
|
|
16
|
-
},
|
|
12
|
+
"repository": "github:momentic-ai/qa",
|
|
17
13
|
"homepage": "https://momentic.ai/mo",
|
|
18
14
|
"bugs": "https://github.com/momentic-ai/qa/issues",
|
|
19
15
|
"keywords": [
|
|
@@ -33,17 +29,19 @@
|
|
|
33
29
|
"cli"
|
|
34
30
|
],
|
|
35
31
|
"publishConfig": {
|
|
36
|
-
"access": "public"
|
|
37
|
-
"tag": "node"
|
|
32
|
+
"access": "public"
|
|
38
33
|
},
|
|
39
34
|
"type": "module",
|
|
40
35
|
"engines": {
|
|
41
36
|
"node": "^22.12.0 || >=24.0.0"
|
|
42
37
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
38
|
+
"optionalDependencies": {
|
|
39
|
+
"@momentic/qa-darwin-arm64": "0.20.2",
|
|
40
|
+
"@momentic/qa-darwin-x64": "0.20.2",
|
|
41
|
+
"@momentic/qa-linux-arm64": "0.20.2",
|
|
42
|
+
"@momentic/qa-linux-arm64-musl": "0.20.2",
|
|
43
|
+
"@momentic/qa-linux-x64": "0.20.2",
|
|
44
|
+
"@momentic/qa-linux-x64-musl": "0.20.2",
|
|
45
|
+
"@momentic/qa-windows-x64": "0.20.2"
|
|
46
|
+
}
|
|
49
47
|
}
|