MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / topologicalSort

Method topologicalSort

packages/bumpy/src/core/dep-graph.ts:55–79  ·  view source on GitHub ↗

Topological sort — returns packages in dependency order (deps first)

(packages: Map<string, WorkspacePackage>)

Source from the content-addressed store, hash-verified

53
54 /** Topological sort — returns packages in dependency order (deps first) */
55 topologicalSort(packages: Map<string, WorkspacePackage>): string[] {
56 const visited = new Set<string>();
57 const result: string[] = [];
58
59 const visit = (name: string) => {
60 if (visited.has(name)) return;
61 visited.add(name);
62 const pkg = packages.get(name);
63 if (!pkg) return;
64 // Visit all internal dependencies first
65 for (const deps of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies, pkg.optionalDependencies]) {
66 for (const depName of Object.keys(deps)) {
67 if (this.internalPackages.has(depName)) {
68 visit(depName);
69 }
70 }
71 }
72 result.push(name);
73 };
74
75 for (const name of this.internalPackages) {
76 visit(name);
77 }
78 return result;
79 }
80}

Callers 2

dep-graph.test.tsFile · 0.80
publishPackagesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected