create-flow-os 0.0.12 → 0.0.13-dev.1772013189
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 +39 -12
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-flow-os",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-dev.1772013189",
|
|
4
4
|
"license": "PolyForm-Shield-1.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@flow-os/client": "0.0.1"
|
|
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/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,18 +12,44 @@ function copyConfig(configDir: string, cwd: string): void {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
function
|
|
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) */
|
|
28
|
+
function resolveFlowDeps(
|
|
29
|
+
deps: Record<string, string> | undefined,
|
|
30
|
+
configDir: string
|
|
31
|
+
): Record<string, string> {
|
|
16
32
|
if (!deps) return {};
|
|
17
33
|
const resolved = { ...deps };
|
|
34
|
+
const ownerPkgPath = join(configDir, "..", "package.json");
|
|
35
|
+
let ownerVersion: string | undefined;
|
|
36
|
+
if (existsSync(ownerPkgPath)) {
|
|
37
|
+
try {
|
|
38
|
+
ownerVersion = (JSON.parse(readFileSync(ownerPkgPath, "utf-8")) as { version?: string }).version;
|
|
39
|
+
} catch {}
|
|
40
|
+
}
|
|
41
|
+
const createFlowOsClientDep = getCreateFlowOsClientDep();
|
|
18
42
|
for (const k of Object.keys(resolved)) {
|
|
19
|
-
if (k.startsWith("@flow-os/")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
43
|
+
if (!k.startsWith("@flow-os/") || (resolved[k] !== "workspace:*" && resolved[k] !== "0.0.1")) continue;
|
|
44
|
+
let spec: string | undefined;
|
|
45
|
+
try {
|
|
46
|
+
const root = pkgRoot(k);
|
|
47
|
+
const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf-8")) as { version?: string };
|
|
48
|
+
if (pkg.version) spec = `^${pkg.version}`;
|
|
49
|
+
} catch {}
|
|
50
|
+
if (!spec && ownerVersion) spec = `^${ownerVersion}`;
|
|
51
|
+
if (!spec && k === "@flow-os/client" && createFlowOsClientDep) spec = createFlowOsClientDep;
|
|
52
|
+
if (spec) resolved[k] = spec;
|
|
26
53
|
}
|
|
27
54
|
return resolved;
|
|
28
55
|
}
|
|
@@ -37,8 +64,8 @@ function mergePkg(configDir: string, cwd: string): void {
|
|
|
37
64
|
: { ...config, name: basename(cwd) || "flow-app" };
|
|
38
65
|
target.dependencies = { ...target.dependencies, ...config.dependencies };
|
|
39
66
|
target.devDependencies = { ...target.devDependencies, ...config.devDependencies };
|
|
40
|
-
for (const [k, v] of Object.entries(resolveFlowDeps(config.dependencies))) target.dependencies[k] = v;
|
|
41
|
-
for (const [k, v] of Object.entries(resolveFlowDeps(config.devDependencies))) target.devDependencies[k] = v;
|
|
67
|
+
for (const [k, v] of Object.entries(resolveFlowDeps(config.dependencies, configDir))) target.dependencies[k] = v;
|
|
68
|
+
for (const [k, v] of Object.entries(resolveFlowDeps(config.devDependencies, configDir))) target.devDependencies[k] = v;
|
|
42
69
|
target.scripts = { ...target.scripts, ...config.scripts };
|
|
43
70
|
writeFileSync(targetPath, JSON.stringify(target, null, 2));
|
|
44
71
|
}
|