silgi 0.8.8 → 0.8.10
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/dist/_chunks/index.mjs +1 -1
- package/dist/cli/prepare.mjs +43 -45
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1036,60 +1036,54 @@ async function scanModules$1(silgi) {
|
|
|
1036
1036
|
const moduleMap = new Map(
|
|
1037
1037
|
silgi.scanModules.map((m) => [m.meta?.configKey, m])
|
|
1038
1038
|
);
|
|
1039
|
-
const
|
|
1040
|
-
const sortedKeys = topologicalSort(
|
|
1039
|
+
const graphData = createDependencyGraph(silgi.scanModules);
|
|
1040
|
+
const sortedKeys = topologicalSort(graphData);
|
|
1041
1041
|
const modules = sortedKeys.map((key) => moduleMap.get(key)).filter((module) => Boolean(module));
|
|
1042
1042
|
silgi.scanModules = modules;
|
|
1043
1043
|
}
|
|
1044
1044
|
function createDependencyGraph(modules) {
|
|
1045
1045
|
const graph = /* @__PURE__ */ new Map();
|
|
1046
|
+
const inDegree = /* @__PURE__ */ new Map();
|
|
1046
1047
|
modules.forEach((module) => {
|
|
1047
1048
|
const key = module.meta?.configKey;
|
|
1048
1049
|
if (key) {
|
|
1049
1050
|
graph.set(key, /* @__PURE__ */ new Set());
|
|
1051
|
+
inDegree.set(key, 0);
|
|
1050
1052
|
}
|
|
1051
1053
|
});
|
|
1052
1054
|
modules.forEach((module) => {
|
|
1053
1055
|
const key = module.meta?.configKey;
|
|
1054
1056
|
const deps = module.meta?.dependencies || [];
|
|
1055
1057
|
if (key && deps.length > 0) {
|
|
1056
|
-
const modulesDeps = graph.get(key) || /* @__PURE__ */ new Set();
|
|
1057
1058
|
deps.forEach((dep) => {
|
|
1058
1059
|
if (graph.has(dep)) {
|
|
1059
|
-
|
|
1060
|
+
graph.get(dep)?.add(key);
|
|
1061
|
+
inDegree.set(key, (inDegree.get(key) || 0) + 1);
|
|
1060
1062
|
}
|
|
1061
1063
|
});
|
|
1062
|
-
graph.set(key, modulesDeps);
|
|
1063
1064
|
}
|
|
1064
1065
|
});
|
|
1065
|
-
return graph;
|
|
1066
|
+
return { graph, inDegree };
|
|
1066
1067
|
}
|
|
1067
|
-
function topologicalSort(
|
|
1068
|
-
const
|
|
1069
|
-
const temp = /* @__PURE__ */ new Set();
|
|
1068
|
+
function topologicalSort(graphData) {
|
|
1069
|
+
const { graph, inDegree } = graphData;
|
|
1070
1070
|
const order = [];
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
return;
|
|
1076
|
-
temp.add(node);
|
|
1077
|
-
const deps = graph.get(node) || /* @__PURE__ */ new Set();
|
|
1078
|
-
for (const dep of deps) {
|
|
1079
|
-
visit(dep);
|
|
1080
|
-
}
|
|
1081
|
-
temp.delete(node);
|
|
1082
|
-
visited.add(node);
|
|
1083
|
-
order.unshift(node);
|
|
1084
|
-
}
|
|
1085
|
-
for (const [node, deps] of graph.entries()) {
|
|
1086
|
-
if (deps.size === 0 && !visited.has(node))
|
|
1087
|
-
visit(node);
|
|
1071
|
+
const queue = [];
|
|
1072
|
+
for (const [node, degree] of inDegree.entries()) {
|
|
1073
|
+
if (degree === 0)
|
|
1074
|
+
queue.push(node);
|
|
1088
1075
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1076
|
+
while (queue.length > 0) {
|
|
1077
|
+
const node = queue.shift();
|
|
1078
|
+
order.push(node);
|
|
1079
|
+
for (const neighbor of graph.get(node) || []) {
|
|
1080
|
+
inDegree.set(neighbor, (inDegree.get(neighbor) || 0) - 1);
|
|
1081
|
+
if (inDegree.get(neighbor) === 0)
|
|
1082
|
+
queue.push(neighbor);
|
|
1083
|
+
}
|
|
1092
1084
|
}
|
|
1085
|
+
if (order.length !== graph.size)
|
|
1086
|
+
throw new Error("Circular dependency detected");
|
|
1093
1087
|
return order;
|
|
1094
1088
|
}
|
|
1095
1089
|
|
|
@@ -1664,23 +1658,27 @@ const prepare = defineCommand({
|
|
|
1664
1658
|
}
|
|
1665
1659
|
},
|
|
1666
1660
|
async run({ args }) {
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1661
|
+
async function generate() {
|
|
1662
|
+
const rootDir = resolve(args.dir || args._dir || ".");
|
|
1663
|
+
const silgi = await createSilgiCLI({
|
|
1664
|
+
rootDir,
|
|
1665
|
+
dev: args.stub,
|
|
1666
|
+
stub: args.stub,
|
|
1667
|
+
preset: args.preset
|
|
1668
|
+
});
|
|
1669
|
+
await prepare$1();
|
|
1670
|
+
for (const framework of frameworkSetup) {
|
|
1671
|
+
await framework(silgi);
|
|
1672
|
+
}
|
|
1673
|
+
await writeTypesAndFiles(silgi);
|
|
1674
|
+
await silgi.callHook("read:core.ts", async () => {
|
|
1675
|
+
const data = await readCoreFile(silgi);
|
|
1676
|
+
return data;
|
|
1677
|
+
});
|
|
1678
|
+
await silgi.close();
|
|
1677
1679
|
}
|
|
1678
|
-
await
|
|
1679
|
-
await
|
|
1680
|
-
const data = await readCoreFile(silgi);
|
|
1681
|
-
return data;
|
|
1682
|
-
});
|
|
1683
|
-
await silgi.close();
|
|
1680
|
+
await generate();
|
|
1681
|
+
await generate();
|
|
1684
1682
|
}
|
|
1685
1683
|
});
|
|
1686
1684
|
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -356,6 +356,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
356
356
|
handler: string;
|
|
357
357
|
description?: string;
|
|
358
358
|
}>>) => HookResult;
|
|
359
|
+
'prepare:installPackages': (packages: string[]) => HookResult;
|
|
359
360
|
}
|
|
360
361
|
|
|
361
362
|
/**
|
|
@@ -736,6 +737,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
736
737
|
handler: string;
|
|
737
738
|
description?: string;
|
|
738
739
|
}>>;
|
|
740
|
+
installPackages: string[];
|
|
739
741
|
}
|
|
740
742
|
/**
|
|
741
743
|
* Silgi input config (silgi.config)
|
package/dist/types/index.d.ts
CHANGED
|
@@ -356,6 +356,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
356
356
|
handler: string;
|
|
357
357
|
description?: string;
|
|
358
358
|
}>>) => HookResult;
|
|
359
|
+
'prepare:installPackages': (packages: string[]) => HookResult;
|
|
359
360
|
}
|
|
360
361
|
|
|
361
362
|
/**
|
|
@@ -736,6 +737,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
736
737
|
handler: string;
|
|
737
738
|
description?: string;
|
|
738
739
|
}>>;
|
|
740
|
+
installPackages: string[];
|
|
739
741
|
}
|
|
740
742
|
/**
|
|
741
743
|
* Silgi input config (silgi.config)
|