forge-pipeline 0.2.0 → 0.3.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/bin/forge.js +71 -22
- package/package.json +1 -1
package/bin/forge.js
CHANGED
|
@@ -1,29 +1,78 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { execFileSync } = require("child_process");
|
|
3
|
+
const { execFileSync, execSync } = require("child_process");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
|
|
6
|
+
const forgePath = path.join(__dirname, "..", "forge");
|
|
7
|
+
|
|
6
8
|
if (process.platform === "win32") {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
" and install forge inside WSL\n" +
|
|
14
|
-
" 2. Git Bash — https://gitforwindows.org\n" +
|
|
15
|
-
"\n" +
|
|
16
|
-
"forge depends on bash, tmux, and git worktrees which are not\n" +
|
|
17
|
-
"available natively on Windows."
|
|
18
|
-
);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
9
|
+
// Check if WSL is available
|
|
10
|
+
let hasWsl = false;
|
|
11
|
+
try {
|
|
12
|
+
execSync("wsl --status", { stdio: "ignore" });
|
|
13
|
+
hasWsl = true;
|
|
14
|
+
} catch {}
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
if (!hasWsl) {
|
|
17
|
+
console.error(
|
|
18
|
+
"Error: forge requires a Unix environment.\n" +
|
|
19
|
+
"\n" +
|
|
20
|
+
"Install WSL (Windows Subsystem for Linux):\n" +
|
|
21
|
+
" 1. Open PowerShell as Administrator\n" +
|
|
22
|
+
" 2. Run: wsl --install\n" +
|
|
23
|
+
" 3. Restart your computer\n" +
|
|
24
|
+
" 4. Run: npm install -g forge-pipeline (inside WSL)\n" +
|
|
25
|
+
"\n" +
|
|
26
|
+
"forge depends on bash, tmux, and git worktrees which\n" +
|
|
27
|
+
"are not available natively on Windows."
|
|
28
|
+
);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check if required tools exist inside WSL
|
|
33
|
+
let missing = [];
|
|
34
|
+
for (const tool of ["tmux", "git", "claude", "jq"]) {
|
|
35
|
+
try {
|
|
36
|
+
execSync(`wsl which ${tool}`, { stdio: "ignore" });
|
|
37
|
+
} catch {
|
|
38
|
+
missing.push(tool);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (missing.length > 0) {
|
|
43
|
+
console.error(
|
|
44
|
+
"WSL detected but missing required tools: " + missing.join(", ") + "\n" +
|
|
45
|
+
"\n" +
|
|
46
|
+
"Open WSL and install them:\n" +
|
|
47
|
+
" wsl\n" +
|
|
48
|
+
" sudo apt update && sudo apt install -y " +
|
|
49
|
+
missing.filter(t => t !== "claude").join(" ") + "\n" +
|
|
50
|
+
(missing.includes("claude")
|
|
51
|
+
? " # Install Claude Code: https://docs.anthropic.com/en/docs/claude-code\n"
|
|
52
|
+
: "")
|
|
53
|
+
);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Convert Windows path to WSL path and run
|
|
58
|
+
const wslForgePath = execSync(`wsl wslpath -u "${forgePath.replace(/\\/g, "\\\\")}"`)
|
|
59
|
+
.toString()
|
|
60
|
+
.trim();
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
execFileSync("wsl", ["bash", wslForgePath, ...process.argv.slice(2)], {
|
|
64
|
+
stdio: "inherit",
|
|
65
|
+
});
|
|
66
|
+
} catch (err) {
|
|
67
|
+
process.exit(err.status || 1);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
// macOS / Linux — run directly
|
|
71
|
+
try {
|
|
72
|
+
execFileSync("bash", [forgePath, ...process.argv.slice(2)], {
|
|
73
|
+
stdio: "inherit",
|
|
74
|
+
});
|
|
75
|
+
} catch (err) {
|
|
76
|
+
process.exit(err.status || 1);
|
|
77
|
+
}
|
|
29
78
|
}
|