@goboost/cli 1.2.3 → 1.2.4
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/cli.js +68 -0
- package/package.json +6 -6
package/bin/cli.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { execFileSync } = require("child_process");
|
|
6
|
+
const { existsSync } = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const os = require("os");
|
|
9
|
+
|
|
10
|
+
const PLATFORMS = {
|
|
11
|
+
"win32 x64": { pkg: "@goboost/cli-win32-x64", bin: "bin/goboost.exe" },
|
|
12
|
+
"linux x64": { pkg: "@goboost/cli-linux-x64", bin: "bin/goboost" },
|
|
13
|
+
"linux arm64": { pkg: "@goboost/cli-linux-arm64", bin: "bin/goboost" },
|
|
14
|
+
"darwin x64": { pkg: "@goboost/cli-darwin-x64", bin: "bin/goboost" },
|
|
15
|
+
"darwin arm64": { pkg: "@goboost/cli-darwin-arm64", bin: "bin/goboost" },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function getBinaryPath() {
|
|
19
|
+
// 1. Environment variable override
|
|
20
|
+
const envPath = process.env.GOBOOST_BINARY_PATH;
|
|
21
|
+
if (envPath) {
|
|
22
|
+
if (existsSync(envPath)) return envPath;
|
|
23
|
+
console.warn("GOBOOST_BINARY_PATH set but not found: " + envPath);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 2. Platform-specific optional dependency
|
|
27
|
+
const platformKey = process.platform + " " + os.arch();
|
|
28
|
+
const platform = PLATFORMS[platformKey];
|
|
29
|
+
|
|
30
|
+
if (platform) {
|
|
31
|
+
try {
|
|
32
|
+
return require.resolve(platform.pkg + "/" + platform.bin);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Not installed — fall through
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 3. Fallback binary from postinstall download
|
|
39
|
+
const binaryName = process.platform === "win32" ? "goboost.exe" : "goboost";
|
|
40
|
+
const fallbackPath = path.join(__dirname, "..", binaryName);
|
|
41
|
+
if (existsSync(fallbackPath)) return fallbackPath;
|
|
42
|
+
|
|
43
|
+
// 4. No binary found
|
|
44
|
+
console.error("Error: Could not find the goboost binary.\n");
|
|
45
|
+
if (!platform) {
|
|
46
|
+
console.error("Unsupported platform: " + platformKey);
|
|
47
|
+
console.error(
|
|
48
|
+
"goBoost supports: linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64\n"
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
console.error(
|
|
52
|
+
'The platform package "' + platform.pkg + '" is not installed and the'
|
|
53
|
+
);
|
|
54
|
+
console.error("postinstall fallback download did not succeed.\n");
|
|
55
|
+
}
|
|
56
|
+
console.error("Try reinstalling:");
|
|
57
|
+
console.error(" npm install -g @goboost/cli\n");
|
|
58
|
+
console.error("Or download manually from:");
|
|
59
|
+
console.error(" https://github.com/abdullahal39/GoBoost/releases\n");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
execFileSync(getBinaryPath(), process.argv.slice(2), { stdio: "inherit" });
|
|
65
|
+
} catch (e) {
|
|
66
|
+
if (e && e.status !== null) process.exit(e.status);
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goboost/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Progressive NestJS-to-Go migration CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"goboost": "bin/cli.js"
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"postinstall": "node scripts/install.js"
|
|
10
10
|
},
|
|
11
11
|
"optionalDependencies": {
|
|
12
|
-
"@goboost/cli-linux-x64": "1.2.
|
|
13
|
-
"@goboost/cli-linux-arm64": "1.2.
|
|
14
|
-
"@goboost/cli-darwin-x64": "1.2.
|
|
15
|
-
"@goboost/cli-darwin-arm64": "1.2.
|
|
16
|
-
"@goboost/cli-win32-x64": "1.2.
|
|
12
|
+
"@goboost/cli-linux-x64": "1.2.4",
|
|
13
|
+
"@goboost/cli-linux-arm64": "1.2.4",
|
|
14
|
+
"@goboost/cli-darwin-x64": "1.2.4",
|
|
15
|
+
"@goboost/cli-darwin-arm64": "1.2.4",
|
|
16
|
+
"@goboost/cli-win32-x64": "1.2.4"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"nestjs",
|