create-flow-os 0.0.46 → 0.0.47-dev.1772043683
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/package.json +2 -2
- package/src/init/index.ts +4 -4
- package/src/init/scaffold.ts +9 -2
- package/src/init/ui.ts +15 -13
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-flow-os",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47-dev.1772043683",
|
|
4
4
|
"license": "PolyForm-Shield-1.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@flow-os/client": "
|
|
7
|
+
"@flow-os/client": ">=0.0.1-dev.0"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"create-flow-os": "./src/index.ts"
|
package/src/init/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { join, dirname } from "path";
|
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
import { libsWithConfig, toShortName, toPkgName } from "./lib";
|
|
9
9
|
import { initLib, fetchFlowPackageVersions } from "./scaffold";
|
|
10
|
-
import {
|
|
10
|
+
import { bannerBox, withLoading, colors } from "./ui";
|
|
11
11
|
|
|
12
12
|
const { V, V_LIGHT, Y, E, R, B } = colors;
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ const available = libsWithConfig(cliRoot).map(toShortName);
|
|
|
21
21
|
let libs = [...new Set(process.argv.slice(3))];
|
|
22
22
|
|
|
23
23
|
if (!libs.length && available.length) {
|
|
24
|
-
console.log(
|
|
24
|
+
console.log(bannerBox("Flow OS", [B + "Packages disponibili:" + R, ...available.map((l) => V + "◆" + R + " " + l)], V));
|
|
25
25
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
26
26
|
const answer = await new Promise<string>((resolve) =>
|
|
27
27
|
rl.question(V + "Seleziona (spazio o virgola): " + R, resolve)
|
|
@@ -34,7 +34,7 @@ const toInit = libs.filter((l) => available.includes(l));
|
|
|
34
34
|
const skipped = libs.filter((l) => !available.includes(l));
|
|
35
35
|
|
|
36
36
|
if (!toInit.length) {
|
|
37
|
-
console.error(
|
|
37
|
+
console.error(bannerBox("Flow OS", [E + "usa " + (available.join(" | ") || "(nessuna lib con config)") + R], E));
|
|
38
38
|
process.exit(1);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -52,7 +52,7 @@ const iconUnrec = Y + "?" + R;
|
|
|
52
52
|
const iconFail = E + "✕" + R;
|
|
53
53
|
const out: string[] = [];
|
|
54
54
|
out.push(bannerBox("Flow OS", [B + "Initialized:" + R, ...toInit.map((l) => iconOk + " " + V_LIGHT + l + R)], V_LIGHT));
|
|
55
|
-
if (skipped.length) out.push(
|
|
55
|
+
if (skipped.length) out.push(bannerBox("Flow OS", [B + "Unrecognized:" + R, ...skipped.map((l) => iconUnrec + " " + Y + l + R)], Y));
|
|
56
56
|
console.log(out.join(""));
|
|
57
57
|
|
|
58
58
|
export {};
|
package/src/init/scaffold.ts
CHANGED
|
@@ -309,9 +309,9 @@ async function collectAllTemplates(
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
export type InitProgressStep = "fetch" | "templates" | "write";
|
|
312
|
+
export type InitProgressStep = "fetch" | "templates" | "write" | "install";
|
|
313
313
|
|
|
314
|
-
/** Init: 1) fetch versioni npm, 2) merge template, 3) mergePkg, 4) merge con file utente */
|
|
314
|
+
/** Init: 1) fetch versioni npm, 2) merge template, 3) mergePkg, 4) merge con file utente, 5) bun install */
|
|
315
315
|
export async function initLib(
|
|
316
316
|
libs: string[],
|
|
317
317
|
cwd: string,
|
|
@@ -339,6 +339,13 @@ export async function initLib(
|
|
|
339
339
|
onProgress?.("write");
|
|
340
340
|
await writeMergedWithUser(combined, cwd, (path, conflicts) => resolveConflicts(conflicts, path));
|
|
341
341
|
|
|
342
|
+
onProgress?.("install");
|
|
343
|
+
const proc = Bun.spawn(["bun", "install"], { cwd, stdout: "inherit", stderr: "inherit" });
|
|
344
|
+
const exitCode = await proc.exited;
|
|
345
|
+
if (exitCode !== 0) {
|
|
346
|
+
throw new Error(`bun install exited with code ${exitCode}`);
|
|
347
|
+
}
|
|
348
|
+
|
|
342
349
|
const { rmSync } = await import("fs");
|
|
343
350
|
for (const d of tmpDirs) {
|
|
344
351
|
try {
|
package/src/init/ui.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* UI per init: loading spinner e box coerenti con flow-os
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
const V = "\x1b[
|
|
6
|
-
const V_LIGHT = "\x1b[38;2;255;0;135m"; //
|
|
5
|
+
const V = "\x1b[38;2;255;0;135m"; // #ff0087 rgb(255,0,135)
|
|
6
|
+
const V_LIGHT = "\x1b[38;2;255;0;135m"; // stesso colore
|
|
7
7
|
const Y = "\x1b[38;5;226m";
|
|
8
8
|
const E = "\x1b[91m";
|
|
9
9
|
const R = "\x1b[0m";
|
|
@@ -20,25 +20,26 @@ export function pad(s: string, w: number): string {
|
|
|
20
20
|
return s + " ".repeat(Math.max(0, w - stripAnsi(s).length));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/** Riquadro
|
|
24
|
-
export function bannerBox(title: string, lines: string[], color: string, w =
|
|
23
|
+
/** Riquadro con Flow OS centrato in grassetto nel bordo superiore, linea singola ─ */
|
|
24
|
+
export function bannerBox(title: string, lines: string[], color: string, w = 46): string {
|
|
25
25
|
const c = color;
|
|
26
|
-
const inner = " " + c + B + title + R + " ";
|
|
26
|
+
const inner = " " + c + B + title + R + " ";
|
|
27
27
|
const innerLen = stripAnsi(inner).length;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
return "\n" + top +
|
|
28
|
+
const half = Math.max(0, Math.floor((w - 2 - innerLen) / 2));
|
|
29
|
+
const top = c + "╭" + "─".repeat(half) + inner + "─".repeat(w - 2 - half - innerLen) + "╮" + R;
|
|
30
|
+
const bottom = c + "╰" + "─".repeat(w - 2) + "╯" + R;
|
|
31
|
+
const emptyLine = c + "│" + R + " " + " ".repeat(w - 2) + c + "│" + R;
|
|
32
|
+
const bodyLines = lines.map((l) => c + "│" + R + " " + pad(l, w - 2) + c + "│" + R);
|
|
33
|
+
return "\n" + top + "\n" + emptyLine + "\n" + bodyLines.join("\n") + "\n" + bottom + "\n";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function box(lines: string[], color: string, w =
|
|
36
|
+
export function box(lines: string[], color: string, w = 46): string {
|
|
37
37
|
const c = color;
|
|
38
38
|
const top = c + "╭" + "─".repeat(w) + "╮" + R;
|
|
39
39
|
const bottom = c + "╰" + "─".repeat(w) + "╯" + R;
|
|
40
|
+
const emptyLine = c + "│" + R + " " + " ".repeat(w - 2) + c + "│" + R;
|
|
40
41
|
const body = lines.map((l) => c + "│" + R + " " + pad(l, w - 2) + c + "│" + R).join("\n");
|
|
41
|
-
return "\n" + top + "\n" + body + "\n" + bottom + "\n";
|
|
42
|
+
return "\n" + top + "\n" + emptyLine + "\n" + body + "\n" + bottom + "\n";
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
import type { InitProgressStep } from "./scaffold";
|
|
@@ -47,6 +48,7 @@ const STEP_LABELS: Record<InitProgressStep, string> = {
|
|
|
47
48
|
fetch: "Fetching packages",
|
|
48
49
|
templates: "Preparing templates",
|
|
49
50
|
write: "Writing files",
|
|
51
|
+
install: "Installing dependencies",
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
/** Esegue fn mostrando uno spinner elegante; onStep viene chiamato per aggiornare lo step */
|