snyk-paket-parser 1.5.0 → 1.7.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/dependencies-parser.js +51 -65
- package/dist/dependencies-parser.js.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/invalid-user-input-error.js +8 -15
- package/dist/errors/invalid-user-input-error.js.map +1 -1
- package/dist/errors/out-of-sync-error.js +10 -13
- package/dist/errors/out-of-sync-error.js.map +1 -1
- package/dist/index.js +115 -223
- package/dist/index.js.map +1 -1
- package/dist/line-parser.js +15 -29
- package/dist/line-parser.js.map +1 -1
- package/dist/lock-parser.js +63 -85
- package/dist/lock-parser.js.map +1 -1
- package/package.json +16 -11
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.parseDependenciesFile = void 0;
|
|
4
|
+
const line_parser_1 = require("./line-parser");
|
|
5
|
+
const COMMENTS = ['#', '//'];
|
|
6
|
+
const GROUP = 'group';
|
|
7
|
+
const SOURCE = 'source';
|
|
8
8
|
// https://fsprojects.github.io/Paket/dependencies-file.html#Sources
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const GITHUB = 'github';
|
|
10
|
+
const NUGET = 'nuget';
|
|
11
|
+
const CLITOOL = 'clitool';
|
|
12
|
+
const GIT = 'git';
|
|
13
|
+
const GIST = 'gist';
|
|
14
|
+
const HTTP = 'http';
|
|
15
15
|
function parseNuget(line) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const commentRegex = new RegExp(`(?:${COMMENTS[0]}|${COMMENTS[1]}).+`);
|
|
17
|
+
const nameVersionOptionsRegex = new RegExp(/(\S+)\s*([^:\n]*)(:.*)?/);
|
|
18
|
+
const versionFirstOptionRegex = new RegExp(/\s(?=[^ ]*$)/);
|
|
19
|
+
const [, name, versionRangeAndFirstOption, restOptions] = line
|
|
20
20
|
.replace(NUGET, '') // Remove 'nuget' string
|
|
21
21
|
.replace(commentRegex, '') // Remove comments from line end
|
|
22
22
|
.trim()
|
|
23
|
-
.match(nameVersionOptionsRegex)
|
|
23
|
+
.match(nameVersionOptionsRegex); // Split into groups for further parsing
|
|
24
24
|
// nuget dependency result object to be returned
|
|
25
|
-
|
|
25
|
+
const result = {
|
|
26
26
|
source: NUGET,
|
|
27
|
-
name
|
|
27
|
+
name,
|
|
28
28
|
versionRange: versionRangeAndFirstOption,
|
|
29
29
|
options: {},
|
|
30
30
|
};
|
|
31
31
|
if (restOptions) {
|
|
32
32
|
// tslint:disable-next-line:prefer-const
|
|
33
|
-
|
|
33
|
+
let [versionRange, firstOptionName] = versionRangeAndFirstOption.split(versionFirstOptionRegex);
|
|
34
34
|
result.versionRange = versionRange;
|
|
35
35
|
// If version is missing it will treat first option as version
|
|
36
36
|
if (!firstOptionName) {
|
|
37
37
|
result.versionRange = '';
|
|
38
38
|
firstOptionName = versionRange;
|
|
39
39
|
}
|
|
40
|
-
result.options =
|
|
40
|
+
result.options = `${firstOptionName}${restOptions}`
|
|
41
41
|
.split(/\s*,\s*/) // Split by comma if there is couple possibilities for option (e.g. framework >= net40, net45)
|
|
42
42
|
.reverse()
|
|
43
|
-
.reduce(
|
|
43
|
+
.reduce((optionsMap, option, index, array) => {
|
|
44
44
|
if (option.includes(':')) {
|
|
45
|
-
|
|
45
|
+
const [optionKey, value] = option.split(/:\s*/);
|
|
46
46
|
optionsMap[optionKey] = value;
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
array[index + 1] = array[index + 1]
|
|
49
|
+
array[index + 1] = `${array[index + 1]}, ${option}`;
|
|
50
50
|
}
|
|
51
51
|
return optionsMap;
|
|
52
52
|
}, {});
|
|
@@ -55,12 +55,12 @@ function parseNuget(line) {
|
|
|
55
55
|
}
|
|
56
56
|
// https://fsprojects.github.io/Paket/github-dependencies.html
|
|
57
57
|
function parseGithub(line) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const re = /"[^"]*"|\S+/g;
|
|
59
|
+
const parts = line.match(re).splice(1);
|
|
60
|
+
const [repo, version] = parts[0].split(':');
|
|
61
61
|
return {
|
|
62
62
|
file: parts[1] || '',
|
|
63
|
-
repo
|
|
63
|
+
repo,
|
|
64
64
|
source: 'github',
|
|
65
65
|
token: parts[2] || '',
|
|
66
66
|
version: version || '',
|
|
@@ -69,45 +69,44 @@ function parseGithub(line) {
|
|
|
69
69
|
// https://fsprojects.github.io/Paket/nuget-dependencies.html#NuGet-feeds
|
|
70
70
|
function parseSource(line) {
|
|
71
71
|
// Split URL and option string including possible comments.
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const urlRe = /^source ([^\s]+)(.*)$/i;
|
|
73
|
+
const [, url, optionsString] = line.match(urlRe);
|
|
74
74
|
// Options in this line is always double quoted.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const options = {};
|
|
76
|
+
const optionsRe = /(.*?)\W*:\W*"(.*?)"/g;
|
|
77
|
+
const optionsStringTrimmed = optionsString.trim();
|
|
78
|
+
let matches = optionsRe.exec(optionsStringTrimmed);
|
|
79
79
|
while (matches) {
|
|
80
80
|
options[matches[1].trim()] = matches[2].trim();
|
|
81
81
|
matches = optionsRe.exec(optionsStringTrimmed);
|
|
82
82
|
}
|
|
83
83
|
return {
|
|
84
|
-
options
|
|
85
|
-
url
|
|
84
|
+
options,
|
|
85
|
+
url,
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
function parseGroupOption(line) {
|
|
89
89
|
// Line could be separated by space or by colon.
|
|
90
90
|
// TODO: Think what to do with possible comment in the line.
|
|
91
|
-
|
|
91
|
+
const result = line.match(/(\S+?)\s*(:|\s)\s*(.*)/);
|
|
92
92
|
return [result[1] || '', result[3] || ''];
|
|
93
93
|
}
|
|
94
94
|
function parseDependenciesFile(input) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var group = {
|
|
95
|
+
const lines = line_parser_1.parseLines(input);
|
|
96
|
+
const result = [];
|
|
97
|
+
let group = {
|
|
99
98
|
dependencies: [],
|
|
100
99
|
name: null,
|
|
101
100
|
options: {},
|
|
102
101
|
sources: [],
|
|
103
102
|
};
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
for (const line of lines) {
|
|
104
|
+
const isComment = !!COMMENTS.find((comment) => line.data.startsWith(comment));
|
|
106
105
|
// Ignore commented lines.
|
|
107
106
|
if (isComment) {
|
|
108
|
-
|
|
107
|
+
continue;
|
|
109
108
|
}
|
|
110
|
-
if (line.data.startsWith(GROUP
|
|
109
|
+
if (line.data.startsWith(`${GROUP} `)) {
|
|
111
110
|
result.push(group);
|
|
112
111
|
group = {
|
|
113
112
|
dependencies: [],
|
|
@@ -116,44 +115,31 @@ function parseDependenciesFile(input) {
|
|
|
116
115
|
sources: [],
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
|
-
else if (line.data.startsWith(SOURCE
|
|
118
|
+
else if (line.data.startsWith(`${SOURCE} `)) {
|
|
120
119
|
group.sources.push(parseSource(line.data));
|
|
121
120
|
}
|
|
122
|
-
else if (line.data.startsWith(GITHUB
|
|
121
|
+
else if (line.data.startsWith(`${GITHUB} `)) {
|
|
123
122
|
group.dependencies.push(parseGithub(line.data));
|
|
124
123
|
}
|
|
125
|
-
else if (line.data.startsWith(NUGET
|
|
124
|
+
else if (line.data.startsWith(`${NUGET} `)) {
|
|
126
125
|
group.dependencies.push(parseNuget(line.data));
|
|
127
126
|
}
|
|
128
|
-
else if (line.data.startsWith(CLITOOL
|
|
127
|
+
else if (line.data.startsWith(`${CLITOOL} `)) {
|
|
129
128
|
// TODO
|
|
130
129
|
}
|
|
131
|
-
else if (line.data.startsWith(GIT
|
|
130
|
+
else if (line.data.startsWith(`${GIT} `)) {
|
|
132
131
|
// TODO
|
|
133
132
|
}
|
|
134
|
-
else if (line.data.startsWith(GIST
|
|
133
|
+
else if (line.data.startsWith(`${GIST} `)) {
|
|
135
134
|
// TODO
|
|
136
135
|
}
|
|
137
|
-
else if (line.data.startsWith(HTTP
|
|
136
|
+
else if (line.data.startsWith(`${HTTP} `)) {
|
|
138
137
|
// TODO
|
|
139
138
|
}
|
|
140
139
|
else {
|
|
141
|
-
|
|
140
|
+
const [name, value] = parseGroupOption(line.data);
|
|
142
141
|
group.options[name] = value;
|
|
143
142
|
}
|
|
144
|
-
};
|
|
145
|
-
try {
|
|
146
|
-
for (var lines_1 = tslib_1.__values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
147
|
-
var line = lines_1_1.value;
|
|
148
|
-
_loop_1(line);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
152
|
-
finally {
|
|
153
|
-
try {
|
|
154
|
-
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
155
|
-
}
|
|
156
|
-
finally { if (e_1) throw e_1.error; }
|
|
157
143
|
}
|
|
158
144
|
result.push(group);
|
|
159
145
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies-parser.js","sourceRoot":"","sources":["../lib/dependencies-parser.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"dependencies-parser.js","sourceRoot":"","sources":["../lib/dependencies-parser.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC7B,MAAM,KAAK,GAAG,OAAO,CAAC;AACtB,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,oEAAoE;AACpE,MAAM,MAAM,GAAG,Q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,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE;YAC3C,OAAO;SACR;aAAM;YACL,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;SAC7B;KACF;IAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEnB,OAAO,MAAM,CAAC;AAChB,CAAC;AAjDD,sDAiDC"}
|
package/dist/errors/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var invalid_user_input_error_1 = require("./invalid-user-input-error");
|
|
4
|
-
exports
|
|
4
|
+
Object.defineProperty(exports, "InvalidUserInputError", { enumerable: true, get: function () { return invalid_user_input_error_1.InvalidUserInputError; } });
|
|
5
5
|
var out_of_sync_error_1 = require("./out-of-sync-error");
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "OutOfSyncError", { enumerable: true, get: function () { return out_of_sync_error_1.OutOfSyncError; } });
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/errors/index.ts"],"names":[],"mappings":";;AAAA,uEAAiE;AAAzD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/errors/index.ts"],"names":[],"mappings":";;AAAA,uEAAiE;AAAzD,iIAAA,qBAAqB,OAAA;AAC7B,yDAAmD;AAA3C,mHAAA,cAAc,OAAA"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
var _this = _super.apply(this, tslib_1.__spread(args)) || this;
|
|
12
|
-
_this.code = 422;
|
|
13
|
-
_this.name = 'InvalidUserInputError';
|
|
14
|
-
Error.captureStackTrace(_this, InvalidUserInputError);
|
|
15
|
-
return _this;
|
|
3
|
+
exports.InvalidUserInputError = void 0;
|
|
4
|
+
class InvalidUserInputError extends Error {
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
super(...args);
|
|
7
|
+
this.code = 422;
|
|
8
|
+
this.name = 'InvalidUserInputError';
|
|
9
|
+
Error.captureStackTrace(this, InvalidUserInputError);
|
|
16
10
|
}
|
|
17
|
-
|
|
18
|
-
}(Error));
|
|
11
|
+
}
|
|
19
12
|
exports.InvalidUserInputError = InvalidUserInputError;
|
|
20
13
|
//# 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":";;;AAAA
|
|
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,IAAW;QACxB,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,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _this = _super.call(this, "Dependency " + dependencyName + " was not found in paket.lock. Your " +
|
|
3
|
+
exports.OutOfSyncError = void 0;
|
|
4
|
+
class OutOfSyncError extends Error {
|
|
5
|
+
constructor(dependencyName) {
|
|
6
|
+
super(`Dependency ${dependencyName} was not found in paket.lock. Your ` +
|
|
8
7
|
'paket.dependencies and paket.lock are probably out of sync. Please ' +
|
|
9
|
-
'run "paket install" and try again.')
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Error.captureStackTrace(
|
|
14
|
-
return _this;
|
|
8
|
+
'run "paket install" and try again.');
|
|
9
|
+
this.code = 422;
|
|
10
|
+
this.name = 'OutOfSyncError';
|
|
11
|
+
this.dependencyName = dependencyName;
|
|
12
|
+
Error.captureStackTrace(this, OutOfSyncError);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
}(Error));
|
|
14
|
+
}
|
|
18
15
|
exports.OutOfSyncError = OutOfSyncError;
|
|
19
16
|
//# 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":";;;AAAA
|
|
1
|
+
{"version":3,"file":"out-of-sync-error.js","sourceRoot":"","sources":["../../lib/errors/out-of-sync-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAY,cAAsB;QAChC,KAAK,CAAC,cAAc,cAAc,qCAAqC;YACrE,qEAAqE;YACrE,oCAAoC,CAAC,CAAC;QARnC,SAAI,GAAG,GAAG,CAAC;QACX,SAAI,GAAG,gBAAgB,CAAC;QAQ7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC;CACF;AAbD,wCAaC"}
|
package/dist/index.js
CHANGED
|
@@ -1,279 +1,171 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
exports.buildDepTreeFromFiles = exports.DepType = exports.OutOfSyncError = exports.InvalidUserInputError = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lock_parser_1 = require("./lock-parser");
|
|
6
|
+
const dependencies_parser_1 = require("./dependencies-parser");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
Object.defineProperty(exports, "InvalidUserInputError", { enumerable: true, get: function () { return errors_1.InvalidUserInputError; } });
|
|
11
|
+
Object.defineProperty(exports, "OutOfSyncError", { enumerable: true, get: function () { return errors_1.OutOfSyncError; } });
|
|
12
|
+
const DEV_GROUPS = ['build', 'test', 'tests'];
|
|
13
|
+
const SUPPORTED_SOURCES = ['nuget'];
|
|
14
|
+
const FREQUENCY_THRESHOLD = 100;
|
|
14
15
|
var DepType;
|
|
15
16
|
(function (DepType) {
|
|
16
17
|
DepType["prod"] = "prod";
|
|
17
18
|
DepType["dev"] = "dev";
|
|
18
19
|
})(DepType = exports.DepType || (exports.DepType = {}));
|
|
19
|
-
function buildDepTreeFromFiles(root, manifestFilePath, lockFilePath, includeDev, strict) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
lockFileContents = fs.readFileSync(lockFileFullPath, 'utf-8');
|
|
39
|
-
_a = {};
|
|
40
|
-
return [4 /*yield*/, buildDepTree(manifestFileContents, lockFileContents, includeDev, strict)];
|
|
41
|
-
case 1: return [2 /*return*/, (_a.dependencies = _b.sent(),
|
|
42
|
-
_a.name = path.basename(path.dirname(manifestFileFullPath)),
|
|
43
|
-
_a.version = '',
|
|
44
|
-
_a)];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
20
|
+
function buildDepTreeFromFiles(root, manifestFilePath, lockFilePath, includeDev = false, strict = true) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const manifestFileFullPath = path.resolve(root, manifestFilePath);
|
|
23
|
+
const lockFileFullPath = path.resolve(root, lockFilePath);
|
|
24
|
+
if (!fs.existsSync(manifestFileFullPath)) {
|
|
25
|
+
throw new errors_1.InvalidUserInputError('Target file paket.dependencies not found at ' +
|
|
26
|
+
`location: ${manifestFileFullPath}`);
|
|
27
|
+
}
|
|
28
|
+
if (!fs.existsSync(lockFileFullPath)) {
|
|
29
|
+
throw new errors_1.InvalidUserInputError('Lockfile not found at location: ' +
|
|
30
|
+
lockFileFullPath);
|
|
31
|
+
}
|
|
32
|
+
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
33
|
+
const lockFileContents = fs.readFileSync(lockFileFullPath, 'utf-8');
|
|
34
|
+
return {
|
|
35
|
+
dependencies: yield buildDepTree(manifestFileContents, lockFileContents, includeDev, strict),
|
|
36
|
+
name: path.basename(path.dirname(manifestFileFullPath)),
|
|
37
|
+
version: '',
|
|
38
|
+
};
|
|
47
39
|
});
|
|
48
40
|
}
|
|
49
41
|
exports.buildDepTreeFromFiles = buildDepTreeFromFiles;
|
|
50
|
-
function buildDepTree(manifestFileContents, lockFileContents, includeDev, strict) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
collectResolvedDeps(lockFile, dependenciesMap);
|
|
61
|
-
try {
|
|
62
|
-
for (_c = tslib_1.__values(dependenciesMap.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
63
|
-
dep = _d.value;
|
|
64
|
-
if (dep.root) {
|
|
65
|
-
calculateReferences(dep, dependenciesMap);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
42
|
+
function buildDepTree(manifestFileContents, lockFileContents, includeDev = false, strict = true) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const manifestFile = dependencies_parser_1.parseDependenciesFile(manifestFileContents);
|
|
45
|
+
const lockFile = lock_parser_1.parseLockFile(lockFileContents);
|
|
46
|
+
const dependenciesMap = new Map();
|
|
47
|
+
collectRootDeps(manifestFile, dependenciesMap);
|
|
48
|
+
collectResolvedDeps(lockFile, dependenciesMap);
|
|
49
|
+
for (const dep of dependenciesMap.values()) {
|
|
50
|
+
if (dep.root) {
|
|
51
|
+
calculateReferences(dep, dependenciesMap);
|
|
68
52
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
dependencies = {};
|
|
77
|
-
try {
|
|
78
|
-
for (_e = tslib_1.__values(dependenciesMap.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
79
|
-
dep = _f.value;
|
|
80
|
-
if (dep.root && (includeDev || dep.depType === DepType.prod)) {
|
|
81
|
-
if (strict && !dep.resolved) {
|
|
82
|
-
throw new errors_1.OutOfSyncError(dep.name);
|
|
83
|
-
}
|
|
84
|
-
dependencies[dep.name] = buildTreeFromList(dep, dependenciesMap);
|
|
85
|
-
if (!dep.resolved) {
|
|
86
|
-
dependencies[dep.name].missingLockFileEntry = true;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
53
|
+
}
|
|
54
|
+
const dependencies = {};
|
|
55
|
+
for (const dep of dependenciesMap.values()) {
|
|
56
|
+
if (dep.root && (includeDev || dep.depType === DepType.prod)) {
|
|
57
|
+
if (strict && !dep.resolved) {
|
|
58
|
+
throw new errors_1.OutOfSyncError(dep.name);
|
|
89
59
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
60
|
+
dependencies[dep.name] = buildTreeFromList(dep, dependenciesMap);
|
|
61
|
+
if (!dep.resolved) {
|
|
62
|
+
dependencies[dep.name].missingLockFileEntry = true;
|
|
95
63
|
}
|
|
96
|
-
finally { if (e_2) throw e_2.error; }
|
|
97
64
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
65
|
+
}
|
|
66
|
+
const frequentSubTree = buildFrequentDepsSubtree(dependenciesMap);
|
|
67
|
+
if (Object.keys(frequentSubTree.dependencies).length) {
|
|
68
|
+
dependencies[frequentSubTree.name] = frequentSubTree;
|
|
69
|
+
}
|
|
70
|
+
return dependencies;
|
|
104
71
|
});
|
|
105
72
|
}
|
|
106
73
|
function collectRootDeps(manifestFile, dependenciesMap) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
for (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
for (var _c = tslib_1.__values(group.dependencies), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
114
|
-
var dep = _d.value;
|
|
115
|
-
if (SUPPORTED_SOURCES.indexOf(dep.source.toLowerCase()) === -1) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
var nugetDep = dep;
|
|
119
|
-
if (!dependenciesMap.has(nugetDep.name.toLowerCase())) {
|
|
120
|
-
dependenciesMap.set(nugetDep.name.toLowerCase(), {
|
|
121
|
-
name: nugetDep.name,
|
|
122
|
-
// Will be overwritten in `collectResolvedDeps`.
|
|
123
|
-
version: nugetDep.versionRange,
|
|
124
|
-
// Will be overwritten in `collectResolvedDeps`.
|
|
125
|
-
dependencies: [],
|
|
126
|
-
depType: isDev ? DepType.dev : DepType.prod,
|
|
127
|
-
root: true,
|
|
128
|
-
refs: 1,
|
|
129
|
-
// Will be overwritten in `collectResolvedDeps`.
|
|
130
|
-
resolved: false,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
74
|
+
for (const group of manifestFile) {
|
|
75
|
+
const isDev = DEV_GROUPS.indexOf((group.name || '').toLowerCase()) !== -1;
|
|
76
|
+
for (const dep of group.dependencies) {
|
|
77
|
+
if (SUPPORTED_SOURCES.indexOf(dep.source.toLowerCase()) === -1) {
|
|
78
|
+
continue;
|
|
134
79
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
80
|
+
const nugetDep = dep;
|
|
81
|
+
if (!dependenciesMap.has(nugetDep.name.toLowerCase())) {
|
|
82
|
+
dependenciesMap.set(nugetDep.name.toLowerCase(), {
|
|
83
|
+
name: nugetDep.name,
|
|
84
|
+
// Will be overwritten in `collectResolvedDeps`.
|
|
85
|
+
version: nugetDep.versionRange,
|
|
86
|
+
// Will be overwritten in `collectResolvedDeps`.
|
|
87
|
+
dependencies: [],
|
|
88
|
+
depType: isDev ? DepType.dev : DepType.prod,
|
|
89
|
+
root: true,
|
|
90
|
+
refs: 1,
|
|
91
|
+
// Will be overwritten in `collectResolvedDeps`.
|
|
92
|
+
resolved: false,
|
|
93
|
+
});
|
|
141
94
|
}
|
|
142
95
|
}
|
|
143
96
|
}
|
|
144
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
145
|
-
finally {
|
|
146
|
-
try {
|
|
147
|
-
if (manifestFile_1_1 && !manifestFile_1_1.done && (_a = manifestFile_1.return)) _a.call(manifestFile_1);
|
|
148
|
-
}
|
|
149
|
-
finally { if (e_3) throw e_3.error; }
|
|
150
|
-
}
|
|
151
97
|
}
|
|
152
98
|
function collectResolvedDeps(lockFile, dependenciesMap) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
for (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
for (var _e = tslib_1.__values(group.dependencies), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
160
|
-
var dep = _f.value;
|
|
161
|
-
if (SUPPORTED_SOURCES.indexOf(dep.repository.toLowerCase()) === -1) {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
if (dependenciesMap.has(dep.name.toLowerCase())) {
|
|
165
|
-
var rootDep = dependenciesMap.get(dep.name.toLowerCase());
|
|
166
|
-
rootDep.version = dep.version;
|
|
167
|
-
rootDep.dependencies = dep.dependencies.map(function (d) { return d.name.toLowerCase(); });
|
|
168
|
-
rootDep.resolved = true;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
dependenciesMap.set(dep.name.toLowerCase(), {
|
|
172
|
-
name: dep.name,
|
|
173
|
-
version: dep.version,
|
|
174
|
-
dependencies: dep.dependencies.map(function (d) { return d.name.toLowerCase(); }),
|
|
175
|
-
depType: isDev ? DepType.dev : DepType.prod,
|
|
176
|
-
root: false,
|
|
177
|
-
refs: 0,
|
|
178
|
-
resolved: true,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
99
|
+
for (const group of lockFile.groups) {
|
|
100
|
+
const isDev = DEV_GROUPS.indexOf((group.name || '').toLowerCase()) !== -1;
|
|
101
|
+
for (const dep of group.dependencies) {
|
|
102
|
+
if (SUPPORTED_SOURCES.indexOf(dep.repository.toLowerCase()) === -1) {
|
|
103
|
+
continue;
|
|
182
104
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
105
|
+
if (dependenciesMap.has(dep.name.toLowerCase())) {
|
|
106
|
+
const rootDep = dependenciesMap.get(dep.name.toLowerCase());
|
|
107
|
+
rootDep.version = dep.version;
|
|
108
|
+
rootDep.dependencies = dep.dependencies.map((d) => d.name.toLowerCase());
|
|
109
|
+
rootDep.resolved = true;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
dependenciesMap.set(dep.name.toLowerCase(), {
|
|
113
|
+
name: dep.name,
|
|
114
|
+
version: dep.version,
|
|
115
|
+
dependencies: dep.dependencies.map((d) => d.name.toLowerCase()),
|
|
116
|
+
depType: isDev ? DepType.dev : DepType.prod,
|
|
117
|
+
root: false,
|
|
118
|
+
refs: 0,
|
|
119
|
+
resolved: true,
|
|
120
|
+
});
|
|
189
121
|
}
|
|
190
122
|
}
|
|
191
123
|
}
|
|
192
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
193
|
-
finally {
|
|
194
|
-
try {
|
|
195
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
196
|
-
}
|
|
197
|
-
finally { if (e_5) throw e_5.error; }
|
|
198
|
-
}
|
|
199
124
|
}
|
|
200
125
|
function calculateReferences(node, dependenciesMap) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
sub
|
|
207
|
-
// Do not propagate calculations if we already reach threshold for the node.
|
|
208
|
-
if (sub.refs < FREQUENCY_THRESHOLD) {
|
|
209
|
-
calculateReferences(sub, dependenciesMap);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
214
|
-
finally {
|
|
215
|
-
try {
|
|
216
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
126
|
+
for (const subName of node.dependencies) {
|
|
127
|
+
const sub = dependenciesMap.get(subName);
|
|
128
|
+
sub.refs += node.refs;
|
|
129
|
+
// Do not propagate calculations if we already reach threshold for the node.
|
|
130
|
+
if (sub.refs < FREQUENCY_THRESHOLD) {
|
|
131
|
+
calculateReferences(sub, dependenciesMap);
|
|
217
132
|
}
|
|
218
|
-
finally { if (e_7) throw e_7.error; }
|
|
219
133
|
}
|
|
220
134
|
}
|
|
221
135
|
function buildFrequentDepsSubtree(dependenciesMap) {
|
|
222
|
-
|
|
136
|
+
const tree = {
|
|
223
137
|
name: 'meta-common-packages',
|
|
224
138
|
version: 'meta',
|
|
225
139
|
dependencies: {},
|
|
226
140
|
};
|
|
227
|
-
getFrequentDependencies(dependenciesMap).forEach(
|
|
228
|
-
|
|
141
|
+
getFrequentDependencies(dependenciesMap).forEach((listItem) => {
|
|
142
|
+
const treeNode = buildTreeFromList(listItem, dependenciesMap);
|
|
229
143
|
tree.dependencies[treeNode.name] = treeNode;
|
|
230
144
|
});
|
|
231
145
|
return tree;
|
|
232
146
|
}
|
|
233
147
|
function getFrequentDependencies(dependenciesMap) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
var dep = _c.value;
|
|
239
|
-
if (!dep.root && dep.refs >= FREQUENCY_THRESHOLD) {
|
|
240
|
-
frequentDeps.push(dep);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
245
|
-
finally {
|
|
246
|
-
try {
|
|
247
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
148
|
+
const frequentDeps = [];
|
|
149
|
+
for (const dep of dependenciesMap.values()) {
|
|
150
|
+
if (!dep.root && dep.refs >= FREQUENCY_THRESHOLD) {
|
|
151
|
+
frequentDeps.push(dep);
|
|
248
152
|
}
|
|
249
|
-
finally { if (e_8) throw e_8.error; }
|
|
250
153
|
}
|
|
251
154
|
return frequentDeps;
|
|
252
155
|
}
|
|
253
156
|
function buildTreeFromList(listItem, dependenciesMap) {
|
|
254
|
-
|
|
255
|
-
var tree = {
|
|
157
|
+
const tree = {
|
|
256
158
|
name: listItem.name,
|
|
257
159
|
version: listItem.version,
|
|
258
160
|
dependencies: {},
|
|
259
161
|
depType: listItem.depType,
|
|
260
162
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
var subtree = buildTreeFromList(subListItem, dependenciesMap);
|
|
267
|
-
tree.dependencies[subtree.name] = subtree;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
272
|
-
finally {
|
|
273
|
-
try {
|
|
274
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
163
|
+
for (const name of listItem.dependencies) {
|
|
164
|
+
const subListItem = dependenciesMap.get(name);
|
|
165
|
+
if (!(subListItem.refs >= FREQUENCY_THRESHOLD)) {
|
|
166
|
+
const subtree = buildTreeFromList(subListItem, dependenciesMap);
|
|
167
|
+
tree.dependencies[subtree.name] = subtree;
|
|
275
168
|
}
|
|
276
|
-
finally { if (e_9) throw e_9.error; }
|
|
277
169
|
}
|
|
278
170
|
return tree;
|
|
279
171
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;AAAA,+CAAuD;AACvD,+DAAgG;AAChG,6BAA6B;AAC7B,yBAAyB;AACzB,qCAA+D;AAMvD,sGANA,8BAAqB,OAMA;AAAE,+FANA,uBAAc,OAMA;AAJ7C,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,CAAC;AACpC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAgBhC,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,sBAAW,CAAA;AACb,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAYD,SAAsB,qBAAqB,CACzC,IAAY,EACZ,gBAAwB,EACxB,YAAoB,EACpB,UAAU,GAAG,KAAK,EAClB,MAAM,GAAG,IAAI;;QAEb,MAAM,oBAAoB,GAAG,IAAI,CAAC,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,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/line-parser.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.parseLines = exports.Line = void 0;
|
|
4
|
+
class Line {
|
|
5
|
+
constructor(data, indentation) {
|
|
6
6
|
this.data = data;
|
|
7
7
|
this.indentation = indentation;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
}());
|
|
9
|
+
}
|
|
11
10
|
exports.Line = Line;
|
|
12
11
|
function countIndents(line, indent) {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const spaces = line.match(/^\s*/)[0].length;
|
|
13
|
+
const count = spaces / indent.length;
|
|
15
14
|
if (count % 1 !== 0) {
|
|
16
15
|
throw new Error('Line indentation malformed');
|
|
17
16
|
}
|
|
@@ -30,29 +29,16 @@ function removeByteOrderMark(input) {
|
|
|
30
29
|
return input;
|
|
31
30
|
}
|
|
32
31
|
// parse space indented lines into array of Lines
|
|
33
|
-
function parseLines(input, indent /* two spaces */, lineSeparator) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (var lines_1 = tslib_1.__values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
41
|
-
var line = lines_1_1.value;
|
|
42
|
-
var data = line.trim();
|
|
43
|
-
if (data === '') { // GROUPS often separated by blank lines
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
var indentation = countIndents(line, indent);
|
|
47
|
-
result.push(new Line(data, indentation));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
51
|
-
finally {
|
|
52
|
-
try {
|
|
53
|
-
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
32
|
+
function parseLines(input, indent = ' ' /* two spaces */, lineSeparator = /\r?\n/) {
|
|
33
|
+
const lines = removeByteOrderMark(input).split(lineSeparator);
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const line of lines) {
|
|
36
|
+
const data = line.trim();
|
|
37
|
+
if (data === '') { // GROUPS often separated by blank lines
|
|
38
|
+
continue;
|
|
54
39
|
}
|
|
55
|
-
|
|
40
|
+
const indentation = countIndents(line, indent);
|
|
41
|
+
result.push(new Line(data, indentation));
|
|
56
42
|
}
|
|
57
43
|
return result;
|
|
58
44
|
}
|
package/dist/line-parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-parser.js","sourceRoot":"","sources":["../lib/line-parser.ts"],"names":[],"mappings":";;;AAAA;
|
|
1
|
+
{"version":3,"file":"line-parser.js","sourceRoot":"","sources":["../lib/line-parser.ts"],"names":[],"mappings":";;;AAAA,MAAa,IAAI;IAIf,YAAY,IAAY,EAAE,WAAmB;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AARD,oBAQC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,MAAc;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAC/C;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oEAAoE;AACpE,+EAA+E;AAC/E,iDAAiD;AACjD,EAAE;AACF,kDAAkD;AAClD,wEAAwE;AACxE,SAAS,mBAAmB,CAAC,KAAa;IACxC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACpD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iDAAiD;AACjD,SAAgB,UAAU,CACxB,KAAa,EACb,SAAiB,IAAI,CAAC,gBAAgB,EACtC,gBAAwB,OAAO;IAG/B,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAW,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEzB,IAAI,IAAI,KAAK,EAAE,EAAE,EAAE,wCAAwC;YACzD,SAAS;SACV;QAED,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/C,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;KAC1C;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAtBD,gCAsBC"}
|
package/dist/lock-parser.js
CHANGED
|
@@ -1,42 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
exports.parseLockFile = void 0;
|
|
4
|
+
const line_parser_1 = require("./line-parser");
|
|
5
|
+
const REPOSITORY_TYPES = ['HTTP', 'GIST', 'GIT', 'NUGET', 'GITHUB']; // naming convention in paket's standard parser
|
|
6
|
+
const GROUP = 'GROUP';
|
|
7
|
+
const REMOTE = 'REMOTE';
|
|
8
|
+
const SPECS = 'SPECS';
|
|
9
9
|
function parseOptions(optionsString) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var optionParts = option.split(/: +/);
|
|
16
|
-
if (optionParts[0] !== '') {
|
|
17
|
-
options[optionParts[0]] = optionParts[1];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
22
|
-
finally {
|
|
23
|
-
try {
|
|
24
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
10
|
+
const options = {};
|
|
11
|
+
for (const option of optionsString.split(/, +/)) {
|
|
12
|
+
const optionParts = option.split(/: +/);
|
|
13
|
+
if (optionParts[0] !== '') {
|
|
14
|
+
options[optionParts[0]] = optionParts[1];
|
|
25
15
|
}
|
|
26
|
-
finally { if (e_1) throw e_1.error; }
|
|
27
16
|
}
|
|
28
17
|
return options;
|
|
29
18
|
}
|
|
30
19
|
function parseDependencyLine(line, isSubDependency) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
const re = /^([^ ]+)\W+\(([^)]+)\)\W*(.*)$/;
|
|
21
|
+
const match = line.data.match(re);
|
|
22
|
+
const result = {
|
|
34
23
|
name: '',
|
|
35
24
|
version: '',
|
|
36
25
|
options: {},
|
|
37
26
|
};
|
|
38
27
|
if (!match && !isSubDependency) {
|
|
39
|
-
throw new Error(
|
|
28
|
+
throw new Error(`Malformed paket.lock file: Missing resolved version on ${line.data}`);
|
|
40
29
|
}
|
|
41
30
|
// Octokit (0.10.0)
|
|
42
31
|
// Microsoft.Net.Http
|
|
@@ -56,79 +45,68 @@ function parseDependencyLine(line, isSubDependency) {
|
|
|
56
45
|
return result;
|
|
57
46
|
}
|
|
58
47
|
function parseLockFile(input) {
|
|
59
|
-
|
|
60
|
-
var result = {
|
|
48
|
+
const result = {
|
|
61
49
|
groups: [],
|
|
62
50
|
};
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
const lines = line_parser_1.parseLines(input);
|
|
52
|
+
let group = {
|
|
65
53
|
name: null,
|
|
66
54
|
repositories: {},
|
|
67
55
|
dependencies: [],
|
|
68
56
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
dependencies: [],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
else if (REPOSITORY_TYPES.indexOf(upperCaseLine) !== -1) {
|
|
86
|
-
depContext.repository = line.data;
|
|
87
|
-
group.repositories[line.data] = [];
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
var _b = tslib_1.__read(line.data.split(':'), 2), optionName = _b[0], optionValue = _b[1];
|
|
91
|
-
group.options = group.options || {};
|
|
92
|
-
// TODO: keeping null option values to know the option names
|
|
93
|
-
// need to decide what to do with them
|
|
94
|
-
group.options[optionName.trim()] = optionValue ? optionValue.trim() : null;
|
|
95
|
-
}
|
|
57
|
+
let depContext = {};
|
|
58
|
+
let dependency = null;
|
|
59
|
+
for (const line of lines) {
|
|
60
|
+
const upperCaseLine = line.data.toUpperCase();
|
|
61
|
+
if (line.indentation === 0) { // group or group option
|
|
62
|
+
if (upperCaseLine.startsWith(GROUP)) {
|
|
63
|
+
result.groups.push(group);
|
|
64
|
+
depContext = {};
|
|
65
|
+
group = {
|
|
66
|
+
name: line.data.substr(GROUP.length).trim(),
|
|
67
|
+
repositories: {},
|
|
68
|
+
dependencies: [],
|
|
69
|
+
};
|
|
96
70
|
}
|
|
97
|
-
else if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (remote) {
|
|
101
|
-
depContext.remote = remote;
|
|
102
|
-
group.repositories[depContext.repository].push(remote);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else if (upperCaseLine.startsWith(SPECS)) {
|
|
106
|
-
// TODO: for now we add the specs as boolean in meta
|
|
107
|
-
group.specs = true;
|
|
108
|
-
}
|
|
71
|
+
else if (REPOSITORY_TYPES.indexOf(upperCaseLine) !== -1) {
|
|
72
|
+
depContext.repository = line.data;
|
|
73
|
+
group.repositories[line.data] = [];
|
|
109
74
|
}
|
|
110
75
|
else {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
76
|
+
const [optionName, optionValue] = line.data.split(':');
|
|
77
|
+
group.options = group.options || {};
|
|
78
|
+
// TODO: keeping null option values to know the option names
|
|
79
|
+
// need to decide what to do with them
|
|
80
|
+
group.options[optionName.trim()] = optionValue ? optionValue.trim() : null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (line.indentation === 1) { // remote or specs
|
|
84
|
+
if (upperCaseLine.startsWith(REMOTE)) {
|
|
85
|
+
const remote = line.data.substring(REMOTE.length + ':'.length).trim();
|
|
86
|
+
if (remote) {
|
|
87
|
+
depContext.remote = remote;
|
|
88
|
+
group.repositories[depContext.repository].push(remote);
|
|
119
89
|
}
|
|
120
90
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
91
|
+
else if (upperCaseLine.startsWith(SPECS)) {
|
|
92
|
+
// TODO: for now we add the specs as boolean in meta
|
|
93
|
+
group.specs = true;
|
|
123
94
|
}
|
|
124
95
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
96
|
+
else {
|
|
97
|
+
const dep = parseDependencyLine(line, line.indentation === 3);
|
|
98
|
+
if (line.indentation === 2) { // Resolved Dependency
|
|
99
|
+
dep.remote = depContext.remote;
|
|
100
|
+
dep.repository = depContext.repository;
|
|
101
|
+
dependency = dep;
|
|
102
|
+
}
|
|
103
|
+
else { // Transitive Dependency
|
|
104
|
+
dependency.dependencies.push(dep);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (group && dependency && group.dependencies.indexOf(dependency) === -1) {
|
|
108
|
+
group.dependencies.push(dependency);
|
|
130
109
|
}
|
|
131
|
-
finally { if (e_2) throw e_2.error; }
|
|
132
110
|
}
|
|
133
111
|
result.groups.push(group);
|
|
134
112
|
return result;
|
package/dist/lock-parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-parser.js","sourceRoot":"","sources":["../lib/lock-parser.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"lock-parser.js","sourceRoot":"","sources":["../lib/lock-parser.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,+CAA+C;AACpH,MAAM,KAAK,GAAG,OAAO,CAAC;AACtB,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,KAAK,GAAG,OAAO,CAAC;AA6BtB,SAAS,YAAY,CAAC,aAAqB;IACzC,MAAM,OAAO,GAAG,EAAY,CAAC;IAE7B,KAAK,MAAM,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACzB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;SAC1C;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAU,EAAE,eAAwB;IAC/D,MAAM,EAAE,GAAG,gCAAgC,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAElC,MAAM,MAAM,GAAe;QACzB,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,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,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;gBAC1C,oDAAoD;gBACpD,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;aACpB;SACF;aAAM;YACL,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC;YAE9D,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE,EAAE,sBAAsB;gBAClD,GAAG,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;gBAC/B,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;gBACvC,UAAU,GAAG,GAAG,CAAC;aAClB;iBAAM,EAAE,wBAAwB;gBAC/B,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACnC;SACF;QAED,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE;YACxE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACrC;KACF;IAED,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE1B,OAAO,MAAM,CAAC;AAChB,CAAC;AAlED,sCAkEC"}
|
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
7
|
-
"test-jest": "jest",
|
|
8
7
|
"lint": "tslint -p tsconfig.json",
|
|
8
|
+
"format": "tslint -p tsconfig.json --fix",
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"build-watch": "tsc -w",
|
|
11
11
|
"prepare": "npm run build"
|
|
@@ -18,24 +18,29 @@
|
|
|
18
18
|
"author": "snyk.io",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=8"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
|
-
"bin",
|
|
25
24
|
"dist"
|
|
26
25
|
],
|
|
27
26
|
"homepage": "https://github.com/snyk/snyk-paket-parser#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/snyk/snyk-paket-parser/issues"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
28
33
|
"dependencies": {
|
|
29
34
|
"tslib": "^1.9.3"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
32
|
-
"@types/
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"jest": "^
|
|
38
|
-
"ts-jest": "^
|
|
37
|
+
"@types/jest": "^25.2.3",
|
|
38
|
+
"@types/node": "^12.20.55",
|
|
39
|
+
"ts-node": "^8.10.2",
|
|
40
|
+
"tslint": "^6.1.3",
|
|
41
|
+
"typescript": "^3.9.10",
|
|
42
|
+
"jest": "^25.5.4",
|
|
43
|
+
"ts-jest": "^25.5.1"
|
|
39
44
|
},
|
|
40
|
-
"version": "1.
|
|
45
|
+
"version": "1.7.0"
|
|
41
46
|
}
|