create-flow-os 0.0.52 → 0.0.53

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "create-flow-os",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "license": "PolyForm-Shield-1.0.0",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@flow-os/client": "^0.0.52"
7
+ "@flow-os/client": "^0.0.53"
8
8
  },
9
9
  "bin": {
10
10
  "create-flow-os": "./src/index.ts"
package/src/init/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  import * as readline from "readline";
4
4
  import { join, dirname } from "path";
5
5
  import { fileURLToPath } from "url";
6
- import { libsWithConfig, toShortName, toPkgName } from "./lib";
6
+ import { libsWithConfig, fetchFlowOsPackagesFromNpm, toShortName, toPkgName } from "./lib";
7
7
  import { initLib, fetchFlowPackageVersions, shouldUseWorkspace, findFlowOsRepoRoot } from "./scaffold";
8
8
  import { bannerBox, withLoading, colors } from "./ui";
9
9
 
@@ -15,7 +15,9 @@ const { V, V_LIGHT, Y, E, R, B } = colors;
15
15
  const cwd = process.cwd();
16
16
  const cliRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
17
17
  const flowOsRepoRoot = findFlowOsRepoRoot(cwd);
18
- const available = libsWithConfig(cliRoot, flowOsRepoRoot).map(toShortName);
18
+ const available = flowOsRepoRoot
19
+ ? libsWithConfig(cliRoot, flowOsRepoRoot).map(toShortName)
20
+ : (await fetchFlowOsPackagesFromNpm()).map(toShortName);
19
21
 
20
22
  let libs = [...new Set(process.argv.slice(3))];
21
23
 
package/src/init/lib.ts CHANGED
@@ -3,6 +3,7 @@ import { join, dirname } from "path";
3
3
  import { fileURLToPath } from "url";
4
4
 
5
5
  const FLOW_PREFIX = "@flow-os/";
6
+ const NPM_ORG_API = "https://registry.npmjs.org/-/org/flow-os/package";
6
7
 
7
8
  export function pkgRoot(pkgName: string): string {
8
9
  const url = import.meta.resolve(pkgName);
@@ -47,6 +48,18 @@ export function libsWithConfig(cliRoot: string, flowOsRepoRoot?: string | null):
47
48
  return deps.filter((name) => existsSync(join(pkgRoot(name), "config")));
48
49
  }
49
50
 
51
+ /** In prod (fuori repo): scarica lista pacchetti @flow-os/* da npm. Mappa automaticamente anche i nuovi. */
52
+ export async function fetchFlowOsPackagesFromNpm(): Promise<string[]> {
53
+ try {
54
+ const res = await fetch(NPM_ORG_API, { headers: { Accept: "application/json" } });
55
+ if (!res.ok) return [];
56
+ const data = (await res.json()) as Record<string, unknown>;
57
+ return Object.keys(data).filter((k) => k.startsWith(FLOW_PREFIX));
58
+ } catch {
59
+ return [];
60
+ }
61
+ }
62
+
50
63
  export function toShortName(name: string): string {
51
64
  return name.replace(FLOW_PREFIX, "");
52
65
  }