create-flow-os 0.0.53 → 0.0.54
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/scaffold.ts +28 -4
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-flow-os",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"license": "PolyForm-Shield-1.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@flow-os/client": "^0.0.
|
|
7
|
+
"@flow-os/client": "^0.0.54"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"create-flow-os": "./src/index.ts"
|
package/src/init/scaffold.ts
CHANGED
|
@@ -105,7 +105,8 @@ export function shouldUseWorkspace(cwd: string): boolean {
|
|
|
105
105
|
return !!findFlowOsRepoRoot(cwd);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/** Recupera versione di un pacchetto @flow-os/* dal registry npm (con cache 5 min)
|
|
108
|
+
/** Recupera versione di un pacchetto @flow-os/* dal registry npm (con cache 5 min).
|
|
109
|
+
* In prod usa la penultima stabile da versions/ per evitare ritardi di propagazione della più recente. */
|
|
109
110
|
async function fetchFlowPackageVersion(pkgName: string): Promise<string | undefined> {
|
|
110
111
|
const tag = isCreateFlowOsDev() ? "dev" : "latest";
|
|
111
112
|
const key = `${pkgName}@${tag}`;
|
|
@@ -117,8 +118,18 @@ async function fetchFlowPackageVersion(pkgName: string): Promise<string | undefi
|
|
|
117
118
|
headers: { "Cache-Control": "max-age=300", Accept: "application/json" },
|
|
118
119
|
});
|
|
119
120
|
if (!res.ok) return undefined;
|
|
120
|
-
const data = (await res.json()) as {
|
|
121
|
-
|
|
121
|
+
const data = (await res.json()) as {
|
|
122
|
+
"dist-tags"?: Record<string, string>;
|
|
123
|
+
versions?: Record<string, unknown>;
|
|
124
|
+
};
|
|
125
|
+
if (isCreateFlowOsDev()) {
|
|
126
|
+
const v = data["dist-tags"]?.["dev"] ?? data["dist-tags"]?.["latest"];
|
|
127
|
+
if (v) versionCache.set(key, { v, ts: Date.now() });
|
|
128
|
+
return v;
|
|
129
|
+
}
|
|
130
|
+
const versions = data.versions ? Object.keys(data.versions) : [];
|
|
131
|
+
const stable = versions.filter((v) => /^\d+\.\d+\.\d+$/.test(v)).sort(semverCompare);
|
|
132
|
+
const v = stable[stable.length - 2] ?? stable[stable.length - 1] ?? data["dist-tags"]?.["latest"];
|
|
122
133
|
if (v) versionCache.set(key, { v, ts: Date.now() });
|
|
123
134
|
return v;
|
|
124
135
|
} catch {
|
|
@@ -126,6 +137,16 @@ async function fetchFlowPackageVersion(pkgName: string): Promise<string | undefi
|
|
|
126
137
|
}
|
|
127
138
|
}
|
|
128
139
|
|
|
140
|
+
function semverCompare(a: string, b: string): number {
|
|
141
|
+
const pa = a.split(".").map(Number);
|
|
142
|
+
const pb = b.split(".").map(Number);
|
|
143
|
+
for (let i = 0; i < 3; i++) {
|
|
144
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
145
|
+
if (d !== 0) return d;
|
|
146
|
+
}
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
129
150
|
/** Recupera versioni di tutti i pacchetti @flow-os/* richiesti dal registry npm */
|
|
130
151
|
export async function fetchFlowPackageVersions(pkgNames: string[]): Promise<Map<string, string>> {
|
|
131
152
|
const out = new Map<string, string>();
|
|
@@ -511,8 +532,11 @@ export async function initLib(
|
|
|
511
532
|
const installCwd = useWorkspace && flowOsRepoRoot ? flowOsRepoRoot : cwd;
|
|
512
533
|
const proc = Bun.spawn(["bun", "install"], { cwd: installCwd, stdout: "pipe", stderr: "pipe" });
|
|
513
534
|
const exitCode = await proc.exited;
|
|
535
|
+
const stdout = await new Response(proc.stdout).text();
|
|
536
|
+
const stderr = await new Response(proc.stderr).text();
|
|
514
537
|
if (exitCode !== 0) {
|
|
515
|
-
|
|
538
|
+
const errMsg = stderr.trim() || stdout.trim() || `exit code ${exitCode}`;
|
|
539
|
+
throw new Error(`bun install failed:\n${errMsg}`);
|
|
516
540
|
}
|
|
517
541
|
|
|
518
542
|
const { rmSync } = await import("fs");
|