silgi 0.8.23 → 0.8.24
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 +33 -2
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1072,6 +1072,33 @@ function createDependencyGraph(modules) {
|
|
|
1072
1072
|
});
|
|
1073
1073
|
return { graph, inDegree };
|
|
1074
1074
|
}
|
|
1075
|
+
function findCyclicDependencies(graph) {
|
|
1076
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1077
|
+
const recursionStack = /* @__PURE__ */ new Set();
|
|
1078
|
+
const cycles = [];
|
|
1079
|
+
function dfs(node, path = []) {
|
|
1080
|
+
if (recursionStack.has(node)) {
|
|
1081
|
+
const cycleStart = path.indexOf(node);
|
|
1082
|
+
cycles.push(path.slice(cycleStart));
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
if (visited.has(node))
|
|
1086
|
+
return;
|
|
1087
|
+
visited.add(node);
|
|
1088
|
+
recursionStack.add(node);
|
|
1089
|
+
path.push(node);
|
|
1090
|
+
for (const neighbor of graph.get(node) || []) {
|
|
1091
|
+
dfs(neighbor, [...path]);
|
|
1092
|
+
}
|
|
1093
|
+
recursionStack.delete(node);
|
|
1094
|
+
}
|
|
1095
|
+
for (const node of graph.keys()) {
|
|
1096
|
+
if (!visited.has(node)) {
|
|
1097
|
+
dfs(node);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return cycles;
|
|
1101
|
+
}
|
|
1075
1102
|
function topologicalSort(graphData) {
|
|
1076
1103
|
const { graph, inDegree } = graphData;
|
|
1077
1104
|
const order = [];
|
|
@@ -1089,8 +1116,12 @@ function topologicalSort(graphData) {
|
|
|
1089
1116
|
queue.push(neighbor);
|
|
1090
1117
|
}
|
|
1091
1118
|
}
|
|
1092
|
-
if (order.length !== graph.size)
|
|
1093
|
-
|
|
1119
|
+
if (order.length !== graph.size) {
|
|
1120
|
+
const cycles = findCyclicDependencies(graph);
|
|
1121
|
+
const cycleStr = cycles.map((cycle) => cycle.join(" -> ")).join("\n");
|
|
1122
|
+
throw new Error(`Circular dependencies detected:
|
|
1123
|
+
${cycleStr}`);
|
|
1124
|
+
}
|
|
1094
1125
|
return order;
|
|
1095
1126
|
}
|
|
1096
1127
|
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED