create-flow-os 0.0.13 → 0.0.15

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/.dockerignore ADDED
@@ -0,0 +1,5 @@
1
+ node_modules
2
+ **/node_modules
3
+ .git
4
+ dist
5
+ *.md
@@ -0,0 +1,6 @@
1
+ {
2
+ "files.exclude": {
3
+ "**/node_modules": true,
4
+ "**/index.html": true
5
+ }
6
+ }
package/Dockerfile ADDED
@@ -0,0 +1,14 @@
1
+ FROM oven/bun:1
2
+ WORKDIR /app
3
+
4
+ COPY package.json bun.lock* ./
5
+ RUN bun install --frozen-lockfile
6
+
7
+ COPY . .
8
+ RUN bun run build
9
+
10
+ ENV NODE_ENV=production
11
+ ENV PORT=3000
12
+ EXPOSE 3000
13
+
14
+ CMD ["bun", "run", "start"]
package/config/flow.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { config } from '@flow-os/client';
2
+
3
+ export default config();
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="it">
3
+ <head>
4
+ <meta charset="UTF-8"/>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
+ <title>Flow</title>
7
+ <style>html,body{margin:0;padding:0;min-height:100vh}#app{min-height:100vh;box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}</style>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module">document.getElementById('app').innerHTML='<h1>Flow</h1><p>Dev server ready.</p>';</script>
12
+ </body>
13
+ </html>
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "create-flow-os",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "license": "PolyForm-Shield-1.0.0",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@flow-os/client": "0.0.11"
7
+ "@flow-os/client": "^0.0.11"
8
8
  },
9
9
  "bin": {
10
10
  "create-flow-os": "./src/index.ts"
11
11
  },
12
12
  "scripts": {
13
- "create": "bun run src/create/index.ts"
13
+ "create": "bun run src/create/index.ts",
14
+ "dev": "flow-os dev",
15
+ "build": "flow-os build",
16
+ "start": "bun run server/start.ts"
14
17
  },
15
18
  "devDependencies": {
16
- "bun-types": "^1.3.9"
19
+ "@types/node": "^25.3.0",
20
+ "bun-types": "^1.3.9",
21
+ "vite": ">=7.3.0"
17
22
  }
18
23
  }
package/src/index.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- // create flow-os [nome] → create/
4
- // create flow-os init [lib] → init/
3
+ // create flow-os [nome] → create/
4
+ // create flow-os i [lib] → init (i = init)
5
5
 
6
6
  const subcommand = process.argv[2];
7
7
 
8
- if (subcommand === "init") {
9
- await import("./init/index.ts");
8
+ if (subcommand === "init" || subcommand === "i") {
9
+ await import("./init/index");
10
10
  } else {
11
- await import("./create/index.ts");
11
+ await import("./create/index");
12
12
  }
13
13
 
14
14
  export {};
package/src/init/index.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { join, dirname } from "node:path";
4
- import { fileURLToPath } from "node:url";
3
+ import * as readline from "readline";
4
+ import { join, dirname } from "path";
5
+ import { fileURLToPath } from "url";
5
6
  import { libsWithConfig, toShortName } from "./lib";
6
7
  import { initLib } from "./scaffold";
7
8
 
8
9
  // ───────────────────────────────────────────────────────────────────────────────
9
- // Usage: bun create flow-os init [lib...] | bunx create flow-os init [lib...]
10
+ // Usage: bun create flow-os i [lib...] | bun create flow-os i (prompt interattivo)
10
11
  // ───────────────────────────────────────────────────────────────────────────────
11
12
 
12
13
  // ───────────────────────────────────────────────────────────────────────────────
13
14
  // ANSI: violet (ok), yellow (unrecognized), red (error/failure)
14
- // 38;5;226 = golden yellow (più vivo di 93)
15
15
  // ───────────────────────────────────────────────────────────────────────────────
16
16
  const V = "\x1b[95m";
17
17
  const Y = "\x1b[38;5;226m";
@@ -35,12 +35,24 @@ const box = (lines: string[], color: string, w = 52) => {
35
35
  };
36
36
 
37
37
  // ───────────────────────────────────────────────────────────────────────────────
38
- // Args: libs richieste (dedup), disponibili, filtro
38
+ // Args: libs da argv o prompt interattivo
39
39
  // ───────────────────────────────────────────────────────────────────────────────
40
- const libs = [...new Set(process.argv.slice(3))];
41
40
  const cwd = process.cwd();
42
41
  const cliRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
43
42
  const available = libsWithConfig(cliRoot).map(toShortName);
43
+
44
+ let libs = [...new Set(process.argv.slice(3))];
45
+
46
+ if (!libs.length && available.length) {
47
+ console.log(box([B + "Packages disponibili:" + R, ...available.map((l) => V + "◆" + R + " " + l)], V));
48
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
49
+ const answer = await new Promise<string>((resolve) =>
50
+ rl.question(V + "Seleziona (spazio o virgola): " + R, resolve)
51
+ );
52
+ rl.close();
53
+ libs = answer.split(/[\s,]+/).map((s) => s.trim()).filter(Boolean);
54
+ }
55
+
44
56
  const toInit = libs.filter((l) => available.includes(l));
45
57
  const skipped = libs.filter((l) => !available.includes(l));
46
58
 
package/src/init/lib.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { join, dirname } from "node:path";
3
- import { fileURLToPath } from "node:url";
1
+ import { existsSync, readFileSync } from "fs";
2
+ import { join, dirname } from "path";
3
+ import { fileURLToPath } from "url";
4
4
 
5
5
  const FLOW_PREFIX = "@flow-os/";
6
6
 
@@ -1,6 +1,7 @@
1
- import { existsSync, cpSync, readFileSync, writeFileSync, readdirSync } from "node:fs";
2
- import { join, basename } from "node:path";
3
- import { pkgRoot, flowDeps, toPkgName, toShortName } from "./lib.ts";
1
+ import { existsSync, cpSync, readFileSync, writeFileSync, readdirSync } from "fs";
2
+ import { join, basename, dirname } from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { pkgRoot, flowDeps, toPkgName, toShortName } from "./lib";
4
5
 
5
6
  const SKIP = new Set(["node_modules", ".git", ".vite", "package.json"]);
6
7
 
@@ -11,18 +12,50 @@ function copyConfig(configDir: string, cwd: string): void {
11
12
  }
12
13
  }
13
14
 
14
- /** Sostituisce workspace:* e 0.0.1 con ^version dal package risolto (per progetti fuori dal monorepo) */
15
- function resolveFlowDeps(deps: Record<string, string> | undefined): Record<string, string> {
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();
42
+ const isDevSpec = createFlowOsClientDep?.includes("dev");
18
43
  for (const k of Object.keys(resolved)) {
19
- if (k.startsWith("@flow-os/") && (resolved[k] === "workspace:*" || resolved[k] === "0.0.1")) {
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 tag "dev" per installare @flow-os/client@dev
47
+ if (k === "@flow-os/client" && isDevSpec) {
48
+ spec = "dev";
49
+ } else {
20
50
  try {
21
51
  const root = pkgRoot(k);
22
52
  const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf-8")) as { version?: string };
23
- if (pkg.version) resolved[k] = `^${pkg.version}`;
53
+ if (pkg.version) spec = `^${pkg.version}`;
24
54
  } catch {}
55
+ if (!spec && ownerVersion) spec = `^${ownerVersion}`;
56
+ if (!spec && k === "@flow-os/client" && createFlowOsClientDep) spec = createFlowOsClientDep;
25
57
  }
58
+ if (spec) resolved[k] = spec;
26
59
  }
27
60
  return resolved;
28
61
  }
@@ -37,8 +70,8 @@ function mergePkg(configDir: string, cwd: string): void {
37
70
  : { ...config, name: basename(cwd) || "flow-app" };
38
71
  target.dependencies = { ...target.dependencies, ...config.dependencies };
39
72
  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;
73
+ for (const [k, v] of Object.entries(resolveFlowDeps(config.dependencies, configDir))) target.dependencies[k] = v;
74
+ for (const [k, v] of Object.entries(resolveFlowDeps(config.devDependencies, configDir))) target.devDependencies[k] = v;
42
75
  target.scripts = { ...target.scripts, ...config.scripts };
43
76
  writeFileSync(targetPath, JSON.stringify(target, null, 2));
44
77
  }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "types": ["bun-types", "node"],
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "noEmit": true,
10
+ "esModuleInterop": true,
11
+ "isolatedModules": true
12
+ },
13
+ "include": ["src/**/*.ts"],
14
+ "exclude": ["node_modules"]
15
+ }