Skip to content

Commit

Permalink
build(deps): update dependency graph-data-structure to v4 (#32320)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <[email protected]>
  • Loading branch information
renovate[bot] and viceice authored Nov 20, 2024
1 parent b8d7e15 commit cb20666
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ env:
SPARSE_CHECKOUT: |-
.github/actions/
data/
patches/
tools/
package.json
pnpm-lock.yaml
Expand Down
10 changes: 5 additions & 5 deletions lib/modules/manager/nuget/package-tree.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import is from '@sindresorhus/is';
import { Graph } from 'graph-data-structure';
import { Graph, hasCycle } from 'graph-data-structure';
import upath from 'upath';
import { logger } from '../../../logger';
import { minimatchFilter } from '../../../util/minimatch';
Expand All @@ -18,7 +18,7 @@ export async function getDependentPackageFiles(
isCentralManagement = false,
): Promise<ProjectFile[]> {
const packageFiles = await getAllPackageFiles();
const graph: ReturnType<typeof Graph> = Graph();
const graph = new Graph();

if (isCentralManagement) {
graph.addNode(packageFileName);
Expand Down Expand Up @@ -62,7 +62,7 @@ export async function getDependentPackageFiles(
graph.addEdge(ref, f);
}

if (graph.hasCycle()) {
if (hasCycle(graph)) {
throw new Error('Circular reference detected in NuGet package files');
}
}
Expand All @@ -84,12 +84,12 @@ export async function getDependentPackageFiles(
*/
function recursivelyGetDependentPackageFiles(
packageFileName: string,
graph: ReturnType<typeof Graph>,
graph: Graph,
deps: Map<string, boolean>,
): void {
const dependents = graph.adjacent(packageFileName);

if (dependents.length === 0) {
if (!dependents || dependents.size === 0) {
deps.set(packageFileName, true);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/manager/pip-compile/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Graph } from 'graph-data-structure';
import { Graph, topologicalSort } from 'graph-data-structure';
import upath from 'upath';
import { logger } from '../../../logger';
import type { PackageFile } from '../types';
Expand All @@ -9,11 +9,11 @@ export function sortPackageFiles(
packageFiles: Map<string, PackageFile>,
): PackageFile[] {
const result: PackageFile[] = [];
const graph: ReturnType<typeof Graph> = Graph();
const graph = new Graph();
depsBetweenFiles.forEach(({ sourceFile, outputFile }) => {
graph.addEdge(sourceFile, outputFile);
});
const sorted = graph.topologicalSort();
const sorted = topologicalSort(graph);
for (const file of sorted) {
if (packageFiles.has(file)) {
const packageFile = packageFiles.get(file)!;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"good-enough-parser": "1.1.23",
"google-auth-library": "9.14.2",
"got": "11.8.6",
"graph-data-structure": "3.5.0",
"graph-data-structure": "4.2.0",
"handlebars": "4.7.8",
"ignore": "6.0.2",
"ini": "5.0.0",
Expand Down
11 changes: 5 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cb20666

Please sign in to comment.