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.
@@ -1,4 +1,4 @@
1
- const version = "0.8.23";
1
+ const version = "0.8.24";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
@@ -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
- throw new Error("Circular dependency detected");
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
 
@@ -1,4 +1,4 @@
1
- const version = "0.8.23";
1
+ const version = "0.8.24";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
@@ -1,4 +1,4 @@
1
- const version = "0.8.23";
1
+ const version = "0.8.24";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.8.23",
4
+ "version": "0.8.24",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {