@nubjs/nub 0.0.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/nub +3 -0
- package/package.json +29 -0
- package/postinstall.js +53 -0
package/bin/nub
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nubjs/nub",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "TypeScript-first developer supertool — a fast script runner and TS runtime powered by Node.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "https://github.com/colinhacks/nub",
|
|
7
|
+
"homepage": "https://github.com/colinhacks/nub",
|
|
8
|
+
"bin": {
|
|
9
|
+
"nub": "bin/nub",
|
|
10
|
+
"nubx": "bin/nub"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"postinstall.js"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"postinstall": "node postinstall.js"
|
|
18
|
+
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"@nubjs/nub-darwin-arm64": "0.0.1",
|
|
21
|
+
"@nubjs/nub-darwin-x64": "0.0.1",
|
|
22
|
+
"@nubjs/nub-linux-x64": "0.0.1",
|
|
23
|
+
"@nubjs/nub-linux-x64-musl": "0.0.1",
|
|
24
|
+
"@nubjs/nub-linux-arm64": "0.0.1",
|
|
25
|
+
"@nubjs/nub-linux-arm64-musl": "0.0.1",
|
|
26
|
+
"@nubjs/nub-win32-x64": "0.0.1",
|
|
27
|
+
"@nubjs/nub-win32-arm64": "0.0.1"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const { platform, arch } = process;
|
|
2
|
+
const { existsSync, mkdirSync, copyFileSync, chmodSync } = require("fs");
|
|
3
|
+
const { join, dirname } = require("path");
|
|
4
|
+
|
|
5
|
+
const PLATFORMS = {
|
|
6
|
+
"darwin-arm64": "@nubjs/nub-darwin-arm64",
|
|
7
|
+
"darwin-x64": "@nubjs/nub-darwin-x64",
|
|
8
|
+
"linux-x64": "@nubjs/nub-linux-x64",
|
|
9
|
+
"linux-arm64": "@nubjs/nub-linux-arm64",
|
|
10
|
+
"win32-x64": "@nubjs/nub-win32-x64",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const key = `${platform}-${arch}`;
|
|
14
|
+
const pkg = PLATFORMS[key];
|
|
15
|
+
|
|
16
|
+
if (!pkg) {
|
|
17
|
+
console.error(`@nubjs/nub: no prebuilt binary for ${platform}-${arch}`);
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let binSrc;
|
|
22
|
+
try {
|
|
23
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
24
|
+
binSrc = require.resolve(`${pkg}/bin/nub${ext}`);
|
|
25
|
+
} catch {
|
|
26
|
+
// optionalDependency not installed (wrong platform) — skip silently
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const binDir = join(__dirname, "bin");
|
|
31
|
+
const binDest = join(binDir, platform === "win32" ? "nub.exe" : "nub");
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
mkdirSync(binDir, { recursive: true });
|
|
35
|
+
// Remove placeholder
|
|
36
|
+
try { require("fs").unlinkSync(binDest); } catch {}
|
|
37
|
+
// Symlink to platform package binary (keeps runtime/ findable via walk-up)
|
|
38
|
+
if (platform === "win32") {
|
|
39
|
+
copyFileSync(binSrc, binDest);
|
|
40
|
+
} else {
|
|
41
|
+
require("fs").symlinkSync(binSrc, binDest);
|
|
42
|
+
}
|
|
43
|
+
chmodSync(binSrc, 0o755);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// Fallback: copy if symlink fails (e.g., cross-device)
|
|
46
|
+
try {
|
|
47
|
+
copyFileSync(binSrc, binDest);
|
|
48
|
+
chmodSync(binDest, 0o755);
|
|
49
|
+
} catch (err2) {
|
|
50
|
+
console.error(`@nubjs/nub: failed to install binary: ${err2.message}`);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
}
|