@forgeone/cli 1.0.0 → 1.0.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/forge.js +35 -8
- package/package.json +7 -9
package/bin/forge.js
CHANGED
|
@@ -39,14 +39,41 @@ function resolveBinary() {
|
|
|
39
39
|
|
|
40
40
|
const [pkgName, binaryName] = entry;
|
|
41
41
|
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
// Strategy 1: Look alongside node.exe (npm global prefix).
|
|
43
|
+
// process.execPath = "C:\Program Files\nodejs\node.exe" (or nvm equiv).
|
|
44
|
+
// Global node_modules live at dirname(execPath)/node_modules on Windows,
|
|
45
|
+
// and at dirname(dirname(execPath))/lib/node_modules on Unix/macOS.
|
|
46
|
+
// This is robust against junction/symlink chains that confuse __dirname.
|
|
47
|
+
const nodeDir = path.dirname(process.execPath);
|
|
48
|
+
const globalCandidates = [
|
|
49
|
+
path.join(nodeDir, "node_modules", pkgName, "bin", binaryName), // Windows
|
|
50
|
+
path.join(nodeDir, "..", "lib", "node_modules", pkgName, "bin", binaryName), // Unix/macOS
|
|
51
|
+
];
|
|
52
|
+
for (const candidate of globalCandidates) {
|
|
53
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Strategy 2: require.resolve — handles standard installs and NODE_PATH setups.
|
|
57
|
+
try {
|
|
58
|
+
const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
|
|
59
|
+
const candidate = path.join(path.dirname(pkgJsonPath), "bin", binaryName);
|
|
60
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
61
|
+
} catch (_) {
|
|
62
|
+
// package not on require path — fall through to directory walk
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Strategy 3: Walk up from the script path as-passed (process.argv[1]).
|
|
66
|
+
// Handles junction links: argv[1] may be the pre-resolved junction path,
|
|
67
|
+
// while __dirname is the fully-resolved real path.
|
|
68
|
+
const scriptDirs = [process.argv[1], __filename].filter(Boolean).map(path.dirname);
|
|
69
|
+
for (const startDir of scriptDirs) {
|
|
70
|
+
let dir = startDir;
|
|
71
|
+
for (let i = 0; i < 6; i++) {
|
|
72
|
+
const candidate = path.join(dir, "node_modules", pkgName, "bin", binaryName);
|
|
73
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
74
|
+
const parent = path.dirname(dir);
|
|
75
|
+
if (parent === dir) break; // reached filesystem root
|
|
76
|
+
dir = parent;
|
|
50
77
|
}
|
|
51
78
|
}
|
|
52
79
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeone/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Forge CLI — AI-native developer framework. Scaffold, lint, scan, ship.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"forge",
|
|
@@ -23,20 +23,18 @@
|
|
|
23
23
|
"bin": {
|
|
24
24
|
"forge": "bin/forge.js"
|
|
25
25
|
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"postinstall": "node bin/forge.js --version 2>/dev/null || true"
|
|
28
|
-
},
|
|
29
26
|
"files": [
|
|
30
27
|
"bin/forge.js",
|
|
31
28
|
"README.md"
|
|
32
29
|
],
|
|
33
30
|
"optionalDependencies": {
|
|
34
|
-
"@forgeone/cli-linux-x64": "1.0.
|
|
35
|
-
"@forgeone/cli-linux-arm64": "1.0.
|
|
36
|
-
"@forgeone/cli-darwin-x64": "1.0.
|
|
37
|
-
"@forgeone/cli-darwin-arm64": "1.0.
|
|
38
|
-
"@forgeone/cli-win32-x64": "1.0.
|
|
31
|
+
"@forgeone/cli-linux-x64": "1.0.3",
|
|
32
|
+
"@forgeone/cli-linux-arm64": "1.0.3",
|
|
33
|
+
"@forgeone/cli-darwin-x64": "1.0.3",
|
|
34
|
+
"@forgeone/cli-darwin-arm64": "1.0.3",
|
|
35
|
+
"@forgeone/cli-win32-x64": "1.0.3"
|
|
39
36
|
},
|
|
37
|
+
"scripts": {},
|
|
40
38
|
"engines": {
|
|
41
39
|
"node": ">=18"
|
|
42
40
|
},
|