snyk-nodejs-lockfile-parser 1.14.0 → 1.17.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/errors/invalid-user-input-error.js +7 -15
- package/dist/errors/invalid-user-input-error.js.map +1 -1
- package/dist/errors/out-of-sync-error.js +14 -18
- package/dist/errors/out-of-sync-error.js.map +1 -1
- package/dist/errors/unsupported-runtime-error.js +7 -15
- package/dist/errors/unsupported-runtime-error.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +74 -87
- package/dist/index.js.map +1 -1
- package/dist/parsers/index.d.ts +19 -10
- package/dist/parsers/index.js +19 -23
- package/dist/parsers/index.js.map +1 -1
- package/dist/parsers/package-lock-parser.js +186 -218
- package/dist/parsers/package-lock-parser.js.map +1 -1
- package/dist/parsers/yarn-lock-parse.d.ts +1 -0
- package/dist/parsers/yarn-lock-parse.js +108 -134
- package/dist/parsers/yarn-lock-parse.js.map +1 -1
- package/dist/set-immediate-promise.js +1 -1
- package/dist/set-immediate-promise.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
args[_i] = arguments[_i];
|
|
10
|
-
}
|
|
11
|
-
var _this = _super.apply(this, args) || this;
|
|
12
|
-
_this.code = 422;
|
|
13
|
-
_this.name = 'InvalidUserInputError';
|
|
14
|
-
Error.captureStackTrace(_this, InvalidUserInputError);
|
|
15
|
-
return _this;
|
|
3
|
+
class InvalidUserInputError extends Error {
|
|
4
|
+
constructor(...args) {
|
|
5
|
+
super(...args);
|
|
6
|
+
this.code = 422;
|
|
7
|
+
this.name = 'InvalidUserInputError';
|
|
8
|
+
Error.captureStackTrace(this, InvalidUserInputError);
|
|
16
9
|
}
|
|
17
|
-
|
|
18
|
-
}(Error));
|
|
10
|
+
}
|
|
19
11
|
exports.InvalidUserInputError = InvalidUserInputError;
|
|
20
12
|
//# sourceMappingURL=invalid-user-input-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-user-input-error.js","sourceRoot":"","sources":["../../lib/errors/invalid-user-input-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invalid-user-input-error.js","sourceRoot":"","sources":["../../lib/errors/invalid-user-input-error.ts"],"names":[],"mappings":";;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAI9C,YAAY,GAAG,IAAI;QACjB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAJV,SAAI,GAAG,GAAG,CAAC;QACX,SAAI,GAAG,uBAAuB,CAAC;QAIpC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IACvD,CAAC;CACF;AARD,sDAQC"}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var LOCK_FILE_NAME = {
|
|
3
|
+
const LOCK_FILE_NAME = {
|
|
5
4
|
npm: 'package-lock.json',
|
|
6
5
|
yarn: 'yarn.lock',
|
|
7
6
|
};
|
|
8
|
-
|
|
7
|
+
const INSTALL_COMMAND = {
|
|
9
8
|
npm: 'npm install',
|
|
10
9
|
yarn: 'yarn install',
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Error.captureStackTrace(_this, OutOfSyncError);
|
|
24
|
-
return _this;
|
|
11
|
+
class OutOfSyncError extends Error {
|
|
12
|
+
constructor(dependencyName, lockFileType) {
|
|
13
|
+
super(`Dependency ${dependencyName} was not found in ` +
|
|
14
|
+
`${LOCK_FILE_NAME[lockFileType]}. Your package.json and ` +
|
|
15
|
+
`${LOCK_FILE_NAME[lockFileType]} are probably out of sync. Please run ` +
|
|
16
|
+
`"${INSTALL_COMMAND[lockFileType]}" and try again.`);
|
|
17
|
+
this.code = 422;
|
|
18
|
+
this.name = 'OutOfSyncError';
|
|
19
|
+
this.dependencyName = dependencyName;
|
|
20
|
+
this.lockFileType = lockFileType;
|
|
21
|
+
Error.captureStackTrace(this, OutOfSyncError);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
}(Error));
|
|
23
|
+
}
|
|
28
24
|
exports.OutOfSyncError = OutOfSyncError;
|
|
29
25
|
//# sourceMappingURL=out-of-sync-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"out-of-sync-error.js","sourceRoot":"","sources":["../../lib/errors/out-of-sync-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"out-of-sync-error.js","sourceRoot":"","sources":["../../lib/errors/out-of-sync-error.ts"],"names":[],"mappings":";;AAAA,MAAM,cAAc,GAAG;IACrB,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,WAAW;CAClB,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,cAAc;CACrB,CAAC;AAEF,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAY,cAAsB,EAAE,YAA4B;QAC9D,KAAK,CAAC,cAAc,cAAc,oBAAoB;YACpD,GAAG,cAAc,CAAC,YAAY,CAAC,0BAA0B;YACzD,GAAG,cAAc,CAAC,YAAY,CAAC,wCAAwC;YACvE,IAAI,eAAe,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QATlD,SAAI,GAAG,GAAG,CAAC;QACX,SAAI,GAAG,gBAAgB,CAAC;QAS7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC;CACF;AAfD,wCAeC"}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
args[_i] = arguments[_i];
|
|
10
|
-
}
|
|
11
|
-
var _this = _super.apply(this, args) || this;
|
|
12
|
-
_this.name = 'UnsupportedRuntimeError';
|
|
13
|
-
_this.code = 500;
|
|
14
|
-
Error.captureStackTrace(_this, UnsupportedRuntimeError);
|
|
15
|
-
return _this;
|
|
3
|
+
class UnsupportedRuntimeError extends Error {
|
|
4
|
+
constructor(...args) {
|
|
5
|
+
super(...args);
|
|
6
|
+
this.name = 'UnsupportedRuntimeError';
|
|
7
|
+
this.code = 500;
|
|
8
|
+
Error.captureStackTrace(this, UnsupportedRuntimeError);
|
|
16
9
|
}
|
|
17
|
-
|
|
18
|
-
}(Error));
|
|
10
|
+
}
|
|
19
11
|
exports.UnsupportedRuntimeError = UnsupportedRuntimeError;
|
|
20
12
|
//# sourceMappingURL=unsupported-runtime-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-runtime-error.js","sourceRoot":"","sources":["../../lib/errors/unsupported-runtime-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unsupported-runtime-error.js","sourceRoot":"","sources":["../../lib/errors/unsupported-runtime-error.ts"],"names":[],"mappings":";;AAAA,MAAa,uBAAwB,SAAQ,KAAK;IAIhD,YAAY,GAAG,IAAI;QACjB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAJV,SAAI,GAAG,yBAAyB,CAAC;QACjC,SAAI,GAAG,GAAG,CAAC;QAIhB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;IACzD,CAAC;CACF;AARD,0DAQC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'source-map-support/register';
|
|
2
|
-
import { PkgTree,
|
|
2
|
+
import { PkgTree, Scope, LockfileType, getYarnWorkspaces } from './parsers';
|
|
3
3
|
import { UnsupportedRuntimeError, InvalidUserInputError, OutOfSyncError } from './errors';
|
|
4
|
-
export { buildDepTree, buildDepTreeFromFiles, getYarnWorkspacesFromFiles, getYarnWorkspaces, PkgTree,
|
|
4
|
+
export { buildDepTree, buildDepTreeFromFiles, getYarnWorkspacesFromFiles, getYarnWorkspaces, PkgTree, Scope, LockfileType, UnsupportedRuntimeError, InvalidUserInputError, OutOfSyncError, };
|
|
5
5
|
declare function buildDepTree(manifestFileContents: string, lockFileContents: string, includeDev?: boolean, lockfileType?: LockfileType, strict?: boolean, defaultManifestFileName?: string): Promise<PkgTree>;
|
|
6
6
|
declare function buildDepTreeFromFiles(root: string, manifestFilePath: string, lockFilePath: string, includeDev?: boolean, strict?: boolean): Promise<PkgTree>;
|
|
7
7
|
declare function getYarnWorkspacesFromFiles(root: any, manifestFilePath: string): string[] | false;
|
package/dist/index.js
CHANGED
|
@@ -1,98 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
4
|
require("source-map-support/register");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const _ = require("lodash");
|
|
8
|
+
const parsers_1 = require("./parsers");
|
|
9
|
+
exports.Scope = parsers_1.Scope;
|
|
10
10
|
exports.LockfileType = parsers_1.LockfileType;
|
|
11
11
|
exports.getYarnWorkspaces = parsers_1.getYarnWorkspaces;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const package_lock_parser_1 = require("./parsers/package-lock-parser");
|
|
13
|
+
const yarn_lock_parse_1 = require("./parsers/yarn-lock-parse");
|
|
14
|
+
const get_node_runtime_version_1 = require("./get-node-runtime-version");
|
|
15
|
+
const errors_1 = require("./errors");
|
|
16
16
|
exports.UnsupportedRuntimeError = errors_1.UnsupportedRuntimeError;
|
|
17
17
|
exports.InvalidUserInputError = errors_1.InvalidUserInputError;
|
|
18
18
|
exports.OutOfSyncError = errors_1.OutOfSyncError;
|
|
19
|
-
function buildDepTree(manifestFileContents, lockFileContents, includeDev, lockfileType, strict, defaultManifestFileName) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
manifestFile.name = defaultManifestFileName;
|
|
52
|
-
}
|
|
53
|
-
lockFile = lockfileParser.parseLockFile(lockFileContents);
|
|
54
|
-
return [2 /*return*/, lockfileParser.getDependencyTree(manifestFile, lockFile, includeDev, strict)];
|
|
55
|
-
});
|
|
19
|
+
function buildDepTree(manifestFileContents, lockFileContents, includeDev = false, lockfileType, strict = true, defaultManifestFileName = 'package.json') {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (!lockfileType) {
|
|
22
|
+
lockfileType = parsers_1.LockfileType.npm;
|
|
23
|
+
}
|
|
24
|
+
let lockfileParser;
|
|
25
|
+
switch (lockfileType) {
|
|
26
|
+
case parsers_1.LockfileType.npm:
|
|
27
|
+
lockfileParser = new package_lock_parser_1.PackageLockParser();
|
|
28
|
+
break;
|
|
29
|
+
case parsers_1.LockfileType.yarn:
|
|
30
|
+
// parsing yarn.lock is supported for Node.js v6 and higher
|
|
31
|
+
if (get_node_runtime_version_1.default() >= 6) {
|
|
32
|
+
lockfileParser = new yarn_lock_parse_1.YarnLockParser();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new errors_1.UnsupportedRuntimeError('Parsing `yarn.lock` is not ' +
|
|
36
|
+
'supported on Node.js version less than 6. Please upgrade your ' +
|
|
37
|
+
'Node.js environment or use `package-lock.json`');
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
throw new errors_1.InvalidUserInputError('Unsupported lockfile type ' +
|
|
42
|
+
`${lockfileType} provided. Only 'npm' or 'yarn' is currently ` +
|
|
43
|
+
'supported.');
|
|
44
|
+
}
|
|
45
|
+
const manifestFile = parsers_1.parseManifestFile(manifestFileContents);
|
|
46
|
+
if (!manifestFile.name) {
|
|
47
|
+
manifestFile.name = defaultManifestFileName;
|
|
48
|
+
}
|
|
49
|
+
const lockFile = lockfileParser.parseLockFile(lockFileContents);
|
|
50
|
+
return lockfileParser.getDependencyTree(manifestFile, lockFile, includeDev, strict);
|
|
56
51
|
});
|
|
57
52
|
}
|
|
58
53
|
exports.buildDepTree = buildDepTree;
|
|
59
|
-
function buildDepTreeFromFiles(root, manifestFilePath, lockFilePath, includeDev, strict) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
lockFileFullPath);
|
|
89
|
-
}
|
|
90
|
-
manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
91
|
-
lockFileContents = fs.readFileSync(lockFileFullPath, 'utf-8');
|
|
92
|
-
return [4 /*yield*/, buildDepTree(manifestFileContents, lockFileContents, includeDev, lockFileType, strict, manifestFilePath)];
|
|
93
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
54
|
+
function buildDepTreeFromFiles(root, manifestFilePath, lockFilePath, includeDev = false, strict = true) {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (!root || !manifestFilePath || !lockFilePath) {
|
|
57
|
+
throw new Error('Missing required parameters for buildDepTreeFromFiles()');
|
|
58
|
+
}
|
|
59
|
+
let lockFileType;
|
|
60
|
+
if (_.endsWith(lockFilePath, 'package-lock.json')) {
|
|
61
|
+
lockFileType = parsers_1.LockfileType.npm;
|
|
62
|
+
}
|
|
63
|
+
else if (_.endsWith(lockFilePath, 'yarn.lock')) {
|
|
64
|
+
lockFileType = parsers_1.LockfileType.yarn;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new errors_1.InvalidUserInputError(`Unknown lockfile ${lockFilePath}. ` +
|
|
68
|
+
'Please provide either package-lock.json or yarn.lock.');
|
|
69
|
+
}
|
|
70
|
+
const manifestFileFullPath = path.resolve(root, manifestFilePath);
|
|
71
|
+
const lockFileFullPath = path.resolve(root, lockFilePath);
|
|
72
|
+
if (!fs.existsSync(manifestFileFullPath)) {
|
|
73
|
+
throw new errors_1.InvalidUserInputError('Target file package.json not found at ' +
|
|
74
|
+
`location: ${manifestFileFullPath}`);
|
|
75
|
+
}
|
|
76
|
+
if (!fs.existsSync(lockFileFullPath)) {
|
|
77
|
+
throw new errors_1.InvalidUserInputError('Lockfile not found at location: ' +
|
|
78
|
+
lockFileFullPath);
|
|
79
|
+
}
|
|
80
|
+
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
81
|
+
const lockFileContents = fs.readFileSync(lockFileFullPath, 'utf-8');
|
|
82
|
+
return yield buildDepTree(manifestFileContents, lockFileContents, includeDev, lockFileType, strict, manifestFilePath);
|
|
96
83
|
});
|
|
97
84
|
}
|
|
98
85
|
exports.buildDepTreeFromFiles = buildDepTreeFromFiles;
|
|
@@ -100,12 +87,12 @@ function getYarnWorkspacesFromFiles(root, manifestFilePath) {
|
|
|
100
87
|
if (!root || !manifestFilePath) {
|
|
101
88
|
throw new Error('Missing required parameters for getYarnWorkspacesFromFiles()');
|
|
102
89
|
}
|
|
103
|
-
|
|
90
|
+
const manifestFileFullPath = path.resolve(root, manifestFilePath);
|
|
104
91
|
if (!fs.existsSync(manifestFileFullPath)) {
|
|
105
92
|
throw new errors_1.InvalidUserInputError('Target file package.json not found at ' +
|
|
106
|
-
|
|
93
|
+
`location: ${manifestFileFullPath}`);
|
|
107
94
|
}
|
|
108
|
-
|
|
95
|
+
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
109
96
|
return parsers_1.getYarnWorkspaces(manifestFileContents);
|
|
110
97
|
}
|
|
111
98
|
exports.getYarnWorkspacesFromFiles = getYarnWorkspacesFromFiles;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAC7B,4BAA4B;AAC5B,uCASmB;AAYjB,gBAhBA,eAAK,CAgBA;AACL,uBAfA,sBAAY,CAeA;AAHZ,4BAXA,2BAAiB,CAWA;AATnB,uEAAgE;AAChE,+DAAyD;AACzD,yEAA2D;AAC3D,qCAAwF;AAUtF,kCAVM,gCAAuB,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AAA;AAnFC,sDAAqB;AAqFvB,SAAS,0BAA0B,CAAC,IAAI,EAAE,gBAAwB;IAChE,IAAI,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;KACjF;IACD,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAClE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;QACxC,MAAM,IAAI,8BAAqB,CAAC,wCAAwC;YACtE,aAAa,oBAAoB,EAAE,CAAC,CAAC;KACxC;IACD,MAAM,oBAAoB,GAAG,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IAE5E,OAAO,2BAAiB,CAAC,oBAAoB,CAAC,CAAC;AACjD,CAAC;AAhGC,gEAA0B"}
|
package/dist/parsers/index.d.ts
CHANGED
|
@@ -20,24 +20,33 @@ export interface ManifestFile {
|
|
|
20
20
|
};
|
|
21
21
|
version?: string;
|
|
22
22
|
}
|
|
23
|
-
export interface
|
|
24
|
-
name
|
|
25
|
-
version
|
|
23
|
+
export interface DepTreeDep {
|
|
24
|
+
name?: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
dependencies?: {
|
|
27
|
+
[depName: string]: DepTreeDep;
|
|
28
|
+
};
|
|
29
|
+
labels?: {
|
|
30
|
+
[key: string]: string | undefined;
|
|
31
|
+
scope?: 'dev' | 'prod';
|
|
32
|
+
pruned?: 'cyclic' | 'true';
|
|
33
|
+
missingLockFileEntry?: 'true';
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface PkgTree extends DepTreeDep {
|
|
37
|
+
type?: string;
|
|
38
|
+
packageFormatVersion?: string;
|
|
26
39
|
dependencies: {
|
|
27
|
-
[
|
|
40
|
+
[depName: string]: DepTreeDep;
|
|
28
41
|
};
|
|
29
42
|
meta?: {
|
|
30
43
|
nodeVersion: string;
|
|
31
44
|
};
|
|
32
|
-
labels?: {
|
|
33
|
-
depType: DepType;
|
|
34
|
-
};
|
|
35
45
|
hasDevDependencies?: boolean;
|
|
36
46
|
cyclic?: boolean;
|
|
37
|
-
missingLockFileEntry?: boolean;
|
|
38
47
|
size?: number;
|
|
39
48
|
}
|
|
40
|
-
export declare enum
|
|
49
|
+
export declare enum Scope {
|
|
41
50
|
prod = "prod",
|
|
42
51
|
dev = "dev"
|
|
43
52
|
}
|
|
@@ -52,5 +61,5 @@ export interface LockfileParser {
|
|
|
52
61
|
export declare type Lockfile = PackageLock | YarnLock;
|
|
53
62
|
export declare function parseManifestFile(manifestFileContents: string): ManifestFile;
|
|
54
63
|
export declare function getTopLevelDeps(targetFile: ManifestFile, includeDev: boolean): Dep[];
|
|
55
|
-
export declare function
|
|
64
|
+
export declare function createDepTreeDepFromDep(dep: Dep): DepTreeDep;
|
|
56
65
|
export declare function getYarnWorkspaces(targetFile: string): string[] | false;
|
package/dist/parsers/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(DepType = exports.DepType || (exports.DepType = {}));
|
|
3
|
+
const _ = require("lodash");
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
var Scope;
|
|
6
|
+
(function (Scope) {
|
|
7
|
+
Scope["prod"] = "prod";
|
|
8
|
+
Scope["dev"] = "dev";
|
|
9
|
+
})(Scope = exports.Scope || (exports.Scope = {}));
|
|
11
10
|
var LockfileType;
|
|
12
11
|
(function (LockfileType) {
|
|
13
12
|
LockfileType["npm"] = "npm";
|
|
@@ -24,43 +23,40 @@ function parseManifestFile(manifestFileContents) {
|
|
|
24
23
|
}
|
|
25
24
|
exports.parseManifestFile = parseManifestFile;
|
|
26
25
|
function getTopLevelDeps(targetFile, includeDev) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (
|
|
30
|
-
var _a = dependenciesIterator_1[_i], name = _a[0], version = _a[1];
|
|
26
|
+
const dependencies = [];
|
|
27
|
+
const dependenciesIterator = _.entries(Object.assign({}, targetFile.dependencies, (includeDev ? targetFile.devDependencies : null)));
|
|
28
|
+
for (const [name, version] of dependenciesIterator) {
|
|
31
29
|
dependencies.push({
|
|
32
30
|
dev: (includeDev && targetFile.devDependencies) ?
|
|
33
31
|
!!targetFile.devDependencies[name] : false,
|
|
34
|
-
name
|
|
35
|
-
version
|
|
32
|
+
name,
|
|
33
|
+
version,
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
return dependencies;
|
|
39
37
|
}
|
|
40
38
|
exports.getTopLevelDeps = getTopLevelDeps;
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
dependencies: {},
|
|
39
|
+
function createDepTreeDepFromDep(dep) {
|
|
40
|
+
return {
|
|
44
41
|
labels: {
|
|
45
|
-
|
|
42
|
+
scope: dep.dev ? Scope.dev : Scope.prod,
|
|
46
43
|
},
|
|
47
44
|
name: dep.name,
|
|
48
45
|
version: dep.version,
|
|
49
46
|
};
|
|
50
|
-
return pkgTree;
|
|
51
47
|
}
|
|
52
|
-
exports.
|
|
48
|
+
exports.createDepTreeDepFromDep = createDepTreeDepFromDep;
|
|
53
49
|
function getYarnWorkspaces(targetFile) {
|
|
54
50
|
try {
|
|
55
|
-
|
|
51
|
+
const packageJson = parseManifestFile(targetFile);
|
|
56
52
|
if (!!packageJson.workspaces && !!packageJson.private) {
|
|
57
|
-
return packageJson.workspaces
|
|
53
|
+
return [...packageJson.workspaces];
|
|
58
54
|
}
|
|
59
55
|
return false;
|
|
60
56
|
}
|
|
61
57
|
catch (e) {
|
|
62
58
|
throw new errors_1.InvalidUserInputError('package.json parsing failed with ' +
|
|
63
|
-
|
|
59
|
+
`error ${e.message}`);
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
62
|
exports.getYarnWorkspaces = getYarnWorkspaces;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/parsers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/parsers/index.ts"],"names":[],"mappings":";;AAAA,4BAA4B;AAG5B,sCAAgD;AAuDhD,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,sBAAa,CAAA;IACb,oBAAW,CAAA;AACb,CAAC,EAHW,KAAK,GAAL,aAAK,KAAL,aAAK,QAGhB;AAED,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAYD,SAAgB,iBAAiB,CAAC,oBAA4B;IAC5D,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACzC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,8BAAqB,CAAC,yCAAyC;YACvE,CAAC,CAAC,OAAO,CAAC,CAAC;KACd;AACH,CAAC;AAPD,8CAOC;AAED,SAAgB,eAAe,CAAC,UAAwB,EAAE,UAAmB;IAC3E,MAAM,YAAY,GAAU,EAAE,CAAC;IAE/B,MAAM,oBAAoB,GAAG,CAAC,CAAC,OAAO,mBACjC,UAAU,CAAC,YAAY,EACvB,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,EACnD,CAAC;IAEH,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,oBAAoB,EAAE;QAClD,YAAY,CAAC,IAAI,CAAC;YAChB,GAAG,EAAE,CAAC,UAAU,IAAI,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;gBAC/C,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,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