snyk 1.1046.0 → 1.1048.0
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.
- package/dist/cli/263.index.js +2531 -49
- package/dist/cli/263.index.js.map +1 -1
- package/dist/cli/395.index.js +2 -2
- package/dist/cli/395.index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +6 -6
- package/dist/scala/SnykSbtPlugin-0.1x.scala +1 -3
- package/dist/scala/SnykSbtPlugin-1.2x.scala +1 -4
- package/package.json +1 -1
- package/pysrc/pip_resolve.py +4 -1
package/dist/cli/263.index.js
CHANGED
|
@@ -140312,7 +140312,7 @@ function groupFilesByDirectory(filePathToContent) {
|
|
|
140312
140312
|
|
|
140313
140313
|
/***/ }),
|
|
140314
140314
|
|
|
140315
|
-
/***/
|
|
140315
|
+
/***/ 95710:
|
|
140316
140316
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
140317
140317
|
|
|
140318
140318
|
"use strict";
|
|
@@ -144345,7 +144345,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
144345
144345
|
exports.appendLatestTagIfMissing = exports.scan = exports.mergeEnvVarsIntoCredentials = void 0;
|
|
144346
144346
|
const fs = __webpack_require__(35747);
|
|
144347
144347
|
const path = __webpack_require__(85622);
|
|
144348
|
-
const image_inspector_1 = __webpack_require__(
|
|
144348
|
+
const image_inspector_1 = __webpack_require__(95710);
|
|
144349
144349
|
const dockerfile_1 = __webpack_require__(79652);
|
|
144350
144350
|
const image_save_path_1 = __webpack_require__(89313);
|
|
144351
144351
|
const image_type_1 = __webpack_require__(38932);
|
|
@@ -165511,9 +165511,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
165511
165511
|
exports.extractCorrectIdentifierBySemver = exports.extractNameAndIdentifier = void 0;
|
|
165512
165512
|
const semver = __webpack_require__(50460);
|
|
165513
165513
|
const extractNameAndIdentifier = (candidate) => {
|
|
165514
|
-
|
|
165515
|
-
|
|
165516
|
-
|
|
165514
|
+
let name, identifier;
|
|
165515
|
+
if (candidate.includes('@')) {
|
|
165516
|
+
const index = candidate.indexOf('@', 1);
|
|
165517
|
+
name = candidate.slice(0, index);
|
|
165518
|
+
identifier = candidate.slice(index + 1);
|
|
165519
|
+
}
|
|
165520
|
+
else {
|
|
165521
|
+
name = candidate;
|
|
165522
|
+
identifier = 'unknown';
|
|
165523
|
+
}
|
|
165517
165524
|
return { name, identifier };
|
|
165518
165525
|
};
|
|
165519
165526
|
exports.extractNameAndIdentifier = extractNameAndIdentifier;
|
|
@@ -165522,7 +165529,7 @@ exports.extractNameAndIdentifier = extractNameAndIdentifier;
|
|
|
165522
165529
|
// will result in debug@2.2.6 - This is required as yarn list does not have the resolved semver
|
|
165523
165530
|
// in dependencies.
|
|
165524
165531
|
const extractCorrectIdentifierBySemver = (possibleMatches, versionToMatch) => {
|
|
165525
|
-
const { name: nameToMatch, identifier: identifierToMatch
|
|
165532
|
+
const { name: nameToMatch, identifier: identifierToMatch } = (0, exports.extractNameAndIdentifier)(versionToMatch);
|
|
165526
165533
|
const hasQualifiers = isNaN(parseInt(identifierToMatch[0]));
|
|
165527
165534
|
if (!hasQualifiers) {
|
|
165528
165535
|
return versionToMatch;
|
|
@@ -165530,10 +165537,10 @@ const extractCorrectIdentifierBySemver = (possibleMatches, versionToMatch) => {
|
|
|
165530
165537
|
// Check for matching name, if only one found shortcircuit
|
|
165531
165538
|
const match = possibleMatches
|
|
165532
165539
|
.filter((name) => name.startsWith(nameToMatch))
|
|
165533
|
-
.filter((name) => semver.satisfies(exports.extractNameAndIdentifier(name).identifier, identifierToMatch))
|
|
165540
|
+
.filter((name) => semver.satisfies((0, exports.extractNameAndIdentifier)(name).identifier, identifierToMatch))
|
|
165534
165541
|
.map((name) => ({
|
|
165535
165542
|
name,
|
|
165536
|
-
identifier: exports.extractNameAndIdentifier(name).identifier,
|
|
165543
|
+
identifier: (0, exports.extractNameAndIdentifier)(name).identifier,
|
|
165537
165544
|
}))
|
|
165538
165545
|
.reduce((acc, item) => semver.gt(item.identifier, acc.identifier) ? item : acc);
|
|
165539
165546
|
return match.name;
|
|
@@ -165550,7 +165557,7 @@ exports.extractCorrectIdentifierBySemver = extractCorrectIdentifierBySemver;
|
|
|
165550
165557
|
|
|
165551
165558
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165552
165559
|
exports.buildDepGraphFromCliOutput = void 0;
|
|
165553
|
-
const dep_graph_1 = __webpack_require__(
|
|
165560
|
+
const dep_graph_1 = __webpack_require__(53789);
|
|
165554
165561
|
const __1 = __webpack_require__(423);
|
|
165555
165562
|
const parsers_1 = __webpack_require__(75873);
|
|
165556
165563
|
const cli_parser_utils_1 = __webpack_require__(80333);
|
|
@@ -165558,13 +165565,13 @@ const yarn_info_parser_1 = __webpack_require__(79326);
|
|
|
165558
165565
|
const yarn_list_parser_1 = __webpack_require__(97016);
|
|
165559
165566
|
const buildDepGraphFromCliOutput = (rawCliOutput, lockfileContent, manifestFileContent) => {
|
|
165560
165567
|
const manifestDependencies = JSON.parse(manifestFileContent).dependencies || {};
|
|
165561
|
-
const lockfileType = __1.getYarnLockfileType(lockfileContent);
|
|
165568
|
+
const lockfileType = (0, __1.getYarnLockfileType)(lockfileContent);
|
|
165562
165569
|
const { name: rootName, version: rootVersion } = JSON.parse(manifestFileContent);
|
|
165563
165570
|
const pkgManagerVersion = lockfileType === parsers_1.LockfileType.yarn ? '1' : '2';
|
|
165564
165571
|
// Build depMap object from the cli output
|
|
165565
165572
|
const formattedCliOutput = pkgManagerVersion === '1'
|
|
165566
|
-
? yarn_list_parser_1.parseYarnListOutput(rawCliOutput, manifestDependencies)
|
|
165567
|
-
: yarn_info_parser_1.parseYarnInfoOutput(rawCliOutput);
|
|
165573
|
+
? (0, yarn_list_parser_1.parseYarnListOutput)(rawCliOutput, manifestDependencies)
|
|
165574
|
+
: (0, yarn_info_parser_1.parseYarnInfoOutput)(rawCliOutput);
|
|
165568
165575
|
const rootPkgInfo = rootName
|
|
165569
165576
|
? Object.assign({ name: rootName }, (rootVersion && { version: rootVersion })) : undefined;
|
|
165570
165577
|
const pkgManager = {
|
|
@@ -165575,7 +165582,7 @@ const buildDepGraphFromCliOutput = (rawCliOutput, lockfileContent, manifestFileC
|
|
|
165575
165582
|
const { topLevelDeps, dependencies: depMap } = formattedCliOutput;
|
|
165576
165583
|
// Add all nodes
|
|
165577
165584
|
[...depMap.keys()].forEach((name) => {
|
|
165578
|
-
const { name: pkgName, identifier: pkgVersion } = cli_parser_utils_1.extractNameAndIdentifier(name);
|
|
165585
|
+
const { name: pkgName, identifier: pkgVersion } = (0, cli_parser_utils_1.extractNameAndIdentifier)(name);
|
|
165579
165586
|
builder.addPkgNode({ name: pkgName, version: pkgVersion.split(':').pop() }, name);
|
|
165580
165587
|
});
|
|
165581
165588
|
// Deal with root special case first
|
|
@@ -165631,12 +165638,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
165631
165638
|
exports.parseYarnListOutput = void 0;
|
|
165632
165639
|
const cli_parser_utils_1 = __webpack_require__(80333);
|
|
165633
165640
|
const parseYarnListOutput = (rawYarnListOutput, manifestDependencies) => {
|
|
165634
|
-
const formattedYarnList = JSON.parse(rawYarnListOutput).data
|
|
165635
|
-
.trees;
|
|
165641
|
+
const formattedYarnList = JSON.parse(rawYarnListOutput).data.trees;
|
|
165636
165642
|
// Reference to all (resolved) dep names to help cleanup in next step
|
|
165637
165643
|
const names = formattedYarnList.map((tree) => tree.name);
|
|
165638
165644
|
const formattedListOutput = formattedYarnList.reduce((result, tree) => {
|
|
165639
|
-
const dependencies = tree.children.map((child) => cli_parser_utils_1.extractCorrectIdentifierBySemver(names, child.name));
|
|
165645
|
+
const dependencies = tree.children.map((child) => (0, cli_parser_utils_1.extractCorrectIdentifierBySemver)(names, child.name));
|
|
165640
165646
|
return result.set(tree.name, dependencies);
|
|
165641
165647
|
}, new Map());
|
|
165642
165648
|
const topLevelDeps = getTopLevelDependencies(formattedListOutput, manifestDependencies);
|
|
@@ -165647,7 +165653,7 @@ const getTopLevelDependencies = (formattedListOutput, topLevelDeps) => {
|
|
|
165647
165653
|
// This logic is to construct an item for the rootPkg because
|
|
165648
165654
|
// we are dealing with a flat map so far so can't tell
|
|
165649
165655
|
const names = [...formattedListOutput.keys()];
|
|
165650
|
-
return Object.entries(topLevelDeps).map(([name, version]) => cli_parser_utils_1.extractCorrectIdentifierBySemver(names, `${name}@${version}`));
|
|
165656
|
+
return Object.entries(topLevelDeps).map(([name, version]) => (0, cli_parser_utils_1.extractCorrectIdentifierBySemver)(names, `${name}@${version}`));
|
|
165651
165657
|
};
|
|
165652
165658
|
//# sourceMappingURL=yarn-list-parser.js.map
|
|
165653
165659
|
|
|
@@ -165661,11 +165667,496 @@ const getTopLevelDependencies = (formattedListOutput, topLevelDeps) => {
|
|
|
165661
165667
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165662
165668
|
exports.config = void 0;
|
|
165663
165669
|
const snyk_config_1 = __webpack_require__(8658);
|
|
165664
|
-
exports.config = snyk_config_1.loadConfig(__dirname + '../..');
|
|
165670
|
+
exports.config = (0, snyk_config_1.loadConfig)(__dirname + '../..');
|
|
165665
165671
|
//# sourceMappingURL=config.js.map
|
|
165666
165672
|
|
|
165667
165673
|
/***/ }),
|
|
165668
165674
|
|
|
165675
|
+
/***/ 61311:
|
|
165676
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165677
|
+
|
|
165678
|
+
"use strict";
|
|
165679
|
+
|
|
165680
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165681
|
+
exports.extractPkgsFromYarnLockV1 = exports.parseYarnLockV1WorkspaceProject = exports.buildDepGraphYarnLockV1WorkspaceCyclesPruned = exports.buildDepGraphYarnLockV1Simple = exports.buildDepGraphYarnLockV1SimpleCyclesPruned = exports.buildDepGraphYarnLockV1Workspace = exports.parseYarnLockV1Project = void 0;
|
|
165682
|
+
const yarn_lock_v1_1 = __webpack_require__(33248);
|
|
165683
|
+
Object.defineProperty(exports, "parseYarnLockV1Project", ({ enumerable: true, get: function () { return yarn_lock_v1_1.parseYarnLockV1Project; } }));
|
|
165684
|
+
Object.defineProperty(exports, "parseYarnLockV1WorkspaceProject", ({ enumerable: true, get: function () { return yarn_lock_v1_1.parseYarnLockV1WorkspaceProject; } }));
|
|
165685
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1SimpleCyclesPruned", ({ enumerable: true, get: function () { return yarn_lock_v1_1.buildDepGraphYarnLockV1SimpleCyclesPruned; } }));
|
|
165686
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1Simple", ({ enumerable: true, get: function () { return yarn_lock_v1_1.buildDepGraphYarnLockV1Simple; } }));
|
|
165687
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1WorkspaceCyclesPruned", ({ enumerable: true, get: function () { return yarn_lock_v1_1.buildDepGraphYarnLockV1WorkspaceCyclesPruned; } }));
|
|
165688
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1Workspace", ({ enumerable: true, get: function () { return yarn_lock_v1_1.buildDepGraphYarnLockV1Workspace; } }));
|
|
165689
|
+
Object.defineProperty(exports, "extractPkgsFromYarnLockV1", ({ enumerable: true, get: function () { return yarn_lock_v1_1.extractPkgsFromYarnLockV1; } }));
|
|
165690
|
+
//# sourceMappingURL=index.js.map
|
|
165691
|
+
|
|
165692
|
+
/***/ }),
|
|
165693
|
+
|
|
165694
|
+
/***/ 46200:
|
|
165695
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165696
|
+
|
|
165697
|
+
"use strict";
|
|
165698
|
+
|
|
165699
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165700
|
+
exports.getChildNodeWorkspace = exports.getChildNode = exports.parsePkgJson = exports.getGraphDependencies = exports.getTopLevelDeps = exports.addPkgNodeToGraph = void 0;
|
|
165701
|
+
const errors_1 = __webpack_require__(1706);
|
|
165702
|
+
const errors_2 = __webpack_require__(1706);
|
|
165703
|
+
const parsers_1 = __webpack_require__(75873);
|
|
165704
|
+
const addPkgNodeToGraph = (depGraphBuilder, node, options) => {
|
|
165705
|
+
return depGraphBuilder.addPkgNode({ name: node.name, version: node.version }, node.id, {
|
|
165706
|
+
labels: Object.assign(Object.assign(Object.assign({ scope: node.isDev ? 'dev' : 'prod' }, (options.isCyclic && { pruned: 'cyclic' })), (options.isWorkspacePkg && { pruned: 'true' })), (node.missingLockFileEntry && { missingLockFileEntry: 'true' })),
|
|
165707
|
+
});
|
|
165708
|
+
};
|
|
165709
|
+
exports.addPkgNodeToGraph = addPkgNodeToGraph;
|
|
165710
|
+
/**
|
|
165711
|
+
* Get top level dependencies from the given package json object which is parsed from a package.json file.
|
|
165712
|
+
* This includes both prod dependencies and dev dependencies supposing includeDevDeps is supported.
|
|
165713
|
+
*/
|
|
165714
|
+
const getTopLevelDeps = (pkgJson, options) => {
|
|
165715
|
+
const prodDeps = (0, exports.getGraphDependencies)(pkgJson.dependencies || {}, false);
|
|
165716
|
+
const devDeps = options.includeDevDeps
|
|
165717
|
+
? (0, exports.getGraphDependencies)(pkgJson.devDependencies || {}, true)
|
|
165718
|
+
: {};
|
|
165719
|
+
return Object.assign(Object.assign({}, prodDeps), devDeps);
|
|
165720
|
+
};
|
|
165721
|
+
exports.getTopLevelDeps = getTopLevelDeps;
|
|
165722
|
+
/**
|
|
165723
|
+
* Converts dependencies parsed from the a lock file to a dependencies object required by the graph.
|
|
165724
|
+
* For example, { 'mime-db': '~1.12.0' } will be converted to { 'mime-db': { version: '~1.12.0', isDev: true/false } }.
|
|
165725
|
+
*/
|
|
165726
|
+
const getGraphDependencies = (dependencies, isDev) => {
|
|
165727
|
+
return Object.entries(dependencies).reduce((acc, [name, semver]) => {
|
|
165728
|
+
acc[name] = { version: semver, isDev: isDev };
|
|
165729
|
+
return acc;
|
|
165730
|
+
}, {});
|
|
165731
|
+
};
|
|
165732
|
+
exports.getGraphDependencies = getGraphDependencies;
|
|
165733
|
+
function parsePkgJson(pkgJsonContent) {
|
|
165734
|
+
try {
|
|
165735
|
+
const parsedPkgJson = JSON.parse(pkgJsonContent);
|
|
165736
|
+
if (!parsedPkgJson.name) {
|
|
165737
|
+
parsedPkgJson.name = 'package.json';
|
|
165738
|
+
}
|
|
165739
|
+
return parsedPkgJson;
|
|
165740
|
+
}
|
|
165741
|
+
catch (e) {
|
|
165742
|
+
throw new errors_1.InvalidUserInputError('package.json parsing failed with error ' + e.message);
|
|
165743
|
+
}
|
|
165744
|
+
}
|
|
165745
|
+
exports.parsePkgJson = parsePkgJson;
|
|
165746
|
+
const getChildNode = (name, depInfo, pkgs, strictOutOfSync, includeOptionalDeps) => {
|
|
165747
|
+
const childNodeKey = `${name}@${depInfo.version}`;
|
|
165748
|
+
let childNode;
|
|
165749
|
+
if (!pkgs[childNodeKey]) {
|
|
165750
|
+
if (strictOutOfSync && !/^file:/.test(depInfo.version)) {
|
|
165751
|
+
throw new errors_2.OutOfSyncError(childNodeKey, parsers_1.LockfileType.yarn);
|
|
165752
|
+
}
|
|
165753
|
+
else {
|
|
165754
|
+
childNode = {
|
|
165755
|
+
id: childNodeKey,
|
|
165756
|
+
name: name,
|
|
165757
|
+
version: depInfo.version,
|
|
165758
|
+
dependencies: {},
|
|
165759
|
+
isDev: depInfo.isDev,
|
|
165760
|
+
missingLockFileEntry: true,
|
|
165761
|
+
};
|
|
165762
|
+
}
|
|
165763
|
+
}
|
|
165764
|
+
else {
|
|
165765
|
+
const depData = pkgs[childNodeKey];
|
|
165766
|
+
const dependencies = (0, exports.getGraphDependencies)(depData.dependencies || {}, depInfo.isDev);
|
|
165767
|
+
const optionalDependencies = includeOptionalDeps
|
|
165768
|
+
? (0, exports.getGraphDependencies)(depData.optionalDependencies || {}, depInfo.isDev)
|
|
165769
|
+
: {};
|
|
165770
|
+
childNode = {
|
|
165771
|
+
id: `${name}@${depData.version}`,
|
|
165772
|
+
name: name,
|
|
165773
|
+
version: depData.version,
|
|
165774
|
+
dependencies: Object.assign(Object.assign({}, dependencies), optionalDependencies),
|
|
165775
|
+
isDev: depInfo.isDev,
|
|
165776
|
+
};
|
|
165777
|
+
}
|
|
165778
|
+
return childNode;
|
|
165779
|
+
};
|
|
165780
|
+
exports.getChildNode = getChildNode;
|
|
165781
|
+
const getChildNodeWorkspace = (name, depInfo, workspacePkgNameToVersion, pkgs, strictOutOfSync, includeOptionalDeps) => {
|
|
165782
|
+
let childNode;
|
|
165783
|
+
if (workspacePkgNameToVersion[name]) {
|
|
165784
|
+
const version = workspacePkgNameToVersion[name];
|
|
165785
|
+
// This is just to mimic old behavior where when StrictOutOfSync is turned on,
|
|
165786
|
+
// any cross referencing between workspace packages will lead to a throw
|
|
165787
|
+
if (strictOutOfSync) {
|
|
165788
|
+
throw new errors_2.OutOfSyncError(`${name}@${version}`, parsers_1.LockfileType.yarn);
|
|
165789
|
+
}
|
|
165790
|
+
childNode = {
|
|
165791
|
+
id: `${name}@${version}`,
|
|
165792
|
+
name: name,
|
|
165793
|
+
version: version,
|
|
165794
|
+
dependencies: {},
|
|
165795
|
+
isDev: depInfo.isDev,
|
|
165796
|
+
};
|
|
165797
|
+
}
|
|
165798
|
+
else {
|
|
165799
|
+
childNode = (0, exports.getChildNode)(name, depInfo, pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165800
|
+
}
|
|
165801
|
+
return childNode;
|
|
165802
|
+
};
|
|
165803
|
+
exports.getChildNodeWorkspace = getChildNodeWorkspace;
|
|
165804
|
+
//# sourceMappingURL=util.js.map
|
|
165805
|
+
|
|
165806
|
+
/***/ }),
|
|
165807
|
+
|
|
165808
|
+
/***/ 6431:
|
|
165809
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165810
|
+
|
|
165811
|
+
"use strict";
|
|
165812
|
+
|
|
165813
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165814
|
+
exports.buildDepGraphYarnLockV1SimpleCyclesPruned = void 0;
|
|
165815
|
+
const dep_graph_1 = __webpack_require__(53789);
|
|
165816
|
+
const util_1 = __webpack_require__(46200);
|
|
165817
|
+
var Color;
|
|
165818
|
+
(function (Color) {
|
|
165819
|
+
Color[Color["GRAY"] = 0] = "GRAY";
|
|
165820
|
+
Color[Color["BLACK"] = 1] = "BLACK";
|
|
165821
|
+
})(Color || (Color = {}));
|
|
165822
|
+
const buildDepGraphYarnLockV1SimpleCyclesPruned = (extractedYarnLockV1Pkgs, pkgJson, options) => {
|
|
165823
|
+
const { includeDevDeps, strictOutOfSync, includeOptionalDeps } = options;
|
|
165824
|
+
const depGraphBuilder = new dep_graph_1.DepGraphBuilder({ name: 'yarn' }, { name: pkgJson.name, version: pkgJson.version });
|
|
165825
|
+
const colorMap = {};
|
|
165826
|
+
const topLevelDeps = (0, util_1.getTopLevelDeps)(pkgJson, { includeDevDeps });
|
|
165827
|
+
const rootNode = {
|
|
165828
|
+
id: 'root-node',
|
|
165829
|
+
name: pkgJson.name,
|
|
165830
|
+
version: pkgJson.version,
|
|
165831
|
+
dependencies: topLevelDeps,
|
|
165832
|
+
isDev: false,
|
|
165833
|
+
};
|
|
165834
|
+
dfsVisit(depGraphBuilder, rootNode, colorMap, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165835
|
+
return depGraphBuilder.build();
|
|
165836
|
+
};
|
|
165837
|
+
exports.buildDepGraphYarnLockV1SimpleCyclesPruned = buildDepGraphYarnLockV1SimpleCyclesPruned;
|
|
165838
|
+
/**
|
|
165839
|
+
* Use DFS to add all nodes and edges to the depGraphBuilder and prune cyclic nodes.
|
|
165840
|
+
* The colorMap keep track of the state of node during traversal.
|
|
165841
|
+
* - If a node doesn't exist in the map, it means it hasn't been visited.
|
|
165842
|
+
* - If a node is GRAY, it means it has already been discovered but its subtree hasn't been fully traversed.
|
|
165843
|
+
* - If a node is BLACK, it means its subtree has already been fully traversed.
|
|
165844
|
+
* - When first exploring an edge, if it points to a GRAY node, a cycle is found and the GRAY node is pruned.
|
|
165845
|
+
* - A pruned node has id `${originalId}|1`
|
|
165846
|
+
*/
|
|
165847
|
+
const dfsVisit = (depGraphBuilder, node, colorMap, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps) => {
|
|
165848
|
+
colorMap[node.id] = Color.GRAY;
|
|
165849
|
+
for (const [name, depInfo] of Object.entries(node.dependencies || {})) {
|
|
165850
|
+
const childNode = (0, util_1.getChildNode)(name, depInfo, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165851
|
+
if (!colorMap.hasOwnProperty(childNode.id)) {
|
|
165852
|
+
(0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, {});
|
|
165853
|
+
dfsVisit(depGraphBuilder, childNode, colorMap, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165854
|
+
}
|
|
165855
|
+
else if (colorMap[childNode.id] === Color.GRAY) {
|
|
165856
|
+
// cycle detected
|
|
165857
|
+
childNode.id = `${childNode.id}|1`;
|
|
165858
|
+
(0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, { isCyclic: true });
|
|
165859
|
+
}
|
|
165860
|
+
depGraphBuilder.connectDep(node.id, childNode.id);
|
|
165861
|
+
}
|
|
165862
|
+
colorMap[node.id] = Color.BLACK;
|
|
165863
|
+
};
|
|
165864
|
+
//# sourceMappingURL=build-depgraph-simple-pruned.js.map
|
|
165865
|
+
|
|
165866
|
+
/***/ }),
|
|
165867
|
+
|
|
165868
|
+
/***/ 91379:
|
|
165869
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165870
|
+
|
|
165871
|
+
"use strict";
|
|
165872
|
+
|
|
165873
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165874
|
+
exports.buildDepGraphYarnLockV1Simple = void 0;
|
|
165875
|
+
const dep_graph_1 = __webpack_require__(53789);
|
|
165876
|
+
const util_1 = __webpack_require__(46200);
|
|
165877
|
+
const buildDepGraphYarnLockV1Simple = (extractedYarnLockV1Pkgs, pkgJson, options) => {
|
|
165878
|
+
const { includeDevDeps, strictOutOfSync, includeOptionalDeps } = options;
|
|
165879
|
+
const depGraphBuilder = new dep_graph_1.DepGraphBuilder({ name: 'yarn' }, { name: pkgJson.name, version: pkgJson.version });
|
|
165880
|
+
const visitedMap = new Set();
|
|
165881
|
+
const topLevelDeps = (0, util_1.getTopLevelDeps)(pkgJson, { includeDevDeps });
|
|
165882
|
+
const rootNode = {
|
|
165883
|
+
id: 'root-node',
|
|
165884
|
+
name: pkgJson.name,
|
|
165885
|
+
version: pkgJson.version,
|
|
165886
|
+
dependencies: topLevelDeps,
|
|
165887
|
+
isDev: false,
|
|
165888
|
+
};
|
|
165889
|
+
dfsVisit(depGraphBuilder, rootNode, visitedMap, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165890
|
+
return depGraphBuilder.build();
|
|
165891
|
+
};
|
|
165892
|
+
exports.buildDepGraphYarnLockV1Simple = buildDepGraphYarnLockV1Simple;
|
|
165893
|
+
/**
|
|
165894
|
+
* Use DFS to add all nodes and edges to the depGraphBuilder and prune cyclic nodes.
|
|
165895
|
+
* The visitedMap keep track of which nodes have already been discovered during traversal.
|
|
165896
|
+
* - If a node doesn't exist in the map, it means it hasn't been visited.
|
|
165897
|
+
* - If a node is already visited, simply connect the new node with this node.
|
|
165898
|
+
*/
|
|
165899
|
+
const dfsVisit = (depGraphBuilder, node, visitedMap, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps) => {
|
|
165900
|
+
visitedMap.add(node.id);
|
|
165901
|
+
for (const [name, depInfo] of Object.entries(node.dependencies || {})) {
|
|
165902
|
+
const childNode = (0, util_1.getChildNode)(name, depInfo, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165903
|
+
if (!visitedMap.has(childNode.id)) {
|
|
165904
|
+
(0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, {});
|
|
165905
|
+
dfsVisit(depGraphBuilder, childNode, visitedMap, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165906
|
+
}
|
|
165907
|
+
depGraphBuilder.connectDep(node.id, childNode.id);
|
|
165908
|
+
}
|
|
165909
|
+
};
|
|
165910
|
+
//# sourceMappingURL=build-depgraph-simple.js.map
|
|
165911
|
+
|
|
165912
|
+
/***/ }),
|
|
165913
|
+
|
|
165914
|
+
/***/ 92602:
|
|
165915
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165916
|
+
|
|
165917
|
+
"use strict";
|
|
165918
|
+
|
|
165919
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165920
|
+
exports.buildDepGraphYarnLockV1WorkspaceCyclesPruned = void 0;
|
|
165921
|
+
const dep_graph_1 = __webpack_require__(53789);
|
|
165922
|
+
const util_1 = __webpack_require__(46200);
|
|
165923
|
+
var Color;
|
|
165924
|
+
(function (Color) {
|
|
165925
|
+
Color[Color["GRAY"] = 0] = "GRAY";
|
|
165926
|
+
Color[Color["BLACK"] = 1] = "BLACK";
|
|
165927
|
+
})(Color || (Color = {}));
|
|
165928
|
+
// Parse a single workspace package using yarn.lock v1
|
|
165929
|
+
// workspaces feature
|
|
165930
|
+
const buildDepGraphYarnLockV1WorkspaceCyclesPruned = (extractedYarnLockV1Pkgs, pkgJson, workspacePkgNameToVersion, options) => {
|
|
165931
|
+
const { includeDevDeps, strictOutOfSync, includeOptionalDeps } = options;
|
|
165932
|
+
const depGraphBuilder = new dep_graph_1.DepGraphBuilder({ name: 'yarn' }, { name: pkgJson.name, version: pkgJson.version });
|
|
165933
|
+
const colorMap = {};
|
|
165934
|
+
const topLevelDeps = (0, util_1.getTopLevelDeps)(pkgJson, { includeDevDeps });
|
|
165935
|
+
const rootNode = {
|
|
165936
|
+
id: 'root-node',
|
|
165937
|
+
name: pkgJson.name,
|
|
165938
|
+
version: pkgJson.version,
|
|
165939
|
+
dependencies: topLevelDeps,
|
|
165940
|
+
isDev: false,
|
|
165941
|
+
};
|
|
165942
|
+
dfsVisit(depGraphBuilder, rootNode, colorMap, extractedYarnLockV1Pkgs, workspacePkgNameToVersion, strictOutOfSync, includeOptionalDeps);
|
|
165943
|
+
return depGraphBuilder.build();
|
|
165944
|
+
};
|
|
165945
|
+
exports.buildDepGraphYarnLockV1WorkspaceCyclesPruned = buildDepGraphYarnLockV1WorkspaceCyclesPruned;
|
|
165946
|
+
/**
|
|
165947
|
+
* Use DFS to add all nodes and edges to the depGraphBuilder and prune cyclic nodes.
|
|
165948
|
+
* The colorMap keep track of the state of node during traversal.
|
|
165949
|
+
* - If a node doesn't exist in the map, it means it hasn't been visited.
|
|
165950
|
+
* - If a node is GRAY, it means it has already been discovered but its subtree hasn't been fully traversed.
|
|
165951
|
+
* - If a node is BLACK, it means its subtree has already been fully traversed.
|
|
165952
|
+
* - When first exploring an edge, if it points to a GRAY node, a cycle is found and the GRAY node is pruned.
|
|
165953
|
+
* - A pruned node has id `${originalId}|1`
|
|
165954
|
+
* When coming across another workspace package as child node, simply add the node and edge to the graph and mark it as BLACK.
|
|
165955
|
+
*/
|
|
165956
|
+
const dfsVisit = (depGraphBuilder, node, colorMap, extractedYarnLockV1Pkgs, workspacePkgNameToVersion, strictOutOfSync, includeOptionalDeps) => {
|
|
165957
|
+
colorMap[node.id] = Color.GRAY;
|
|
165958
|
+
for (const [name, depInfo] of Object.entries(node.dependencies || {})) {
|
|
165959
|
+
const isWorkspacePkg = !!workspacePkgNameToVersion[name];
|
|
165960
|
+
const childNode = (0, util_1.getChildNodeWorkspace)(name, depInfo, workspacePkgNameToVersion, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
165961
|
+
if (!colorMap.hasOwnProperty(childNode.id)) {
|
|
165962
|
+
(0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, {
|
|
165963
|
+
isCyclic: false,
|
|
165964
|
+
isWorkspacePkg,
|
|
165965
|
+
});
|
|
165966
|
+
if (!isWorkspacePkg) {
|
|
165967
|
+
dfsVisit(depGraphBuilder, childNode, colorMap, extractedYarnLockV1Pkgs, workspacePkgNameToVersion, strictOutOfSync, includeOptionalDeps);
|
|
165968
|
+
}
|
|
165969
|
+
else {
|
|
165970
|
+
colorMap[childNode.id] = Color.BLACK;
|
|
165971
|
+
}
|
|
165972
|
+
}
|
|
165973
|
+
else if (colorMap[childNode.id] === Color.GRAY) {
|
|
165974
|
+
// cycle detected
|
|
165975
|
+
childNode.id = `${childNode.id}|1`;
|
|
165976
|
+
(0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, {
|
|
165977
|
+
isCyclic: true,
|
|
165978
|
+
isWorkspacePkg,
|
|
165979
|
+
});
|
|
165980
|
+
}
|
|
165981
|
+
depGraphBuilder.connectDep(node.id, childNode.id);
|
|
165982
|
+
}
|
|
165983
|
+
colorMap[node.id] = Color.BLACK;
|
|
165984
|
+
};
|
|
165985
|
+
//# sourceMappingURL=build-depgraph-workspace-package-pruned.js.map
|
|
165986
|
+
|
|
165987
|
+
/***/ }),
|
|
165988
|
+
|
|
165989
|
+
/***/ 10860:
|
|
165990
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165991
|
+
|
|
165992
|
+
"use strict";
|
|
165993
|
+
|
|
165994
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165995
|
+
exports.buildDepGraphYarnLockV1Workspace = void 0;
|
|
165996
|
+
const dep_graph_1 = __webpack_require__(53789);
|
|
165997
|
+
const util_1 = __webpack_require__(46200);
|
|
165998
|
+
const buildDepGraphYarnLockV1Workspace = (extractedYarnLockV1Pkgs, pkgJson, workspacePkgNameToVersion, options) => {
|
|
165999
|
+
const { includeDevDeps, strictOutOfSync, includeOptionalDeps } = options;
|
|
166000
|
+
const depGraphBuilder = new dep_graph_1.DepGraphBuilder({ name: 'yarn' }, { name: pkgJson.name, version: pkgJson.version });
|
|
166001
|
+
const visitedMap = new Set();
|
|
166002
|
+
const topLevelDeps = (0, util_1.getTopLevelDeps)(pkgJson, { includeDevDeps });
|
|
166003
|
+
const rootNode = {
|
|
166004
|
+
id: 'root-node',
|
|
166005
|
+
name: pkgJson.name,
|
|
166006
|
+
version: pkgJson.version,
|
|
166007
|
+
dependencies: topLevelDeps,
|
|
166008
|
+
isDev: false,
|
|
166009
|
+
};
|
|
166010
|
+
dfsVisit(depGraphBuilder, rootNode, visitedMap, extractedYarnLockV1Pkgs, workspacePkgNameToVersion, strictOutOfSync, includeOptionalDeps);
|
|
166011
|
+
return depGraphBuilder.build();
|
|
166012
|
+
};
|
|
166013
|
+
exports.buildDepGraphYarnLockV1Workspace = buildDepGraphYarnLockV1Workspace;
|
|
166014
|
+
/**
|
|
166015
|
+
* Use DFS to add all nodes and edges to the depGraphBuilder and prune cyclic nodes.
|
|
166016
|
+
* The colorMap keep track of the state of node during traversal.
|
|
166017
|
+
* - If a node doesn't exist in the map, it means it hasn't been visited.
|
|
166018
|
+
* - If a node is GRAY, it means it has already been discovered but its subtree hasn't been fully traversed.
|
|
166019
|
+
* - If a node is BLACK, it means its subtree has already been fully traversed.
|
|
166020
|
+
* - When first exploring an edge, if it points to a GRAY node, a cycle is found and the GRAY node is pruned.
|
|
166021
|
+
* - A pruned node has id `${originalId}|1`
|
|
166022
|
+
* When coming across another workspace package as child node, simply add the node and edge to the graph and mark it as BLACK.
|
|
166023
|
+
*/
|
|
166024
|
+
const dfsVisit = (depGraphBuilder, node, visitedMap, extractedYarnLockV1Pkgs, workspacePkgNameToVersion, strictOutOfSync, includeOptionalDeps) => {
|
|
166025
|
+
visitedMap.add(node.id);
|
|
166026
|
+
for (const [name, depInfo] of Object.entries(node.dependencies || {})) {
|
|
166027
|
+
const isWorkspacePkg = !!workspacePkgNameToVersion[name];
|
|
166028
|
+
const childNode = (0, util_1.getChildNodeWorkspace)(name, depInfo, workspacePkgNameToVersion, extractedYarnLockV1Pkgs, strictOutOfSync, includeOptionalDeps);
|
|
166029
|
+
if (!visitedMap.has(childNode.id)) {
|
|
166030
|
+
(0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, {
|
|
166031
|
+
isCyclic: false,
|
|
166032
|
+
isWorkspacePkg,
|
|
166033
|
+
});
|
|
166034
|
+
if (!isWorkspacePkg) {
|
|
166035
|
+
dfsVisit(depGraphBuilder, childNode, visitedMap, extractedYarnLockV1Pkgs, workspacePkgNameToVersion, strictOutOfSync, includeOptionalDeps);
|
|
166036
|
+
}
|
|
166037
|
+
}
|
|
166038
|
+
depGraphBuilder.connectDep(node.id, childNode.id);
|
|
166039
|
+
}
|
|
166040
|
+
};
|
|
166041
|
+
//# sourceMappingURL=build-depgraph-workspace-package.js.map
|
|
166042
|
+
|
|
166043
|
+
/***/ }),
|
|
166044
|
+
|
|
166045
|
+
/***/ 86631:
|
|
166046
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
166047
|
+
|
|
166048
|
+
"use strict";
|
|
166049
|
+
|
|
166050
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
166051
|
+
exports.extractPkgsFromYarnLockV1 = void 0;
|
|
166052
|
+
const yarnLockfileParser = __webpack_require__(7615);
|
|
166053
|
+
const extractPkgsFromYarnLockV1 = (yarnLockContent) => {
|
|
166054
|
+
return yarnLockfileParser.parse(yarnLockContent).object;
|
|
166055
|
+
};
|
|
166056
|
+
exports.extractPkgsFromYarnLockV1 = extractPkgsFromYarnLockV1;
|
|
166057
|
+
//# sourceMappingURL=extract-yarnlock-v1-pkgs.js.map
|
|
166058
|
+
|
|
166059
|
+
/***/ }),
|
|
166060
|
+
|
|
166061
|
+
/***/ 33248:
|
|
166062
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
166063
|
+
|
|
166064
|
+
"use strict";
|
|
166065
|
+
|
|
166066
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
166067
|
+
exports.buildDepGraphYarnLockV1Simple = exports.buildDepGraphYarnLockV1SimpleCyclesPruned = exports.buildDepGraphYarnLockV1Workspace = exports.buildDepGraphYarnLockV1WorkspaceCyclesPruned = exports.extractPkgsFromYarnLockV1 = exports.parseYarnLockV1Project = exports.parseYarnLockV1WorkspaceProject = void 0;
|
|
166068
|
+
const build_depgraph_simple_pruned_1 = __webpack_require__(6431);
|
|
166069
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1SimpleCyclesPruned", ({ enumerable: true, get: function () { return build_depgraph_simple_pruned_1.buildDepGraphYarnLockV1SimpleCyclesPruned; } }));
|
|
166070
|
+
const build_depgraph_simple_1 = __webpack_require__(91379);
|
|
166071
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1Simple", ({ enumerable: true, get: function () { return build_depgraph_simple_1.buildDepGraphYarnLockV1Simple; } }));
|
|
166072
|
+
const build_depgraph_workspace_package_pruned_1 = __webpack_require__(92602);
|
|
166073
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1WorkspaceCyclesPruned", ({ enumerable: true, get: function () { return build_depgraph_workspace_package_pruned_1.buildDepGraphYarnLockV1WorkspaceCyclesPruned; } }));
|
|
166074
|
+
const build_depgraph_workspace_package_1 = __webpack_require__(10860);
|
|
166075
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1Workspace", ({ enumerable: true, get: function () { return build_depgraph_workspace_package_1.buildDepGraphYarnLockV1Workspace; } }));
|
|
166076
|
+
const extract_yarnlock_v1_pkgs_1 = __webpack_require__(86631);
|
|
166077
|
+
Object.defineProperty(exports, "extractPkgsFromYarnLockV1", ({ enumerable: true, get: function () { return extract_yarnlock_v1_pkgs_1.extractPkgsFromYarnLockV1; } }));
|
|
166078
|
+
const simple_1 = __webpack_require__(98216);
|
|
166079
|
+
Object.defineProperty(exports, "parseYarnLockV1Project", ({ enumerable: true, get: function () { return simple_1.parseYarnLockV1Project; } }));
|
|
166080
|
+
const workspaces_1 = __webpack_require__(53483);
|
|
166081
|
+
Object.defineProperty(exports, "parseYarnLockV1WorkspaceProject", ({ enumerable: true, get: function () { return workspaces_1.parseYarnLockV1WorkspaceProject; } }));
|
|
166082
|
+
//# sourceMappingURL=index.js.map
|
|
166083
|
+
|
|
166084
|
+
/***/ }),
|
|
166085
|
+
|
|
166086
|
+
/***/ 98216:
|
|
166087
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
166088
|
+
|
|
166089
|
+
"use strict";
|
|
166090
|
+
|
|
166091
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
166092
|
+
exports.parseYarnLockV1Project = void 0;
|
|
166093
|
+
const _1 = __webpack_require__(33248);
|
|
166094
|
+
const util_1 = __webpack_require__(46200);
|
|
166095
|
+
const build_depgraph_simple_pruned_1 = __webpack_require__(6431);
|
|
166096
|
+
const extract_yarnlock_v1_pkgs_1 = __webpack_require__(86631);
|
|
166097
|
+
const parseYarnLockV1Project = async (pkgJsonContent, yarnLockContent, options) => {
|
|
166098
|
+
const { includeDevDeps, includeOptionalDeps, pruneCycles, strictOutOfSync } = options;
|
|
166099
|
+
const pkgs = (0, extract_yarnlock_v1_pkgs_1.extractPkgsFromYarnLockV1)(yarnLockContent);
|
|
166100
|
+
const pkgJson = (0, util_1.parsePkgJson)(pkgJsonContent);
|
|
166101
|
+
const depGraph = pruneCycles
|
|
166102
|
+
? (0, build_depgraph_simple_pruned_1.buildDepGraphYarnLockV1SimpleCyclesPruned)(pkgs, pkgJson, {
|
|
166103
|
+
includeDevDeps,
|
|
166104
|
+
strictOutOfSync,
|
|
166105
|
+
includeOptionalDeps,
|
|
166106
|
+
})
|
|
166107
|
+
: (0, _1.buildDepGraphYarnLockV1Simple)(pkgs, pkgJson, {
|
|
166108
|
+
includeDevDeps,
|
|
166109
|
+
strictOutOfSync,
|
|
166110
|
+
includeOptionalDeps,
|
|
166111
|
+
});
|
|
166112
|
+
return depGraph;
|
|
166113
|
+
};
|
|
166114
|
+
exports.parseYarnLockV1Project = parseYarnLockV1Project;
|
|
166115
|
+
//# sourceMappingURL=simple.js.map
|
|
166116
|
+
|
|
166117
|
+
/***/ }),
|
|
166118
|
+
|
|
166119
|
+
/***/ 53483:
|
|
166120
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
166121
|
+
|
|
166122
|
+
"use strict";
|
|
166123
|
+
|
|
166124
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
166125
|
+
exports.parseYarnLockV1WorkspaceProject = void 0;
|
|
166126
|
+
const build_depgraph_workspace_package_pruned_1 = __webpack_require__(92602);
|
|
166127
|
+
const build_depgraph_workspace_package_1 = __webpack_require__(10860);
|
|
166128
|
+
const extract_yarnlock_v1_pkgs_1 = __webpack_require__(86631);
|
|
166129
|
+
const util_1 = __webpack_require__(46200);
|
|
166130
|
+
const parseYarnLockV1WorkspaceProject = async (yarnLockContent, workspacePackagesPkgJsons, options) => {
|
|
166131
|
+
const { includeDevDeps, includeOptionalDeps, pruneCycles, strictOutOfSync } = options;
|
|
166132
|
+
const extractedYarnLockV1Pkgs = (0, extract_yarnlock_v1_pkgs_1.extractPkgsFromYarnLockV1)(yarnLockContent);
|
|
166133
|
+
// Parse all package.json files and also extract names cross referencing later
|
|
166134
|
+
const workspacePkgNameToVersion = {};
|
|
166135
|
+
const parsedWorkspacePkgJsons = workspacePackagesPkgJsons.map((wsPkgJsonContent) => {
|
|
166136
|
+
const parsedPkgJson = (0, util_1.parsePkgJson)(wsPkgJsonContent);
|
|
166137
|
+
workspacePkgNameToVersion[parsedPkgJson.name] = parsedPkgJson.version;
|
|
166138
|
+
return parsedPkgJson;
|
|
166139
|
+
});
|
|
166140
|
+
const depGraphs = parsedWorkspacePkgJsons.map((parsedPkgJson) => {
|
|
166141
|
+
return pruneCycles
|
|
166142
|
+
? (0, build_depgraph_workspace_package_pruned_1.buildDepGraphYarnLockV1WorkspaceCyclesPruned)(extractedYarnLockV1Pkgs, parsedPkgJson, workspacePkgNameToVersion, {
|
|
166143
|
+
includeDevDeps,
|
|
166144
|
+
strictOutOfSync,
|
|
166145
|
+
includeOptionalDeps,
|
|
166146
|
+
})
|
|
166147
|
+
: (0, build_depgraph_workspace_package_1.buildDepGraphYarnLockV1Workspace)(extractedYarnLockV1Pkgs, parsedPkgJson, workspacePkgNameToVersion, {
|
|
166148
|
+
includeDevDeps,
|
|
166149
|
+
strictOutOfSync,
|
|
166150
|
+
includeOptionalDeps,
|
|
166151
|
+
});
|
|
166152
|
+
});
|
|
166153
|
+
return depGraphs;
|
|
166154
|
+
};
|
|
166155
|
+
exports.parseYarnLockV1WorkspaceProject = parseYarnLockV1WorkspaceProject;
|
|
166156
|
+
//# sourceMappingURL=workspaces.js.map
|
|
166157
|
+
|
|
166158
|
+
/***/ }),
|
|
166159
|
+
|
|
165669
166160
|
/***/ 1706:
|
|
165670
166161
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
165671
166162
|
|
|
@@ -165810,7 +166301,7 @@ exports.UnsupportedRuntimeError = UnsupportedRuntimeError;
|
|
|
165810
166301
|
"use strict";
|
|
165811
166302
|
|
|
165812
166303
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
165813
|
-
exports.getYarnLockfileType = exports.OutOfSyncError = exports.InvalidUserInputError = exports.UnsupportedRuntimeError = exports.LockfileType = exports.Scope = exports.getYarnWorkspaces = exports.getYarnWorkspacesFromFiles = exports.buildDepGraphFromCliOutput = exports.buildDepTreeFromFiles = exports.buildDepTree = void 0;
|
|
166304
|
+
exports.getYarnLockfileType = exports.buildDepGraphYarnLockV1Workspace = exports.buildDepGraphYarnLockV1WorkspaceCyclesPruned = exports.buildDepGraphYarnLockV1Simple = exports.buildDepGraphYarnLockV1SimpleCyclesPruned = exports.parseYarnLockV1WorkspaceProject = exports.parseYarnLockV1Project = exports.extractPkgsFromYarnLockV1 = exports.OutOfSyncError = exports.InvalidUserInputError = exports.UnsupportedRuntimeError = exports.LockfileType = exports.Scope = exports.getYarnWorkspaces = exports.getYarnWorkspacesFromFiles = exports.buildDepGraphFromCliOutput = exports.buildDepTreeFromFiles = exports.buildDepTree = void 0;
|
|
165814
166305
|
const fs = __webpack_require__(35747);
|
|
165815
166306
|
const path = __webpack_require__(85622);
|
|
165816
166307
|
const parsers_1 = __webpack_require__(75873);
|
|
@@ -165826,6 +166317,17 @@ Object.defineProperty(exports, "InvalidUserInputError", ({ enumerable: true, get
|
|
|
165826
166317
|
Object.defineProperty(exports, "OutOfSyncError", ({ enumerable: true, get: function () { return errors_1.OutOfSyncError; } }));
|
|
165827
166318
|
const cli_parsers_1 = __webpack_require__(27819);
|
|
165828
166319
|
Object.defineProperty(exports, "buildDepGraphFromCliOutput", ({ enumerable: true, get: function () { return cli_parsers_1.buildDepGraphFromCliOutput; } }));
|
|
166320
|
+
// New Parser Functions *************
|
|
166321
|
+
// **********************************
|
|
166322
|
+
const dep_graph_builders_1 = __webpack_require__(61311);
|
|
166323
|
+
Object.defineProperty(exports, "extractPkgsFromYarnLockV1", ({ enumerable: true, get: function () { return dep_graph_builders_1.extractPkgsFromYarnLockV1; } }));
|
|
166324
|
+
Object.defineProperty(exports, "parseYarnLockV1Project", ({ enumerable: true, get: function () { return dep_graph_builders_1.parseYarnLockV1Project; } }));
|
|
166325
|
+
Object.defineProperty(exports, "parseYarnLockV1WorkspaceProject", ({ enumerable: true, get: function () { return dep_graph_builders_1.parseYarnLockV1WorkspaceProject; } }));
|
|
166326
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1SimpleCyclesPruned", ({ enumerable: true, get: function () { return dep_graph_builders_1.buildDepGraphYarnLockV1SimpleCyclesPruned; } }));
|
|
166327
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1Simple", ({ enumerable: true, get: function () { return dep_graph_builders_1.buildDepGraphYarnLockV1Simple; } }));
|
|
166328
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1WorkspaceCyclesPruned", ({ enumerable: true, get: function () { return dep_graph_builders_1.buildDepGraphYarnLockV1WorkspaceCyclesPruned; } }));
|
|
166329
|
+
Object.defineProperty(exports, "buildDepGraphYarnLockV1Workspace", ({ enumerable: true, get: function () { return dep_graph_builders_1.buildDepGraphYarnLockV1Workspace; } }));
|
|
166330
|
+
// **********************************
|
|
165829
166331
|
async function buildDepTree(manifestFileContents, lockFileContents, includeDev = false, lockfileType, strictOutOfSync = true, defaultManifestFileName = 'package.json') {
|
|
165830
166332
|
if (!lockfileType) {
|
|
165831
166333
|
lockfileType = parsers_1.LockfileType.npm;
|
|
@@ -165849,7 +166351,7 @@ async function buildDepTree(manifestFileContents, lockFileContents, includeDev =
|
|
|
165849
166351
|
`${lockfileType} provided. Only 'npm' or 'yarn' is currently ` +
|
|
165850
166352
|
'supported.');
|
|
165851
166353
|
}
|
|
165852
|
-
const manifestFile = parsers_1.parseManifestFile(manifestFileContents);
|
|
166354
|
+
const manifestFile = (0, parsers_1.parseManifestFile)(manifestFileContents);
|
|
165853
166355
|
if (!manifestFile.name) {
|
|
165854
166356
|
manifestFile.name = path.isAbsolute(defaultManifestFileName)
|
|
165855
166357
|
? path.basename(defaultManifestFileName)
|
|
@@ -165898,7 +166400,7 @@ function getYarnWorkspacesFromFiles(root, manifestFilePath) {
|
|
|
165898
166400
|
`location: ${manifestFileFullPath}`);
|
|
165899
166401
|
}
|
|
165900
166402
|
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
165901
|
-
return parsers_1.getYarnWorkspaces(manifestFileContents);
|
|
166403
|
+
return (0, parsers_1.getYarnWorkspaces)(manifestFileContents);
|
|
165902
166404
|
}
|
|
165903
166405
|
exports.getYarnWorkspacesFromFiles = getYarnWorkspacesFromFiles;
|
|
165904
166406
|
function getYarnLockfileType(lockFileContents, root, lockFilePath) {
|
|
@@ -165994,10 +166496,13 @@ function getYarnWorkspaces(targetFile) {
|
|
|
165994
166496
|
try {
|
|
165995
166497
|
const packageJson = parseManifestFile(targetFile);
|
|
165996
166498
|
if (!!packageJson.workspaces && !!packageJson.private) {
|
|
165997
|
-
|
|
165998
|
-
|
|
165999
|
-
|
|
166000
|
-
|
|
166499
|
+
if (Array.isArray(packageJson.workspaces)) {
|
|
166500
|
+
return packageJson.workspaces;
|
|
166501
|
+
}
|
|
166502
|
+
if ('packages' in packageJson.workspaces &&
|
|
166503
|
+
Array.isArray(packageJson.workspaces.packages)) {
|
|
166504
|
+
return packageJson.workspaces.packages;
|
|
166505
|
+
}
|
|
166001
166506
|
}
|
|
166002
166507
|
return false;
|
|
166003
166508
|
}
|
|
@@ -166024,6 +166529,7 @@ const graphlib = __webpack_require__(39322);
|
|
|
166024
166529
|
const uuid_1 = __webpack_require__(42277);
|
|
166025
166530
|
const event_loop_spinner_1 = __webpack_require__(77158);
|
|
166026
166531
|
const baseDebug = __webpack_require__(15158);
|
|
166532
|
+
const cli_parser_utils_1 = __webpack_require__(80333);
|
|
166027
166533
|
const _1 = __webpack_require__(75873);
|
|
166028
166534
|
const errors_1 = __webpack_require__(1706);
|
|
166029
166535
|
const debug = baseDebug('snyk-nodejs-parser');
|
|
@@ -166080,7 +166586,7 @@ class LockParserBase {
|
|
|
166080
166586
|
// Only include peerDependencies if using npm and npm is at least
|
|
166081
166587
|
// version 7 as npm v7 automatically installs peerDependencies
|
|
166082
166588
|
// get trees for dependencies from manifest file
|
|
166083
|
-
const topLevelDeps = _1.getTopLevelDeps({
|
|
166589
|
+
const topLevelDeps = (0, _1.getTopLevelDeps)({
|
|
166084
166590
|
targetFile: manifestFile,
|
|
166085
166591
|
includeDev,
|
|
166086
166592
|
includePeerDeps: lockfile.type === _1.LockfileType.npm7,
|
|
@@ -166107,7 +166613,7 @@ class LockParserBase {
|
|
|
166107
166613
|
}
|
|
166108
166614
|
}
|
|
166109
166615
|
else if (/^file:/.test(dep.version)) {
|
|
166110
|
-
depTree.dependencies[dep.name] = _1.createDepTreeDepFromDep(dep);
|
|
166616
|
+
depTree.dependencies[dep.name] = (0, _1.createDepTreeDepFromDep)(dep);
|
|
166111
166617
|
treeSize++;
|
|
166112
166618
|
}
|
|
166113
166619
|
else {
|
|
@@ -166116,7 +166622,7 @@ class LockParserBase {
|
|
|
166116
166622
|
if (strictOutOfSync) {
|
|
166117
166623
|
throw new errors_1.OutOfSyncError(dep.name, this.type);
|
|
166118
166624
|
}
|
|
166119
|
-
depTree.dependencies[dep.name] = _1.createDepTreeDepFromDep(dep);
|
|
166625
|
+
depTree.dependencies[dep.name] = (0, _1.createDepTreeDepFromDep)(dep);
|
|
166120
166626
|
if (!depTree.dependencies[dep.name].labels) {
|
|
166121
166627
|
depTree.dependencies[dep.name].labels = {};
|
|
166122
166628
|
}
|
|
@@ -166131,9 +166637,7 @@ class LockParserBase {
|
|
|
166131
166637
|
for (const [name, subTree] of _toPairs(pkgTree.dependencies)) {
|
|
166132
166638
|
pkgTree.dependencies[name] = this.setDevDepRec(subTree);
|
|
166133
166639
|
}
|
|
166134
|
-
pkgTree.labels = {
|
|
166135
|
-
scope: _1.Scope.dev,
|
|
166136
|
-
};
|
|
166640
|
+
pkgTree.labels = Object.assign(Object.assign({}, pkgTree.labels), { scope: _1.Scope.dev });
|
|
166137
166641
|
return pkgTree;
|
|
166138
166642
|
}
|
|
166139
166643
|
/* Algorithm for cycle removal:
|
|
@@ -166225,7 +166729,7 @@ class LockParserBase {
|
|
|
166225
166729
|
}
|
|
166226
166730
|
}
|
|
166227
166731
|
cloneNodeWithoutEdges(node, depMap, depGraph) {
|
|
166228
|
-
const newNode = node + uuid_1.v4();
|
|
166732
|
+
const newNode = node + (0, uuid_1.v4)();
|
|
166229
166733
|
// update depMap with new node
|
|
166230
166734
|
depMap[newNode] = _cloneDeep(depMap[node]);
|
|
166231
166735
|
// add new node to the graph
|
|
@@ -166268,6 +166772,7 @@ class LockParserBase {
|
|
|
166268
166772
|
// Algorithm is based on dynamic programming technique and tries to build
|
|
166269
166773
|
// "more simple" trees and compose them into bigger ones.
|
|
166270
166774
|
async createDepTrees(depMap, depGraph) {
|
|
166775
|
+
var _a;
|
|
166271
166776
|
// Graph has to be acyclic
|
|
166272
166777
|
if (!graphlib.alg.isAcyclic(depGraph)) {
|
|
166273
166778
|
throw new Error('Cycles were not removed from graph.');
|
|
@@ -166295,16 +166800,12 @@ class LockParserBase {
|
|
|
166295
166800
|
}
|
|
166296
166801
|
if (!subDep) {
|
|
166297
166802
|
debug(`Missing entry for ${subDepPath}`);
|
|
166298
|
-
const
|
|
166299
|
-
const name = subDepPath.slice(0, index);
|
|
166300
|
-
const identifier = subDepPath.slice(index + 1);
|
|
166803
|
+
const { name, identifier } = (0, cli_parser_utils_1.extractNameAndIdentifier)(subDepPath);
|
|
166301
166804
|
subDep = {
|
|
166302
166805
|
name: name,
|
|
166303
166806
|
version: identifier,
|
|
166304
166807
|
dependencies: {},
|
|
166305
|
-
labels: {
|
|
166306
|
-
missingLockFileEntry: 'true',
|
|
166307
|
-
},
|
|
166808
|
+
labels: Object.assign({ missingLockFileEntry: 'true' }, (((_a = dep.labels) === null || _a === void 0 ? void 0 : _a.scope) && { scope: dep.labels.scope })),
|
|
166308
166809
|
};
|
|
166309
166810
|
treeSize += 1;
|
|
166310
166811
|
}
|
|
@@ -166371,7 +166872,8 @@ class PackageLockParser extends lock_parser_base_1.LockParserBase {
|
|
|
166371
166872
|
return packageLock;
|
|
166372
166873
|
}
|
|
166373
166874
|
catch (e) {
|
|
166374
|
-
throw new errors_1.InvalidUserInputError('package-lock.json parsing failed with ' +
|
|
166875
|
+
throw new errors_1.InvalidUserInputError('package-lock.json parsing failed with ' +
|
|
166876
|
+
`error ${e.message}`);
|
|
166375
166877
|
}
|
|
166376
166878
|
}
|
|
166377
166879
|
async getDependencyTree(manifestFile, lockfile, includeDev = false, strictOutOfSync = true) {
|
|
@@ -166577,7 +167079,7 @@ class Yarn2LockParser extends lock_parser_base_1.LockParserBase {
|
|
|
166577
167079
|
}
|
|
166578
167080
|
parseLockFile(lockFileContents) {
|
|
166579
167081
|
try {
|
|
166580
|
-
const rawYarnLock = js_yaml_1.load(lockFileContents, {
|
|
167082
|
+
const rawYarnLock = (0, js_yaml_1.load)(lockFileContents, {
|
|
166581
167083
|
json: true,
|
|
166582
167084
|
schema: js_yaml_1.FAILSAFE_SCHEMA,
|
|
166583
167085
|
});
|
|
@@ -166586,7 +167088,7 @@ class Yarn2LockParser extends lock_parser_base_1.LockParserBase {
|
|
|
166586
167088
|
const structUtils = yarnCore.structUtils;
|
|
166587
167089
|
const parseDescriptor = structUtils.parseDescriptor;
|
|
166588
167090
|
const parseRange = structUtils.parseRange;
|
|
166589
|
-
const keyNormalizer = yarn_utils_1.yarnLockFileKeyNormalizer(parseDescriptor, parseRange);
|
|
167091
|
+
const keyNormalizer = (0, yarn_utils_1.yarnLockFileKeyNormalizer)(parseDescriptor, parseRange);
|
|
166590
167092
|
Object.entries(rawYarnLock).forEach(([fullDescriptor, versionData]) => {
|
|
166591
167093
|
keyNormalizer(fullDescriptor).forEach((descriptor) => {
|
|
166592
167094
|
dependencies[descriptor] = versionData;
|
|
@@ -166663,6 +167165,1524 @@ function findResolutions(dependencies, depName, subDepKey, resolutions) {
|
|
|
166663
167165
|
|
|
166664
167166
|
/***/ }),
|
|
166665
167167
|
|
|
167168
|
+
/***/ 20922:
|
|
167169
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167170
|
+
|
|
167171
|
+
"use strict";
|
|
167172
|
+
|
|
167173
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167174
|
+
exports.DepGraphBuilder = void 0;
|
|
167175
|
+
const graphlib = __webpack_require__(82107);
|
|
167176
|
+
const dep_graph_1 = __webpack_require__(44912);
|
|
167177
|
+
class DepGraphBuilder {
|
|
167178
|
+
constructor(pkgManager, rootPkg) {
|
|
167179
|
+
this._pkgs = {};
|
|
167180
|
+
this._pkgNodes = {};
|
|
167181
|
+
const graph = new graphlib.Graph({
|
|
167182
|
+
directed: true,
|
|
167183
|
+
multigraph: false,
|
|
167184
|
+
compound: false,
|
|
167185
|
+
});
|
|
167186
|
+
if (!rootPkg) {
|
|
167187
|
+
rootPkg = {
|
|
167188
|
+
name: '_root',
|
|
167189
|
+
version: '0.0.0',
|
|
167190
|
+
};
|
|
167191
|
+
}
|
|
167192
|
+
this._rootNodeId = 'root-node';
|
|
167193
|
+
this._rootPkgId = DepGraphBuilder._getPkgId(rootPkg);
|
|
167194
|
+
this._pkgs[this._rootPkgId] = rootPkg;
|
|
167195
|
+
graph.setNode(this._rootNodeId, { pkgId: this._rootPkgId });
|
|
167196
|
+
this._pkgNodes[this._rootPkgId] = new Set([this._rootNodeId]);
|
|
167197
|
+
this._graph = graph;
|
|
167198
|
+
this._pkgManager = pkgManager;
|
|
167199
|
+
}
|
|
167200
|
+
get rootNodeId() {
|
|
167201
|
+
return this._rootNodeId;
|
|
167202
|
+
}
|
|
167203
|
+
static _getPkgId(pkg) {
|
|
167204
|
+
return `${pkg.name}@${pkg.version || ''}`;
|
|
167205
|
+
}
|
|
167206
|
+
getPkgs() {
|
|
167207
|
+
return Object.values(this._pkgs);
|
|
167208
|
+
}
|
|
167209
|
+
// TODO: this can create disconnected nodes
|
|
167210
|
+
addPkgNode(pkgInfo, nodeId, nodeInfo) {
|
|
167211
|
+
if (nodeId === this._rootNodeId) {
|
|
167212
|
+
throw new Error('DepGraphBuilder.addPkgNode() cant override root node');
|
|
167213
|
+
}
|
|
167214
|
+
const pkgId = DepGraphBuilder._getPkgId(pkgInfo);
|
|
167215
|
+
this._pkgs[pkgId] = pkgInfo;
|
|
167216
|
+
this._pkgNodes[pkgId] = this._pkgNodes[pkgId] || new Set();
|
|
167217
|
+
this._pkgNodes[pkgId].add(nodeId);
|
|
167218
|
+
this._graph.setNode(nodeId, { pkgId, info: nodeInfo });
|
|
167219
|
+
return this;
|
|
167220
|
+
}
|
|
167221
|
+
// TODO: this can create cycles
|
|
167222
|
+
connectDep(parentNodeId, depNodeId) {
|
|
167223
|
+
if (!this._graph.hasNode(parentNodeId)) {
|
|
167224
|
+
throw new Error('parentNodeId does not exist');
|
|
167225
|
+
}
|
|
167226
|
+
if (!this._graph.hasNode(depNodeId)) {
|
|
167227
|
+
throw new Error('depNodeId does not exist');
|
|
167228
|
+
}
|
|
167229
|
+
this._graph.setEdge(parentNodeId, depNodeId);
|
|
167230
|
+
return this;
|
|
167231
|
+
}
|
|
167232
|
+
build() {
|
|
167233
|
+
return new dep_graph_1.DepGraphImpl(this._graph, this._rootNodeId, this._pkgs, this._pkgNodes, this._pkgManager);
|
|
167234
|
+
}
|
|
167235
|
+
}
|
|
167236
|
+
exports.DepGraphBuilder = DepGraphBuilder;
|
|
167237
|
+
//# sourceMappingURL=builder.js.map
|
|
167238
|
+
|
|
167239
|
+
/***/ }),
|
|
167240
|
+
|
|
167241
|
+
/***/ 28391:
|
|
167242
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167243
|
+
|
|
167244
|
+
"use strict";
|
|
167245
|
+
|
|
167246
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167247
|
+
exports.createFromJSON = exports.SUPPORTED_SCHEMA_RANGE = void 0;
|
|
167248
|
+
const semver = __webpack_require__(50460);
|
|
167249
|
+
const graphlib = __webpack_require__(82107);
|
|
167250
|
+
const errors_1 = __webpack_require__(50481);
|
|
167251
|
+
const validate_graph_1 = __webpack_require__(5141);
|
|
167252
|
+
const dep_graph_1 = __webpack_require__(44912);
|
|
167253
|
+
exports.SUPPORTED_SCHEMA_RANGE = '^1.0.0';
|
|
167254
|
+
/**
|
|
167255
|
+
* Create a DepGraph instance from a JSON representation of a dep graph. This
|
|
167256
|
+
* is typically used after passing the graph over the wire as `DepGraphData`.
|
|
167257
|
+
*/
|
|
167258
|
+
function createFromJSON(depGraphData) {
|
|
167259
|
+
validateDepGraphData(depGraphData);
|
|
167260
|
+
const graph = new graphlib.Graph({
|
|
167261
|
+
directed: true,
|
|
167262
|
+
multigraph: false,
|
|
167263
|
+
compound: false,
|
|
167264
|
+
});
|
|
167265
|
+
const pkgs = {};
|
|
167266
|
+
const pkgNodes = {};
|
|
167267
|
+
for (const { id, info } of depGraphData.pkgs) {
|
|
167268
|
+
pkgs[id] = info.version ? info : { ...info, version: undefined };
|
|
167269
|
+
}
|
|
167270
|
+
for (const node of depGraphData.graph.nodes) {
|
|
167271
|
+
const pkgId = node.pkgId;
|
|
167272
|
+
if (!pkgNodes[pkgId]) {
|
|
167273
|
+
pkgNodes[pkgId] = new Set();
|
|
167274
|
+
}
|
|
167275
|
+
pkgNodes[pkgId].add(node.nodeId);
|
|
167276
|
+
graph.setNode(node.nodeId, { pkgId, info: node.info });
|
|
167277
|
+
}
|
|
167278
|
+
for (const node of depGraphData.graph.nodes) {
|
|
167279
|
+
for (const depNodeId of node.deps) {
|
|
167280
|
+
graph.setEdge(node.nodeId, depNodeId.nodeId);
|
|
167281
|
+
}
|
|
167282
|
+
}
|
|
167283
|
+
(0, validate_graph_1.validateGraph)(graph, depGraphData.graph.rootNodeId, pkgs, pkgNodes);
|
|
167284
|
+
return new dep_graph_1.DepGraphImpl(graph, depGraphData.graph.rootNodeId, pkgs, pkgNodes, depGraphData.pkgManager);
|
|
167285
|
+
}
|
|
167286
|
+
exports.createFromJSON = createFromJSON;
|
|
167287
|
+
function assert(condition, msg) {
|
|
167288
|
+
if (!condition) {
|
|
167289
|
+
throw new errors_1.ValidationError(msg);
|
|
167290
|
+
}
|
|
167291
|
+
}
|
|
167292
|
+
function validateDepGraphData(depGraphData) {
|
|
167293
|
+
assert(!!semver.valid(depGraphData.schemaVersion) &&
|
|
167294
|
+
semver.satisfies(depGraphData.schemaVersion, exports.SUPPORTED_SCHEMA_RANGE), `dep-graph schemaVersion not in "${exports.SUPPORTED_SCHEMA_RANGE}"`);
|
|
167295
|
+
assert(depGraphData.pkgManager && !!depGraphData.pkgManager.name, '.pkgManager.name is missing');
|
|
167296
|
+
const pkgsMap = depGraphData.pkgs.reduce((acc, cur) => {
|
|
167297
|
+
assert(!(cur.id in acc), 'more than one pkg with same id');
|
|
167298
|
+
assert(!!cur.info, '.pkgs item missing .info');
|
|
167299
|
+
acc[cur.id] = cur.info;
|
|
167300
|
+
return acc;
|
|
167301
|
+
}, {});
|
|
167302
|
+
const nodesMap = depGraphData.graph.nodes.reduce((acc, cur) => {
|
|
167303
|
+
assert(!(cur.nodeId in acc), 'more than on node with same id');
|
|
167304
|
+
acc[cur.nodeId] = cur;
|
|
167305
|
+
return acc;
|
|
167306
|
+
}, {});
|
|
167307
|
+
const rootNodeId = depGraphData.graph.rootNodeId;
|
|
167308
|
+
const rootNode = nodesMap[rootNodeId];
|
|
167309
|
+
assert(rootNodeId in nodesMap, `.${rootNodeId} root graph node is missing`);
|
|
167310
|
+
const rootPkgId = rootNode.pkgId;
|
|
167311
|
+
assert(rootPkgId in pkgsMap, `.${rootPkgId} root pkg missing`);
|
|
167312
|
+
assert(nodesMap[rootNodeId].pkgId === rootPkgId, `the root node .pkgId should be "${rootPkgId}"`);
|
|
167313
|
+
const pkgIds = Object.keys(pkgsMap);
|
|
167314
|
+
// NOTE: this name@version check is very strict,
|
|
167315
|
+
// we can relax it later, it just makes things easier now
|
|
167316
|
+
assert(pkgIds.filter((pkgId) => pkgId !== dep_graph_1.DepGraphImpl.getPkgId(pkgsMap[pkgId]))
|
|
167317
|
+
.length === 0, 'pkgs ids should be name@version');
|
|
167318
|
+
assert(Object.values(nodesMap).filter((node) => !(node.pkgId in pkgsMap))
|
|
167319
|
+
.length === 0, 'some instance nodes belong to non-existing pkgIds');
|
|
167320
|
+
assert(Object.values(pkgsMap).filter((pkg) => !pkg.name)
|
|
167321
|
+
.length === 0, 'some .pkgs elements have no .name field');
|
|
167322
|
+
}
|
|
167323
|
+
//# sourceMappingURL=create-from-json.js.map
|
|
167324
|
+
|
|
167325
|
+
/***/ }),
|
|
167326
|
+
|
|
167327
|
+
/***/ 44912:
|
|
167328
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167329
|
+
|
|
167330
|
+
"use strict";
|
|
167331
|
+
|
|
167332
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167333
|
+
exports.DepGraphImpl = void 0;
|
|
167334
|
+
const _isEqual = __webpack_require__(72307);
|
|
167335
|
+
const graphlib = __webpack_require__(82107);
|
|
167336
|
+
const create_from_json_1 = __webpack_require__(28391);
|
|
167337
|
+
class DepGraphImpl {
|
|
167338
|
+
constructor(_graph, _rootNodeId, _pkgs, _pkgNodes, _pkgManager) {
|
|
167339
|
+
this._graph = _graph;
|
|
167340
|
+
this._rootNodeId = _rootNodeId;
|
|
167341
|
+
this._pkgs = _pkgs;
|
|
167342
|
+
this._pkgNodes = _pkgNodes;
|
|
167343
|
+
this._pkgManager = _pkgManager;
|
|
167344
|
+
this._countNodePathsToRootCache = new Map();
|
|
167345
|
+
this._rootPkgId = _graph.node(_rootNodeId).pkgId;
|
|
167346
|
+
this._pkgList = Object.values(_pkgs);
|
|
167347
|
+
this._depPkgsList = this._pkgList.filter((pkg) => pkg !== this.rootPkg);
|
|
167348
|
+
}
|
|
167349
|
+
static getPkgId(pkg) {
|
|
167350
|
+
return `${pkg.name}@${pkg.version || ''}`;
|
|
167351
|
+
}
|
|
167352
|
+
get pkgManager() {
|
|
167353
|
+
return this._pkgManager;
|
|
167354
|
+
}
|
|
167355
|
+
get rootPkg() {
|
|
167356
|
+
return this._pkgs[this._rootPkgId];
|
|
167357
|
+
}
|
|
167358
|
+
get rootNodeId() {
|
|
167359
|
+
return this._rootNodeId;
|
|
167360
|
+
}
|
|
167361
|
+
/**
|
|
167362
|
+
* Get all unique packages in the graph (including the root package)
|
|
167363
|
+
*/
|
|
167364
|
+
getPkgs() {
|
|
167365
|
+
return this._pkgList;
|
|
167366
|
+
}
|
|
167367
|
+
/**
|
|
167368
|
+
* Get all unique packages in the graph (excluding the root package)
|
|
167369
|
+
*/
|
|
167370
|
+
getDepPkgs() {
|
|
167371
|
+
return this._depPkgsList;
|
|
167372
|
+
}
|
|
167373
|
+
getPkgNodes(pkg) {
|
|
167374
|
+
const pkgId = DepGraphImpl.getPkgId(pkg);
|
|
167375
|
+
const nodes = [];
|
|
167376
|
+
for (const nodeId of Array.from(this._pkgNodes[pkgId])) {
|
|
167377
|
+
const graphNode = this.getGraphNode(nodeId);
|
|
167378
|
+
nodes.push({
|
|
167379
|
+
info: graphNode.info || {},
|
|
167380
|
+
});
|
|
167381
|
+
}
|
|
167382
|
+
return nodes;
|
|
167383
|
+
}
|
|
167384
|
+
getNode(nodeId) {
|
|
167385
|
+
return this.getGraphNode(nodeId).info || {};
|
|
167386
|
+
}
|
|
167387
|
+
getNodePkg(nodeId) {
|
|
167388
|
+
return this._pkgs[this.getGraphNode(nodeId).pkgId];
|
|
167389
|
+
}
|
|
167390
|
+
getPkgNodeIds(pkg) {
|
|
167391
|
+
const pkgId = DepGraphImpl.getPkgId(pkg);
|
|
167392
|
+
if (!this._pkgs[pkgId]) {
|
|
167393
|
+
throw new Error(`no such pkg: ${pkgId}`);
|
|
167394
|
+
}
|
|
167395
|
+
return Array.from(this._pkgNodes[pkgId]);
|
|
167396
|
+
}
|
|
167397
|
+
getNodeDepsNodeIds(nodeId) {
|
|
167398
|
+
const deps = this._graph.successors(nodeId);
|
|
167399
|
+
if (!deps) {
|
|
167400
|
+
throw new Error(`no such node: ${nodeId}`);
|
|
167401
|
+
}
|
|
167402
|
+
return deps;
|
|
167403
|
+
}
|
|
167404
|
+
getNodeParentsNodeIds(nodeId) {
|
|
167405
|
+
const parents = this._graph.predecessors(nodeId);
|
|
167406
|
+
if (!parents) {
|
|
167407
|
+
throw new Error(`no such node: ${nodeId}`);
|
|
167408
|
+
}
|
|
167409
|
+
return parents;
|
|
167410
|
+
}
|
|
167411
|
+
hasCycles() {
|
|
167412
|
+
// `isAcyclic` is expensive, so memoize
|
|
167413
|
+
if (this._hasCycles === undefined) {
|
|
167414
|
+
this._hasCycles = !graphlib.alg.isAcyclic(this._graph);
|
|
167415
|
+
}
|
|
167416
|
+
return this._hasCycles;
|
|
167417
|
+
}
|
|
167418
|
+
pkgPathsToRoot(pkg, opts) {
|
|
167419
|
+
const pathsToRoot = [];
|
|
167420
|
+
const limit = opts === null || opts === void 0 ? void 0 : opts.limit;
|
|
167421
|
+
for (const nodeId of this.getPkgNodeIds(pkg)) {
|
|
167422
|
+
const pathsFromNodeToRoot = this.pathsFromNodeToRoot(nodeId, [], {
|
|
167423
|
+
limit,
|
|
167424
|
+
});
|
|
167425
|
+
for (const path of pathsFromNodeToRoot) {
|
|
167426
|
+
pathsToRoot.push(path);
|
|
167427
|
+
}
|
|
167428
|
+
if (limit && pathsToRoot.length >= limit) {
|
|
167429
|
+
break;
|
|
167430
|
+
}
|
|
167431
|
+
}
|
|
167432
|
+
// note: sorting to get shorter paths first -
|
|
167433
|
+
// it's nicer - and better resembles older behaviour
|
|
167434
|
+
return pathsToRoot.sort((a, b) => a.length - b.length);
|
|
167435
|
+
}
|
|
167436
|
+
countPathsToRoot(pkg) {
|
|
167437
|
+
let count = 0;
|
|
167438
|
+
for (const nodeId of this.getPkgNodeIds(pkg)) {
|
|
167439
|
+
count += this.countNodePathsToRoot(nodeId);
|
|
167440
|
+
}
|
|
167441
|
+
return count;
|
|
167442
|
+
}
|
|
167443
|
+
isTransitive(pkg) {
|
|
167444
|
+
const checking = new Set(this.getPkgNodeIds(pkg));
|
|
167445
|
+
for (const directDep of this.getNodeDepsNodeIds(this.rootNodeId)) {
|
|
167446
|
+
if (checking.has(directDep))
|
|
167447
|
+
return false;
|
|
167448
|
+
}
|
|
167449
|
+
return true;
|
|
167450
|
+
}
|
|
167451
|
+
equals(other, { compareRoot = true } = {}) {
|
|
167452
|
+
let otherDepGraph;
|
|
167453
|
+
if (other instanceof DepGraphImpl) {
|
|
167454
|
+
otherDepGraph = other;
|
|
167455
|
+
}
|
|
167456
|
+
else {
|
|
167457
|
+
// At runtime theoretically we can have multiple versions of
|
|
167458
|
+
// @snyk/dep-graph. If "other" is not an instance of the same class it is
|
|
167459
|
+
// safer to rebuild it from JSON.
|
|
167460
|
+
otherDepGraph = (0, create_from_json_1.createFromJSON)(other.toJSON());
|
|
167461
|
+
}
|
|
167462
|
+
// In theory, for the graphs created by standard means, `_.isEquals(this._data, otherDepGraph._data)`
|
|
167463
|
+
// should suffice, since node IDs will be generated in a predictable way.
|
|
167464
|
+
// However, there might be different versions of graph and inconsistencies
|
|
167465
|
+
// in the ordering of the arrays, so we perform a deep comparison.
|
|
167466
|
+
return this.nodeEquals(this, this.rootNodeId, otherDepGraph, otherDepGraph.rootNodeId, compareRoot);
|
|
167467
|
+
}
|
|
167468
|
+
directDepsLeadingTo(pkg) {
|
|
167469
|
+
const pkgNodes = this.getPkgNodeIds(pkg);
|
|
167470
|
+
const directDeps = this.getNodeDepsNodeIds(this.rootNodeId);
|
|
167471
|
+
const nodes = directDeps.filter((directDep) => {
|
|
167472
|
+
const reachableNodes = graphlib.alg.postorder(this._graph, [directDep]);
|
|
167473
|
+
return reachableNodes.filter((node) => pkgNodes.includes(node)).length;
|
|
167474
|
+
});
|
|
167475
|
+
return nodes.map((node) => this.getNodePkg(node));
|
|
167476
|
+
}
|
|
167477
|
+
/**
|
|
167478
|
+
* Create a JSON representation of a dep graph. This is typically used to
|
|
167479
|
+
* send the dep graph over the wire
|
|
167480
|
+
*/
|
|
167481
|
+
toJSON() {
|
|
167482
|
+
const nodeIds = this._graph.nodes();
|
|
167483
|
+
const nodes = nodeIds.reduce((acc, nodeId) => {
|
|
167484
|
+
const deps = (this._graph.successors(nodeId) || []).map((depNodeId) => ({
|
|
167485
|
+
nodeId: depNodeId,
|
|
167486
|
+
}));
|
|
167487
|
+
const node = this._graph.node(nodeId);
|
|
167488
|
+
const elem = {
|
|
167489
|
+
nodeId,
|
|
167490
|
+
pkgId: node.pkgId,
|
|
167491
|
+
deps,
|
|
167492
|
+
};
|
|
167493
|
+
if (node.info && Object.keys(node.info).length > 0) {
|
|
167494
|
+
elem.info = node.info;
|
|
167495
|
+
}
|
|
167496
|
+
acc.push(elem);
|
|
167497
|
+
return acc;
|
|
167498
|
+
}, []);
|
|
167499
|
+
const pkgs = Object.keys(this._pkgs).map((pkgId) => ({
|
|
167500
|
+
id: pkgId,
|
|
167501
|
+
info: this._pkgs[pkgId],
|
|
167502
|
+
}));
|
|
167503
|
+
return {
|
|
167504
|
+
schemaVersion: DepGraphImpl.SCHEMA_VERSION,
|
|
167505
|
+
pkgManager: this._pkgManager,
|
|
167506
|
+
pkgs,
|
|
167507
|
+
graph: {
|
|
167508
|
+
rootNodeId: this._rootNodeId,
|
|
167509
|
+
nodes,
|
|
167510
|
+
},
|
|
167511
|
+
};
|
|
167512
|
+
}
|
|
167513
|
+
nodeEquals(graphA, nodeIdA, graphB, nodeIdB, compareRoot, traversedPairs = new Set()) {
|
|
167514
|
+
// Skip root nodes comparision if needed.
|
|
167515
|
+
if (compareRoot ||
|
|
167516
|
+
(nodeIdA !== graphA.rootNodeId && nodeIdB !== graphB.rootNodeId)) {
|
|
167517
|
+
const pkgA = graphA.getNodePkg(nodeIdA);
|
|
167518
|
+
const pkgB = graphB.getNodePkg(nodeIdB);
|
|
167519
|
+
// Compare PkgInfo (name and version).
|
|
167520
|
+
if (!_isEqual(pkgA, pkgB)) {
|
|
167521
|
+
return false;
|
|
167522
|
+
}
|
|
167523
|
+
const infoA = graphA.getNode(nodeIdA);
|
|
167524
|
+
const infoB = graphB.getNode(nodeIdB);
|
|
167525
|
+
// Compare NodeInfo (VersionProvenance and labels).
|
|
167526
|
+
if (!_isEqual(infoA, infoB)) {
|
|
167527
|
+
return false;
|
|
167528
|
+
}
|
|
167529
|
+
}
|
|
167530
|
+
let depsA = graphA.getNodeDepsNodeIds(nodeIdA);
|
|
167531
|
+
let depsB = graphB.getNodeDepsNodeIds(nodeIdB);
|
|
167532
|
+
// Number of dependencies should be the same.
|
|
167533
|
+
if (depsA.length !== depsB.length) {
|
|
167534
|
+
return false;
|
|
167535
|
+
}
|
|
167536
|
+
// Sort dependencies by name@version string.
|
|
167537
|
+
const sortFn = (graph) => (idA, idB) => {
|
|
167538
|
+
const pkgA = graph.getNodePkg(idA);
|
|
167539
|
+
const pkgB = graph.getNodePkg(idB);
|
|
167540
|
+
return DepGraphImpl.getPkgId(pkgA).localeCompare(DepGraphImpl.getPkgId(pkgB));
|
|
167541
|
+
};
|
|
167542
|
+
depsA = depsA.sort(sortFn(graphA));
|
|
167543
|
+
depsB = depsB.sort(sortFn(graphB));
|
|
167544
|
+
// Compare Each dependency recursively.
|
|
167545
|
+
for (let i = 0; i < depsA.length; i++) {
|
|
167546
|
+
const pairKey = `${depsA[i]}_${depsB[i]}`;
|
|
167547
|
+
// Prevent cycles.
|
|
167548
|
+
if (traversedPairs.has(pairKey)) {
|
|
167549
|
+
continue;
|
|
167550
|
+
}
|
|
167551
|
+
traversedPairs.add(pairKey);
|
|
167552
|
+
if (!this.nodeEquals(graphA, depsA[i], graphB, depsB[i], compareRoot, traversedPairs)) {
|
|
167553
|
+
return false;
|
|
167554
|
+
}
|
|
167555
|
+
}
|
|
167556
|
+
return true;
|
|
167557
|
+
}
|
|
167558
|
+
getGraphNode(nodeId) {
|
|
167559
|
+
const node = this._graph.node(nodeId);
|
|
167560
|
+
if (!node) {
|
|
167561
|
+
throw new Error(`no such node: ${nodeId}`);
|
|
167562
|
+
}
|
|
167563
|
+
return node;
|
|
167564
|
+
}
|
|
167565
|
+
pathsFromNodeToRoot(nodeId, ancestors = [], opts) {
|
|
167566
|
+
const parentNodesIds = this.getNodeParentsNodeIds(nodeId);
|
|
167567
|
+
const pkgInfo = this.getNodePkg(nodeId);
|
|
167568
|
+
if (parentNodesIds.length === 0) {
|
|
167569
|
+
return [[pkgInfo]];
|
|
167570
|
+
}
|
|
167571
|
+
const allPaths = [];
|
|
167572
|
+
ancestors = ancestors.concat(nodeId);
|
|
167573
|
+
const limit = opts.limit;
|
|
167574
|
+
for (const id of parentNodesIds) {
|
|
167575
|
+
if (ancestors.includes(id))
|
|
167576
|
+
continue;
|
|
167577
|
+
const pathsFromNodeToRoot = this.pathsFromNodeToRoot(id, ancestors, opts);
|
|
167578
|
+
for (const path of pathsFromNodeToRoot) {
|
|
167579
|
+
allPaths.push([pkgInfo].concat(path));
|
|
167580
|
+
}
|
|
167581
|
+
if (limit && allPaths.length >= limit) {
|
|
167582
|
+
break;
|
|
167583
|
+
}
|
|
167584
|
+
}
|
|
167585
|
+
return allPaths;
|
|
167586
|
+
}
|
|
167587
|
+
countNodePathsToRoot(nodeId, ancestors = []) {
|
|
167588
|
+
if (ancestors.includes(nodeId)) {
|
|
167589
|
+
return 0;
|
|
167590
|
+
}
|
|
167591
|
+
if (this._countNodePathsToRootCache.has(nodeId)) {
|
|
167592
|
+
return this._countNodePathsToRootCache.get(nodeId) || 0;
|
|
167593
|
+
}
|
|
167594
|
+
const parentNodesIds = this.getNodeParentsNodeIds(nodeId);
|
|
167595
|
+
if (parentNodesIds.length === 0) {
|
|
167596
|
+
this._countNodePathsToRootCache.set(nodeId, 1);
|
|
167597
|
+
return 1;
|
|
167598
|
+
}
|
|
167599
|
+
ancestors = ancestors.concat(nodeId);
|
|
167600
|
+
const count = parentNodesIds.reduce((acc, parentNodeId) => {
|
|
167601
|
+
return acc + this.countNodePathsToRoot(parentNodeId, ancestors);
|
|
167602
|
+
}, 0);
|
|
167603
|
+
this._countNodePathsToRootCache.set(nodeId, count);
|
|
167604
|
+
return count;
|
|
167605
|
+
}
|
|
167606
|
+
}
|
|
167607
|
+
exports.DepGraphImpl = DepGraphImpl;
|
|
167608
|
+
DepGraphImpl.SCHEMA_VERSION = '1.2.0';
|
|
167609
|
+
//# sourceMappingURL=dep-graph.js.map
|
|
167610
|
+
|
|
167611
|
+
/***/ }),
|
|
167612
|
+
|
|
167613
|
+
/***/ 44493:
|
|
167614
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
167615
|
+
|
|
167616
|
+
"use strict";
|
|
167617
|
+
|
|
167618
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167619
|
+
exports.CustomError = void 0;
|
|
167620
|
+
class CustomError extends Error {
|
|
167621
|
+
constructor(message) {
|
|
167622
|
+
super(message);
|
|
167623
|
+
Object.setPrototypeOf(this, CustomError.prototype);
|
|
167624
|
+
Error.captureStackTrace(this, this.constructor);
|
|
167625
|
+
this.name = this.constructor.name;
|
|
167626
|
+
}
|
|
167627
|
+
}
|
|
167628
|
+
exports.CustomError = CustomError;
|
|
167629
|
+
//# sourceMappingURL=custom-error.js.map
|
|
167630
|
+
|
|
167631
|
+
/***/ }),
|
|
167632
|
+
|
|
167633
|
+
/***/ 50481:
|
|
167634
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167635
|
+
|
|
167636
|
+
"use strict";
|
|
167637
|
+
|
|
167638
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167639
|
+
exports.ValidationError = void 0;
|
|
167640
|
+
const validation_error_1 = __webpack_require__(83709);
|
|
167641
|
+
Object.defineProperty(exports, "ValidationError", ({ enumerable: true, get: function () { return validation_error_1.ValidationError; } }));
|
|
167642
|
+
//# sourceMappingURL=index.js.map
|
|
167643
|
+
|
|
167644
|
+
/***/ }),
|
|
167645
|
+
|
|
167646
|
+
/***/ 83709:
|
|
167647
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167648
|
+
|
|
167649
|
+
"use strict";
|
|
167650
|
+
|
|
167651
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167652
|
+
exports.ValidationError = void 0;
|
|
167653
|
+
const custom_error_1 = __webpack_require__(44493);
|
|
167654
|
+
class ValidationError extends custom_error_1.CustomError {
|
|
167655
|
+
constructor(message) {
|
|
167656
|
+
super(message);
|
|
167657
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
167658
|
+
}
|
|
167659
|
+
}
|
|
167660
|
+
exports.ValidationError = ValidationError;
|
|
167661
|
+
//# sourceMappingURL=validation-error.js.map
|
|
167662
|
+
|
|
167663
|
+
/***/ }),
|
|
167664
|
+
|
|
167665
|
+
/***/ 5141:
|
|
167666
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167667
|
+
|
|
167668
|
+
"use strict";
|
|
167669
|
+
|
|
167670
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167671
|
+
exports.validateGraph = void 0;
|
|
167672
|
+
const graphlib = __webpack_require__(82107);
|
|
167673
|
+
const errors_1 = __webpack_require__(50481);
|
|
167674
|
+
function assert(condition, msg) {
|
|
167675
|
+
if (!condition) {
|
|
167676
|
+
throw new errors_1.ValidationError(msg);
|
|
167677
|
+
}
|
|
167678
|
+
}
|
|
167679
|
+
function validateGraph(graph, rootNodeId, pkgs, pkgNodes) {
|
|
167680
|
+
assert((graph.predecessors(rootNodeId) || []).length === 0, `"${rootNodeId}" is not really the root`);
|
|
167681
|
+
const reachableFromRoot = graphlib.alg.postorder(graph, [rootNodeId]);
|
|
167682
|
+
const nodeIds = graph.nodes();
|
|
167683
|
+
assert(JSON.stringify(nodeIds.sort()) === JSON.stringify(reachableFromRoot.sort()), 'not all graph nodes are reachable from root');
|
|
167684
|
+
const pkgIds = Object.keys(pkgs);
|
|
167685
|
+
const pkgsWithoutInstances = pkgIds.filter((pkgId) => !pkgNodes[pkgId] || pkgNodes[pkgId].size === 0);
|
|
167686
|
+
assert(pkgsWithoutInstances.length === 0, 'not all pkgs have instance nodes');
|
|
167687
|
+
}
|
|
167688
|
+
exports.validateGraph = validateGraph;
|
|
167689
|
+
//# sourceMappingURL=validate-graph.js.map
|
|
167690
|
+
|
|
167691
|
+
/***/ }),
|
|
167692
|
+
|
|
167693
|
+
/***/ 44529:
|
|
167694
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167695
|
+
|
|
167696
|
+
"use strict";
|
|
167697
|
+
|
|
167698
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167699
|
+
exports.dfs = void 0;
|
|
167700
|
+
const each = __webpack_require__(43590);
|
|
167701
|
+
/*
|
|
167702
|
+
* A helper that preforms a pre- or post-order traversal on the input graph
|
|
167703
|
+
* and returns the nodes in the order they were visited. If the graph is
|
|
167704
|
+
* undirected then this algorithm will navigate using neighbors. If the graph
|
|
167705
|
+
* is directed then this algorithm will navigate using successors.
|
|
167706
|
+
*
|
|
167707
|
+
* Order must be one of "pre" or "post".
|
|
167708
|
+
*/
|
|
167709
|
+
function dfs(g, vs, order) {
|
|
167710
|
+
if (!Array.isArray(vs)) {
|
|
167711
|
+
vs = [vs];
|
|
167712
|
+
}
|
|
167713
|
+
const navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);
|
|
167714
|
+
const acc = [];
|
|
167715
|
+
const visited = {};
|
|
167716
|
+
each(vs, (v) => {
|
|
167717
|
+
if (!g.hasNode(v)) {
|
|
167718
|
+
throw new Error('Graph does not have node: ' + v);
|
|
167719
|
+
}
|
|
167720
|
+
doDfs(g, v, order === 'post', visited, navigation, acc);
|
|
167721
|
+
});
|
|
167722
|
+
return acc;
|
|
167723
|
+
}
|
|
167724
|
+
exports.dfs = dfs;
|
|
167725
|
+
function doDfs(g, v, postorder, visited, navigation, acc) {
|
|
167726
|
+
if (!(v in visited)) {
|
|
167727
|
+
visited[v] = true;
|
|
167728
|
+
if (!postorder) {
|
|
167729
|
+
acc.push(v);
|
|
167730
|
+
}
|
|
167731
|
+
each(navigation(v), function (w) {
|
|
167732
|
+
doDfs(g, w, postorder, visited, navigation, acc);
|
|
167733
|
+
});
|
|
167734
|
+
if (postorder) {
|
|
167735
|
+
acc.push(v);
|
|
167736
|
+
}
|
|
167737
|
+
}
|
|
167738
|
+
}
|
|
167739
|
+
//# sourceMappingURL=dfs.js.map
|
|
167740
|
+
|
|
167741
|
+
/***/ }),
|
|
167742
|
+
|
|
167743
|
+
/***/ 65608:
|
|
167744
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167745
|
+
|
|
167746
|
+
"use strict";
|
|
167747
|
+
|
|
167748
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167749
|
+
exports.isAcyclic = void 0;
|
|
167750
|
+
const topsort_1 = __webpack_require__(45706);
|
|
167751
|
+
function isAcyclic(g) {
|
|
167752
|
+
try {
|
|
167753
|
+
(0, topsort_1.topsort)(g);
|
|
167754
|
+
}
|
|
167755
|
+
catch (e) {
|
|
167756
|
+
if (e instanceof topsort_1.CycleException) {
|
|
167757
|
+
return false;
|
|
167758
|
+
}
|
|
167759
|
+
throw e;
|
|
167760
|
+
}
|
|
167761
|
+
return true;
|
|
167762
|
+
}
|
|
167763
|
+
exports.isAcyclic = isAcyclic;
|
|
167764
|
+
//# sourceMappingURL=is-acyclic.js.map
|
|
167765
|
+
|
|
167766
|
+
/***/ }),
|
|
167767
|
+
|
|
167768
|
+
/***/ 96835:
|
|
167769
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167770
|
+
|
|
167771
|
+
"use strict";
|
|
167772
|
+
|
|
167773
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167774
|
+
exports.postorder = void 0;
|
|
167775
|
+
const dfs_1 = __webpack_require__(44529);
|
|
167776
|
+
function postorder(g, vs) {
|
|
167777
|
+
return (0, dfs_1.dfs)(g, vs, 'post');
|
|
167778
|
+
}
|
|
167779
|
+
exports.postorder = postorder;
|
|
167780
|
+
//# sourceMappingURL=postorder.js.map
|
|
167781
|
+
|
|
167782
|
+
/***/ }),
|
|
167783
|
+
|
|
167784
|
+
/***/ 45706:
|
|
167785
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167786
|
+
|
|
167787
|
+
"use strict";
|
|
167788
|
+
|
|
167789
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167790
|
+
exports.CycleException = exports.topsort = void 0;
|
|
167791
|
+
const each = __webpack_require__(43590);
|
|
167792
|
+
const size = __webpack_require__(27946);
|
|
167793
|
+
function topsort(g) {
|
|
167794
|
+
const visited = {};
|
|
167795
|
+
const stack = {};
|
|
167796
|
+
const results = [];
|
|
167797
|
+
function visit(node) {
|
|
167798
|
+
if (node in stack) {
|
|
167799
|
+
throw new CycleException();
|
|
167800
|
+
}
|
|
167801
|
+
if (!(node in visited)) {
|
|
167802
|
+
stack[node] = true;
|
|
167803
|
+
visited[node] = true;
|
|
167804
|
+
each(g.predecessors(node), visit);
|
|
167805
|
+
delete stack[node];
|
|
167806
|
+
results.push(node);
|
|
167807
|
+
}
|
|
167808
|
+
}
|
|
167809
|
+
each(g.sinks(), visit);
|
|
167810
|
+
if (size(visited) !== g.nodeCount()) {
|
|
167811
|
+
throw new CycleException();
|
|
167812
|
+
}
|
|
167813
|
+
return results;
|
|
167814
|
+
}
|
|
167815
|
+
exports.topsort = topsort;
|
|
167816
|
+
class CycleException extends Error {
|
|
167817
|
+
}
|
|
167818
|
+
exports.CycleException = CycleException;
|
|
167819
|
+
//# sourceMappingURL=topsort.js.map
|
|
167820
|
+
|
|
167821
|
+
/***/ }),
|
|
167822
|
+
|
|
167823
|
+
/***/ 8529:
|
|
167824
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
167825
|
+
|
|
167826
|
+
"use strict";
|
|
167827
|
+
|
|
167828
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167829
|
+
exports.Graph = void 0;
|
|
167830
|
+
/* eslint-disable prefer-rest-params */
|
|
167831
|
+
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
167832
|
+
const constant = __webpack_require__(4254);
|
|
167833
|
+
const each = __webpack_require__(43590);
|
|
167834
|
+
const _filter = __webpack_require__(43590);
|
|
167835
|
+
const isEmpty = __webpack_require__(99245);
|
|
167836
|
+
const isFunction = __webpack_require__(98423);
|
|
167837
|
+
const isUndefined = __webpack_require__(28801);
|
|
167838
|
+
const reduce = __webpack_require__(34766);
|
|
167839
|
+
const union = __webpack_require__(96744);
|
|
167840
|
+
const values = __webpack_require__(17720);
|
|
167841
|
+
const DEFAULT_EDGE_NAME = '\x00';
|
|
167842
|
+
const GRAPH_NODE = '\x00';
|
|
167843
|
+
const EDGE_KEY_DELIM = '\x01';
|
|
167844
|
+
// Implementation notes:
|
|
167845
|
+
//
|
|
167846
|
+
// * Node id query functions should return string ids for the nodes
|
|
167847
|
+
// * Edge id query functions should return an "edgeObj", edge object, that is
|
|
167848
|
+
// composed of enough information to uniquely identify an edge: {v, w, name}.
|
|
167849
|
+
// * Internally we use an "edgeId", a stringified form of the edgeObj, to
|
|
167850
|
+
// reference edges. This is because we need a performant way to look these
|
|
167851
|
+
// edges up and, object properties, which have string keys, are the closest
|
|
167852
|
+
// we're going to get to a performant hashtable in JavaScript.
|
|
167853
|
+
class Graph {
|
|
167854
|
+
constructor(opts) {
|
|
167855
|
+
var _a, _b, _c;
|
|
167856
|
+
/* Number of nodes in the graph. Should only be changed by the implementation. */
|
|
167857
|
+
this._nodeCount = 0;
|
|
167858
|
+
/* Number of edges in the graph. Should only be changed by the implementation. */
|
|
167859
|
+
this._edgeCount = 0;
|
|
167860
|
+
this._isDirected = (_a = opts === null || opts === void 0 ? void 0 : opts.directed) !== null && _a !== void 0 ? _a : true;
|
|
167861
|
+
this._isMultigraph = (_b = opts === null || opts === void 0 ? void 0 : opts.multigraph) !== null && _b !== void 0 ? _b : false;
|
|
167862
|
+
this._isCompound = (_c = opts === null || opts === void 0 ? void 0 : opts.compound) !== null && _c !== void 0 ? _c : false;
|
|
167863
|
+
// Label for the graph itself
|
|
167864
|
+
this._label = undefined;
|
|
167865
|
+
// Defaults to be set when creating a new node
|
|
167866
|
+
this._defaultNodeLabelFn = constant(undefined);
|
|
167867
|
+
// Defaults to be set when creating a new edge
|
|
167868
|
+
this._defaultEdgeLabelFn = constant(undefined);
|
|
167869
|
+
// v -> label
|
|
167870
|
+
this._nodes = {};
|
|
167871
|
+
if (this._isCompound) {
|
|
167872
|
+
// v -> parent
|
|
167873
|
+
this._parent = {};
|
|
167874
|
+
// v -> children
|
|
167875
|
+
this._children = {};
|
|
167876
|
+
this._children[GRAPH_NODE] = {};
|
|
167877
|
+
}
|
|
167878
|
+
// v -> edgeObj
|
|
167879
|
+
this._in = {};
|
|
167880
|
+
// u -> v -> Number
|
|
167881
|
+
this._preds = {};
|
|
167882
|
+
// v -> edgeObj
|
|
167883
|
+
this._out = {};
|
|
167884
|
+
// v -> w -> Number
|
|
167885
|
+
this._sucs = {};
|
|
167886
|
+
// e -> edgeObj
|
|
167887
|
+
this._edgeObjs = {};
|
|
167888
|
+
// e -> label
|
|
167889
|
+
this._edgeLabels = {};
|
|
167890
|
+
}
|
|
167891
|
+
/* === Graph functions ========= */
|
|
167892
|
+
isDirected() {
|
|
167893
|
+
return this._isDirected;
|
|
167894
|
+
}
|
|
167895
|
+
isMultigraph() {
|
|
167896
|
+
return this._isMultigraph;
|
|
167897
|
+
}
|
|
167898
|
+
isCompound() {
|
|
167899
|
+
return this._isCompound;
|
|
167900
|
+
}
|
|
167901
|
+
setGraph(label) {
|
|
167902
|
+
this._label = label;
|
|
167903
|
+
return this;
|
|
167904
|
+
}
|
|
167905
|
+
graph() {
|
|
167906
|
+
return this._label;
|
|
167907
|
+
}
|
|
167908
|
+
/* === Node functions ========== */
|
|
167909
|
+
setDefaultNodeLabel(newDefault) {
|
|
167910
|
+
if (!isFunction(newDefault)) {
|
|
167911
|
+
newDefault = constant(newDefault);
|
|
167912
|
+
}
|
|
167913
|
+
this._defaultNodeLabelFn = newDefault;
|
|
167914
|
+
return this;
|
|
167915
|
+
}
|
|
167916
|
+
nodeCount() {
|
|
167917
|
+
return this._nodeCount;
|
|
167918
|
+
}
|
|
167919
|
+
nodes() {
|
|
167920
|
+
return Object.keys(this._nodes);
|
|
167921
|
+
}
|
|
167922
|
+
sources() {
|
|
167923
|
+
const self = this;
|
|
167924
|
+
return _filter(this.nodes(), function (v) {
|
|
167925
|
+
return isEmpty(self._in[v]);
|
|
167926
|
+
});
|
|
167927
|
+
}
|
|
167928
|
+
sinks() {
|
|
167929
|
+
const self = this;
|
|
167930
|
+
return _filter(this.nodes(), function (v) {
|
|
167931
|
+
return isEmpty(self._out[v]);
|
|
167932
|
+
});
|
|
167933
|
+
}
|
|
167934
|
+
setNodes(vs, value) {
|
|
167935
|
+
const args = arguments;
|
|
167936
|
+
const self = this;
|
|
167937
|
+
each(vs, function (v) {
|
|
167938
|
+
if (args.length > 1) {
|
|
167939
|
+
self.setNode(v, value);
|
|
167940
|
+
}
|
|
167941
|
+
else {
|
|
167942
|
+
self.setNode(v);
|
|
167943
|
+
}
|
|
167944
|
+
});
|
|
167945
|
+
return this;
|
|
167946
|
+
}
|
|
167947
|
+
setNode(v, value) {
|
|
167948
|
+
if (v in this._nodes) {
|
|
167949
|
+
if (arguments.length > 1) {
|
|
167950
|
+
this._nodes[v] = value;
|
|
167951
|
+
}
|
|
167952
|
+
return this;
|
|
167953
|
+
}
|
|
167954
|
+
this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
|
|
167955
|
+
if (this._isCompound) {
|
|
167956
|
+
this._parent[v] = GRAPH_NODE;
|
|
167957
|
+
this._children[v] = {};
|
|
167958
|
+
this._children[GRAPH_NODE][v] = true;
|
|
167959
|
+
}
|
|
167960
|
+
this._in[v] = {};
|
|
167961
|
+
this._preds[v] = {};
|
|
167962
|
+
this._out[v] = {};
|
|
167963
|
+
this._sucs[v] = {};
|
|
167964
|
+
++this._nodeCount;
|
|
167965
|
+
return this;
|
|
167966
|
+
}
|
|
167967
|
+
node(v) {
|
|
167968
|
+
return this._nodes[v];
|
|
167969
|
+
}
|
|
167970
|
+
hasNode(v) {
|
|
167971
|
+
return v in this._nodes;
|
|
167972
|
+
}
|
|
167973
|
+
removeNode(v) {
|
|
167974
|
+
const self = this;
|
|
167975
|
+
if (v in this._nodes) {
|
|
167976
|
+
const removeEdge = function (e) {
|
|
167977
|
+
self.removeEdge(self._edgeObjs[e]);
|
|
167978
|
+
};
|
|
167979
|
+
delete this._nodes[v];
|
|
167980
|
+
if (this._isCompound) {
|
|
167981
|
+
this._removeFromParentsChildList(v);
|
|
167982
|
+
delete this._parent[v];
|
|
167983
|
+
each(this.children(v), function (child) {
|
|
167984
|
+
self.setParent(child);
|
|
167985
|
+
});
|
|
167986
|
+
delete this._children[v];
|
|
167987
|
+
}
|
|
167988
|
+
each(Object.keys(this._in[v]), removeEdge);
|
|
167989
|
+
delete this._in[v];
|
|
167990
|
+
delete this._preds[v];
|
|
167991
|
+
each(Object.keys(this._out[v]), removeEdge);
|
|
167992
|
+
delete this._out[v];
|
|
167993
|
+
delete this._sucs[v];
|
|
167994
|
+
--this._nodeCount;
|
|
167995
|
+
}
|
|
167996
|
+
return this;
|
|
167997
|
+
}
|
|
167998
|
+
setParent(v, parent) {
|
|
167999
|
+
if (!this._isCompound) {
|
|
168000
|
+
throw new Error('Cannot set parent in a non-compound graph');
|
|
168001
|
+
}
|
|
168002
|
+
if (isUndefined(parent)) {
|
|
168003
|
+
parent = GRAPH_NODE;
|
|
168004
|
+
}
|
|
168005
|
+
else {
|
|
168006
|
+
// Coerce parent to string
|
|
168007
|
+
parent += '';
|
|
168008
|
+
for (let ancestor = parent; !isUndefined(ancestor); ancestor = this.parent(ancestor)) {
|
|
168009
|
+
if (ancestor === v) {
|
|
168010
|
+
throw new Error('Setting ' +
|
|
168011
|
+
parent +
|
|
168012
|
+
' as parent of ' +
|
|
168013
|
+
v +
|
|
168014
|
+
' would create a cycle');
|
|
168015
|
+
}
|
|
168016
|
+
}
|
|
168017
|
+
this.setNode(parent);
|
|
168018
|
+
}
|
|
168019
|
+
this.setNode(v);
|
|
168020
|
+
this._removeFromParentsChildList(v);
|
|
168021
|
+
this._parent[v] = parent;
|
|
168022
|
+
this._children[parent][v] = true;
|
|
168023
|
+
return this;
|
|
168024
|
+
}
|
|
168025
|
+
_removeFromParentsChildList(v) {
|
|
168026
|
+
delete this._children[this._parent[v]][v];
|
|
168027
|
+
}
|
|
168028
|
+
parent(v) {
|
|
168029
|
+
if (this._isCompound) {
|
|
168030
|
+
const parent = this._parent[v];
|
|
168031
|
+
if (parent !== GRAPH_NODE) {
|
|
168032
|
+
return parent;
|
|
168033
|
+
}
|
|
168034
|
+
}
|
|
168035
|
+
}
|
|
168036
|
+
children(v) {
|
|
168037
|
+
if (isUndefined(v)) {
|
|
168038
|
+
v = GRAPH_NODE;
|
|
168039
|
+
}
|
|
168040
|
+
if (this._isCompound) {
|
|
168041
|
+
const children = this._children[v];
|
|
168042
|
+
if (children) {
|
|
168043
|
+
return Object.keys(children);
|
|
168044
|
+
}
|
|
168045
|
+
}
|
|
168046
|
+
else if (v === GRAPH_NODE) {
|
|
168047
|
+
return this.nodes();
|
|
168048
|
+
}
|
|
168049
|
+
else if (this.hasNode(v)) {
|
|
168050
|
+
return [];
|
|
168051
|
+
}
|
|
168052
|
+
}
|
|
168053
|
+
predecessors(v) {
|
|
168054
|
+
const predsV = this._preds[v];
|
|
168055
|
+
if (predsV) {
|
|
168056
|
+
return Object.keys(predsV);
|
|
168057
|
+
}
|
|
168058
|
+
}
|
|
168059
|
+
successors(v) {
|
|
168060
|
+
const sucsV = this._sucs[v];
|
|
168061
|
+
if (sucsV) {
|
|
168062
|
+
return Object.keys(sucsV);
|
|
168063
|
+
}
|
|
168064
|
+
}
|
|
168065
|
+
neighbors(v) {
|
|
168066
|
+
const preds = this.predecessors(v);
|
|
168067
|
+
if (preds) {
|
|
168068
|
+
return union(preds, this.successors(v));
|
|
168069
|
+
}
|
|
168070
|
+
}
|
|
168071
|
+
isLeaf(v) {
|
|
168072
|
+
let neighbors;
|
|
168073
|
+
if (this.isDirected()) {
|
|
168074
|
+
neighbors = this.successors(v);
|
|
168075
|
+
}
|
|
168076
|
+
else {
|
|
168077
|
+
neighbors = this.neighbors(v);
|
|
168078
|
+
}
|
|
168079
|
+
return neighbors.length === 0;
|
|
168080
|
+
}
|
|
168081
|
+
filterNodes(filter) {
|
|
168082
|
+
const copy = new Graph({
|
|
168083
|
+
directed: this._isDirected,
|
|
168084
|
+
multigraph: this._isMultigraph,
|
|
168085
|
+
compound: this._isCompound,
|
|
168086
|
+
});
|
|
168087
|
+
copy.setGraph(this.graph());
|
|
168088
|
+
const self = this;
|
|
168089
|
+
each(this._nodes, function (value, v) {
|
|
168090
|
+
if (filter(v)) {
|
|
168091
|
+
copy.setNode(v, value);
|
|
168092
|
+
}
|
|
168093
|
+
});
|
|
168094
|
+
each(this._edgeObjs, function (e) {
|
|
168095
|
+
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
|
|
168096
|
+
copy.setEdge(e, self.edge(e));
|
|
168097
|
+
}
|
|
168098
|
+
});
|
|
168099
|
+
const parents = {};
|
|
168100
|
+
function findParent(v) {
|
|
168101
|
+
const parent = self.parent(v);
|
|
168102
|
+
if (parent === undefined || copy.hasNode(parent)) {
|
|
168103
|
+
parents[v] = parent;
|
|
168104
|
+
return parent;
|
|
168105
|
+
}
|
|
168106
|
+
else if (parent in parents) {
|
|
168107
|
+
return parents[parent];
|
|
168108
|
+
}
|
|
168109
|
+
else {
|
|
168110
|
+
return findParent(parent);
|
|
168111
|
+
}
|
|
168112
|
+
}
|
|
168113
|
+
if (this._isCompound) {
|
|
168114
|
+
each(copy.nodes(), function (v) {
|
|
168115
|
+
copy.setParent(v, findParent(v));
|
|
168116
|
+
});
|
|
168117
|
+
}
|
|
168118
|
+
return copy;
|
|
168119
|
+
}
|
|
168120
|
+
/* === Edge functions ========== */
|
|
168121
|
+
setDefaultEdgeLabel(newDefault) {
|
|
168122
|
+
if (!isFunction(newDefault)) {
|
|
168123
|
+
newDefault = constant(newDefault);
|
|
168124
|
+
}
|
|
168125
|
+
this._defaultEdgeLabelFn = newDefault;
|
|
168126
|
+
return this;
|
|
168127
|
+
}
|
|
168128
|
+
edgeCount() {
|
|
168129
|
+
return this._edgeCount;
|
|
168130
|
+
}
|
|
168131
|
+
edges() {
|
|
168132
|
+
return values(this._edgeObjs);
|
|
168133
|
+
}
|
|
168134
|
+
setPath(vs, value) {
|
|
168135
|
+
const self = this;
|
|
168136
|
+
const args = arguments;
|
|
168137
|
+
reduce(vs, function (v, w) {
|
|
168138
|
+
if (args.length > 1) {
|
|
168139
|
+
self.setEdge(v, w, value);
|
|
168140
|
+
}
|
|
168141
|
+
else {
|
|
168142
|
+
self.setEdge(v, w);
|
|
168143
|
+
}
|
|
168144
|
+
return w;
|
|
168145
|
+
});
|
|
168146
|
+
return this;
|
|
168147
|
+
}
|
|
168148
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
168149
|
+
setEdge(...args) {
|
|
168150
|
+
let v, w, name, value;
|
|
168151
|
+
let valueSpecified = false;
|
|
168152
|
+
const arg0 = arguments[0];
|
|
168153
|
+
if (typeof arg0 === 'object' && arg0 !== null && 'v' in arg0) {
|
|
168154
|
+
v = arg0.v;
|
|
168155
|
+
w = arg0.w;
|
|
168156
|
+
name = arg0.name;
|
|
168157
|
+
if (arguments.length === 2) {
|
|
168158
|
+
value = arguments[1];
|
|
168159
|
+
valueSpecified = true;
|
|
168160
|
+
}
|
|
168161
|
+
}
|
|
168162
|
+
else {
|
|
168163
|
+
v = arg0;
|
|
168164
|
+
w = arguments[1];
|
|
168165
|
+
name = arguments[3];
|
|
168166
|
+
if (arguments.length > 2) {
|
|
168167
|
+
value = arguments[2];
|
|
168168
|
+
valueSpecified = true;
|
|
168169
|
+
}
|
|
168170
|
+
}
|
|
168171
|
+
v = '' + v;
|
|
168172
|
+
w = '' + w;
|
|
168173
|
+
if (!isUndefined(name)) {
|
|
168174
|
+
name = '' + name;
|
|
168175
|
+
}
|
|
168176
|
+
const e = edgeArgsToId(this._isDirected, v, w, name);
|
|
168177
|
+
if (e in this._edgeLabels) {
|
|
168178
|
+
if (valueSpecified) {
|
|
168179
|
+
this._edgeLabels[e] = value;
|
|
168180
|
+
}
|
|
168181
|
+
return this;
|
|
168182
|
+
}
|
|
168183
|
+
if (!isUndefined(name) && !this._isMultigraph) {
|
|
168184
|
+
throw new Error('Cannot set a named edge when isMultigraph = false');
|
|
168185
|
+
}
|
|
168186
|
+
// It didn't exist, so we need to create it.
|
|
168187
|
+
// First ensure the nodes exist.
|
|
168188
|
+
this.setNode(v);
|
|
168189
|
+
this.setNode(w);
|
|
168190
|
+
this._edgeLabels[e] = valueSpecified
|
|
168191
|
+
? value
|
|
168192
|
+
: this._defaultEdgeLabelFn(v, w, name);
|
|
168193
|
+
const edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
|
|
168194
|
+
// Ensure we add undirected edges in a consistent way.
|
|
168195
|
+
v = edgeObj.v;
|
|
168196
|
+
w = edgeObj.w;
|
|
168197
|
+
Object.freeze(edgeObj);
|
|
168198
|
+
this._edgeObjs[e] = edgeObj;
|
|
168199
|
+
incrementOrInitEntry(this._preds[w], v);
|
|
168200
|
+
incrementOrInitEntry(this._sucs[v], w);
|
|
168201
|
+
this._in[w][e] = edgeObj;
|
|
168202
|
+
this._out[v][e] = edgeObj;
|
|
168203
|
+
this._edgeCount++;
|
|
168204
|
+
return this;
|
|
168205
|
+
}
|
|
168206
|
+
edge(v, w, name) {
|
|
168207
|
+
const e = arguments.length === 1
|
|
168208
|
+
? edgeObjToId(this._isDirected, arguments[0])
|
|
168209
|
+
: edgeArgsToId(this._isDirected, v, w, name);
|
|
168210
|
+
return this._edgeLabels[e];
|
|
168211
|
+
}
|
|
168212
|
+
hasEdge(v, w, name) {
|
|
168213
|
+
const e = arguments.length === 1
|
|
168214
|
+
? edgeObjToId(this._isDirected, arguments[0])
|
|
168215
|
+
: edgeArgsToId(this._isDirected, v, w, name);
|
|
168216
|
+
return e in this._edgeLabels;
|
|
168217
|
+
}
|
|
168218
|
+
removeEdge(v, w, name) {
|
|
168219
|
+
const e = arguments.length === 1
|
|
168220
|
+
? edgeObjToId(this._isDirected, arguments[0])
|
|
168221
|
+
: edgeArgsToId(this._isDirected, v, w, name);
|
|
168222
|
+
const edge = this._edgeObjs[e];
|
|
168223
|
+
if (edge) {
|
|
168224
|
+
v = edge.v;
|
|
168225
|
+
w = edge.w;
|
|
168226
|
+
delete this._edgeLabels[e];
|
|
168227
|
+
delete this._edgeObjs[e];
|
|
168228
|
+
decrementOrRemoveEntry(this._preds[w], v);
|
|
168229
|
+
decrementOrRemoveEntry(this._sucs[v], w);
|
|
168230
|
+
delete this._in[w][e];
|
|
168231
|
+
delete this._out[v][e];
|
|
168232
|
+
this._edgeCount--;
|
|
168233
|
+
}
|
|
168234
|
+
return this;
|
|
168235
|
+
}
|
|
168236
|
+
inEdges(v, u) {
|
|
168237
|
+
const inV = this._in[v];
|
|
168238
|
+
if (inV) {
|
|
168239
|
+
const edges = values(inV);
|
|
168240
|
+
if (!u) {
|
|
168241
|
+
return edges;
|
|
168242
|
+
}
|
|
168243
|
+
return _filter(edges, function (edge) {
|
|
168244
|
+
return edge.v === u;
|
|
168245
|
+
});
|
|
168246
|
+
}
|
|
168247
|
+
}
|
|
168248
|
+
outEdges(v, w) {
|
|
168249
|
+
const outV = this._out[v];
|
|
168250
|
+
if (outV) {
|
|
168251
|
+
const edges = values(outV);
|
|
168252
|
+
if (!w) {
|
|
168253
|
+
return edges;
|
|
168254
|
+
}
|
|
168255
|
+
return _filter(edges, function (edge) {
|
|
168256
|
+
return edge.w === w;
|
|
168257
|
+
});
|
|
168258
|
+
}
|
|
168259
|
+
}
|
|
168260
|
+
nodeEdges(v, w) {
|
|
168261
|
+
const inEdges = this.inEdges(v, w);
|
|
168262
|
+
if (inEdges) {
|
|
168263
|
+
return inEdges.concat(this.outEdges(v, w));
|
|
168264
|
+
}
|
|
168265
|
+
}
|
|
168266
|
+
}
|
|
168267
|
+
exports.Graph = Graph;
|
|
168268
|
+
function incrementOrInitEntry(map, k) {
|
|
168269
|
+
if (map[k]) {
|
|
168270
|
+
map[k]++;
|
|
168271
|
+
}
|
|
168272
|
+
else {
|
|
168273
|
+
map[k] = 1;
|
|
168274
|
+
}
|
|
168275
|
+
}
|
|
168276
|
+
function decrementOrRemoveEntry(map, k) {
|
|
168277
|
+
if (!--map[k]) {
|
|
168278
|
+
delete map[k];
|
|
168279
|
+
}
|
|
168280
|
+
}
|
|
168281
|
+
function edgeArgsToId(isDirected, v_, w_, name) {
|
|
168282
|
+
let v = '' + v_;
|
|
168283
|
+
let w = '' + w_;
|
|
168284
|
+
if (!isDirected && v > w) {
|
|
168285
|
+
const tmp = v;
|
|
168286
|
+
v = w;
|
|
168287
|
+
w = tmp;
|
|
168288
|
+
}
|
|
168289
|
+
return (v +
|
|
168290
|
+
EDGE_KEY_DELIM +
|
|
168291
|
+
w +
|
|
168292
|
+
EDGE_KEY_DELIM +
|
|
168293
|
+
(isUndefined(name) ? DEFAULT_EDGE_NAME : name));
|
|
168294
|
+
}
|
|
168295
|
+
function edgeArgsToObj(isDirected, v_, w_, name) {
|
|
168296
|
+
let v = '' + v_;
|
|
168297
|
+
let w = '' + w_;
|
|
168298
|
+
if (!isDirected && v > w) {
|
|
168299
|
+
const tmp = v;
|
|
168300
|
+
v = w;
|
|
168301
|
+
w = tmp;
|
|
168302
|
+
}
|
|
168303
|
+
const edgeObj = { v: v, w: w };
|
|
168304
|
+
if (name) {
|
|
168305
|
+
edgeObj.name = name;
|
|
168306
|
+
}
|
|
168307
|
+
return edgeObj;
|
|
168308
|
+
}
|
|
168309
|
+
function edgeObjToId(isDirected, edgeObj) {
|
|
168310
|
+
return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
|
|
168311
|
+
}
|
|
168312
|
+
//# sourceMappingURL=graph.js.map
|
|
168313
|
+
|
|
168314
|
+
/***/ }),
|
|
168315
|
+
|
|
168316
|
+
/***/ 82107:
|
|
168317
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
168318
|
+
|
|
168319
|
+
"use strict";
|
|
168320
|
+
|
|
168321
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168322
|
+
exports.alg = exports.Graph = void 0;
|
|
168323
|
+
var graph_1 = __webpack_require__(8529);
|
|
168324
|
+
Object.defineProperty(exports, "Graph", ({ enumerable: true, get: function () { return graph_1.Graph; } }));
|
|
168325
|
+
const is_acyclic_1 = __webpack_require__(65608);
|
|
168326
|
+
const postorder_1 = __webpack_require__(96835);
|
|
168327
|
+
exports.alg = {
|
|
168328
|
+
isAcyclic: is_acyclic_1.isAcyclic,
|
|
168329
|
+
postorder: postorder_1.postorder,
|
|
168330
|
+
};
|
|
168331
|
+
//# sourceMappingURL=index.js.map
|
|
168332
|
+
|
|
168333
|
+
/***/ }),
|
|
168334
|
+
|
|
168335
|
+
/***/ 53789:
|
|
168336
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
168337
|
+
|
|
168338
|
+
"use strict";
|
|
168339
|
+
|
|
168340
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168341
|
+
exports.legacy = exports.Errors = exports.DepGraphBuilder = exports.createFromJSON = void 0;
|
|
168342
|
+
var create_from_json_1 = __webpack_require__(28391);
|
|
168343
|
+
Object.defineProperty(exports, "createFromJSON", ({ enumerable: true, get: function () { return create_from_json_1.createFromJSON; } }));
|
|
168344
|
+
var builder_1 = __webpack_require__(20922);
|
|
168345
|
+
Object.defineProperty(exports, "DepGraphBuilder", ({ enumerable: true, get: function () { return builder_1.DepGraphBuilder; } }));
|
|
168346
|
+
const Errors = __webpack_require__(50481);
|
|
168347
|
+
exports.Errors = Errors;
|
|
168348
|
+
const legacy = __webpack_require__(15195);
|
|
168349
|
+
exports.legacy = legacy;
|
|
168350
|
+
//# sourceMappingURL=index.js.map
|
|
168351
|
+
|
|
168352
|
+
/***/ }),
|
|
168353
|
+
|
|
168354
|
+
/***/ 37680:
|
|
168355
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
168356
|
+
|
|
168357
|
+
"use strict";
|
|
168358
|
+
|
|
168359
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168360
|
+
exports.partitionCycles = exports.getCycle = void 0;
|
|
168361
|
+
function getCycle(ancestors, nodeId) {
|
|
168362
|
+
if (!ancestors.includes(nodeId)) {
|
|
168363
|
+
return null;
|
|
168364
|
+
}
|
|
168365
|
+
// first item is where the cycle starts and ends.
|
|
168366
|
+
return ancestors.slice(ancestors.indexOf(nodeId));
|
|
168367
|
+
}
|
|
168368
|
+
exports.getCycle = getCycle;
|
|
168369
|
+
function partitionCycles(nodeId, allCyclesTheNodeIsPartOf) {
|
|
168370
|
+
const cyclesStartWithThisNode = [];
|
|
168371
|
+
const cyclesWithThisNode = [];
|
|
168372
|
+
for (const cycle of allCyclesTheNodeIsPartOf) {
|
|
168373
|
+
const nodeStartsCycle = cycle[0] === nodeId;
|
|
168374
|
+
if (nodeStartsCycle) {
|
|
168375
|
+
cyclesStartWithThisNode.push(cycle);
|
|
168376
|
+
}
|
|
168377
|
+
else {
|
|
168378
|
+
cyclesWithThisNode.push(cycle);
|
|
168379
|
+
}
|
|
168380
|
+
}
|
|
168381
|
+
return { cyclesStartWithThisNode, cyclesWithThisNode };
|
|
168382
|
+
}
|
|
168383
|
+
exports.partitionCycles = partitionCycles;
|
|
168384
|
+
//# sourceMappingURL=cycles.js.map
|
|
168385
|
+
|
|
168386
|
+
/***/ }),
|
|
168387
|
+
|
|
168388
|
+
/***/ 15195:
|
|
168389
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
168390
|
+
|
|
168391
|
+
"use strict";
|
|
168392
|
+
|
|
168393
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168394
|
+
exports.graphToDepTree = exports.depTreeToGraph = void 0;
|
|
168395
|
+
const crypto = __webpack_require__(76417);
|
|
168396
|
+
const event_loop_spinner_1 = __webpack_require__(77158);
|
|
168397
|
+
const builder_1 = __webpack_require__(20922);
|
|
168398
|
+
const objectHash = __webpack_require__(37266);
|
|
168399
|
+
const cycles_1 = __webpack_require__(37680);
|
|
168400
|
+
const memiozation_1 = __webpack_require__(6720);
|
|
168401
|
+
function addLabel(dep, key, value) {
|
|
168402
|
+
if (!dep.labels) {
|
|
168403
|
+
dep.labels = {};
|
|
168404
|
+
}
|
|
168405
|
+
dep.labels[key] = value;
|
|
168406
|
+
}
|
|
168407
|
+
/**
|
|
168408
|
+
* @deprecated Don't use dep trees as an intermediate step, because they are
|
|
168409
|
+
* large structures, resulting in high memory usage and high CPU costs from
|
|
168410
|
+
* serializing / deserializing. Instead, create a graph directly with
|
|
168411
|
+
* {@link DepGraphBuilder}
|
|
168412
|
+
*/
|
|
168413
|
+
async function depTreeToGraph(depTree, pkgManagerName) {
|
|
168414
|
+
const rootPkg = {
|
|
168415
|
+
name: depTree.name,
|
|
168416
|
+
version: depTree.version || undefined,
|
|
168417
|
+
};
|
|
168418
|
+
const pkgManagerInfo = {
|
|
168419
|
+
name: pkgManagerName,
|
|
168420
|
+
};
|
|
168421
|
+
const targetOS = depTree.targetOS;
|
|
168422
|
+
if (targetOS) {
|
|
168423
|
+
pkgManagerInfo.repositories = [
|
|
168424
|
+
{
|
|
168425
|
+
alias: `${targetOS.name}:${targetOS.version}`,
|
|
168426
|
+
},
|
|
168427
|
+
];
|
|
168428
|
+
}
|
|
168429
|
+
const builder = new builder_1.DepGraphBuilder(pkgManagerInfo, rootPkg);
|
|
168430
|
+
await buildGraph(builder, depTree, depTree.name, true);
|
|
168431
|
+
const depGraph = await builder.build();
|
|
168432
|
+
return shortenNodeIds(depGraph);
|
|
168433
|
+
}
|
|
168434
|
+
exports.depTreeToGraph = depTreeToGraph;
|
|
168435
|
+
async function buildGraph(builder, depTree, pkgName, isRoot = false, memoizationMap = new Map()) {
|
|
168436
|
+
if (memoizationMap.has(depTree)) {
|
|
168437
|
+
return memoizationMap.get(depTree);
|
|
168438
|
+
}
|
|
168439
|
+
const getNodeId = (name, version, hashId) => `${name}@${version || ''}|${hashId}`;
|
|
168440
|
+
const depNodesIds = [];
|
|
168441
|
+
const hash = crypto.createHash('sha1');
|
|
168442
|
+
if (depTree.versionProvenance) {
|
|
168443
|
+
hash.update(objectHash(depTree.versionProvenance));
|
|
168444
|
+
}
|
|
168445
|
+
if (depTree.labels) {
|
|
168446
|
+
hash.update(objectHash(depTree.labels));
|
|
168447
|
+
}
|
|
168448
|
+
const deps = depTree.dependencies || {};
|
|
168449
|
+
// filter-out invalid null deps (shouldn't happen - but did...)
|
|
168450
|
+
const depNames = Object.keys(deps).filter((d) => !!deps[d]);
|
|
168451
|
+
for (const depName of depNames.sort()) {
|
|
168452
|
+
const dep = deps[depName];
|
|
168453
|
+
const subtreeHash = await buildGraph(builder, dep, depName, false, memoizationMap);
|
|
168454
|
+
const depPkg = {
|
|
168455
|
+
name: depName,
|
|
168456
|
+
version: dep.version,
|
|
168457
|
+
};
|
|
168458
|
+
const depNodeId = getNodeId(depPkg.name, depPkg.version, subtreeHash);
|
|
168459
|
+
depNodesIds.push(depNodeId);
|
|
168460
|
+
const nodeInfo = {};
|
|
168461
|
+
if (dep.versionProvenance) {
|
|
168462
|
+
nodeInfo.versionProvenance = dep.versionProvenance;
|
|
168463
|
+
}
|
|
168464
|
+
if (dep.labels) {
|
|
168465
|
+
nodeInfo.labels = dep.labels;
|
|
168466
|
+
}
|
|
168467
|
+
builder.addPkgNode(depPkg, depNodeId, nodeInfo);
|
|
168468
|
+
hash.update(depNodeId);
|
|
168469
|
+
}
|
|
168470
|
+
const treeHash = hash.digest('hex');
|
|
168471
|
+
let pkgNodeId;
|
|
168472
|
+
if (isRoot) {
|
|
168473
|
+
pkgNodeId = builder.rootNodeId;
|
|
168474
|
+
}
|
|
168475
|
+
else {
|
|
168476
|
+
// we don't assume depTree has a .name to support output of `npm list --json`
|
|
168477
|
+
const pkg = {
|
|
168478
|
+
name: pkgName,
|
|
168479
|
+
version: depTree.version,
|
|
168480
|
+
};
|
|
168481
|
+
pkgNodeId = getNodeId(pkg.name, pkg.version, treeHash);
|
|
168482
|
+
const nodeInfo = {};
|
|
168483
|
+
if (depTree.versionProvenance) {
|
|
168484
|
+
nodeInfo.versionProvenance = depTree.versionProvenance;
|
|
168485
|
+
}
|
|
168486
|
+
if (depTree.labels) {
|
|
168487
|
+
nodeInfo.labels = depTree.labels;
|
|
168488
|
+
}
|
|
168489
|
+
builder.addPkgNode(pkg, pkgNodeId, nodeInfo);
|
|
168490
|
+
}
|
|
168491
|
+
for (const depNodeId of depNodesIds) {
|
|
168492
|
+
builder.connectDep(pkgNodeId, depNodeId);
|
|
168493
|
+
}
|
|
168494
|
+
if (depNodesIds.length > 0 && event_loop_spinner_1.eventLoopSpinner.isStarving()) {
|
|
168495
|
+
await event_loop_spinner_1.eventLoopSpinner.spin();
|
|
168496
|
+
}
|
|
168497
|
+
memoizationMap.set(depTree, treeHash);
|
|
168498
|
+
return treeHash;
|
|
168499
|
+
}
|
|
168500
|
+
async function shortenNodeIds(depGraph) {
|
|
168501
|
+
const builder = new builder_1.DepGraphBuilder(depGraph.pkgManager, depGraph.rootPkg);
|
|
168502
|
+
const nodesMap = {};
|
|
168503
|
+
// create nodes with shorter ids
|
|
168504
|
+
for (const pkg of depGraph.getPkgs()) {
|
|
168505
|
+
const nodeIds = depGraph.getPkgNodeIds(pkg);
|
|
168506
|
+
for (let i = 0; i < nodeIds.length; i++) {
|
|
168507
|
+
const nodeId = nodeIds[i];
|
|
168508
|
+
if (nodeId === depGraph.rootNodeId) {
|
|
168509
|
+
continue;
|
|
168510
|
+
}
|
|
168511
|
+
const nodeInfo = depGraph.getNode(nodeId);
|
|
168512
|
+
let newNodeId;
|
|
168513
|
+
if (nodeIds.length === 1) {
|
|
168514
|
+
newNodeId = `${trimAfterLastSep(nodeId, '|')}`;
|
|
168515
|
+
}
|
|
168516
|
+
else {
|
|
168517
|
+
newNodeId = `${trimAfterLastSep(nodeId, '|')}|${i + 1}`;
|
|
168518
|
+
}
|
|
168519
|
+
nodesMap[nodeId] = newNodeId;
|
|
168520
|
+
builder.addPkgNode(pkg, newNodeId, nodeInfo);
|
|
168521
|
+
}
|
|
168522
|
+
if (event_loop_spinner_1.eventLoopSpinner.isStarving()) {
|
|
168523
|
+
await event_loop_spinner_1.eventLoopSpinner.spin();
|
|
168524
|
+
}
|
|
168525
|
+
}
|
|
168526
|
+
// connect nodes
|
|
168527
|
+
for (const pkg of depGraph.getPkgs()) {
|
|
168528
|
+
for (const nodeId of depGraph.getPkgNodeIds(pkg)) {
|
|
168529
|
+
for (const depNodeId of depGraph.getNodeDepsNodeIds(nodeId)) {
|
|
168530
|
+
const parentNode = nodesMap[nodeId] || nodeId;
|
|
168531
|
+
const childNode = nodesMap[depNodeId] || depNodeId;
|
|
168532
|
+
builder.connectDep(parentNode, childNode);
|
|
168533
|
+
}
|
|
168534
|
+
}
|
|
168535
|
+
if (event_loop_spinner_1.eventLoopSpinner.isStarving()) {
|
|
168536
|
+
await event_loop_spinner_1.eventLoopSpinner.spin();
|
|
168537
|
+
}
|
|
168538
|
+
}
|
|
168539
|
+
return builder.build();
|
|
168540
|
+
}
|
|
168541
|
+
/**
|
|
168542
|
+
* @deprecated Don't use dep trees. You should adapt your code to use graphs,
|
|
168543
|
+
* and enhance the dep-graph library if there is missing functionality from
|
|
168544
|
+
* the graph structure
|
|
168545
|
+
*/
|
|
168546
|
+
async function graphToDepTree(depGraphInterface, pkgType, opts = { deduplicateWithinTopLevelDeps: false }) {
|
|
168547
|
+
const depGraph = depGraphInterface;
|
|
168548
|
+
const [depTree] = await buildSubtree(depGraph, depGraph.rootNodeId, opts.deduplicateWithinTopLevelDeps ? null : false);
|
|
168549
|
+
depTree.type = depGraph.pkgManager.name;
|
|
168550
|
+
depTree.packageFormatVersion = constructPackageFormatVersion(pkgType);
|
|
168551
|
+
const targetOS = constructTargetOS(depGraph);
|
|
168552
|
+
if (targetOS) {
|
|
168553
|
+
depTree.targetOS = targetOS;
|
|
168554
|
+
}
|
|
168555
|
+
return depTree;
|
|
168556
|
+
}
|
|
168557
|
+
exports.graphToDepTree = graphToDepTree;
|
|
168558
|
+
function constructPackageFormatVersion(pkgType) {
|
|
168559
|
+
if (pkgType === 'maven') {
|
|
168560
|
+
pkgType = 'mvn';
|
|
168561
|
+
}
|
|
168562
|
+
return `${pkgType}:0.0.1`;
|
|
168563
|
+
}
|
|
168564
|
+
function constructTargetOS(depGraph) {
|
|
168565
|
+
if (['apk', 'apt', 'deb', 'rpm', 'linux'].indexOf(depGraph.pkgManager.name) ===
|
|
168566
|
+
-1) {
|
|
168567
|
+
// .targetOS is undefined unless its a linux pkgManager
|
|
168568
|
+
return;
|
|
168569
|
+
}
|
|
168570
|
+
if (!depGraph.pkgManager.repositories ||
|
|
168571
|
+
!depGraph.pkgManager.repositories.length ||
|
|
168572
|
+
!depGraph.pkgManager.repositories[0].alias) {
|
|
168573
|
+
throw new Error('Incomplete .pkgManager, could not create .targetOS');
|
|
168574
|
+
}
|
|
168575
|
+
const [name, version] = depGraph.pkgManager.repositories[0].alias.split(':');
|
|
168576
|
+
return { name, version };
|
|
168577
|
+
}
|
|
168578
|
+
async function buildSubtree(depGraph, nodeId, maybeDeduplicationSet = false, // false = disabled; null = not in deduplication scope yet
|
|
168579
|
+
ancestors = [], memoizationMap = new Map()) {
|
|
168580
|
+
if (!maybeDeduplicationSet) {
|
|
168581
|
+
const memoizedDepTree = (0, memiozation_1.getMemoizedDepTree)(nodeId, ancestors, memoizationMap);
|
|
168582
|
+
if (memoizedDepTree) {
|
|
168583
|
+
return [memoizedDepTree, undefined];
|
|
168584
|
+
}
|
|
168585
|
+
}
|
|
168586
|
+
const isRoot = nodeId === depGraph.rootNodeId;
|
|
168587
|
+
const nodePkg = depGraph.getNodePkg(nodeId);
|
|
168588
|
+
const nodeInfo = depGraph.getNode(nodeId);
|
|
168589
|
+
const depTree = {};
|
|
168590
|
+
depTree.name = nodePkg.name;
|
|
168591
|
+
depTree.version = nodePkg.version;
|
|
168592
|
+
if (nodeInfo.versionProvenance) {
|
|
168593
|
+
depTree.versionProvenance = nodeInfo.versionProvenance;
|
|
168594
|
+
}
|
|
168595
|
+
if (nodeInfo.labels) {
|
|
168596
|
+
depTree.labels = { ...nodeInfo.labels };
|
|
168597
|
+
}
|
|
168598
|
+
const depInstanceIds = depGraph.getNodeDepsNodeIds(nodeId);
|
|
168599
|
+
if (!depInstanceIds || depInstanceIds.length === 0) {
|
|
168600
|
+
memoizationMap.set(nodeId, { depTree });
|
|
168601
|
+
return [depTree, undefined];
|
|
168602
|
+
}
|
|
168603
|
+
const cycle = (0, cycles_1.getCycle)(ancestors, nodeId);
|
|
168604
|
+
if (cycle) {
|
|
168605
|
+
// This node starts a cycle and now it's the second visit.
|
|
168606
|
+
addLabel(depTree, 'pruned', 'cyclic');
|
|
168607
|
+
return [depTree, [cycle]];
|
|
168608
|
+
}
|
|
168609
|
+
if (maybeDeduplicationSet) {
|
|
168610
|
+
if (maybeDeduplicationSet.has(nodeId)) {
|
|
168611
|
+
if (depInstanceIds.length > 0) {
|
|
168612
|
+
addLabel(depTree, 'pruned', 'true');
|
|
168613
|
+
}
|
|
168614
|
+
return [depTree, undefined];
|
|
168615
|
+
}
|
|
168616
|
+
maybeDeduplicationSet.add(nodeId);
|
|
168617
|
+
}
|
|
168618
|
+
const cycles = [];
|
|
168619
|
+
for (const depInstId of depInstanceIds) {
|
|
168620
|
+
// Deduplication of nodes occurs only within a scope of a top-level dependency.
|
|
168621
|
+
// Therefore, every top-level dep gets an independent set to track duplicates.
|
|
168622
|
+
if (isRoot && maybeDeduplicationSet !== false) {
|
|
168623
|
+
maybeDeduplicationSet = new Set();
|
|
168624
|
+
}
|
|
168625
|
+
const [subtree, subtreeCycles] = await buildSubtree(depGraph, depInstId, maybeDeduplicationSet, ancestors.concat(nodeId), memoizationMap);
|
|
168626
|
+
if (subtreeCycles) {
|
|
168627
|
+
for (const cycle of subtreeCycles) {
|
|
168628
|
+
cycles.push(cycle);
|
|
168629
|
+
}
|
|
168630
|
+
}
|
|
168631
|
+
if (!subtree) {
|
|
168632
|
+
continue;
|
|
168633
|
+
}
|
|
168634
|
+
if (!depTree.dependencies) {
|
|
168635
|
+
depTree.dependencies = {};
|
|
168636
|
+
}
|
|
168637
|
+
depTree.dependencies[subtree.name] = subtree;
|
|
168638
|
+
}
|
|
168639
|
+
if (event_loop_spinner_1.eventLoopSpinner.isStarving()) {
|
|
168640
|
+
await event_loop_spinner_1.eventLoopSpinner.spin();
|
|
168641
|
+
}
|
|
168642
|
+
const partitionedCycles = (0, cycles_1.partitionCycles)(nodeId, cycles);
|
|
168643
|
+
(0, memiozation_1.memoize)(nodeId, memoizationMap, depTree, partitionedCycles);
|
|
168644
|
+
return [depTree, partitionedCycles.cyclesWithThisNode];
|
|
168645
|
+
}
|
|
168646
|
+
function trimAfterLastSep(str, sep) {
|
|
168647
|
+
return str.slice(0, str.lastIndexOf(sep));
|
|
168648
|
+
}
|
|
168649
|
+
//# sourceMappingURL=index.js.map
|
|
168650
|
+
|
|
168651
|
+
/***/ }),
|
|
168652
|
+
|
|
168653
|
+
/***/ 6720:
|
|
168654
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
168655
|
+
|
|
168656
|
+
"use strict";
|
|
168657
|
+
|
|
168658
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168659
|
+
exports.getMemoizedDepTree = exports.memoize = void 0;
|
|
168660
|
+
function memoize(nodeId, memoizationMap, depTree, partitionedCycles) {
|
|
168661
|
+
const { cyclesStartWithThisNode, cyclesWithThisNode } = partitionedCycles;
|
|
168662
|
+
if (cyclesStartWithThisNode.length > 0) {
|
|
168663
|
+
const cycleNodeIds = new Set(...cyclesStartWithThisNode);
|
|
168664
|
+
memoizationMap.set(nodeId, { depTree, cycleNodeIds });
|
|
168665
|
+
}
|
|
168666
|
+
else if (cyclesWithThisNode.length === 0) {
|
|
168667
|
+
memoizationMap.set(nodeId, { depTree });
|
|
168668
|
+
}
|
|
168669
|
+
// Don't memoize nodes in cycles (cyclesWithThisNode.length > 0)
|
|
168670
|
+
}
|
|
168671
|
+
exports.memoize = memoize;
|
|
168672
|
+
function getMemoizedDepTree(nodeId, ancestors, memoizationMap) {
|
|
168673
|
+
if (!memoizationMap.has(nodeId))
|
|
168674
|
+
return null;
|
|
168675
|
+
const { depTree, cycleNodeIds } = memoizationMap.get(nodeId);
|
|
168676
|
+
if (!cycleNodeIds)
|
|
168677
|
+
return depTree;
|
|
168678
|
+
const ancestorsArePartOfTheCycle = ancestors.some((nodeId) => cycleNodeIds.has(nodeId));
|
|
168679
|
+
return ancestorsArePartOfTheCycle ? null : depTree;
|
|
168680
|
+
}
|
|
168681
|
+
exports.getMemoizedDepTree = getMemoizedDepTree;
|
|
168682
|
+
//# sourceMappingURL=memiozation.js.map
|
|
168683
|
+
|
|
168684
|
+
/***/ }),
|
|
168685
|
+
|
|
166666
168686
|
/***/ 59572:
|
|
166667
168687
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
166668
168688
|
|
|
@@ -171111,6 +173131,467 @@ const forEachStep = (self, fn, node, thisp) => {
|
|
|
171111
173131
|
module.exports = LRUCache
|
|
171112
173132
|
|
|
171113
173133
|
|
|
173134
|
+
/***/ }),
|
|
173135
|
+
|
|
173136
|
+
/***/ 37266:
|
|
173137
|
+
/***/ ((module, exports, __webpack_require__) => {
|
|
173138
|
+
|
|
173139
|
+
"use strict";
|
|
173140
|
+
|
|
173141
|
+
|
|
173142
|
+
var crypto = __webpack_require__(76417);
|
|
173143
|
+
|
|
173144
|
+
/**
|
|
173145
|
+
* Exported function
|
|
173146
|
+
*
|
|
173147
|
+
* Options:
|
|
173148
|
+
*
|
|
173149
|
+
* - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
|
|
173150
|
+
* - `excludeValues` {true|*false} hash object keys, values ignored
|
|
173151
|
+
* - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
|
|
173152
|
+
* - `ignoreUnknown` {true|*false} ignore unknown object types
|
|
173153
|
+
* - `replacer` optional function that replaces values before hashing
|
|
173154
|
+
* - `respectFunctionProperties` {*true|false} consider function properties when hashing
|
|
173155
|
+
* - `respectFunctionNames` {*true|false} consider 'name' property of functions for hashing
|
|
173156
|
+
* - `respectType` {*true|false} Respect special properties (prototype, constructor)
|
|
173157
|
+
* when hashing to distinguish between types
|
|
173158
|
+
* - `unorderedArrays` {true|*false} Sort all arrays before hashing
|
|
173159
|
+
* - `unorderedSets` {*true|false} Sort `Set` and `Map` instances before hashing
|
|
173160
|
+
* * = default
|
|
173161
|
+
*
|
|
173162
|
+
* @param {object} object value to hash
|
|
173163
|
+
* @param {object} options hashing options
|
|
173164
|
+
* @return {string} hash value
|
|
173165
|
+
* @api public
|
|
173166
|
+
*/
|
|
173167
|
+
exports = module.exports = objectHash;
|
|
173168
|
+
|
|
173169
|
+
function objectHash(object, options){
|
|
173170
|
+
options = applyDefaults(object, options);
|
|
173171
|
+
|
|
173172
|
+
return hash(object, options);
|
|
173173
|
+
}
|
|
173174
|
+
|
|
173175
|
+
/**
|
|
173176
|
+
* Exported sugar methods
|
|
173177
|
+
*
|
|
173178
|
+
* @param {object} object value to hash
|
|
173179
|
+
* @return {string} hash value
|
|
173180
|
+
* @api public
|
|
173181
|
+
*/
|
|
173182
|
+
exports.sha1 = function(object){
|
|
173183
|
+
return objectHash(object);
|
|
173184
|
+
};
|
|
173185
|
+
exports.keys = function(object){
|
|
173186
|
+
return objectHash(object, {excludeValues: true, algorithm: 'sha1', encoding: 'hex'});
|
|
173187
|
+
};
|
|
173188
|
+
exports.MD5 = function(object){
|
|
173189
|
+
return objectHash(object, {algorithm: 'md5', encoding: 'hex'});
|
|
173190
|
+
};
|
|
173191
|
+
exports.keysMD5 = function(object){
|
|
173192
|
+
return objectHash(object, {algorithm: 'md5', encoding: 'hex', excludeValues: true});
|
|
173193
|
+
};
|
|
173194
|
+
|
|
173195
|
+
// Internals
|
|
173196
|
+
var hashes = crypto.getHashes ? crypto.getHashes().slice() : ['sha1', 'md5'];
|
|
173197
|
+
hashes.push('passthrough');
|
|
173198
|
+
var encodings = ['buffer', 'hex', 'binary', 'base64'];
|
|
173199
|
+
|
|
173200
|
+
function applyDefaults(object, sourceOptions){
|
|
173201
|
+
sourceOptions = sourceOptions || {};
|
|
173202
|
+
|
|
173203
|
+
// create a copy rather than mutating
|
|
173204
|
+
var options = {};
|
|
173205
|
+
options.algorithm = sourceOptions.algorithm || 'sha1';
|
|
173206
|
+
options.encoding = sourceOptions.encoding || 'hex';
|
|
173207
|
+
options.excludeValues = sourceOptions.excludeValues ? true : false;
|
|
173208
|
+
options.algorithm = options.algorithm.toLowerCase();
|
|
173209
|
+
options.encoding = options.encoding.toLowerCase();
|
|
173210
|
+
options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true; // default to false
|
|
173211
|
+
options.respectType = sourceOptions.respectType === false ? false : true; // default to true
|
|
173212
|
+
options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
|
|
173213
|
+
options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
|
|
173214
|
+
options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true; // default to false
|
|
173215
|
+
options.unorderedSets = sourceOptions.unorderedSets === false ? false : true; // default to false
|
|
173216
|
+
options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true; // default to true
|
|
173217
|
+
options.replacer = sourceOptions.replacer || undefined;
|
|
173218
|
+
options.excludeKeys = sourceOptions.excludeKeys || undefined;
|
|
173219
|
+
|
|
173220
|
+
if(typeof object === 'undefined') {
|
|
173221
|
+
throw new Error('Object argument required.');
|
|
173222
|
+
}
|
|
173223
|
+
|
|
173224
|
+
// if there is a case-insensitive match in the hashes list, accept it
|
|
173225
|
+
// (i.e. SHA256 for sha256)
|
|
173226
|
+
for (var i = 0; i < hashes.length; ++i) {
|
|
173227
|
+
if (hashes[i].toLowerCase() === options.algorithm.toLowerCase()) {
|
|
173228
|
+
options.algorithm = hashes[i];
|
|
173229
|
+
}
|
|
173230
|
+
}
|
|
173231
|
+
|
|
173232
|
+
if(hashes.indexOf(options.algorithm) === -1){
|
|
173233
|
+
throw new Error('Algorithm "' + options.algorithm + '" not supported. ' +
|
|
173234
|
+
'supported values: ' + hashes.join(', '));
|
|
173235
|
+
}
|
|
173236
|
+
|
|
173237
|
+
if(encodings.indexOf(options.encoding) === -1 &&
|
|
173238
|
+
options.algorithm !== 'passthrough'){
|
|
173239
|
+
throw new Error('Encoding "' + options.encoding + '" not supported. ' +
|
|
173240
|
+
'supported values: ' + encodings.join(', '));
|
|
173241
|
+
}
|
|
173242
|
+
|
|
173243
|
+
return options;
|
|
173244
|
+
}
|
|
173245
|
+
|
|
173246
|
+
/** Check if the given function is a native function */
|
|
173247
|
+
function isNativeFunction(f) {
|
|
173248
|
+
if ((typeof f) !== 'function') {
|
|
173249
|
+
return false;
|
|
173250
|
+
}
|
|
173251
|
+
var exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
|
|
173252
|
+
return exp.exec(Function.prototype.toString.call(f)) != null;
|
|
173253
|
+
}
|
|
173254
|
+
|
|
173255
|
+
function hash(object, options) {
|
|
173256
|
+
var hashingStream;
|
|
173257
|
+
|
|
173258
|
+
if (options.algorithm !== 'passthrough') {
|
|
173259
|
+
hashingStream = crypto.createHash(options.algorithm);
|
|
173260
|
+
} else {
|
|
173261
|
+
hashingStream = new PassThrough();
|
|
173262
|
+
}
|
|
173263
|
+
|
|
173264
|
+
if (typeof hashingStream.write === 'undefined') {
|
|
173265
|
+
hashingStream.write = hashingStream.update;
|
|
173266
|
+
hashingStream.end = hashingStream.update;
|
|
173267
|
+
}
|
|
173268
|
+
|
|
173269
|
+
var hasher = typeHasher(options, hashingStream);
|
|
173270
|
+
hasher.dispatch(object);
|
|
173271
|
+
if (!hashingStream.update) {
|
|
173272
|
+
hashingStream.end('');
|
|
173273
|
+
}
|
|
173274
|
+
|
|
173275
|
+
if (hashingStream.digest) {
|
|
173276
|
+
return hashingStream.digest(options.encoding === 'buffer' ? undefined : options.encoding);
|
|
173277
|
+
}
|
|
173278
|
+
|
|
173279
|
+
var buf = hashingStream.read();
|
|
173280
|
+
if (options.encoding === 'buffer') {
|
|
173281
|
+
return buf;
|
|
173282
|
+
}
|
|
173283
|
+
|
|
173284
|
+
return buf.toString(options.encoding);
|
|
173285
|
+
}
|
|
173286
|
+
|
|
173287
|
+
/**
|
|
173288
|
+
* Expose streaming API
|
|
173289
|
+
*
|
|
173290
|
+
* @param {object} object Value to serialize
|
|
173291
|
+
* @param {object} options Options, as for hash()
|
|
173292
|
+
* @param {object} stream A stream to write the serializiation to
|
|
173293
|
+
* @api public
|
|
173294
|
+
*/
|
|
173295
|
+
exports.writeToStream = function(object, options, stream) {
|
|
173296
|
+
if (typeof stream === 'undefined') {
|
|
173297
|
+
stream = options;
|
|
173298
|
+
options = {};
|
|
173299
|
+
}
|
|
173300
|
+
|
|
173301
|
+
options = applyDefaults(object, options);
|
|
173302
|
+
|
|
173303
|
+
return typeHasher(options, stream).dispatch(object);
|
|
173304
|
+
};
|
|
173305
|
+
|
|
173306
|
+
function typeHasher(options, writeTo, context){
|
|
173307
|
+
context = context || [];
|
|
173308
|
+
var write = function(str) {
|
|
173309
|
+
if (writeTo.update) {
|
|
173310
|
+
return writeTo.update(str, 'utf8');
|
|
173311
|
+
} else {
|
|
173312
|
+
return writeTo.write(str, 'utf8');
|
|
173313
|
+
}
|
|
173314
|
+
};
|
|
173315
|
+
|
|
173316
|
+
return {
|
|
173317
|
+
dispatch: function(value){
|
|
173318
|
+
if (options.replacer) {
|
|
173319
|
+
value = options.replacer(value);
|
|
173320
|
+
}
|
|
173321
|
+
|
|
173322
|
+
var type = typeof value;
|
|
173323
|
+
if (value === null) {
|
|
173324
|
+
type = 'null';
|
|
173325
|
+
}
|
|
173326
|
+
|
|
173327
|
+
//console.log("[DEBUG] Dispatch: ", value, "->", type, " -> ", "_" + type);
|
|
173328
|
+
|
|
173329
|
+
return this['_' + type](value);
|
|
173330
|
+
},
|
|
173331
|
+
_object: function(object) {
|
|
173332
|
+
var pattern = (/\[object (.*)\]/i);
|
|
173333
|
+
var objString = Object.prototype.toString.call(object);
|
|
173334
|
+
var objType = pattern.exec(objString);
|
|
173335
|
+
if (!objType) { // object type did not match [object ...]
|
|
173336
|
+
objType = 'unknown:[' + objString + ']';
|
|
173337
|
+
} else {
|
|
173338
|
+
objType = objType[1]; // take only the class name
|
|
173339
|
+
}
|
|
173340
|
+
|
|
173341
|
+
objType = objType.toLowerCase();
|
|
173342
|
+
|
|
173343
|
+
var objectNumber = null;
|
|
173344
|
+
|
|
173345
|
+
if ((objectNumber = context.indexOf(object)) >= 0) {
|
|
173346
|
+
return this.dispatch('[CIRCULAR:' + objectNumber + ']');
|
|
173347
|
+
} else {
|
|
173348
|
+
context.push(object);
|
|
173349
|
+
}
|
|
173350
|
+
|
|
173351
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
|
173352
|
+
write('buffer:');
|
|
173353
|
+
return write(object);
|
|
173354
|
+
}
|
|
173355
|
+
|
|
173356
|
+
if(objType !== 'object' && objType !== 'function' && objType !== 'asyncfunction') {
|
|
173357
|
+
if(this['_' + objType]) {
|
|
173358
|
+
this['_' + objType](object);
|
|
173359
|
+
} else if (options.ignoreUnknown) {
|
|
173360
|
+
return write('[' + objType + ']');
|
|
173361
|
+
} else {
|
|
173362
|
+
throw new Error('Unknown object type "' + objType + '"');
|
|
173363
|
+
}
|
|
173364
|
+
}else{
|
|
173365
|
+
var keys = Object.keys(object);
|
|
173366
|
+
if (options.unorderedObjects) {
|
|
173367
|
+
keys = keys.sort();
|
|
173368
|
+
}
|
|
173369
|
+
// Make sure to incorporate special properties, so
|
|
173370
|
+
// Types with different prototypes will produce
|
|
173371
|
+
// a different hash and objects derived from
|
|
173372
|
+
// different functions (`new Foo`, `new Bar`) will
|
|
173373
|
+
// produce different hashes.
|
|
173374
|
+
// We never do this for native functions since some
|
|
173375
|
+
// seem to break because of that.
|
|
173376
|
+
if (options.respectType !== false && !isNativeFunction(object)) {
|
|
173377
|
+
keys.splice(0, 0, 'prototype', '__proto__', 'constructor');
|
|
173378
|
+
}
|
|
173379
|
+
|
|
173380
|
+
if (options.excludeKeys) {
|
|
173381
|
+
keys = keys.filter(function(key) { return !options.excludeKeys(key); });
|
|
173382
|
+
}
|
|
173383
|
+
|
|
173384
|
+
write('object:' + keys.length + ':');
|
|
173385
|
+
var self = this;
|
|
173386
|
+
return keys.forEach(function(key){
|
|
173387
|
+
self.dispatch(key);
|
|
173388
|
+
write(':');
|
|
173389
|
+
if(!options.excludeValues) {
|
|
173390
|
+
self.dispatch(object[key]);
|
|
173391
|
+
}
|
|
173392
|
+
write(',');
|
|
173393
|
+
});
|
|
173394
|
+
}
|
|
173395
|
+
},
|
|
173396
|
+
_array: function(arr, unordered){
|
|
173397
|
+
unordered = typeof unordered !== 'undefined' ? unordered :
|
|
173398
|
+
options.unorderedArrays !== false; // default to options.unorderedArrays
|
|
173399
|
+
|
|
173400
|
+
var self = this;
|
|
173401
|
+
write('array:' + arr.length + ':');
|
|
173402
|
+
if (!unordered || arr.length <= 1) {
|
|
173403
|
+
return arr.forEach(function(entry) {
|
|
173404
|
+
return self.dispatch(entry);
|
|
173405
|
+
});
|
|
173406
|
+
}
|
|
173407
|
+
|
|
173408
|
+
// the unordered case is a little more complicated:
|
|
173409
|
+
// since there is no canonical ordering on objects,
|
|
173410
|
+
// i.e. {a:1} < {a:2} and {a:1} > {a:2} are both false,
|
|
173411
|
+
// we first serialize each entry using a PassThrough stream
|
|
173412
|
+
// before sorting.
|
|
173413
|
+
// also: we can’t use the same context array for all entries
|
|
173414
|
+
// since the order of hashing should *not* matter. instead,
|
|
173415
|
+
// we keep track of the additions to a copy of the context array
|
|
173416
|
+
// and add all of them to the global context array when we’re done
|
|
173417
|
+
var contextAdditions = [];
|
|
173418
|
+
var entries = arr.map(function(entry) {
|
|
173419
|
+
var strm = new PassThrough();
|
|
173420
|
+
var localContext = context.slice(); // make copy
|
|
173421
|
+
var hasher = typeHasher(options, strm, localContext);
|
|
173422
|
+
hasher.dispatch(entry);
|
|
173423
|
+
// take only what was added to localContext and append it to contextAdditions
|
|
173424
|
+
contextAdditions = contextAdditions.concat(localContext.slice(context.length));
|
|
173425
|
+
return strm.read().toString();
|
|
173426
|
+
});
|
|
173427
|
+
context = context.concat(contextAdditions);
|
|
173428
|
+
entries.sort();
|
|
173429
|
+
return this._array(entries, false);
|
|
173430
|
+
},
|
|
173431
|
+
_date: function(date){
|
|
173432
|
+
return write('date:' + date.toJSON());
|
|
173433
|
+
},
|
|
173434
|
+
_symbol: function(sym){
|
|
173435
|
+
return write('symbol:' + sym.toString());
|
|
173436
|
+
},
|
|
173437
|
+
_error: function(err){
|
|
173438
|
+
return write('error:' + err.toString());
|
|
173439
|
+
},
|
|
173440
|
+
_boolean: function(bool){
|
|
173441
|
+
return write('bool:' + bool.toString());
|
|
173442
|
+
},
|
|
173443
|
+
_string: function(string){
|
|
173444
|
+
write('string:' + string.length + ':');
|
|
173445
|
+
write(string.toString());
|
|
173446
|
+
},
|
|
173447
|
+
_function: function(fn){
|
|
173448
|
+
write('fn:');
|
|
173449
|
+
if (isNativeFunction(fn)) {
|
|
173450
|
+
this.dispatch('[native]');
|
|
173451
|
+
} else {
|
|
173452
|
+
this.dispatch(fn.toString());
|
|
173453
|
+
}
|
|
173454
|
+
|
|
173455
|
+
if (options.respectFunctionNames !== false) {
|
|
173456
|
+
// Make sure we can still distinguish native functions
|
|
173457
|
+
// by their name, otherwise String and Function will
|
|
173458
|
+
// have the same hash
|
|
173459
|
+
this.dispatch("function-name:" + String(fn.name));
|
|
173460
|
+
}
|
|
173461
|
+
|
|
173462
|
+
if (options.respectFunctionProperties) {
|
|
173463
|
+
this._object(fn);
|
|
173464
|
+
}
|
|
173465
|
+
},
|
|
173466
|
+
_number: function(number){
|
|
173467
|
+
return write('number:' + number.toString());
|
|
173468
|
+
},
|
|
173469
|
+
_xml: function(xml){
|
|
173470
|
+
return write('xml:' + xml.toString());
|
|
173471
|
+
},
|
|
173472
|
+
_null: function() {
|
|
173473
|
+
return write('Null');
|
|
173474
|
+
},
|
|
173475
|
+
_undefined: function() {
|
|
173476
|
+
return write('Undefined');
|
|
173477
|
+
},
|
|
173478
|
+
_regexp: function(regex){
|
|
173479
|
+
return write('regex:' + regex.toString());
|
|
173480
|
+
},
|
|
173481
|
+
_uint8array: function(arr){
|
|
173482
|
+
write('uint8array:');
|
|
173483
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173484
|
+
},
|
|
173485
|
+
_uint8clampedarray: function(arr){
|
|
173486
|
+
write('uint8clampedarray:');
|
|
173487
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173488
|
+
},
|
|
173489
|
+
_int8array: function(arr){
|
|
173490
|
+
write('int8array:');
|
|
173491
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173492
|
+
},
|
|
173493
|
+
_uint16array: function(arr){
|
|
173494
|
+
write('uint16array:');
|
|
173495
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173496
|
+
},
|
|
173497
|
+
_int16array: function(arr){
|
|
173498
|
+
write('int16array:');
|
|
173499
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173500
|
+
},
|
|
173501
|
+
_uint32array: function(arr){
|
|
173502
|
+
write('uint32array:');
|
|
173503
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173504
|
+
},
|
|
173505
|
+
_int32array: function(arr){
|
|
173506
|
+
write('int32array:');
|
|
173507
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173508
|
+
},
|
|
173509
|
+
_float32array: function(arr){
|
|
173510
|
+
write('float32array:');
|
|
173511
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173512
|
+
},
|
|
173513
|
+
_float64array: function(arr){
|
|
173514
|
+
write('float64array:');
|
|
173515
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
173516
|
+
},
|
|
173517
|
+
_arraybuffer: function(arr){
|
|
173518
|
+
write('arraybuffer:');
|
|
173519
|
+
return this.dispatch(new Uint8Array(arr));
|
|
173520
|
+
},
|
|
173521
|
+
_url: function(url) {
|
|
173522
|
+
return write('url:' + url.toString(), 'utf8');
|
|
173523
|
+
},
|
|
173524
|
+
_map: function(map) {
|
|
173525
|
+
write('map:');
|
|
173526
|
+
var arr = Array.from(map);
|
|
173527
|
+
return this._array(arr, options.unorderedSets !== false);
|
|
173528
|
+
},
|
|
173529
|
+
_set: function(set) {
|
|
173530
|
+
write('set:');
|
|
173531
|
+
var arr = Array.from(set);
|
|
173532
|
+
return this._array(arr, options.unorderedSets !== false);
|
|
173533
|
+
},
|
|
173534
|
+
_file: function(file) {
|
|
173535
|
+
write('file:');
|
|
173536
|
+
return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
|
|
173537
|
+
},
|
|
173538
|
+
_blob: function() {
|
|
173539
|
+
if (options.ignoreUnknown) {
|
|
173540
|
+
return write('[blob]');
|
|
173541
|
+
}
|
|
173542
|
+
|
|
173543
|
+
throw Error('Hashing Blob objects is currently not supported\n' +
|
|
173544
|
+
'(see https://github.com/puleos/object-hash/issues/26)\n' +
|
|
173545
|
+
'Use "options.replacer" or "options.ignoreUnknown"\n');
|
|
173546
|
+
},
|
|
173547
|
+
_domwindow: function() { return write('domwindow'); },
|
|
173548
|
+
_bigint: function(number){
|
|
173549
|
+
return write('bigint:' + number.toString());
|
|
173550
|
+
},
|
|
173551
|
+
/* Node.js standard native objects */
|
|
173552
|
+
_process: function() { return write('process'); },
|
|
173553
|
+
_timer: function() { return write('timer'); },
|
|
173554
|
+
_pipe: function() { return write('pipe'); },
|
|
173555
|
+
_tcp: function() { return write('tcp'); },
|
|
173556
|
+
_udp: function() { return write('udp'); },
|
|
173557
|
+
_tty: function() { return write('tty'); },
|
|
173558
|
+
_statwatcher: function() { return write('statwatcher'); },
|
|
173559
|
+
_securecontext: function() { return write('securecontext'); },
|
|
173560
|
+
_connection: function() { return write('connection'); },
|
|
173561
|
+
_zlib: function() { return write('zlib'); },
|
|
173562
|
+
_context: function() { return write('context'); },
|
|
173563
|
+
_nodescript: function() { return write('nodescript'); },
|
|
173564
|
+
_httpparser: function() { return write('httpparser'); },
|
|
173565
|
+
_dataview: function() { return write('dataview'); },
|
|
173566
|
+
_signal: function() { return write('signal'); },
|
|
173567
|
+
_fsevent: function() { return write('fsevent'); },
|
|
173568
|
+
_tlswrap: function() { return write('tlswrap'); },
|
|
173569
|
+
};
|
|
173570
|
+
}
|
|
173571
|
+
|
|
173572
|
+
// Mini-implementation of stream.PassThrough
|
|
173573
|
+
// We are far from having need for the full implementation, and we can
|
|
173574
|
+
// make assumptions like "many writes, then only one final read"
|
|
173575
|
+
// and we can ignore encoding specifics
|
|
173576
|
+
function PassThrough() {
|
|
173577
|
+
return {
|
|
173578
|
+
buf: '',
|
|
173579
|
+
|
|
173580
|
+
write: function(b) {
|
|
173581
|
+
this.buf += b;
|
|
173582
|
+
},
|
|
173583
|
+
|
|
173584
|
+
end: function(b) {
|
|
173585
|
+
this.buf += b;
|
|
173586
|
+
},
|
|
173587
|
+
|
|
173588
|
+
read: function() {
|
|
173589
|
+
return this.buf;
|
|
173590
|
+
}
|
|
173591
|
+
};
|
|
173592
|
+
}
|
|
173593
|
+
|
|
173594
|
+
|
|
171114
173595
|
/***/ }),
|
|
171115
173596
|
|
|
171116
173597
|
/***/ 47860:
|
|
@@ -190044,7 +192525,7 @@ function buildDepGraph(partialDepTree, projectName) {
|
|
|
190044
192525
|
});
|
|
190045
192526
|
if (projectName)
|
|
190046
192527
|
partialDepTree.name = projectName;
|
|
190047
|
-
return legacy_1.depTreeToGraph(partialDepTree, 'pip');
|
|
192528
|
+
return (0, legacy_1.depTreeToGraph)(partialDepTree, 'pip');
|
|
190048
192529
|
}
|
|
190049
192530
|
exports.buildDepGraph = buildDepGraph;
|
|
190050
192531
|
//# sourceMappingURL=build-dep-graph.js.map
|
|
@@ -190075,7 +192556,7 @@ function getDependencies(root, targetFile, options) {
|
|
|
190075
192556
|
const includeDevDeps = !!(options.dev || false);
|
|
190076
192557
|
// handle poetry projects by parsing manifest & lockfile and return a dep-graph
|
|
190077
192558
|
if (path.basename(targetFile) === types_1.FILENAMES.poetry.lockfile) {
|
|
190078
|
-
return poetry_1.getPoetryDependencies(command, root, targetFile, includeDevDeps);
|
|
192559
|
+
return (0, poetry_1.getPoetryDependencies)(command, root, targetFile, includeDevDeps);
|
|
190079
192560
|
}
|
|
190080
192561
|
let baseargs = [];
|
|
190081
192562
|
if (path.basename(targetFile) === types_1.FILENAMES.pipenv.manifest) {
|
|
@@ -190088,8 +192569,8 @@ function getDependencies(root, targetFile, options) {
|
|
|
190088
192569
|
baseargs = ['run', 'python'];
|
|
190089
192570
|
}
|
|
190090
192571
|
const [plugin, dependencyGraph] = yield Promise.all([
|
|
190091
|
-
inspect_implementation_1.getMetaData(command, baseargs, root, targetFile),
|
|
190092
|
-
inspect_implementation_1.inspectInstalledDeps(command, baseargs, root, targetFile, options.allowMissing || false, includeDevDeps, options.allowEmpty, options.args, options.projectName),
|
|
192572
|
+
(0, inspect_implementation_1.getMetaData)(command, baseargs, root, targetFile),
|
|
192573
|
+
(0, inspect_implementation_1.inspectInstalledDeps)(command, baseargs, root, targetFile, options.allowMissing || false, includeDevDeps, options.allowEmpty, options.args, options.projectName),
|
|
190093
192574
|
]);
|
|
190094
192575
|
return { plugin, dependencyGraph };
|
|
190095
192576
|
});
|
|
@@ -190209,7 +192690,7 @@ function inspectInstalledDeps(command, baseargs, root, targetFile, allowMissing,
|
|
|
190209
192690
|
env: pythonEnv,
|
|
190210
192691
|
});
|
|
190211
192692
|
const result = JSON.parse(output);
|
|
190212
|
-
return build_dep_graph_1.buildDepGraph(result, projectName);
|
|
192693
|
+
return (0, build_dep_graph_1.buildDepGraph)(result, projectName);
|
|
190213
192694
|
}
|
|
190214
192695
|
catch (error) {
|
|
190215
192696
|
if (typeof error === 'string') {
|
|
@@ -190309,7 +192790,7 @@ function getPoetryDependencies(command, root, targetFile, includeDevDeps = false
|
|
|
190309
192790
|
const manifestContents = fs.readFileSync(manifestPath, 'utf-8');
|
|
190310
192791
|
const lockfileContents = fs.readFileSync(lockfilePath, 'utf-8');
|
|
190311
192792
|
const dependencyGraph = poetry.buildDepGraph(manifestContents, lockfileContents, includeDevDeps);
|
|
190312
|
-
const plugin = yield inspect_implementation_1.getMetaData(command, [], root, targetFile);
|
|
192793
|
+
const plugin = yield (0, inspect_implementation_1.getMetaData)(command, [], root, targetFile);
|
|
190313
192794
|
return {
|
|
190314
192795
|
plugin,
|
|
190315
192796
|
package: null,
|
|
@@ -190349,7 +192830,7 @@ function execute(command, args, options) {
|
|
|
190349
192830
|
return new Promise((resolve, reject) => {
|
|
190350
192831
|
let stdout = '';
|
|
190351
192832
|
let stderr = '';
|
|
190352
|
-
const proc = child_process_1.spawn(command, args, spawnOptions);
|
|
192833
|
+
const proc = (0, child_process_1.spawn)(command, args, spawnOptions);
|
|
190353
192834
|
proc.stdout.on('data', (data) => {
|
|
190354
192835
|
stdout = stdout + data;
|
|
190355
192836
|
});
|
|
@@ -190367,7 +192848,7 @@ function execute(command, args, options) {
|
|
|
190367
192848
|
exports.execute = execute;
|
|
190368
192849
|
function executeSync(command, args, options) {
|
|
190369
192850
|
const spawnOptions = makeSpawnOptions(options);
|
|
190370
|
-
return child_process_1.spawnSync(command, args, spawnOptions);
|
|
192851
|
+
return (0, child_process_1.spawnSync)(command, args, spawnOptions);
|
|
190371
192852
|
}
|
|
190372
192853
|
exports.executeSync = executeSync;
|
|
190373
192854
|
//# sourceMappingURL=sub-process.js.map
|
|
@@ -190410,6 +192891,7 @@ exports.RequiredPackagesMissingError = RequiredPackagesMissingError;
|
|
|
190410
192891
|
"use strict";
|
|
190411
192892
|
|
|
190412
192893
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
192894
|
+
exports.PythonPluginErrorNames = exports.RequiredPackagesMissingError = exports.EmptyManifestError = exports.inspect = void 0;
|
|
190413
192895
|
var dependencies_1 = __webpack_require__(69797);
|
|
190414
192896
|
Object.defineProperty(exports, "inspect", ({ enumerable: true, get: function () { return dependencies_1.getDependencies; } }));
|
|
190415
192897
|
var errors_1 = __webpack_require__(99893);
|