@pmaddire/gcie 0.1.2 → 0.1.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/README.md +1 -0
- package/bin/gcie.js +53 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ npx gcie@latest
|
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
This runs `gcie setup .` in the current repo by default.
|
|
108
|
+
If Python deps are missing, GCIE now bootstraps a local package venv and installs required runtime dependencies automatically on first run.
|
|
108
109
|
|
|
109
110
|
Optional setup flags are passed through:
|
|
110
111
|
|
package/bin/gcie.js
CHANGED
|
@@ -5,19 +5,36 @@ const { spawnSync } = require("child_process");
|
|
|
5
5
|
const { existsSync } = require("fs");
|
|
6
6
|
const { join, resolve, delimiter } = require("path");
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function run(cmd, args, env, stdio = "inherit") {
|
|
9
|
+
return spawnSync(cmd, args, { stdio, env });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function resolveVenvPython(gcieRoot) {
|
|
9
13
|
const winVenv = join(gcieRoot, ".venv", "Scripts", "python.exe");
|
|
10
14
|
const nixVenv = join(gcieRoot, ".venv", "bin", "python");
|
|
11
|
-
|
|
12
15
|
if (existsSync(winVenv)) return winVenv;
|
|
13
16
|
if (existsSync(nixVenv)) return nixVenv;
|
|
14
|
-
|
|
15
17
|
return null;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
|
|
20
|
+
function createVenv(gcieRoot, env) {
|
|
21
|
+
const venvDir = join(gcieRoot, ".venv");
|
|
22
|
+
|
|
23
|
+
let r = run("py", ["-3", "-m", "venv", venvDir], env, "pipe");
|
|
24
|
+
if (r.status === 0) return true;
|
|
25
|
+
|
|
26
|
+
r = run("python", ["-m", "venv", venvDir], env, "pipe");
|
|
27
|
+
return r.status === 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function installDeps(venvPython, env) {
|
|
31
|
+
const deps = ["typer", "networkx", "GitPython"];
|
|
32
|
+
const r = run(venvPython, ["-m", "pip", "install", "--disable-pip-version-check", "--quiet", ...deps], env);
|
|
33
|
+
return r.status === 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function runCli(pythonCmd, cliArgs, env) {
|
|
37
|
+
return run(pythonCmd, ["-m", "cli.app", ...cliArgs], env);
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
function main() {
|
|
@@ -30,16 +47,39 @@ function main() {
|
|
|
30
47
|
const env = { ...process.env };
|
|
31
48
|
env.PYTHONPATH = env.PYTHONPATH ? `${gcieRoot}${delimiter}${env.PYTHONPATH}` : gcieRoot;
|
|
32
49
|
|
|
33
|
-
|
|
34
|
-
if (venvPython) {
|
|
35
|
-
|
|
50
|
+
let venvPython = resolveVenvPython(gcieRoot);
|
|
51
|
+
if (!venvPython) {
|
|
52
|
+
console.error("[GCIE] No local venv found. Bootstrapping Python environment...");
|
|
53
|
+
if (!createVenv(gcieRoot, env)) {
|
|
54
|
+
console.error("No Python interpreter found. Install Python 3.11+ and retry.");
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
venvPython = resolveVenvPython(gcieRoot);
|
|
58
|
+
if (!venvPython) {
|
|
59
|
+
console.error("[GCIE] Failed to create .venv.");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
if (!installDeps(venvPython, env)) {
|
|
63
|
+
console.error("[GCIE] Failed to install Python dependencies (typer, networkx, GitPython).");
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
36
66
|
}
|
|
37
67
|
|
|
38
|
-
|
|
39
|
-
if (
|
|
68
|
+
let result = runCli(venvPython, cliArgs, env);
|
|
69
|
+
if (result.status === 0) {
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const stderr = (result.stderr || "").toString();
|
|
74
|
+
if (stderr.includes("No module named") || stderr.includes("ModuleNotFoundError")) {
|
|
75
|
+
console.error("[GCIE] Missing Python deps detected. Installing required dependencies...");
|
|
76
|
+
if (installDeps(venvPython, env)) {
|
|
77
|
+
result = runCli(venvPython, cliArgs, env);
|
|
78
|
+
process.exit(result.status || 0);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
40
81
|
|
|
41
|
-
|
|
42
|
-
process.exit(1);
|
|
82
|
+
process.exit(result.status || 1);
|
|
43
83
|
}
|
|
44
84
|
|
|
45
85
|
main();
|