@mettlelabs/mettle 0.0.0-0 → 0.0.0-beta.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/bin/mettle.js +51 -0
- package/package.json +22 -3
package/bin/mettle.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// docs/scripts/src/launcher.md
|
|
3
|
+
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { constants } from "node:os";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const { name, bin, optionalDependencies } = require("../package.json");
|
|
11
|
+
const target = `${process.platform}-${process.arch}`;
|
|
12
|
+
const [command] = Object.keys(bin);
|
|
13
|
+
|
|
14
|
+
let binary;
|
|
15
|
+
try {
|
|
16
|
+
binary = join(
|
|
17
|
+
dirname(require.resolve(`${name}-${target}/package.json`)),
|
|
18
|
+
"bin",
|
|
19
|
+
command,
|
|
20
|
+
);
|
|
21
|
+
} catch {
|
|
22
|
+
const supported = Object.keys(optionalDependencies)
|
|
23
|
+
.map((alias) => alias.slice(name.length + 1))
|
|
24
|
+
.join(", ");
|
|
25
|
+
process.stderr.write(
|
|
26
|
+
`${name} has no build installed for ${target}. Builds exist for ${supported}. ` +
|
|
27
|
+
"If yours is listed, reinstall without --omit=optional or --no-optional.\n",
|
|
28
|
+
);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
33
|
+
|
|
34
|
+
for (const signal of ["SIGINT", "SIGHUP", "SIGQUIT"])
|
|
35
|
+
process.on(signal, () => {});
|
|
36
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
37
|
+
|
|
38
|
+
child.on("error", (error) => {
|
|
39
|
+
process.stderr.write(`${binary}: ${error.message}\n`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
child.on("exit", (code, signal) => {
|
|
44
|
+
if (signal) {
|
|
45
|
+
process.removeAllListeners(signal);
|
|
46
|
+
process.exitCode = 128 + constants.signals[signal];
|
|
47
|
+
process.kill(process.pid, signal);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
process.exit(code);
|
|
51
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mettlelabs/mettle",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0-beta.1",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mettle": "bin/mettle.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "24.x"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/prolabsinc/mettle-cli.git"
|
|
18
|
+
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"@mettlelabs/mettle-darwin-arm64": "npm:@mettlelabs/mettle@0.0.0-beta.1-darwin-arm64",
|
|
21
|
+
"@mettlelabs/mettle-darwin-x64": "npm:@mettlelabs/mettle@0.0.0-beta.1-darwin-x64",
|
|
22
|
+
"@mettlelabs/mettle-linux-x64": "npm:@mettlelabs/mettle@0.0.0-beta.1-linux-x64",
|
|
23
|
+
"@mettlelabs/mettle-linux-arm64": "npm:@mettlelabs/mettle@0.0.0-beta.1-linux-arm64"
|
|
24
|
+
}
|
|
6
25
|
}
|