@forgeailab/smith 0.0.1 → 0.1.0
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/README.md +5 -3
- package/bin/cli.js +6 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,9 +7,11 @@ npx @forgeailab/smith
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
The package downloads the matching Smith GitHub release archive for macOS or
|
|
10
|
-
|
|
11
|
-
`~/.smith/npx`, and starts the `smith` binary.
|
|
12
|
-
|
|
10
|
+
Linux, verifies it against `SHA256SUMS` when available, caches it under
|
|
11
|
+
`~/.smith/npx`, and starts the `smith` binary. Linux always uses Smith's
|
|
12
|
+
fully static musl archive, so the same package works on glibc and musl hosts.
|
|
13
|
+
Explicitly named `smith-<arch>-linux-gnu.tar.gz` archives remain available
|
|
14
|
+
for users who prefer an Ubuntu 22.04-baseline GNU build.
|
|
13
15
|
|
|
14
16
|
Useful commands:
|
|
15
17
|
|
package/bin/cli.js
CHANGED
|
@@ -43,11 +43,11 @@ function isVersion(args) {
|
|
|
43
43
|
return args.includes("--version") || args.includes("-V");
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function parseArgs(argv) {
|
|
46
|
+
function parseArgs(argv, packageVersion = PACKAGE.version, env = process.env) {
|
|
47
47
|
const args = [...argv];
|
|
48
48
|
let release =
|
|
49
|
-
|
|
50
|
-
(
|
|
49
|
+
env.SMITH_NPX_TAG ||
|
|
50
|
+
(packageVersion === "0.0.0" ? "latest" : `v${packageVersion}`);
|
|
51
51
|
const passthrough = [];
|
|
52
52
|
|
|
53
53
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -71,14 +71,10 @@ function parseArgs(argv) {
|
|
|
71
71
|
return { passthrough, release };
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function platformInfo(
|
|
75
|
-
platform = process.platform,
|
|
76
|
-
archInput = process.arch,
|
|
77
|
-
libc = platform === "linux" ? linuxLibc() : null
|
|
78
|
-
) {
|
|
74
|
+
function platformInfo(platform = process.platform, archInput = process.arch) {
|
|
79
75
|
if (platform !== "darwin" && platform !== "linux") {
|
|
80
76
|
throw new Error(
|
|
81
|
-
`Unsupported platform ${platform}. Smith release archives currently support macOS and
|
|
77
|
+
`Unsupported platform ${platform}. Smith release archives currently support macOS and Linux.`
|
|
82
78
|
);
|
|
83
79
|
}
|
|
84
80
|
|
|
@@ -91,40 +87,10 @@ function platformInfo(
|
|
|
91
87
|
throw new Error(`Unsupported architecture ${archInput}`);
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
if (platform === "linux" && libc === "musl") {
|
|
95
|
-
throw new Error(
|
|
96
|
-
"Unsupported Linux libc musl. Smith release binaries currently require glibc; build from source on musl Linux."
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
90
|
const artifact = `smith-${arch}-${osName}`;
|
|
101
91
|
return { artifact, archiveName: `${artifact}.tar.gz` };
|
|
102
92
|
}
|
|
103
93
|
|
|
104
|
-
function linuxLibc() {
|
|
105
|
-
const override = process.env.SMITH_NPX_LIBC;
|
|
106
|
-
if (override === "gnu" || override === "musl") {
|
|
107
|
-
return override;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const report = process.report?.getReport?.();
|
|
111
|
-
if (report?.header?.glibcVersionRuntime) {
|
|
112
|
-
return "gnu";
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
let output = "";
|
|
116
|
-
try {
|
|
117
|
-
output = childProcess.execFileSync("ldd", ["--version"], {
|
|
118
|
-
encoding: "utf8",
|
|
119
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
120
|
-
});
|
|
121
|
-
} catch (error) {
|
|
122
|
-
output = `${error.stdout || ""}\n${error.stderr || ""}`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return /musl/i.test(output) ? "musl" : "gnu";
|
|
126
|
-
}
|
|
127
|
-
|
|
128
94
|
function request(url, redirects = 0) {
|
|
129
95
|
return new Promise((resolve, reject) => {
|
|
130
96
|
const req = https.get(
|
|
@@ -356,7 +322,7 @@ async function main() {
|
|
|
356
322
|
runBinary(release.binaryPath, options.passthrough, { ...process.env });
|
|
357
323
|
}
|
|
358
324
|
|
|
359
|
-
module.exports = { platformInfo };
|
|
325
|
+
module.exports = { parseArgs, platformInfo };
|
|
360
326
|
|
|
361
327
|
if (require.main === module) {
|
|
362
328
|
main().catch((error) => {
|
package/package.json
CHANGED