@nuucognition/flint-cli 0.2.0-beta.1 → 0.2.0-beta.2

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/bin/flint-prod.js CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ process.env.BUILD_MODE = 'prod';
4
+
3
5
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
6
  import { dirname, join } from 'node:path';
5
7
 
@@ -1,4 +1,4 @@
1
- // ../../packages/flint/dist/chunk-E7CDAGZD.js
1
+ // ../../packages/flint/dist/chunk-CKCIJQXP.js
2
2
  import { readdir, readFile, mkdir, writeFile, rm, stat } from "fs/promises";
3
3
  import { join, basename, dirname, resolve, relative, sep } from "path";
4
4
  async function exists(path) {
@@ -224,7 +224,7 @@ function getDisambiguatedExportName(flintPath, sourcePath, baseName) {
224
224
  return `${baseName} (${dirLabel})`;
225
225
  }
226
226
  async function scanExports(flintPath) {
227
- const { readFlintToml } = await import("./mesh-config-VGFSHC2G-YCC4ZIAT.js");
227
+ const { readFlintToml } = await import("./mesh-config-J6WB4RFV-G7RGPOZA.js");
228
228
  const config = await readFlintToml(flintPath);
229
229
  const declarations = config?.exports?.required;
230
230
  if (declarations && declarations.length > 0) {
@@ -270,7 +270,7 @@ async function scanExportsLegacy(flintPath) {
270
270
  async function scanExportEligible(flintPath) {
271
271
  const meshDir = join(flintPath, "Mesh");
272
272
  if (!await exists(meshDir)) return [];
273
- const { readFlintToml } = await import("./mesh-config-VGFSHC2G-YCC4ZIAT.js");
273
+ const { readFlintToml } = await import("./mesh-config-J6WB4RFV-G7RGPOZA.js");
274
274
  const config = await readFlintToml(flintPath);
275
275
  const declared = new Set(
276
276
  (config?.exports?.required || []).map((d) => d.file.replace(/\.md$/, "").toLowerCase())
@@ -319,13 +319,15 @@ async function buildExport(manifest, flintPath) {
319
319
  const resolvedFiles = [];
320
320
  const processedPaths = /* @__PURE__ */ new Set();
321
321
  processedPaths.add(manifest.sourcePath);
322
- for (const docRef of manifest.files) {
323
- const sourcePath = await resolveDocument(docRef, flintPath);
324
- if (!sourcePath || processedPaths.has(sourcePath)) continue;
325
- resolvedFiles.push({ sourcePath, docRef });
326
- processedPaths.add(sourcePath);
327
- }
328
322
  const depth = manifest.depth;
323
+ if (depth === -1 || depth > 0) {
324
+ for (const docRef of manifest.files) {
325
+ const sourcePath = await resolveDocument(docRef, flintPath);
326
+ if (!sourcePath || processedPaths.has(sourcePath)) continue;
327
+ resolvedFiles.push({ sourcePath, docRef });
328
+ processedPaths.add(sourcePath);
329
+ }
330
+ }
329
331
  const allReferencedFiles = /* @__PURE__ */ new Set();
330
332
  const exportContent = await readFile(manifest.sourcePath, "utf-8");
331
333
  await collectReferencedFiles(exportContent, flintPath, allReferencedFiles, new Set(processedPaths), depth, 0);
@@ -340,7 +342,7 @@ async function buildExport(manifest, flintPath) {
340
342
  }
341
343
  }
342
344
  const allExportFiles = [
343
- { sourcePath: manifest.sourcePath, baseName: manifest.name },
345
+ { sourcePath: manifest.sourcePath, baseName: basename(manifest.sourcePath, ".md") },
344
346
  ...resolvedFiles.map((f) => ({ sourcePath: f.sourcePath, baseName: basename(f.sourcePath, ".md") }))
345
347
  ];
346
348
  const baseNameCounts = /* @__PURE__ */ new Map();
@@ -382,6 +384,7 @@ async function buildExport(manifest, flintPath) {
382
384
  const manifestJson = {
383
385
  name: manifest.name,
384
386
  flint: flintName,
387
+ rootFile: rootFileName,
385
388
  builtAt: (/* @__PURE__ */ new Date()).toISOString(),
386
389
  files: copiedFiles
387
390
  };
@@ -1,4 +1,4 @@
1
- // ../../packages/flint/dist/chunk-OXC4WBGK.js
1
+ // ../../packages/flint/dist/chunk-2WZYXQX5.js
2
2
  import { readFile, writeFile, stat } from "fs/promises";
3
3
  import { join } from "path";
4
4
 
@@ -828,12 +828,10 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
828
828
  return str;
829
829
  }
830
830
 
831
- // ../../packages/flint/dist/chunk-OXC4WBGK.js
831
+ // ../../packages/flint/dist/chunk-2WZYXQX5.js
832
832
  import { randomUUID } from "crypto";
833
833
  function resolveShardMode(decl) {
834
- if (decl.mode) return decl.mode;
835
- if (decl.dev) return "dev";
836
- return void 0;
834
+ return decl.mode;
837
835
  }
838
836
  function isLocalShard(decl) {
839
837
  const mode = resolveShardMode(decl);
@@ -1075,6 +1073,11 @@ function formatFlintToml(config) {
1075
1073
  lines.push(`flints = ${inlineTableArray(items).join("\n")}`);
1076
1074
  lines.push("");
1077
1075
  }
1076
+ if (config.git?.remote) {
1077
+ lines.push("[git]");
1078
+ lines.push(`remote = ${tv(config.git.remote)}`);
1079
+ lines.push("");
1080
+ }
1078
1081
  if (config.lattices?.length) {
1079
1082
  for (const lattice of config.lattices) {
1080
1083
  lines.push("[[lattices]]");
@@ -1083,7 +1086,7 @@ function formatFlintToml(config) {
1083
1086
  lines.push("");
1084
1087
  }
1085
1088
  }
1086
- const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "mods", "exports", "imports", "workspace", "connections", "lattices"]);
1089
+ const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "mods", "exports", "imports", "workspace", "connections", "git", "lattices"]);
1087
1090
  const unknownKeys = Object.keys(config).filter((k) => !knownKeys.has(k));
1088
1091
  if (unknownKeys.length > 0) {
1089
1092
  const unknownConfig = {};
@@ -1118,8 +1121,7 @@ async function addShardToConfig(flintPath, shardName, source, options = {}) {
1118
1121
  const effectiveSource = source || kebabName;
1119
1122
  if (!existing || existing.source !== effectiveSource) {
1120
1123
  const decl = { source: effectiveSource };
1121
- const effectiveMode = options.mode || (options.dev ? "dev" : void 0);
1122
- if (effectiveMode) decl.mode = effectiveMode;
1124
+ if (options.mode) decl.mode = options.mode;
1123
1125
  config.shards[kebabName] = decl;
1124
1126
  await writeFlintToml(flintPath, config);
1125
1127
  }
@@ -1496,19 +1498,6 @@ async function getFlintImports(flintPath) {
1496
1498
  if (!config) return [];
1497
1499
  return resolveFlintImports(config);
1498
1500
  }
1499
- var getRequiredImports = getFlintImports;
1500
- async function addWorkspaceEntry(flintPath, name, path) {
1501
- console.warn("addWorkspaceEntry is deprecated, use addWorkspaceReference instead");
1502
- }
1503
- async function removeWorkspaceEntry(flintPath, name) {
1504
- console.warn("removeWorkspaceEntry is deprecated, use removeWorkspaceReference instead");
1505
- }
1506
- async function getWorkspaceEntries(flintPath) {
1507
- return {};
1508
- }
1509
- async function getWorkspaceEntry(flintPath, name) {
1510
- return null;
1511
- }
1512
1501
 
1513
1502
  export {
1514
1503
  parse,
@@ -1567,12 +1556,7 @@ export {
1567
1556
  getExportDeclarations,
1568
1557
  addImportToConfig,
1569
1558
  removeImportFromConfig,
1570
- getFlintImports,
1571
- getRequiredImports,
1572
- addWorkspaceEntry,
1573
- removeWorkspaceEntry,
1574
- getWorkspaceEntries,
1575
- getWorkspaceEntry
1559
+ getFlintImports
1576
1560
  };
1577
1561
  /*! Bundled license information:
1578
1562
 
@@ -0,0 +1,43 @@
1
+ // ../../packages/flint/dist/chunk-STM4NXTT.js
2
+ import { access } from "fs/promises";
3
+ async function exists(path) {
4
+ try {
5
+ await access(path);
6
+ return true;
7
+ } catch {
8
+ return false;
9
+ }
10
+ }
11
+ async function runConcurrent(tasks, options = {}) {
12
+ const { concurrency = 10, onComplete, onError, onStart } = options;
13
+ const results = [];
14
+ if (tasks.length === 0) return results;
15
+ let taskIdx = 0;
16
+ async function runNext() {
17
+ while (taskIdx < tasks.length) {
18
+ const idx = taskIdx++;
19
+ const task = tasks[idx];
20
+ onStart?.(task.name);
21
+ try {
22
+ const value = await task.run();
23
+ results.push({ name: task.name, status: "ok", value });
24
+ onComplete?.(task.name, value);
25
+ } catch (err) {
26
+ const error = err instanceof Error ? err : new Error(String(err));
27
+ results.push({ name: task.name, status: "error", error });
28
+ onError?.(task.name, error);
29
+ }
30
+ }
31
+ }
32
+ const workers = [];
33
+ for (let i = 0; i < Math.min(concurrency, tasks.length); i++) {
34
+ workers.push(runNext());
35
+ }
36
+ await Promise.all(workers);
37
+ return results;
38
+ }
39
+
40
+ export {
41
+ exists,
42
+ runConcurrent
43
+ };
@@ -1,4 +1,4 @@
1
- // ../../packages/flint/dist/chunk-CJE24DAP.js
1
+ // ../../packages/flint/dist/chunk-7YSFBSPS.js
2
2
  import { mkdir, readFile, writeFile } from "fs/promises";
3
3
  import { homedir } from "os";
4
4
  import { join, resolve } from "path";
@@ -58,13 +58,14 @@ async function findFlintByPath(path) {
58
58
  const flints = await getFlintRegistry();
59
59
  return flints.find((f) => f.path === resolvedPath) ?? null;
60
60
  }
61
- async function findFlintById(_id) {
62
- return null;
63
- }
64
61
  async function findFlintByName(name) {
65
62
  const flints = await getFlintRegistry();
66
63
  return flints.find((f) => f.name === name) ?? null;
67
64
  }
65
+ async function isFlintNameTaken(name) {
66
+ const flints = await getFlintRegistry();
67
+ return flints.find((f) => f.name === name);
68
+ }
68
69
  async function upsertFlintEntry(entry) {
69
70
  const normalizedEntry = { ...entry, path: resolve(entry.path) };
70
71
  const flints = await getFlintRegistry();
@@ -184,7 +185,7 @@ async function cleanRegistryFile() {
184
185
  return result;
185
186
  }
186
187
  async function registerFlintByPath(path, options) {
187
- const { readFlintToml, hasFlintToml } = await import("./mesh-config-VGFSHC2G-YCC4ZIAT.js");
188
+ const { readFlintToml, hasFlintToml } = await import("./mesh-config-J6WB4RFV-G7RGPOZA.js");
188
189
  const isFlint = await hasFlintToml(path);
189
190
  if (!isFlint) {
190
191
  throw new Error(`Not a valid flint: ${path}
@@ -223,8 +224,8 @@ export {
223
224
  registerFlint,
224
225
  unregisterFlint,
225
226
  findFlintByPath,
226
- findFlintById,
227
227
  findFlintByName,
228
+ isFlintNameTaken,
228
229
  upsertFlintEntry,
229
230
  updateFlintEntry,
230
231
  isPathRegistered,
@@ -5,7 +5,7 @@ import {
5
5
  cleanupStaleExports,
6
6
  scanExportEligible,
7
7
  scanExports
8
- } from "./chunk-VO4ZYDCW.js";
8
+ } from "./chunk-K5QP4OME.js";
9
9
  export {
10
10
  buildAllExports,
11
11
  buildExport,