create-flow-os 0.0.13-dev.1772013136 → 0.0.13-dev.1772013290
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 +1 -1
- package/src/init/scaffold.ts +32 -11
package/package.json
CHANGED
package/src/init/scaffold.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, cpSync, readFileSync, writeFileSync, readdirSync } from "node:fs";
|
|
2
|
-
import { join, basename } from "node:path";
|
|
2
|
+
import { join, basename, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { pkgRoot, flowDeps, toPkgName, toShortName } from "./lib.ts";
|
|
4
5
|
|
|
5
6
|
const SKIP = new Set(["node_modules", ".git", ".vite", "package.json"]);
|
|
@@ -11,7 +12,19 @@ function copyConfig(configDir: string, cwd: string): void {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
+
/** Versione @flow-os/client da create-flow-os (fallback quando pkgRoot non risolve) */
|
|
16
|
+
function getCreateFlowOsClientDep(): string | undefined {
|
|
17
|
+
try {
|
|
18
|
+
const cliRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
19
|
+
const pkg = JSON.parse(readFileSync(join(cliRoot, "package.json"), "utf-8")) as { dependencies?: Record<string, string> };
|
|
20
|
+
const v = pkg.dependencies?.["@flow-os/client"];
|
|
21
|
+
return v && v !== "workspace:*" ? v : undefined;
|
|
22
|
+
} catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Sostituisce workspace:* e 0.0.1 con versione concreta (workspace va bene solo dentro flow-os) */
|
|
15
28
|
function resolveFlowDeps(
|
|
16
29
|
deps: Record<string, string> | undefined,
|
|
17
30
|
configDir: string
|
|
@@ -25,16 +38,24 @@ function resolveFlowDeps(
|
|
|
25
38
|
ownerVersion = (JSON.parse(readFileSync(ownerPkgPath, "utf-8")) as { version?: string }).version;
|
|
26
39
|
} catch {}
|
|
27
40
|
}
|
|
41
|
+
const createFlowOsClientDep = getCreateFlowOsClientDep();
|
|
42
|
+
const isDevSpec = createFlowOsClientDep?.includes("dev");
|
|
28
43
|
for (const k of Object.keys(resolved)) {
|
|
29
|
-
if (!k.startsWith("@flow-os/") || resolved[k] !== "workspace:*" && resolved[k] !== "0.0.1") continue;
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
if (!k.startsWith("@flow-os/") || (resolved[k] !== "workspace:*" && resolved[k] !== "0.0.1")) continue;
|
|
45
|
+
let spec: string | undefined;
|
|
46
|
+
// flow-os@dev → usa lo stesso specifier di create-flow-os (>=0.0.1-dev.0) per installare la dev
|
|
47
|
+
if (k === "@flow-os/client" && isDevSpec && createFlowOsClientDep) {
|
|
48
|
+
spec = createFlowOsClientDep;
|
|
49
|
+
} else {
|
|
50
|
+
try {
|
|
51
|
+
const root = pkgRoot(k);
|
|
52
|
+
const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf-8")) as { version?: string };
|
|
53
|
+
if (pkg.version) spec = `^${pkg.version}`;
|
|
54
|
+
} catch {}
|
|
55
|
+
if (!spec && ownerVersion) spec = `^${ownerVersion}`;
|
|
56
|
+
if (!spec && k === "@flow-os/client" && createFlowOsClientDep) spec = createFlowOsClientDep;
|
|
57
|
+
}
|
|
58
|
+
if (spec) resolved[k] = spec;
|
|
38
59
|
}
|
|
39
60
|
return resolved;
|
|
40
61
|
}
|