@substructure.ai/cli 0.2.0 → 0.2.3
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/subs.js +0 -0
- package/install.mjs +35 -0
- package/package.json +9 -5
package/bin/subs.js
CHANGED
|
Binary file
|
package/install.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Overwrite the bin shim with the native binary so `subs` execs it directly,
|
|
3
|
+
// skipping Node startup. Best-effort: on any failure the Node shim
|
|
4
|
+
// (bin/subs.js) stays in place and still works, just slower.
|
|
5
|
+
import { linkSync, copyFileSync, chmodSync, renameSync, unlinkSync } from "node:fs";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { resolve } from "./src/index.js";
|
|
9
|
+
|
|
10
|
+
// Skip under Yarn (overwriting a package file can corrupt its shared cache) and
|
|
11
|
+
// when a binary is supplied out of band.
|
|
12
|
+
const isYarn = (process.env.npm_config_user_agent || "").startsWith("yarn");
|
|
13
|
+
if (process.env.SUBS_BIN || process.env.SUBS_SKIP_POSTINSTALL || isYarn) process.exit(0);
|
|
14
|
+
|
|
15
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const shim = join(here, "bin", "subs.js");
|
|
17
|
+
const tmp = `${shim}.tmp`;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const bin = resolve();
|
|
21
|
+
if (bin === shim) process.exit(0);
|
|
22
|
+
let linked = false;
|
|
23
|
+
try {
|
|
24
|
+
linkSync(bin, tmp); // hardlink: no duplicate on disk
|
|
25
|
+
linked = true;
|
|
26
|
+
} catch {
|
|
27
|
+
copyFileSync(bin, tmp); // cross-device or unsupported: fall back to a copy
|
|
28
|
+
chmodSync(tmp, 0o755);
|
|
29
|
+
}
|
|
30
|
+
renameSync(tmp, shim); // atomic replace
|
|
31
|
+
} catch {
|
|
32
|
+
try {
|
|
33
|
+
unlinkSync(tmp);
|
|
34
|
+
} catch {}
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substructure.ai/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "CLI for Substructure",
|
|
5
5
|
"license": "FSL-1.1-ALv2",
|
|
6
6
|
"type": "module",
|
|
@@ -32,13 +32,17 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"bin",
|
|
34
34
|
"src",
|
|
35
|
+
"install.mjs",
|
|
35
36
|
"LICENSE",
|
|
36
37
|
"README.md"
|
|
37
38
|
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"postinstall": "node ./install.mjs"
|
|
41
|
+
},
|
|
38
42
|
"optionalDependencies": {
|
|
39
|
-
"@substructure.ai/cli-darwin-arm64": "0.
|
|
40
|
-
"@substructure.ai/cli-darwin-x64": "0.
|
|
41
|
-
"@substructure.ai/cli-linux-arm64": "0.
|
|
42
|
-
"@substructure.ai/cli-linux-x64": "0.
|
|
43
|
+
"@substructure.ai/cli-darwin-arm64": "0.2.3",
|
|
44
|
+
"@substructure.ai/cli-darwin-x64": "0.2.3",
|
|
45
|
+
"@substructure.ai/cli-linux-arm64": "0.2.3",
|
|
46
|
+
"@substructure.ai/cli-linux-x64": "0.2.3"
|
|
43
47
|
}
|
|
44
48
|
}
|