komplian 0.3.3 → 0.3.5
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/komplian-onboard.mjs +58 -29
- package/package.json +1 -1
package/komplian-onboard.mjs
CHANGED
|
@@ -18,6 +18,13 @@ import { homedir } from "node:os";
|
|
|
18
18
|
|
|
19
19
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
20
|
|
|
21
|
+
/** Windows: sin esto, CreateProcess no resuelve gh.cmd / git.exe / npm.cmd como la consola. */
|
|
22
|
+
const IS_WIN = process.platform === "win32";
|
|
23
|
+
|
|
24
|
+
function spawnWin(extra = {}) {
|
|
25
|
+
return IS_WIN ? { ...extra, shell: true } : extra;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
const c = {
|
|
22
29
|
reset: "\x1b[0m",
|
|
23
30
|
dim: "\x1b[2m",
|
|
@@ -51,10 +58,14 @@ function banner() {
|
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
function ghOk() {
|
|
54
|
-
const r = spawnSync(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
const r = spawnSync(
|
|
62
|
+
"gh",
|
|
63
|
+
["auth", "status", "-h", "github.com"],
|
|
64
|
+
spawnWin({
|
|
65
|
+
encoding: "utf8",
|
|
66
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
67
|
+
})
|
|
68
|
+
);
|
|
58
69
|
return r.status === 0;
|
|
59
70
|
}
|
|
60
71
|
|
|
@@ -65,16 +76,20 @@ function runGhAuth() {
|
|
|
65
76
|
const r = spawnSync(
|
|
66
77
|
"gh",
|
|
67
78
|
["auth", "login", "-h", "github.com", "-s", "repo", "-s", "read:org", "-w"],
|
|
68
|
-
{ stdio: "inherit" }
|
|
79
|
+
spawnWin({ stdio: "inherit" })
|
|
69
80
|
);
|
|
70
81
|
return r.status === 0;
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
function ghApiJson(path) {
|
|
74
|
-
const r = spawnSync(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
const r = spawnSync(
|
|
86
|
+
"gh",
|
|
87
|
+
["api", path],
|
|
88
|
+
spawnWin({
|
|
89
|
+
encoding: "utf8",
|
|
90
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
91
|
+
})
|
|
92
|
+
);
|
|
78
93
|
return { status: r.status, stdout: r.stdout || "", stderr: r.stderr || "" };
|
|
79
94
|
}
|
|
80
95
|
|
|
@@ -128,18 +143,26 @@ function logGhIdentity() {
|
|
|
128
143
|
}
|
|
129
144
|
}
|
|
130
145
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} catch {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
146
|
+
/** Misma resolución que los clones: en Windows hace falta shell para gh.cmd / git / npm. */
|
|
147
|
+
function canRun(cmd, args) {
|
|
148
|
+
const r = spawnSync(cmd, args, spawnWin({ stdio: "ignore" }));
|
|
149
|
+
return r.status === 0 && !r.error;
|
|
138
150
|
}
|
|
139
151
|
|
|
140
152
|
function needCmd(name, hint = "") {
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
const ok =
|
|
154
|
+
name === "gh"
|
|
155
|
+
? canRun("gh", ["version"])
|
|
156
|
+
: name === "git"
|
|
157
|
+
? canRun("git", ["--version"])
|
|
158
|
+
: canRun(name, ["--version"]);
|
|
159
|
+
if (!ok) {
|
|
160
|
+
log(`${c.red}✗${c.reset} No se puede ejecutar ${c.bold}${name}${c.reset} (¿PATH o instalación?).${hint ? ` ${hint}` : ""}`);
|
|
161
|
+
if (IS_WIN) {
|
|
162
|
+
log(
|
|
163
|
+
`${c.dim} Windows: cierra y abre la terminal tras instalar gh/git, o reinicia para refrescar PATH.${c.reset}`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
143
166
|
process.exit(1);
|
|
144
167
|
}
|
|
145
168
|
}
|
|
@@ -152,7 +175,7 @@ function ghRepoList(org) {
|
|
|
152
175
|
const r = spawnSync(
|
|
153
176
|
"gh",
|
|
154
177
|
["repo", "list", org, "--limit", "1000", "--json", "name,isArchived,isFork"],
|
|
155
|
-
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
178
|
+
spawnWin({ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] })
|
|
156
179
|
);
|
|
157
180
|
if (r.status !== 0) {
|
|
158
181
|
log(`${c.red}✗${c.reset} gh repo list falló:\n${r.stderr || r.stdout}`);
|
|
@@ -234,9 +257,11 @@ function cloneOne(org, name, workspace, useSsh) {
|
|
|
234
257
|
: ["repo", "clone", `${org}/${name}`, name];
|
|
235
258
|
const cmd = useSsh ? "git" : "gh";
|
|
236
259
|
const r = spawnSync(cmd, args, {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
260
|
+
...spawnWin({
|
|
261
|
+
cwd: workspace,
|
|
262
|
+
encoding: "utf8",
|
|
263
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
264
|
+
}),
|
|
240
265
|
});
|
|
241
266
|
process.stdout.write("\r\x1b[K");
|
|
242
267
|
if (r.status === 0) {
|
|
@@ -254,11 +279,15 @@ function copyCursorPack(workspace, cursorRepoUrl) {
|
|
|
254
279
|
const tmp = join(workspace, ".cursor-bootstrap-tmp");
|
|
255
280
|
rmSync(tmp, { recursive: true, force: true });
|
|
256
281
|
log(`${c.dim}→${c.reset} Cursor pack (clone superficial)…`);
|
|
257
|
-
const r = spawnSync(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
282
|
+
const r = spawnSync(
|
|
283
|
+
"git",
|
|
284
|
+
["clone", "--depth", "1", String(cursorRepoUrl).trim(), tmp],
|
|
285
|
+
spawnWin({
|
|
286
|
+
cwd: workspace,
|
|
287
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
288
|
+
encoding: "utf8",
|
|
289
|
+
})
|
|
290
|
+
);
|
|
262
291
|
if (r.status === 0 && existsSync(join(tmp, ".cursor"))) {
|
|
263
292
|
rmSync(rootCursor, { recursive: true, force: true });
|
|
264
293
|
cpSync(join(tmp, ".cursor"), rootCursor, { recursive: true });
|
|
@@ -277,7 +306,7 @@ function copyCursorPack(workspace, cursorRepoUrl) {
|
|
|
277
306
|
function npmInstallEach(workspace) {
|
|
278
307
|
log("");
|
|
279
308
|
log(`${c.cyan}━━ npm install por repo ━━${c.reset}`);
|
|
280
|
-
if (!
|
|
309
|
+
if (!canRun("npm", ["--version"])) {
|
|
281
310
|
log(`${c.yellow}○${c.reset} npm no está en PATH — omito installs`);
|
|
282
311
|
return;
|
|
283
312
|
}
|
|
@@ -287,7 +316,7 @@ function npmInstallEach(workspace) {
|
|
|
287
316
|
const pkg = join(d, "package.json");
|
|
288
317
|
if (!existsSync(pkg)) continue;
|
|
289
318
|
log(`${c.dim}→${c.reset} ${ent}`);
|
|
290
|
-
const ir = spawnSync("npm", ["install"], { cwd: d, stdio: "inherit" });
|
|
319
|
+
const ir = spawnSync("npm", ["install"], spawnWin({ cwd: d, stdio: "inherit" }));
|
|
291
320
|
if (ir.status !== 0) {
|
|
292
321
|
log(`${c.yellow}○${c.reset} npm install con avisos en ${ent}`);
|
|
293
322
|
} else {
|
package/package.json
CHANGED