silgi 0.8.7 → 0.8.9
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 +23 -29
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- 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);
|
|
1071
|
+
const queue = [];
|
|
1072
|
+
for (const [node, degree] of inDegree.entries()) {
|
|
1073
|
+
if (degree === 0)
|
|
1074
|
+
queue.push(node);
|
|
1084
1075
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
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
|
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -740,7 +740,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
740
740
|
/**
|
|
741
741
|
* Silgi input config (silgi.config)
|
|
742
742
|
*/
|
|
743
|
-
interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>,
|
|
743
|
+
interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, Partial<SilgiModuleOptions> {
|
|
744
744
|
preset?: PresetNameInput;
|
|
745
745
|
extends?: string | string[] | SilgiPreset;
|
|
746
746
|
compatibilityDate?: CompatibilityDateSpec;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -740,7 +740,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
740
740
|
/**
|
|
741
741
|
* Silgi input config (silgi.config)
|
|
742
742
|
*/
|
|
743
|
-
interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>,
|
|
743
|
+
interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, Partial<SilgiModuleOptions> {
|
|
744
744
|
preset?: PresetNameInput;
|
|
745
745
|
extends?: string | string[] | SilgiPreset;
|
|
746
746
|
compatibilityDate?: CompatibilityDateSpec;
|