UNPKG

snyk-mvn-plugin

Version:
52 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MavenGraphBuilder = void 0; class MavenGraphBuilder { #graph; constructor(rootId) { this.#graph = { rootId, nodes: { [rootId]: { dependsOn: [], parents: [], reachesProdDep: false }, }, }; } findOrCreateNode(id) { return this.findNode(id) || this.createNode(id); } findNode(id) { return this.#graph.nodes[id]; } createNode(id) { const node = { dependsOn: [], parents: [], reachesProdDep: false }; this.#graph.nodes[id] = node; return node; } markNodeProdReachable(id) { const node = this.findNode(id); if (node && !node.reachesProdDep) { node.reachesProdDep = true; for (const parentId of node.parents) { this.markNodeProdReachable(parentId); } } } connect(parentId, id) { const parentNode = this.findOrCreateNode(parentId); const childNode = this.findOrCreateNode(id); if (!childNode.parents.includes(parentId)) { childNode.parents.push(parentId); } if (!parentNode.dependsOn.includes(id)) { parentNode.dependsOn.push(id); } if (!id.endsWith(':test')) { this.markNodeProdReachable(id); } } get graph() { return this.#graph; } } exports.MavenGraphBuilder = MavenGraphBuilder; //# sourceMappingURL=maven-graph-builder.js.map