snyk-nodejs-lockfile-parser 1.35.1 → 1.36.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.
@@ -0,0 +1,27 @@
1
+ export interface FormattedCliOutput {
2
+ topLevelDeps: string[];
3
+ dependencies: FlatDependenciesMap;
4
+ }
5
+ export declare type FlatDependenciesMap = Map<string, string[]>;
6
+ export declare type YarnInfoOutput = Array<{
7
+ value: string;
8
+ children: {
9
+ Version: string;
10
+ Dependents?: string[];
11
+ Dependencies?: {
12
+ descriptor: string;
13
+ locator: string;
14
+ }[];
15
+ };
16
+ }>;
17
+ export interface YarnListTree {
18
+ name: string;
19
+ children: {
20
+ name: string;
21
+ color: string;
22
+ shadow: boolean;
23
+ }[];
24
+ hint: string | null;
25
+ color: string | null;
26
+ depth: number;
27
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=cli-parser-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-parser-types.js","sourceRoot":"","sources":["../../lib/cli-parsers/cli-parser-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare const extractNameAndIdentifier: (candidate: string) => {
2
+ name: string;
3
+ identifier: string;
4
+ };
5
+ export declare const extractCorrectIdentifierBySemver: (possibleMatches: string[], versionToMatch: string) => string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractCorrectIdentifierBySemver = exports.extractNameAndIdentifier = void 0;
4
+ const semver = require("semver");
5
+ const extractNameAndIdentifier = (candidate) => {
6
+ const index = candidate.indexOf('@', 1);
7
+ const name = candidate.slice(0, index);
8
+ const identifier = candidate.slice(index + 1);
9
+ return { name, identifier };
10
+ };
11
+ exports.extractNameAndIdentifier = extractNameAndIdentifier;
12
+ // This function will choose an item in a particular list that satisfies the semver provided
13
+ // i.e. possibleMatches = [debug@1.2.0, debug@2.2.6] and versionToMatch = debug@~2.2.0
14
+ // will result in debug@2.2.6 - This is required as yarn list does not have the resolved semver
15
+ // in dependencies.
16
+ const extractCorrectIdentifierBySemver = (possibleMatches, versionToMatch) => {
17
+ const { name: nameToMatch, identifier: identifierToMatch, } = exports.extractNameAndIdentifier(versionToMatch);
18
+ const hasQualifiers = isNaN(parseInt(identifierToMatch[0]));
19
+ if (!hasQualifiers) {
20
+ return versionToMatch;
21
+ }
22
+ // Check for matching name, if only one found shortcircuit
23
+ const match = possibleMatches
24
+ .filter((name) => name.startsWith(nameToMatch))
25
+ .filter((name) => semver.satisfies(exports.extractNameAndIdentifier(name).identifier, identifierToMatch))
26
+ .map((name) => ({
27
+ name,
28
+ identifier: exports.extractNameAndIdentifier(name).identifier,
29
+ }))
30
+ .reduce((acc, item) => semver.gt(item.identifier, acc.identifier) ? item : acc);
31
+ return match.name;
32
+ };
33
+ exports.extractCorrectIdentifierBySemver = extractCorrectIdentifierBySemver;
34
+ //# sourceMappingURL=cli-parser-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-parser-utils.js","sourceRoot":"","sources":["../../lib/cli-parsers/cli-parser-utils.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAE1B,MAAM,wBAAwB,GAAG,CACtC,SAAiB,EACqB,EAAE;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC,CAAC;AAPW,QAAA,wBAAwB,4BAOnC;AAEF,4FAA4F;AAC5F,sFAAsF;AACtF,+FAA+F;AAC/F,mBAAmB;AACZ,MAAM,gCAAgC,GAAG,CAC9C,eAAyB,EACzB,cAAsB,EACd,EAAE;IACV,MAAM,EACJ,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,iBAAiB,GAC9B,GAAG,gCAAwB,CAAC,cAAc,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,cAAc,CAAC;KACvB;IACD,0DAA0D;IAC1D,MAAM,KAAK,GAAG,eAAe;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SAC9C,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACf,MAAM,CAAC,SAAS,CACd,gCAAwB,CAAC,IAAI,CAAC,CAAC,UAAU,EACzC,iBAAiB,CAClB,CACF;SACA,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,IAAI;QACJ,UAAU,EAAE,gCAAwB,CAAC,IAAI,CAAC,CAAC,UAAU;KACtD,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CACpB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CACxD,CAAC;IAEJ,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC,CAAC;AA/BW,QAAA,gCAAgC,oCA+B3C"}
@@ -0,0 +1,2 @@
1
+ import { DepGraph } from '@snyk/dep-graph';
2
+ export declare const buildDepGraphFromCliOutput: (rawCliOutput: string, lockfileContent: string, manifestFileContent: string) => DepGraph;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildDepGraphFromCliOutput = void 0;
4
+ const dep_graph_1 = require("@snyk/dep-graph");
5
+ const __1 = require("..");
6
+ const parsers_1 = require("../parsers");
7
+ const cli_parser_utils_1 = require("./cli-parser-utils");
8
+ const yarn_info_parser_1 = require("./yarn-info-parser");
9
+ const yarn_list_parser_1 = require("./yarn-list-parser");
10
+ const buildDepGraphFromCliOutput = (rawCliOutput, lockfileContent, manifestFileContent) => {
11
+ const manifestDependencies = JSON.parse(manifestFileContent).dependencies || {};
12
+ const lockfileType = __1.getYarnLockfileType(lockfileContent);
13
+ const { name: rootName, version: rootVersion } = JSON.parse(manifestFileContent);
14
+ const pkgManagerVersion = lockfileType === parsers_1.LockfileType.yarn ? '1' : '2';
15
+ // Build depMap object from the cli output
16
+ const formattedCliOutput = pkgManagerVersion === '1'
17
+ ? yarn_list_parser_1.parseYarnListOutput(rawCliOutput, manifestDependencies)
18
+ : yarn_info_parser_1.parseYarnInfoOutput(rawCliOutput);
19
+ const rootPkgInfo = rootName
20
+ ? Object.assign({ name: rootName }, (rootVersion && { version: rootVersion })) : undefined;
21
+ const pkgManager = {
22
+ name: 'yarn',
23
+ version: pkgManagerVersion,
24
+ };
25
+ const builder = new dep_graph_1.DepGraphBuilder(pkgManager, rootPkgInfo);
26
+ const { topLevelDeps, dependencies: depMap } = formattedCliOutput;
27
+ // Add all nodes
28
+ [...depMap.keys()].forEach((name) => {
29
+ const { name: pkgName, identifier: pkgVersion } = cli_parser_utils_1.extractNameAndIdentifier(name);
30
+ builder.addPkgNode({ name: pkgName, version: pkgVersion.split(':').pop() }, name);
31
+ });
32
+ // Deal with root special case first
33
+ const rootNodeId = builder.rootNodeId;
34
+ topLevelDeps.forEach((dep) => builder.connectDep(rootNodeId, dep));
35
+ // Now rest of deps
36
+ [...depMap.entries()].forEach(([parent, deps]) => {
37
+ deps.forEach((dep) => {
38
+ builder.connectDep(parent, dep);
39
+ });
40
+ });
41
+ return builder.build();
42
+ };
43
+ exports.buildDepGraphFromCliOutput = buildDepGraphFromCliOutput;
44
+ //# sourceMapping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,gBAAgB;IAChB,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,2CAAwB,CACxE,IAAI,CACL,CAAC;QACF,OAAO,CAAC,UAAU,CAChB,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAY,EAAE,EACjE,IAAI,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACtC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IAEnE,mBAAmB;IACnB,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/C,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC,CAAC;AA3DW,QAAA,0BAA0B,8BA2DrC"}
@@ -0,0 +1,2 @@
1
+ import { FormattedCliOutput } from './cli-parser-types';
2
+ export declare const parseYarnInfoOutput: (rawYarnInfoOutput: string) => FormattedCliOutput;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseYarnInfoOutput = void 0;
4
+ const parseYarnInfoOutput = (rawYarnInfoOutput) => {
5
+ const formattedYarnInfo = rawYarnInfoOutput
6
+ .split('\n')
7
+ .filter(Boolean)
8
+ .map((el) => JSON.parse(el));
9
+ const formattedInfoOutput = formattedYarnInfo.reduce((result, { value, children }) => {
10
+ var _a;
11
+ const dependencies = ((_a = children.Dependencies) === null || _a === void 0 ? void 0 : _a.map((el) => el.locator.replace(/@virtual:.*#/, '@'))) || [];
12
+ return result.set(value, dependencies);
13
+ }, new Map());
14
+ const rootWorkspaceKey = [...formattedInfoOutput.keys()].find((el) => el.includes('@workspace:.'));
15
+ const topLevelDeps = formattedInfoOutput.get(rootWorkspaceKey) || [];
16
+ // Now we have rootdeps we delete the key
17
+ formattedInfoOutput.delete(rootWorkspaceKey);
18
+ return { topLevelDeps, dependencies: formattedInfoOutput };
19
+ };
20
+ exports.parseYarnInfoOutput = parseYarnInfoOutput;
21
+ //# sourceMappingURL=yarn-info-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarn-info-parser.js","sourceRoot":"","sources":["../../lib/cli-parsers/yarn-info-parser.ts"],"names":[],"mappings":";;;AAMO,MAAM,mBAAmB,GAAG,CACjC,iBAAyB,EACL,EAAE;IACtB,MAAM,iBAAiB,GAAmB,iBAAiB;SACxD,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/B,MAAM,mBAAmB,GAAwB,iBAAiB,CAAC,MAAM,CACvE,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;;QAC9B,MAAM,YAAY,GAChB,CAAA,MAAA,QAAQ,CAAC,YAAY,0CAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAChC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CACxC,KAAI,EAAE,CAAC;QAEV,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACzC,CAAC,EACD,IAAI,GAAG,EAAoB,CAC5B,CAAC;IAEF,MAAM,gBAAgB,GAAG,CAAC,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CACnE,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAClB,CAAC;IACZ,MAAM,YAAY,GAChB,mBAAmB,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;IAElD,yCAAyC;IACzC,mBAAmB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAE7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAC7D,CAAC,CAAC;AA9BW,QAAA,mBAAmB,uBA8B9B"}
@@ -0,0 +1,2 @@
1
+ import { FormattedCliOutput } from './cli-parser-types';
2
+ export declare const parseYarnListOutput: (rawYarnListOutput: string, manifestDependencies: Record<string, string>) => FormattedCliOutput;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseYarnListOutput = void 0;
4
+ const cli_parser_utils_1 = require("./cli-parser-utils");
5
+ const parseYarnListOutput = (rawYarnListOutput, manifestDependencies) => {
6
+ const formattedYarnList = JSON.parse(rawYarnListOutput).data
7
+ .trees;
8
+ // Reference to all (resolved) dep names to help cleanup in next step
9
+ const names = formattedYarnList.map((tree) => tree.name);
10
+ const formattedListOutput = formattedYarnList.reduce((result, tree) => {
11
+ const dependencies = tree.children.map((child) => cli_parser_utils_1.extractCorrectIdentifierBySemver(names, child.name));
12
+ return result.set(tree.name, dependencies);
13
+ }, new Map());
14
+ const topLevelDeps = getTopLevelDependencies(formattedListOutput, manifestDependencies);
15
+ return { topLevelDeps, dependencies: formattedListOutput };
16
+ };
17
+ exports.parseYarnListOutput = parseYarnListOutput;
18
+ const getTopLevelDependencies = (formattedListOutput, topLevelDeps) => {
19
+ // This logic is to construct an item for the rootPkg because
20
+ // we are dealing with a flat map so far so can't tell
21
+ const names = [...formattedListOutput.keys()];
22
+ return Object.entries(topLevelDeps).map(([name, version]) => cli_parser_utils_1.extractCorrectIdentifierBySemver(names, `${name}@${version}`));
23
+ };
24
+ //# sourceMappingURL=yarn-list-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarn-list-parser.js","sourceRoot":"","sources":["../../lib/cli-parsers/yarn-list-parser.ts"],"names":[],"mappings":";;;AAKA,yDAAsE;AAE/D,MAAM,mBAAmB,GAAG,CACjC,iBAAyB,EACzB,oBAA4C,EACxB,EAAE;IACtB,MAAM,iBAAiB,GAAmB,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,IAAI;SACzE,KAAK,CAAC;IAET,qEAAqE;IACrE,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEzD,MAAM,mBAAmB,GAAwB,iBAAiB,CAAC,MAAM,CACvE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QACf,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC/C,mDAAgC,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CACpD,CAAC;QAEF,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC,EACD,IAAI,GAAG,EAAoB,CAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,uBAAuB,CAC1C,mBAAmB,EACnB,oBAAoB,CACrB,CAAC;IAEF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAC7D,CAAC,CAAC;AA3BW,QAAA,mBAAmB,uBA2B9B;AAEF,MAAM,uBAAuB,GAAG,CAC9B,mBAAwC,EACxC,YAAoC,EACpC,EAAE;IACF,6DAA6D;IAC7D,sDAAsD;IACtD,MAAM,KAAK,GAAG,CAAC,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAC1D,mDAAgC,CAAC,KAAK,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,CAC9D,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { ManifestFile, PkgTree, Scope, LockfileType, getYarnWorkspaces } from './parsers';
2
2
  import { UnsupportedRuntimeError, InvalidUserInputError, OutOfSyncError } from './errors';
3
- export { buildDepTree, buildDepTreeFromFiles, getYarnWorkspacesFromFiles, getYarnWorkspaces, PkgTree, Scope, LockfileType, UnsupportedRuntimeError, InvalidUserInputError, OutOfSyncError, ManifestFile, };
3
+ import { buildDepGraphFromCliOutput } from './cli-parsers';
4
+ export { buildDepTree, buildDepTreeFromFiles, buildDepGraphFromCliOutput, getYarnWorkspacesFromFiles, getYarnWorkspaces, PkgTree, Scope, LockfileType, UnsupportedRuntimeError, InvalidUserInputError, OutOfSyncError, ManifestFile, };
4
5
  declare function buildDepTree(manifestFileContents: string, lockFileContents: string, includeDev?: boolean, lockfileType?: LockfileType, strict?: boolean, defaultManifestFileName?: string): Promise<PkgTree>;
5
6
  declare function buildDepTreeFromFiles(root: string, manifestFilePath: string, lockFilePath: string, includeDev?: boolean, strict?: boolean): Promise<PkgTree>;
6
7
  declare function getYarnWorkspacesFromFiles(root: any, manifestFilePath: string): string[] | false;
8
+ export declare function getYarnLockfileType(lockFileContents: string, root?: string, lockFilePath?: string): LockfileType;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OutOfSyncError = exports.InvalidUserInputError = exports.UnsupportedRuntimeError = exports.LockfileType = exports.Scope = exports.getYarnWorkspaces = exports.getYarnWorkspacesFromFiles = exports.buildDepTreeFromFiles = exports.buildDepTree = void 0;
3
+ exports.getYarnLockfileType = exports.OutOfSyncError = exports.InvalidUserInputError = exports.UnsupportedRuntimeError = exports.LockfileType = exports.Scope = exports.getYarnWorkspaces = exports.getYarnWorkspacesFromFiles = exports.buildDepGraphFromCliOutput = exports.buildDepTreeFromFiles = exports.buildDepTree = void 0;
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
  const parsers_1 = require("./parsers");
@@ -14,6 +14,8 @@ const errors_1 = require("./errors");
14
14
  Object.defineProperty(exports, "UnsupportedRuntimeError", { enumerable: true, get: function () { return errors_1.UnsupportedRuntimeError; } });
15
15
  Object.defineProperty(exports, "InvalidUserInputError", { enumerable: true, get: function () { return errors_1.InvalidUserInputError; } });
16
16
  Object.defineProperty(exports, "OutOfSyncError", { enumerable: true, get: function () { return errors_1.OutOfSyncError; } });
17
+ const cli_parsers_1 = require("./cli-parsers");
18
+ Object.defineProperty(exports, "buildDepGraphFromCliOutput", { enumerable: true, get: function () { return cli_parsers_1.buildDepGraphFromCliOutput; } });
17
19
  async function buildDepTree(manifestFileContents, lockFileContents, includeDev = false, lockfileType, strict = true, defaultManifestFileName = 'package.json') {
18
20
  if (!lockfileType) {
19
21
  lockfileType = parsers_1.LockfileType.npm;
@@ -100,4 +102,5 @@ function getYarnLockfileType(lockFileContents, root, lockFilePath) {
100
102
  return parsers_1.LockfileType.yarn;
101
103
  }
102
104
  }
105
+ exports.getYarnLockfileType = getYarnLockfileType;
103
106
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAC7B,uCASmB;AAgBjB,sFApBA,eAAK,OAoBA;AACL,6FAnBA,sBAAY,OAmBA;AAHZ,kGAfA,2BAAiB,OA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ACJ;QACA,OAAO,sBAAY,CAAC,KAAK,CAAC;KAC3B;SAAM;QACL,OAAO,sBAAY,CAAC,IAAI,CAAC;KAC1B;AACH,CAAC;AAjBD,kDAiBC"}
package/package.json CHANGED
@@ -31,6 +31,7 @@
31
31
  ],
32
32
  "homepage": "https://github.com/snyk/nodejs-lockfile-parser#readme",
33
33
  "dependencies": {
34
+ "@snyk/dep-graph": "^1.28.0",
34
35
  "@snyk/graphlib": "2.1.9-patch.3",
35
36
  "@yarnpkg/core": "^2.4.0",
36
37
  "@yarnpkg/lockfile": "^1.1.0",
@@ -41,6 +42,7 @@
41
42
  "lodash.isempty": "^4.4.0",
42
43
  "lodash.set": "^4.3.2",
43
44
  "lodash.topairs": "^4.3.0",
45
+ "semver": "^7.3.5",
44
46
  "snyk-config": "^4.0.0-rc.2",
45
47
  "tslib": "^1.9.3",
46
48
  "uuid": "^8.3.0"
@@ -48,6 +50,7 @@
48
50
  "devDependencies": {
49
51
  "@types/jest": "^26.0.23",
50
52
  "@types/node": "^12.0.0",
53
+ "@types/semver": "^7.3.6",
51
54
  "@types/uuid": "^8.3.0",
52
55
  "@typescript-eslint/eslint-plugin": "^4.20.0",
53
56
  "@typescript-eslint/parser": "^4.0.0",
@@ -61,5 +64,5 @@
61
64
  "ts-node": "^9.1.1",
62
65
  "typescript": "^4.1.0"
63
66
  },
64
- "version": "1.35.1"
67
+ "version": "1.36.0"
65
68
  }