diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e616a5f6b984e..6e896b6390085c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,7 @@ env: SPARSE_CHECKOUT: |- .github/actions/ data/ + patches/ tools/ package.json pnpm-lock.yaml diff --git a/lib/modules/manager/nuget/package-tree.ts b/lib/modules/manager/nuget/package-tree.ts index 56b3f874ff6470..fd4595e31d453e 100644 --- a/lib/modules/manager/nuget/package-tree.ts +++ b/lib/modules/manager/nuget/package-tree.ts @@ -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'; @@ -18,7 +18,7 @@ export async function getDependentPackageFiles( isCentralManagement = false, ): Promise { const packageFiles = await getAllPackageFiles(); - const graph: ReturnType = Graph(); + const graph = new Graph(); if (isCentralManagement) { graph.addNode(packageFileName); @@ -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'); } } @@ -84,12 +84,12 @@ export async function getDependentPackageFiles( */ function recursivelyGetDependentPackageFiles( packageFileName: string, - graph: ReturnType, + graph: Graph, deps: Map, ): void { const dependents = graph.adjacent(packageFileName); - if (dependents.length === 0) { + if (!dependents || dependents.size === 0) { deps.set(packageFileName, true); return; } diff --git a/lib/modules/manager/pip-compile/utils.ts b/lib/modules/manager/pip-compile/utils.ts index 50fcdde6585feb..8ae1d5126903d4 100644 --- a/lib/modules/manager/pip-compile/utils.ts +++ b/lib/modules/manager/pip-compile/utils.ts @@ -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'; @@ -9,11 +9,11 @@ export function sortPackageFiles( packageFiles: Map, ): PackageFile[] { const result: PackageFile[] = []; - const graph: ReturnType = 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)!; diff --git a/package.json b/package.json index 66cf98e64d47ff..392fcac80a322a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b22f2a3315b2b..ecc090d1fa68b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -198,8 +198,8 @@ importers: specifier: 11.8.6 version: 11.8.6 graph-data-structure: - specifier: 3.5.0 - version: 3.5.0 + specifier: 4.2.0 + version: 4.2.0 handlebars: specifier: 4.7.8 version: 4.7.8 @@ -1187,7 +1187,6 @@ packages: '@ls-lint/ls-lint@2.2.3': resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==} - cpu: [x64, arm64, s390x] os: [darwin, linux, win32] hasBin: true @@ -3617,8 +3616,8 @@ packages: graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - graph-data-structure@3.5.0: - resolution: {integrity: sha512-AAgjRtBZC1acIExgK2otv2LDdcYeZdQFKiEStXRDTyaVs6sUUaGUif05pCczTqAU4ny82NQtM1p5PK7AQEYgRA==} + graph-data-structure@4.2.0: + resolution: {integrity: sha512-DFGyFROTYJAXwLjBPvj6LYihF2zIUDKt6Rzgo18E+FFKtHm7dJnE/bMHVp6fji5IchykUg3ctS9gwS0L5azwDw==} grapheme-splitter@1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} @@ -10445,7 +10444,7 @@ snapshots: graceful-fs@4.2.11: {} - graph-data-structure@3.5.0: {} + graph-data-structure@4.2.0: {} grapheme-splitter@1.0.4: {}