@nuucognition/flint-cli 0.2.0-beta.0 → 0.2.0-beta.1
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 +2 -2
- package/bin/flint.js +0 -0
- package/dist/{chunk-EICASOEX.js → chunk-5YLBX2W6.js} +157 -66
- package/dist/{chunk-F5Q2BJFK.js → chunk-UNMULXL5.js} +3 -3
- package/dist/{chunk-BVYUS7NX.js → chunk-VO4ZYDCW.js} +71 -4
- package/dist/{exports-Y3NVZFFT.js → exports-CA5QHVI7-6IDFKMCF.js} +3 -1
- package/dist/index.js +6674 -5024
- package/dist/{mesh-config-O3UKKKAO.js → mesh-config-VGFSHC2G-YCC4ZIAT.js} +13 -1
- package/dist/presets/blank/preset.toml +3 -0
- package/dist/presets/default/preset.toml +23 -0
- package/dist/{registry-FUIZ2SKS.js → registry-5QFQ3XPR-G7IB3KWS.js} +1 -1
- package/package.json +6 -4
package/bin/flint-prod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
|
|
6
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
await import(join(__dirname, '..', 'dist', 'index.js'));
|
|
7
|
+
await import(pathToFileURL(join(__dirname, '..', 'dist', 'index.js')).href);
|
package/bin/flint.js
CHANGED
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../packages/flint/
|
|
1
|
+
// ../../packages/flint/dist/chunk-OXC4WBGK.js
|
|
2
2
|
import { readFile, writeFile, stat } from "fs/promises";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
|
|
@@ -828,8 +828,17 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
|
828
828
|
return str;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
// ../../packages/flint/
|
|
831
|
+
// ../../packages/flint/dist/chunk-OXC4WBGK.js
|
|
832
832
|
import { randomUUID } from "crypto";
|
|
833
|
+
function resolveShardMode(decl) {
|
|
834
|
+
if (decl.mode) return decl.mode;
|
|
835
|
+
if (decl.dev) return "dev";
|
|
836
|
+
return void 0;
|
|
837
|
+
}
|
|
838
|
+
function isLocalShard(decl) {
|
|
839
|
+
const mode = resolveShardMode(decl);
|
|
840
|
+
return mode === "dev" || mode === "custom";
|
|
841
|
+
}
|
|
833
842
|
var FLINT_CONFIG_FILENAME = "flint.toml";
|
|
834
843
|
var FLINT_JSON_FILENAME = "flint.json";
|
|
835
844
|
var FLINT_VERSION = "0.2.0";
|
|
@@ -964,26 +973,49 @@ async function readFlintToml(flintPath) {
|
|
|
964
973
|
throw error;
|
|
965
974
|
}
|
|
966
975
|
}
|
|
976
|
+
function tv(v) {
|
|
977
|
+
if (typeof v === "string") return `"${v}"`;
|
|
978
|
+
if (typeof v === "boolean") return v ? "true" : "false";
|
|
979
|
+
if (typeof v === "number") return String(v);
|
|
980
|
+
if (Array.isArray(v)) return `[${v.map(tv).join(", ")}]`;
|
|
981
|
+
return String(v);
|
|
982
|
+
}
|
|
983
|
+
function inlineTable(obj) {
|
|
984
|
+
const parts = Object.entries(obj).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${k} = ${tv(v)}`);
|
|
985
|
+
return `{ ${parts.join(", ")} }`;
|
|
986
|
+
}
|
|
987
|
+
function inlineTableArray(items) {
|
|
988
|
+
return [
|
|
989
|
+
"[",
|
|
990
|
+
...items.map((item) => ` ${inlineTable(item)},`),
|
|
991
|
+
"]"
|
|
992
|
+
];
|
|
993
|
+
}
|
|
994
|
+
function stringArray(items) {
|
|
995
|
+
return [
|
|
996
|
+
"[",
|
|
997
|
+
...items.map((s) => ` "${s}",`),
|
|
998
|
+
"]"
|
|
999
|
+
];
|
|
1000
|
+
}
|
|
967
1001
|
function formatFlintToml(config) {
|
|
968
1002
|
const lines = [];
|
|
969
1003
|
lines.push("[flint]");
|
|
970
|
-
lines.push(`name =
|
|
971
|
-
if (config.flint.type) {
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
if (config.flint.
|
|
975
|
-
lines.push(`description = "${config.flint.description}"`);
|
|
976
|
-
}
|
|
977
|
-
if (config.flint.tags && config.flint.tags.length > 0) {
|
|
978
|
-
lines.push(`tags = [${config.flint.tags.map((t) => `"${t}"`).join(", ")}]`);
|
|
979
|
-
}
|
|
1004
|
+
lines.push(`name = ${tv(config.flint.name)}`);
|
|
1005
|
+
if (config.flint.type) lines.push(`type = ${tv(config.flint.type)}`);
|
|
1006
|
+
if (config.flint.description) lines.push(`description = ${tv(config.flint.description)}`);
|
|
1007
|
+
if (config.flint.tags?.length) lines.push(`tags = ${tv(config.flint.tags)}`);
|
|
1008
|
+
if (config.flint.org) lines.push(`org = ${tv(config.flint.org)}`);
|
|
980
1009
|
lines.push("");
|
|
981
1010
|
if (config.shards) {
|
|
982
1011
|
const declarations = getShardDeclarationsFromConfig(config);
|
|
983
1012
|
if (Object.keys(declarations).length > 0) {
|
|
984
1013
|
lines.push("[shards]");
|
|
985
1014
|
for (const [shorthand, decl] of Object.entries(declarations)) {
|
|
986
|
-
|
|
1015
|
+
const mode = resolveShardMode(decl);
|
|
1016
|
+
const fields = { source: decl.source };
|
|
1017
|
+
if (mode) fields.mode = mode;
|
|
1018
|
+
lines.push(`${shorthand} = ${inlineTable(fields)}`);
|
|
987
1019
|
}
|
|
988
1020
|
lines.push("");
|
|
989
1021
|
}
|
|
@@ -993,68 +1025,65 @@ function formatFlintToml(config) {
|
|
|
993
1025
|
if (Object.keys(modDeclarations).length > 0) {
|
|
994
1026
|
lines.push("[mods]");
|
|
995
1027
|
for (const [name, decl] of Object.entries(modDeclarations)) {
|
|
996
|
-
|
|
1028
|
+
const fields = { source: decl.source };
|
|
1029
|
+
if (decl.dev) fields.dev = true;
|
|
1030
|
+
lines.push(`${name} = ${inlineTable(fields)}`);
|
|
997
1031
|
}
|
|
998
1032
|
lines.push("");
|
|
999
1033
|
}
|
|
1000
1034
|
}
|
|
1001
|
-
if (config.
|
|
1035
|
+
if (config.exports?.required?.length) {
|
|
1036
|
+
lines.push("[exports]");
|
|
1037
|
+
const items = config.exports.required.map((e) => {
|
|
1038
|
+
const fields = { name: e.name, file: e.file, mode: e.mode };
|
|
1039
|
+
if (e.depth !== void 0 && e.depth !== 1) fields.depth = e.depth;
|
|
1040
|
+
return fields;
|
|
1041
|
+
});
|
|
1042
|
+
lines.push(`required = ${inlineTableArray(items).join("\n")}`);
|
|
1043
|
+
lines.push("");
|
|
1044
|
+
}
|
|
1045
|
+
const flintImports = config.imports?.flints || config.imports?.required || [];
|
|
1046
|
+
if (flintImports.length) {
|
|
1002
1047
|
lines.push("[imports]");
|
|
1003
|
-
lines.push(
|
|
1004
|
-
for (const ref of config.imports.required) {
|
|
1005
|
-
lines.push(` "${ref}",`);
|
|
1006
|
-
}
|
|
1007
|
-
lines.push("]");
|
|
1048
|
+
lines.push(`flints = ${stringArray(flintImports).join("\n")}`);
|
|
1008
1049
|
lines.push("");
|
|
1009
1050
|
}
|
|
1010
|
-
const
|
|
1011
|
-
const
|
|
1012
|
-
const
|
|
1013
|
-
if (
|
|
1051
|
+
const hasRefs = config.workspace?.references?.length;
|
|
1052
|
+
const hasRepos = config.workspace?.repositories?.length;
|
|
1053
|
+
const hasSrcRepos = config.workspace?.sources?.repositories?.length;
|
|
1054
|
+
if (hasRefs || hasRepos) {
|
|
1014
1055
|
lines.push("[workspace]");
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
lines.push(` { name = "${ref.name}", type = "${ref.type}" },`);
|
|
1019
|
-
}
|
|
1020
|
-
lines.push("]");
|
|
1056
|
+
if (hasRefs) {
|
|
1057
|
+
const items = config.workspace.references.map((r) => ({ name: r.name, type: r.type }));
|
|
1058
|
+
lines.push(`references = ${inlineTableArray(items).join("\n")}`);
|
|
1021
1059
|
}
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
lines.push(` { name = "${repo.name}", url = "${repo.url}" },`);
|
|
1026
|
-
}
|
|
1027
|
-
lines.push("]");
|
|
1060
|
+
if (hasRepos) {
|
|
1061
|
+
const items = config.workspace.repositories.map((r) => ({ name: r.name, url: r.url }));
|
|
1062
|
+
lines.push(`repositories = ${inlineTableArray(items).join("\n")}`);
|
|
1028
1063
|
}
|
|
1029
1064
|
lines.push("");
|
|
1030
1065
|
}
|
|
1031
|
-
if (
|
|
1066
|
+
if (hasSrcRepos) {
|
|
1032
1067
|
lines.push("[workspace.sources]");
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
lines.push(` { name = "${repo.name}", url = "${repo.url}" },`);
|
|
1036
|
-
}
|
|
1037
|
-
lines.push("]");
|
|
1068
|
+
const items = config.workspace.sources.repositories.map((r) => ({ name: r.name, url: r.url }));
|
|
1069
|
+
lines.push(`repositories = ${inlineTableArray(items).join("\n")}`);
|
|
1038
1070
|
lines.push("");
|
|
1039
1071
|
}
|
|
1040
|
-
if (config.connections?.flints
|
|
1072
|
+
if (config.connections?.flints?.length) {
|
|
1041
1073
|
lines.push("[connections]");
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
lines.push(` { name = "${conn.name}" },`);
|
|
1045
|
-
}
|
|
1046
|
-
lines.push("]");
|
|
1074
|
+
const items = config.connections.flints.map((c) => ({ name: c.name }));
|
|
1075
|
+
lines.push(`flints = ${inlineTableArray(items).join("\n")}`);
|
|
1047
1076
|
lines.push("");
|
|
1048
1077
|
}
|
|
1049
|
-
if (config.lattices
|
|
1078
|
+
if (config.lattices?.length) {
|
|
1050
1079
|
for (const lattice of config.lattices) {
|
|
1051
1080
|
lines.push("[[lattices]]");
|
|
1052
|
-
lines.push(`name =
|
|
1053
|
-
lines.push(`path =
|
|
1081
|
+
lines.push(`name = ${tv(lattice.name)}`);
|
|
1082
|
+
lines.push(`path = ${tv(lattice.path)}`);
|
|
1054
1083
|
lines.push("");
|
|
1055
1084
|
}
|
|
1056
1085
|
}
|
|
1057
|
-
const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "mods", "imports", "workspace", "connections", "lattices"]);
|
|
1086
|
+
const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "mods", "exports", "imports", "workspace", "connections", "lattices"]);
|
|
1058
1087
|
const unknownKeys = Object.keys(config).filter((k) => !knownKeys.has(k));
|
|
1059
1088
|
if (unknownKeys.length > 0) {
|
|
1060
1089
|
const unknownConfig = {};
|
|
@@ -1089,7 +1118,8 @@ async function addShardToConfig(flintPath, shardName, source, options = {}) {
|
|
|
1089
1118
|
const effectiveSource = source || kebabName;
|
|
1090
1119
|
if (!existing || existing.source !== effectiveSource) {
|
|
1091
1120
|
const decl = { source: effectiveSource };
|
|
1092
|
-
|
|
1121
|
+
const effectiveMode = options.mode || (options.dev ? "dev" : void 0);
|
|
1122
|
+
if (effectiveMode) decl.mode = effectiveMode;
|
|
1093
1123
|
config.shards[kebabName] = decl;
|
|
1094
1124
|
await writeFlintToml(flintPath, config);
|
|
1095
1125
|
}
|
|
@@ -1378,41 +1408,95 @@ async function getLatticeReference(flintPath, name) {
|
|
|
1378
1408
|
const normalizedName = name.toLowerCase();
|
|
1379
1409
|
return config?.lattices?.find((entry) => entry.name.toLowerCase() === normalizedName) || null;
|
|
1380
1410
|
}
|
|
1381
|
-
async function
|
|
1411
|
+
async function addExportToConfig(flintPath, declaration) {
|
|
1382
1412
|
let config = await readFlintToml(flintPath);
|
|
1383
1413
|
if (!config) {
|
|
1384
1414
|
throw new Error("flint.toml not found");
|
|
1385
1415
|
}
|
|
1416
|
+
if (!config.exports) {
|
|
1417
|
+
config.exports = { required: [] };
|
|
1418
|
+
}
|
|
1419
|
+
if (!config.exports.required) {
|
|
1420
|
+
config.exports.required = [];
|
|
1421
|
+
}
|
|
1422
|
+
const existing = config.exports.required.find(
|
|
1423
|
+
(e) => e.name.toLowerCase() === declaration.name.toLowerCase()
|
|
1424
|
+
);
|
|
1425
|
+
if (existing) {
|
|
1426
|
+
throw new Error(`Export "${declaration.name}" already declared`);
|
|
1427
|
+
}
|
|
1428
|
+
config.exports.required.push({
|
|
1429
|
+
name: declaration.name,
|
|
1430
|
+
file: declaration.file,
|
|
1431
|
+
mode: declaration.mode,
|
|
1432
|
+
...declaration.depth !== void 0 ? { depth: declaration.depth } : {}
|
|
1433
|
+
});
|
|
1434
|
+
await writeFlintToml(flintPath, config);
|
|
1435
|
+
}
|
|
1436
|
+
async function removeExportFromConfig(flintPath, exportName) {
|
|
1437
|
+
let config = await readFlintToml(flintPath);
|
|
1438
|
+
if (!config?.exports?.required) return false;
|
|
1439
|
+
const index = config.exports.required.findIndex(
|
|
1440
|
+
(e) => e.name.toLowerCase() === exportName.toLowerCase()
|
|
1441
|
+
);
|
|
1442
|
+
if (index === -1) return false;
|
|
1443
|
+
config.exports.required.splice(index, 1);
|
|
1444
|
+
await writeFlintToml(flintPath, config);
|
|
1445
|
+
return true;
|
|
1446
|
+
}
|
|
1447
|
+
async function getExportDeclarations(flintPath) {
|
|
1448
|
+
const config = await readFlintToml(flintPath);
|
|
1449
|
+
return config?.exports?.required || [];
|
|
1450
|
+
}
|
|
1451
|
+
function resolveFlintImports(config) {
|
|
1452
|
+
return config.imports?.flints || config.imports?.required || [];
|
|
1453
|
+
}
|
|
1454
|
+
function ensureFlintImports(config) {
|
|
1386
1455
|
if (!config.imports) {
|
|
1387
|
-
config.imports = {
|
|
1456
|
+
config.imports = { flints: [] };
|
|
1457
|
+
}
|
|
1458
|
+
if (config.imports.required && !config.imports.flints) {
|
|
1459
|
+
config.imports.flints = config.imports.required;
|
|
1460
|
+
}
|
|
1461
|
+
delete config.imports.required;
|
|
1462
|
+
if (!config.imports.flints) {
|
|
1463
|
+
config.imports.flints = [];
|
|
1388
1464
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1465
|
+
return config.imports.flints;
|
|
1466
|
+
}
|
|
1467
|
+
async function addImportToConfig(flintPath, ref) {
|
|
1468
|
+
let config = await readFlintToml(flintPath);
|
|
1469
|
+
if (!config) {
|
|
1470
|
+
throw new Error("flint.toml not found");
|
|
1391
1471
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1472
|
+
const flints = ensureFlintImports(config);
|
|
1473
|
+
if (!flints.includes(ref)) {
|
|
1474
|
+
flints.push(ref);
|
|
1394
1475
|
await writeFlintToml(flintPath, config);
|
|
1395
1476
|
}
|
|
1396
1477
|
}
|
|
1397
1478
|
async function removeImportFromConfig(flintPath, ref) {
|
|
1398
1479
|
let config = await readFlintToml(flintPath);
|
|
1399
|
-
if (!config
|
|
1400
|
-
const
|
|
1480
|
+
if (!config) return false;
|
|
1481
|
+
const flints = ensureFlintImports(config);
|
|
1482
|
+
const index = flints.indexOf(ref);
|
|
1401
1483
|
if (index === -1) {
|
|
1402
1484
|
const lowerRef = ref.toLowerCase();
|
|
1403
|
-
const foundIndex =
|
|
1485
|
+
const foundIndex = flints.findIndex((r) => r.toLowerCase() === lowerRef);
|
|
1404
1486
|
if (foundIndex === -1) return false;
|
|
1405
|
-
|
|
1487
|
+
flints.splice(foundIndex, 1);
|
|
1406
1488
|
} else {
|
|
1407
|
-
|
|
1489
|
+
flints.splice(index, 1);
|
|
1408
1490
|
}
|
|
1409
1491
|
await writeFlintToml(flintPath, config);
|
|
1410
1492
|
return true;
|
|
1411
1493
|
}
|
|
1412
|
-
async function
|
|
1494
|
+
async function getFlintImports(flintPath) {
|
|
1413
1495
|
const config = await readFlintToml(flintPath);
|
|
1414
|
-
|
|
1496
|
+
if (!config) return [];
|
|
1497
|
+
return resolveFlintImports(config);
|
|
1415
1498
|
}
|
|
1499
|
+
var getRequiredImports = getFlintImports;
|
|
1416
1500
|
async function addWorkspaceEntry(flintPath, name, path) {
|
|
1417
1501
|
console.warn("addWorkspaceEntry is deprecated, use addWorkspaceReference instead");
|
|
1418
1502
|
}
|
|
@@ -1428,6 +1512,9 @@ async function getWorkspaceEntry(flintPath, name) {
|
|
|
1428
1512
|
|
|
1429
1513
|
export {
|
|
1430
1514
|
parse,
|
|
1515
|
+
stringify,
|
|
1516
|
+
resolveShardMode,
|
|
1517
|
+
isLocalShard,
|
|
1431
1518
|
FLINT_CONFIG_FILENAME,
|
|
1432
1519
|
FLINT_JSON_FILENAME,
|
|
1433
1520
|
FLINT_VERSION,
|
|
@@ -1475,8 +1562,12 @@ export {
|
|
|
1475
1562
|
removeLatticeReference,
|
|
1476
1563
|
getLatticeReferences,
|
|
1477
1564
|
getLatticeReference,
|
|
1565
|
+
addExportToConfig,
|
|
1566
|
+
removeExportFromConfig,
|
|
1567
|
+
getExportDeclarations,
|
|
1478
1568
|
addImportToConfig,
|
|
1479
1569
|
removeImportFromConfig,
|
|
1570
|
+
getFlintImports,
|
|
1480
1571
|
getRequiredImports,
|
|
1481
1572
|
addWorkspaceEntry,
|
|
1482
1573
|
removeWorkspaceEntry,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// ../../packages/flint/
|
|
1
|
+
// ../../packages/flint/dist/chunk-CJE24DAP.js
|
|
2
2
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
3
3
|
import { homedir } from "os";
|
|
4
4
|
import { join, resolve } from "path";
|
|
5
5
|
var REGISTRY_VERSION = 1;
|
|
6
6
|
function getGlobalFlintDir() {
|
|
7
|
-
return join(homedir(), ".flint");
|
|
7
|
+
return join(homedir(), ".nuucognition", "flint");
|
|
8
8
|
}
|
|
9
9
|
function getFlintRegistryPath() {
|
|
10
10
|
return join(getGlobalFlintDir(), "registry.json");
|
|
@@ -184,7 +184,7 @@ async function cleanRegistryFile() {
|
|
|
184
184
|
return result;
|
|
185
185
|
}
|
|
186
186
|
async function registerFlintByPath(path, options) {
|
|
187
|
-
const { readFlintToml, hasFlintToml } = await import("./mesh-config-
|
|
187
|
+
const { readFlintToml, hasFlintToml } = await import("./mesh-config-VGFSHC2G-YCC4ZIAT.js");
|
|
188
188
|
const isFlint = await hasFlintToml(path);
|
|
189
189
|
if (!isFlint) {
|
|
190
190
|
throw new Error(`Not a valid flint: ${path}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../packages/flint/
|
|
1
|
+
// ../../packages/flint/dist/chunk-E7CDAGZD.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,6 +224,31 @@ 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");
|
|
228
|
+
const config = await readFlintToml(flintPath);
|
|
229
|
+
const declarations = config?.exports?.required;
|
|
230
|
+
if (declarations && declarations.length > 0) {
|
|
231
|
+
return scanExportsFromConfig(flintPath, declarations);
|
|
232
|
+
}
|
|
233
|
+
return scanExportsLegacy(flintPath);
|
|
234
|
+
}
|
|
235
|
+
async function scanExportsFromConfig(flintPath, declarations) {
|
|
236
|
+
const manifests = [];
|
|
237
|
+
for (const decl of declarations) {
|
|
238
|
+
const sourcePath = await resolveDocument(decl.file.replace(/\.md$/, ""), flintPath);
|
|
239
|
+
if (!sourcePath) continue;
|
|
240
|
+
try {
|
|
241
|
+
const content = await readFile(sourcePath, "utf-8");
|
|
242
|
+
const depth = decl.depth ?? (decl.mode === "mesh" ? 1 : 1);
|
|
243
|
+
const manifest = parseExportDocument(content, decl.name, sourcePath);
|
|
244
|
+
manifest.depth = depth;
|
|
245
|
+
manifests.push(manifest);
|
|
246
|
+
} catch {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return manifests;
|
|
250
|
+
}
|
|
251
|
+
async function scanExportsLegacy(flintPath) {
|
|
227
252
|
const meshDir = join(flintPath, "Mesh");
|
|
228
253
|
if (!await exists(meshDir)) {
|
|
229
254
|
return [];
|
|
@@ -242,9 +267,49 @@ async function scanExports(flintPath) {
|
|
|
242
267
|
}
|
|
243
268
|
return manifests;
|
|
244
269
|
}
|
|
270
|
+
async function scanExportEligible(flintPath) {
|
|
271
|
+
const meshDir = join(flintPath, "Mesh");
|
|
272
|
+
if (!await exists(meshDir)) return [];
|
|
273
|
+
const { readFlintToml } = await import("./mesh-config-VGFSHC2G-YCC4ZIAT.js");
|
|
274
|
+
const config = await readFlintToml(flintPath);
|
|
275
|
+
const declared = new Set(
|
|
276
|
+
(config?.exports?.required || []).map((d) => d.file.replace(/\.md$/, "").toLowerCase())
|
|
277
|
+
);
|
|
278
|
+
const eligible = [];
|
|
279
|
+
await findExportTaggedFiles(meshDir, flintPath, declared, eligible);
|
|
280
|
+
return eligible;
|
|
281
|
+
}
|
|
282
|
+
async function findExportTaggedFiles(dir, flintPath, declared, results) {
|
|
283
|
+
try {
|
|
284
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
285
|
+
for (const entry of entries) {
|
|
286
|
+
const fullPath = join(dir, entry.name);
|
|
287
|
+
if (entry.isDirectory()) {
|
|
288
|
+
await findExportTaggedFiles(fullPath, flintPath, declared, results);
|
|
289
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
290
|
+
try {
|
|
291
|
+
const content = await readFile(fullPath, "utf-8");
|
|
292
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
293
|
+
if (!fmMatch || !fmMatch[1]) continue;
|
|
294
|
+
const hasExportTag = /["']#export["']/.test(fmMatch[1]);
|
|
295
|
+
if (!hasExportTag) continue;
|
|
296
|
+
const fileName = basename(fullPath, ".md");
|
|
297
|
+
if (declared.has(fileName.toLowerCase())) continue;
|
|
298
|
+
results.push({
|
|
299
|
+
filePath: fullPath,
|
|
300
|
+
fileName: entry.name,
|
|
301
|
+
name: fileName
|
|
302
|
+
});
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
245
310
|
async function buildExport(manifest, flintPath) {
|
|
246
311
|
const exportsDir = join(flintPath, "Exports");
|
|
247
|
-
const outputDir = join(exportsDir, manifest.name);
|
|
312
|
+
const outputDir = join(exportsDir, `(Mesh) ${manifest.name}`);
|
|
248
313
|
if (await exists(outputDir)) {
|
|
249
314
|
await rm(outputDir, { recursive: true });
|
|
250
315
|
}
|
|
@@ -345,11 +410,12 @@ async function cleanupStaleExports(flintPath) {
|
|
|
345
410
|
return removed;
|
|
346
411
|
}
|
|
347
412
|
const manifests = await scanExports(flintPath);
|
|
348
|
-
const
|
|
413
|
+
const validFolderNames = new Set(manifests.map((m) => `(Mesh) ${m.name}`));
|
|
414
|
+
const validLegacyNames = new Set(manifests.map((m) => m.name));
|
|
349
415
|
const entries = await readdir(exportsDir, { withFileTypes: true });
|
|
350
416
|
for (const entry of entries) {
|
|
351
417
|
if (entry.isDirectory()) {
|
|
352
|
-
if (!
|
|
418
|
+
if (!validFolderNames.has(entry.name) && !validLegacyNames.has(entry.name)) {
|
|
353
419
|
try {
|
|
354
420
|
await rm(join(exportsDir, entry.name), { recursive: true });
|
|
355
421
|
removed.push(entry.name);
|
|
@@ -379,6 +445,7 @@ async function buildAllExports(flintPath) {
|
|
|
379
445
|
|
|
380
446
|
export {
|
|
381
447
|
scanExports,
|
|
448
|
+
scanExportEligible,
|
|
382
449
|
buildExport,
|
|
383
450
|
buildExportByName,
|
|
384
451
|
cleanupStaleExports,
|
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
buildExport,
|
|
4
4
|
buildExportByName,
|
|
5
5
|
cleanupStaleExports,
|
|
6
|
+
scanExportEligible,
|
|
6
7
|
scanExports
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VO4ZYDCW.js";
|
|
8
9
|
export {
|
|
9
10
|
buildAllExports,
|
|
10
11
|
buildExport,
|
|
11
12
|
buildExportByName,
|
|
12
13
|
cleanupStaleExports,
|
|
14
|
+
scanExportEligible,
|
|
13
15
|
scanExports
|
|
14
16
|
};
|