snyk-paket-parser 1.4.1 → 1.6.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 +73 -71
- package/dist/dependencies-parser.js.map +1 -1
- 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 +9 -13
- package/dist/errors/out-of-sync-error.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +112 -223
- package/dist/index.js.map +1 -1
- package/dist/line-parser.js +14 -29
- package/dist/line-parser.js.map +1 -1
- package/dist/lock-parser.js +62 -85
- package/dist/lock-parser.js.map +1 -1
- package/package.json +4 -5
|
@@ -1,49 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var SOURCE = 'source';
|
|
3
|
+
const line_parser_1 = require("./line-parser");
|
|
4
|
+
const COMMENTS = ['#', '//'];
|
|
5
|
+
const GROUP = 'group';
|
|
6
|
+
const SOURCE = 'source';
|
|
8
7
|
// https://fsprojects.github.io/Paket/dependencies-file.html#Sources
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const GITHUB = 'github';
|
|
9
|
+
const NUGET = 'nuget';
|
|
10
|
+
const CLITOOL = 'clitool';
|
|
11
|
+
const GIT = 'git';
|
|
12
|
+
const GIST = 'gist';
|
|
13
|
+
const HTTP = 'http';
|
|
15
14
|
function parseNuget(line) {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const commentRegex = new RegExp(`(?:${COMMENTS[0]}|${COMMENTS[1]}).+`);
|
|
16
|
+
const nameVersionOptionsRegex = new RegExp(/(\S+)\s*([^:\n]*)(:.*)?/);
|
|
17
|
+
const versionFirstOptionRegex = new RegExp(/\s(?=[^ ]*$)/);
|
|
18
|
+
const [, name, versionRangeAndFirstOption, restOptions] = line
|
|
19
|
+
.replace(NUGET, '') // Remove 'nuget' string
|
|
20
|
+
.replace(commentRegex, '') // Remove comments from line end
|
|
21
|
+
.trim()
|
|
22
|
+
.match(nameVersionOptionsRegex); // Split into groups for further parsing
|
|
23
|
+
// nuget dependency result object to be returned
|
|
24
|
+
const result = {
|
|
25
|
+
source: NUGET,
|
|
26
|
+
name,
|
|
27
|
+
versionRange: versionRangeAndFirstOption,
|
|
18
28
|
options: {},
|
|
19
|
-
source: 'nuget',
|
|
20
|
-
versionRange: '',
|
|
21
29
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
if (restOptions) {
|
|
31
|
+
// tslint:disable-next-line:prefer-const
|
|
32
|
+
let [versionRange, firstOptionName] = versionRangeAndFirstOption.split(versionFirstOptionRegex);
|
|
33
|
+
result.versionRange = versionRange;
|
|
34
|
+
// If version is missing it will treat first option as version
|
|
35
|
+
if (!firstOptionName) {
|
|
36
|
+
result.versionRange = '';
|
|
37
|
+
firstOptionName = versionRange;
|
|
38
|
+
}
|
|
39
|
+
result.options = `${firstOptionName}${restOptions}`
|
|
40
|
+
.split(/\s*,\s*/) // Split by comma if there is couple possibilities for option (e.g. framework >= net40, net45)
|
|
41
|
+
.reverse()
|
|
42
|
+
.reduce((optionsMap, option, index, array) => {
|
|
43
|
+
if (option.includes(':')) {
|
|
44
|
+
const [optionKey, value] = option.split(/:\s*/);
|
|
45
|
+
optionsMap[optionKey] = value;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
array[index + 1] = `${array[index + 1]}, ${option}`;
|
|
49
|
+
}
|
|
50
|
+
return optionsMap;
|
|
51
|
+
}, {});
|
|
30
52
|
}
|
|
31
|
-
dependencyString = dependencyString.replace(NUGET, '').trim();
|
|
32
|
-
// Split by space between words. First chunk will be name of the dependency and all rest - version.
|
|
33
|
-
var dependencyStringParts = dependencyString.split(/\s+/);
|
|
34
|
-
result.name = dependencyStringParts[0];
|
|
35
|
-
result.versionRange = dependencyStringParts.splice(1).join(' ');
|
|
36
|
-
// TODO: parse options
|
|
37
53
|
return result;
|
|
38
54
|
}
|
|
39
55
|
// https://fsprojects.github.io/Paket/github-dependencies.html
|
|
40
56
|
function parseGithub(line) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
const re = /"[^"]*"|\S+/g;
|
|
58
|
+
const parts = line.match(re).splice(1);
|
|
59
|
+
const [repo, version] = parts[0].split(':');
|
|
44
60
|
return {
|
|
45
61
|
file: parts[1] || '',
|
|
46
|
-
repo
|
|
62
|
+
repo,
|
|
47
63
|
source: 'github',
|
|
48
64
|
token: parts[2] || '',
|
|
49
65
|
version: version || '',
|
|
@@ -52,45 +68,44 @@ function parseGithub(line) {
|
|
|
52
68
|
// https://fsprojects.github.io/Paket/nuget-dependencies.html#NuGet-feeds
|
|
53
69
|
function parseSource(line) {
|
|
54
70
|
// Split URL and option string including possible comments.
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
const urlRe = /^source ([^\s]+)(.*)$/i;
|
|
72
|
+
const [, url, optionsString] = line.match(urlRe);
|
|
57
73
|
// Options in this line is always double quoted.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
const options = {};
|
|
75
|
+
const optionsRe = /(.*?)\W*:\W*"(.*?)"/g;
|
|
76
|
+
const optionsStringTrimmed = optionsString.trim();
|
|
77
|
+
let matches = optionsRe.exec(optionsStringTrimmed);
|
|
62
78
|
while (matches) {
|
|
63
79
|
options[matches[1].trim()] = matches[2].trim();
|
|
64
80
|
matches = optionsRe.exec(optionsStringTrimmed);
|
|
65
81
|
}
|
|
66
82
|
return {
|
|
67
|
-
options
|
|
68
|
-
url
|
|
83
|
+
options,
|
|
84
|
+
url,
|
|
69
85
|
};
|
|
70
86
|
}
|
|
71
87
|
function parseGroupOption(line) {
|
|
72
88
|
// Line could be separated by space or by colon.
|
|
73
89
|
// TODO: Think what to do with possible comment in the line.
|
|
74
|
-
|
|
90
|
+
const result = line.match(/(\S+?)\s*(:|\s)\s*(.*)/);
|
|
75
91
|
return [result[1] || '', result[3] || ''];
|
|
76
92
|
}
|
|
77
93
|
function parseDependenciesFile(input) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var group = {
|
|
94
|
+
const lines = line_parser_1.parseLines(input);
|
|
95
|
+
const result = [];
|
|
96
|
+
let group = {
|
|
82
97
|
dependencies: [],
|
|
83
98
|
name: null,
|
|
84
99
|
options: {},
|
|
85
100
|
sources: [],
|
|
86
101
|
};
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
const isComment = !!COMMENTS.find((comment) => line.data.startsWith(comment));
|
|
89
104
|
// Ignore commented lines.
|
|
90
105
|
if (isComment) {
|
|
91
|
-
|
|
106
|
+
continue;
|
|
92
107
|
}
|
|
93
|
-
if (line.data.startsWith(GROUP
|
|
108
|
+
if (line.data.startsWith(`${GROUP} `)) {
|
|
94
109
|
result.push(group);
|
|
95
110
|
group = {
|
|
96
111
|
dependencies: [],
|
|
@@ -99,44 +114,31 @@ function parseDependenciesFile(input) {
|
|
|
99
114
|
sources: [],
|
|
100
115
|
};
|
|
101
116
|
}
|
|
102
|
-
else if (line.data.startsWith(SOURCE
|
|
117
|
+
else if (line.data.startsWith(`${SOURCE} `)) {
|
|
103
118
|
group.sources.push(parseSource(line.data));
|
|
104
119
|
}
|
|
105
|
-
else if (line.data.startsWith(GITHUB
|
|
120
|
+
else if (line.data.startsWith(`${GITHUB} `)) {
|
|
106
121
|
group.dependencies.push(parseGithub(line.data));
|
|
107
122
|
}
|
|
108
|
-
else if (line.data.startsWith(NUGET
|
|
123
|
+
else if (line.data.startsWith(`${NUGET} `)) {
|
|
109
124
|
group.dependencies.push(parseNuget(line.data));
|
|
110
125
|
}
|
|
111
|
-
else if (line.data.startsWith(CLITOOL
|
|
126
|
+
else if (line.data.startsWith(`${CLITOOL} `)) {
|
|
112
127
|
// TODO
|
|
113
128
|
}
|
|
114
|
-
else if (line.data.startsWith(GIT
|
|
129
|
+
else if (line.data.startsWith(`${GIT} `)) {
|
|
115
130
|
// TODO
|
|
116
131
|
}
|
|
117
|
-
else if (line.data.startsWith(GIST
|
|
132
|
+
else if (line.data.startsWith(`${GIST} `)) {
|
|
118
133
|
// TODO
|
|
119
134
|
}
|
|
120
|
-
else if (line.data.startsWith(HTTP
|
|
135
|
+
else if (line.data.startsWith(`${HTTP} `)) {
|
|
121
136
|
// TODO
|
|
122
137
|
}
|
|
123
138
|
else {
|
|
124
|
-
|
|
139
|
+
const [name, value] = parseGroupOption(line.data);
|
|
125
140
|
group.options[name] = value;
|
|
126
141
|
}
|
|
127
|
-
};
|
|
128
|
-
try {
|
|
129
|
-
for (var lines_1 = tslib_1.__values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
130
|
-
var line = lines_1_1.value;
|
|
131
|
-
_loop_1(line);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
135
|
-
finally {
|
|
136
|
-
try {
|
|
137
|
-
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
138
|
-
}
|
|
139
|
-
finally { if (e_1) throw e_1.error; }
|
|
140
142
|
}
|
|
141
143
|
result.push(group);
|
|
142
144
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies-parser.js","sourceRoot":"","sources":["../lib/dependencies-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies-parser.js","sourceRoot":"","sources":["../lib/dependencies-parser.ts"],"names":[],"mappings":";;AAAA,+CAAyC;AAEzC,MAAM,QAAQ,GAAG,CAAC,GAAG,EAA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C1C,OAAO;SACR;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE;YAC3C,OAAO;SACR;aAAM,IAAI,IAAI,CAAC,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"}
|
|
@@ -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, tslib_1.__spread(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,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,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function OutOfSyncError(dependencyName) {
|
|
7
|
-
var _this = _super.call(this, "Dependency " + dependencyName + " was not found in paket.lock. Your " +
|
|
3
|
+
class OutOfSyncError extends Error {
|
|
4
|
+
constructor(dependencyName) {
|
|
5
|
+
super(`Dependency ${dependencyName} was not found in paket.lock. Your ` +
|
|
8
6
|
'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;
|
|
7
|
+
'run "paket install" and try again.');
|
|
8
|
+
this.code = 422;
|
|
9
|
+
this.name = 'OutOfSyncError';
|
|
10
|
+
this.dependencyName = dependencyName;
|
|
11
|
+
Error.captureStackTrace(this, OutOfSyncError);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
}(Error));
|
|
13
|
+
}
|
|
18
14
|
exports.OutOfSyncError = OutOfSyncError;
|
|
19
15
|
//# 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,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.d.ts
CHANGED
|
@@ -16,4 +16,3 @@ export declare enum DepType {
|
|
|
16
16
|
dev = "dev"
|
|
17
17
|
}
|
|
18
18
|
export declare function buildDepTreeFromFiles(root: string, manifestFilePath: string, lockFilePath: string, includeDev?: boolean, strict?: boolean): Promise<DepTree>;
|
|
19
|
-
export declare function buildDepTree(manifestFileContents: string, lockFileContents: string, includeDev?: boolean, strict?: boolean, defaultManifestFileName?: string): Promise<DepTree>;
|
package/dist/index.js
CHANGED
|
@@ -1,281 +1,170 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const lock_parser_1 = require("./lock-parser");
|
|
5
|
+
const dependencies_parser_1 = require("./dependencies-parser");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
9
|
exports.InvalidUserInputError = errors_1.InvalidUserInputError;
|
|
10
10
|
exports.OutOfSyncError = errors_1.OutOfSyncError;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const DEV_GROUPS = ['build', 'test', 'tests'];
|
|
12
|
+
const SUPPORTED_SOURCES = ['nuget'];
|
|
13
|
+
const FREQUENCY_THRESHOLD = 100;
|
|
14
14
|
var DepType;
|
|
15
15
|
(function (DepType) {
|
|
16
16
|
DepType["prod"] = "prod";
|
|
17
17
|
DepType["dev"] = "dev";
|
|
18
18
|
})(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
|
-
return [4 /*yield*/, buildDepTree(manifestFileContents, lockFileContents, includeDev, strict, manifestFileFullPath)];
|
|
40
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
41
|
-
}
|
|
42
|
-
});
|
|
19
|
+
function buildDepTreeFromFiles(root, manifestFilePath, lockFilePath, includeDev = false, strict = true) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const manifestFileFullPath = path.resolve(root, manifestFilePath);
|
|
22
|
+
const lockFileFullPath = path.resolve(root, lockFilePath);
|
|
23
|
+
if (!fs.existsSync(manifestFileFullPath)) {
|
|
24
|
+
throw new errors_1.InvalidUserInputError('Target file paket.dependencies not found at ' +
|
|
25
|
+
`location: ${manifestFileFullPath}`);
|
|
26
|
+
}
|
|
27
|
+
if (!fs.existsSync(lockFileFullPath)) {
|
|
28
|
+
throw new errors_1.InvalidUserInputError('Lockfile not found at location: ' +
|
|
29
|
+
lockFileFullPath);
|
|
30
|
+
}
|
|
31
|
+
const manifestFileContents = fs.readFileSync(manifestFileFullPath, 'utf-8');
|
|
32
|
+
const lockFileContents = fs.readFileSync(lockFileFullPath, 'utf-8');
|
|
33
|
+
return {
|
|
34
|
+
dependencies: yield buildDepTree(manifestFileContents, lockFileContents, includeDev, strict),
|
|
35
|
+
name: path.basename(path.dirname(manifestFileFullPath)),
|
|
36
|
+
version: '',
|
|
37
|
+
};
|
|
43
38
|
});
|
|
44
39
|
}
|
|
45
40
|
exports.buildDepTreeFromFiles = buildDepTreeFromFiles;
|
|
46
|
-
function buildDepTree(manifestFileContents, lockFileContents, includeDev, strict
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
dependencies: {},
|
|
57
|
-
name: defaultManifestFileName,
|
|
58
|
-
version: '',
|
|
59
|
-
};
|
|
60
|
-
dependenciesMap = new Map();
|
|
61
|
-
collectRootDeps(manifestFile, dependenciesMap);
|
|
62
|
-
collectResolvedDeps(lockFile, dependenciesMap);
|
|
63
|
-
try {
|
|
64
|
-
for (_c = tslib_1.__values(dependenciesMap.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
65
|
-
dep = _d.value;
|
|
66
|
-
if (dep.root) {
|
|
67
|
-
calculateReferences(dep, dependenciesMap);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
41
|
+
function buildDepTree(manifestFileContents, lockFileContents, includeDev = false, strict = true) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const manifestFile = dependencies_parser_1.parseDependenciesFile(manifestFileContents);
|
|
44
|
+
const lockFile = lock_parser_1.parseLockFile(lockFileContents);
|
|
45
|
+
const dependenciesMap = new Map();
|
|
46
|
+
collectRootDeps(manifestFile, dependenciesMap);
|
|
47
|
+
collectResolvedDeps(lockFile, dependenciesMap);
|
|
48
|
+
for (const dep of dependenciesMap.values()) {
|
|
49
|
+
if (dep.root) {
|
|
50
|
+
calculateReferences(dep, dependenciesMap);
|
|
70
51
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
for (_e = tslib_1.__values(dependenciesMap.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
80
|
-
dep = _f.value;
|
|
81
|
-
if (dep.root && (includeDev || dep.depType === DepType.prod)) {
|
|
82
|
-
if (strict && !dep.resolved) {
|
|
83
|
-
throw new errors_1.OutOfSyncError(dep.name);
|
|
84
|
-
}
|
|
85
|
-
depTree.dependencies[dep.name] = buildTreeFromList(dep, dependenciesMap);
|
|
86
|
-
if (!dep.resolved) {
|
|
87
|
-
depTree.dependencies[dep.name].missingLockFileEntry = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
52
|
+
}
|
|
53
|
+
const dependencies = {};
|
|
54
|
+
for (const dep of dependenciesMap.values()) {
|
|
55
|
+
if (dep.root && (includeDev || dep.depType === DepType.prod)) {
|
|
56
|
+
if (strict && !dep.resolved) {
|
|
57
|
+
throw new errors_1.OutOfSyncError(dep.name);
|
|
90
58
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
59
|
+
dependencies[dep.name] = buildTreeFromList(dep, dependenciesMap);
|
|
60
|
+
if (!dep.resolved) {
|
|
61
|
+
dependencies[dep.name].missingLockFileEntry = true;
|
|
96
62
|
}
|
|
97
|
-
finally { if (e_2) throw e_2.error; }
|
|
98
63
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
64
|
+
}
|
|
65
|
+
const frequentSubTree = buildFrequentDepsSubtree(dependenciesMap);
|
|
66
|
+
if (Object.keys(frequentSubTree.dependencies).length) {
|
|
67
|
+
dependencies[frequentSubTree.name] = frequentSubTree;
|
|
68
|
+
}
|
|
69
|
+
return dependencies;
|
|
105
70
|
});
|
|
106
71
|
}
|
|
107
|
-
exports.buildDepTree = buildDepTree;
|
|
108
72
|
function collectRootDeps(manifestFile, dependenciesMap) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
for (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
for (var _c = tslib_1.__values(group.dependencies), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
116
|
-
var dep = _d.value;
|
|
117
|
-
if (SUPPORTED_SOURCES.indexOf(dep.source.toLowerCase()) === -1) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
var nugetDep = dep;
|
|
121
|
-
if (!dependenciesMap.has(nugetDep.name.toLowerCase())) {
|
|
122
|
-
dependenciesMap.set(nugetDep.name.toLowerCase(), {
|
|
123
|
-
name: nugetDep.name,
|
|
124
|
-
// Will be overwritten in `collectResolvedDeps`.
|
|
125
|
-
version: nugetDep.versionRange,
|
|
126
|
-
// Will be overwritten in `collectResolvedDeps`.
|
|
127
|
-
dependencies: [],
|
|
128
|
-
depType: isDev ? DepType.dev : DepType.prod,
|
|
129
|
-
root: true,
|
|
130
|
-
refs: 1,
|
|
131
|
-
// Will be overwritten in `collectResolvedDeps`.
|
|
132
|
-
resolved: false,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
73
|
+
for (const group of manifestFile) {
|
|
74
|
+
const isDev = DEV_GROUPS.indexOf((group.name || '').toLowerCase()) !== -1;
|
|
75
|
+
for (const dep of group.dependencies) {
|
|
76
|
+
if (SUPPORTED_SOURCES.indexOf(dep.source.toLowerCase()) === -1) {
|
|
77
|
+
continue;
|
|
136
78
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
79
|
+
const nugetDep = dep;
|
|
80
|
+
if (!dependenciesMap.has(nugetDep.name.toLowerCase())) {
|
|
81
|
+
dependenciesMap.set(nugetDep.name.toLowerCase(), {
|
|
82
|
+
name: nugetDep.name,
|
|
83
|
+
// Will be overwritten in `collectResolvedDeps`.
|
|
84
|
+
version: nugetDep.versionRange,
|
|
85
|
+
// Will be overwritten in `collectResolvedDeps`.
|
|
86
|
+
dependencies: [],
|
|
87
|
+
depType: isDev ? DepType.dev : DepType.prod,
|
|
88
|
+
root: true,
|
|
89
|
+
refs: 1,
|
|
90
|
+
// Will be overwritten in `collectResolvedDeps`.
|
|
91
|
+
resolved: false,
|
|
92
|
+
});
|
|
143
93
|
}
|
|
144
94
|
}
|
|
145
95
|
}
|
|
146
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
147
|
-
finally {
|
|
148
|
-
try {
|
|
149
|
-
if (manifestFile_1_1 && !manifestFile_1_1.done && (_a = manifestFile_1.return)) _a.call(manifestFile_1);
|
|
150
|
-
}
|
|
151
|
-
finally { if (e_3) throw e_3.error; }
|
|
152
|
-
}
|
|
153
96
|
}
|
|
154
97
|
function collectResolvedDeps(lockFile, dependenciesMap) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
for (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
for (var _e = tslib_1.__values(group.dependencies), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
162
|
-
var dep = _f.value;
|
|
163
|
-
if (SUPPORTED_SOURCES.indexOf(dep.repository.toLowerCase()) === -1) {
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
if (dependenciesMap.has(dep.name.toLowerCase())) {
|
|
167
|
-
var rootDep = dependenciesMap.get(dep.name.toLowerCase());
|
|
168
|
-
rootDep.version = dep.version;
|
|
169
|
-
rootDep.dependencies = dep.dependencies.map(function (d) { return d.name.toLowerCase(); });
|
|
170
|
-
rootDep.resolved = true;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
dependenciesMap.set(dep.name.toLowerCase(), {
|
|
174
|
-
name: dep.name,
|
|
175
|
-
version: dep.version,
|
|
176
|
-
dependencies: dep.dependencies.map(function (d) { return d.name.toLowerCase(); }),
|
|
177
|
-
depType: isDev ? DepType.dev : DepType.prod,
|
|
178
|
-
root: false,
|
|
179
|
-
refs: 0,
|
|
180
|
-
resolved: true,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
98
|
+
for (const group of lockFile.groups) {
|
|
99
|
+
const isDev = DEV_GROUPS.indexOf((group.name || '').toLowerCase()) !== -1;
|
|
100
|
+
for (const dep of group.dependencies) {
|
|
101
|
+
if (SUPPORTED_SOURCES.indexOf(dep.repository.toLowerCase()) === -1) {
|
|
102
|
+
continue;
|
|
184
103
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
104
|
+
if (dependenciesMap.has(dep.name.toLowerCase())) {
|
|
105
|
+
const rootDep = dependenciesMap.get(dep.name.toLowerCase());
|
|
106
|
+
rootDep.version = dep.version;
|
|
107
|
+
rootDep.dependencies = dep.dependencies.map((d) => d.name.toLowerCase());
|
|
108
|
+
rootDep.resolved = true;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
dependenciesMap.set(dep.name.toLowerCase(), {
|
|
112
|
+
name: dep.name,
|
|
113
|
+
version: dep.version,
|
|
114
|
+
dependencies: dep.dependencies.map((d) => d.name.toLowerCase()),
|
|
115
|
+
depType: isDev ? DepType.dev : DepType.prod,
|
|
116
|
+
root: false,
|
|
117
|
+
refs: 0,
|
|
118
|
+
resolved: true,
|
|
119
|
+
});
|
|
191
120
|
}
|
|
192
121
|
}
|
|
193
122
|
}
|
|
194
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
195
|
-
finally {
|
|
196
|
-
try {
|
|
197
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
198
|
-
}
|
|
199
|
-
finally { if (e_5) throw e_5.error; }
|
|
200
|
-
}
|
|
201
123
|
}
|
|
202
124
|
function calculateReferences(node, dependenciesMap) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
sub
|
|
209
|
-
// Do not propagate calculations if we already reach threshold for the node.
|
|
210
|
-
if (sub.refs < FREQUENCY_THRESHOLD) {
|
|
211
|
-
calculateReferences(sub, dependenciesMap);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
216
|
-
finally {
|
|
217
|
-
try {
|
|
218
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
125
|
+
for (const subName of node.dependencies) {
|
|
126
|
+
const sub = dependenciesMap.get(subName);
|
|
127
|
+
sub.refs += node.refs;
|
|
128
|
+
// Do not propagate calculations if we already reach threshold for the node.
|
|
129
|
+
if (sub.refs < FREQUENCY_THRESHOLD) {
|
|
130
|
+
calculateReferences(sub, dependenciesMap);
|
|
219
131
|
}
|
|
220
|
-
finally { if (e_7) throw e_7.error; }
|
|
221
132
|
}
|
|
222
133
|
}
|
|
223
134
|
function buildFrequentDepsSubtree(dependenciesMap) {
|
|
224
|
-
|
|
135
|
+
const tree = {
|
|
225
136
|
name: 'meta-common-packages',
|
|
226
137
|
version: 'meta',
|
|
227
138
|
dependencies: {},
|
|
228
139
|
};
|
|
229
|
-
getFrequentDependencies(dependenciesMap).forEach(
|
|
230
|
-
|
|
140
|
+
getFrequentDependencies(dependenciesMap).forEach((listItem) => {
|
|
141
|
+
const treeNode = buildTreeFromList(listItem, dependenciesMap);
|
|
231
142
|
tree.dependencies[treeNode.name] = treeNode;
|
|
232
143
|
});
|
|
233
144
|
return tree;
|
|
234
145
|
}
|
|
235
146
|
function getFrequentDependencies(dependenciesMap) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
var dep = _c.value;
|
|
241
|
-
if (!dep.root && dep.refs >= FREQUENCY_THRESHOLD) {
|
|
242
|
-
frequentDeps.push(dep);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
247
|
-
finally {
|
|
248
|
-
try {
|
|
249
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
147
|
+
const frequentDeps = [];
|
|
148
|
+
for (const dep of dependenciesMap.values()) {
|
|
149
|
+
if (!dep.root && dep.refs >= FREQUENCY_THRESHOLD) {
|
|
150
|
+
frequentDeps.push(dep);
|
|
250
151
|
}
|
|
251
|
-
finally { if (e_8) throw e_8.error; }
|
|
252
152
|
}
|
|
253
153
|
return frequentDeps;
|
|
254
154
|
}
|
|
255
155
|
function buildTreeFromList(listItem, dependenciesMap) {
|
|
256
|
-
|
|
257
|
-
var tree = {
|
|
156
|
+
const tree = {
|
|
258
157
|
name: listItem.name,
|
|
259
158
|
version: listItem.version,
|
|
260
159
|
dependencies: {},
|
|
261
160
|
depType: listItem.depType,
|
|
262
161
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
var subtree = buildTreeFromList(subListItem, dependenciesMap);
|
|
269
|
-
tree.dependencies[subtree.name] = subtree;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
274
|
-
finally {
|
|
275
|
-
try {
|
|
276
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
162
|
+
for (const name of listItem.dependencies) {
|
|
163
|
+
const subListItem = dependenciesMap.get(name);
|
|
164
|
+
if (!(subListItem.refs >= FREQUENCY_THRESHOLD)) {
|
|
165
|
+
const subtree = buildTreeFromList(subListItem, dependenciesMap);
|
|
166
|
+
tree.dependencies[subtree.name] = subtree;
|
|
277
167
|
}
|
|
278
|
-
finally { if (e_9) throw e_9.error; }
|
|
279
168
|
}
|
|
280
169
|
return tree;
|
|
281
170
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA
|
|
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,gCANA,8BAAqB,CAMA;AAAE,yBANA,uBAAc,CAMA;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,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAClE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAE1D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YACxC,MAAM,IAAI,8BAAqB,CAAC,8CAA8C;gBAC5E,aAAa,oBAAoB,EAAE,CAAC,CAAC;SACxC;QACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;YACpC,MAAM,IAAI,8BAAqB,CAAC,kCAAkC;gBAChE,gBAAgB,CAAC,CAAC;SACrB;QAED,MAAM,oBAAoB,GAAG,EAAE,CAAC,YAA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,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE;QAC1C,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,mBAAmB,EAAE;YAChD,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACxB;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAwB,EAAE,eAA4C;IAC/F,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE,QAAQ,CAAC,OAAO;KACf,CAAC;IAEb,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,YAAY,EAAE;QACxC,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,CAAC,WAAW,CAAC,IAAI,IAAI,mBAAmB,CAAC,EAAE;YAC9C,MAAM,OAAO,GAAG,iBAAiB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;YAChE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;SAC3C;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/line-parser.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function Line(data, indentation) {
|
|
3
|
+
class Line {
|
|
4
|
+
constructor(data, indentation) {
|
|
6
5
|
this.data = data;
|
|
7
6
|
this.indentation = indentation;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
}());
|
|
8
|
+
}
|
|
11
9
|
exports.Line = Line;
|
|
12
10
|
function countIndents(line, indent) {
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const spaces = line.match(/^\s*/)[0].length;
|
|
12
|
+
const count = spaces / indent.length;
|
|
15
13
|
if (count % 1 !== 0) {
|
|
16
14
|
throw new Error('Line indentation malformed');
|
|
17
15
|
}
|
|
@@ -30,29 +28,16 @@ function removeByteOrderMark(input) {
|
|
|
30
28
|
return input;
|
|
31
29
|
}
|
|
32
30
|
// 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);
|
|
31
|
+
function parseLines(input, indent = ' ' /* two spaces */, lineSeparator = /\r?\n/) {
|
|
32
|
+
const lines = removeByteOrderMark(input).split(lineSeparator);
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const line of lines) {
|
|
35
|
+
const data = line.trim();
|
|
36
|
+
if (data === '') { // GROUPS often separated by blank lines
|
|
37
|
+
continue;
|
|
54
38
|
}
|
|
55
|
-
|
|
39
|
+
const indentation = countIndents(line, indent);
|
|
40
|
+
result.push(new Line(data, indentation));
|
|
56
41
|
}
|
|
57
42
|
return result;
|
|
58
43
|
}
|
package/dist/line-parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-parser.js","sourceRoot":"","sources":["../lib/line-parser.ts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EzB,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,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var SPECS = 'SPECS';
|
|
3
|
+
const line_parser_1 = require("./line-parser");
|
|
4
|
+
const REPOSITORY_TYPES = ['HTTP', 'GIST', 'GIT', 'NUGET', 'GITHUB']; // naming convention in paket's standard parser
|
|
5
|
+
const GROUP = 'GROUP';
|
|
6
|
+
const REMOTE = 'REMOTE';
|
|
7
|
+
const SPECS = 'SPECS';
|
|
9
8
|
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);
|
|
9
|
+
const options = {};
|
|
10
|
+
for (const option of optionsString.split(/, +/)) {
|
|
11
|
+
const optionParts = option.split(/: +/);
|
|
12
|
+
if (optionParts[0] !== '') {
|
|
13
|
+
options[optionParts[0]] = optionParts[1];
|
|
25
14
|
}
|
|
26
|
-
finally { if (e_1) throw e_1.error; }
|
|
27
15
|
}
|
|
28
16
|
return options;
|
|
29
17
|
}
|
|
30
18
|
function parseDependencyLine(line, isSubDependency) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const re = /^([^ ]+)\W+\(([^)]+)\)\W*(.*)$/;
|
|
20
|
+
const match = line.data.match(re);
|
|
21
|
+
const result = {
|
|
34
22
|
name: '',
|
|
35
23
|
version: '',
|
|
36
24
|
options: {},
|
|
37
25
|
};
|
|
38
26
|
if (!match && !isSubDependency) {
|
|
39
|
-
throw new Error(
|
|
27
|
+
throw new Error(`Malformed paket.lock file: Missing resolved version on ${line.data}`);
|
|
40
28
|
}
|
|
41
29
|
// Octokit (0.10.0)
|
|
42
30
|
// Microsoft.Net.Http
|
|
@@ -56,79 +44,68 @@ function parseDependencyLine(line, isSubDependency) {
|
|
|
56
44
|
return result;
|
|
57
45
|
}
|
|
58
46
|
function parseLockFile(input) {
|
|
59
|
-
|
|
60
|
-
var result = {
|
|
47
|
+
const result = {
|
|
61
48
|
groups: [],
|
|
62
49
|
};
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
const lines = line_parser_1.parseLines(input);
|
|
51
|
+
let group = {
|
|
65
52
|
name: null,
|
|
66
53
|
repositories: {},
|
|
67
54
|
dependencies: [],
|
|
68
55
|
};
|
|
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
|
-
}
|
|
56
|
+
let depContext = {};
|
|
57
|
+
let dependency = null;
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
const upperCaseLine = line.data.toUpperCase();
|
|
60
|
+
if (line.indentation === 0) { // group or group option
|
|
61
|
+
if (upperCaseLine.startsWith(GROUP)) {
|
|
62
|
+
result.groups.push(group);
|
|
63
|
+
depContext = {};
|
|
64
|
+
group = {
|
|
65
|
+
name: line.data.substr(GROUP.length).trim(),
|
|
66
|
+
repositories: {},
|
|
67
|
+
dependencies: [],
|
|
68
|
+
};
|
|
96
69
|
}
|
|
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
|
-
}
|
|
70
|
+
else if (REPOSITORY_TYPES.indexOf(upperCaseLine) !== -1) {
|
|
71
|
+
depContext.repository = line.data;
|
|
72
|
+
group.repositories[line.data] = [];
|
|
109
73
|
}
|
|
110
74
|
else {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
75
|
+
const [optionName, optionValue] = line.data.split(':');
|
|
76
|
+
group.options = group.options || {};
|
|
77
|
+
// TODO: keeping null option values to know the option names
|
|
78
|
+
// need to decide what to do with them
|
|
79
|
+
group.options[optionName.trim()] = optionValue ? optionValue.trim() : null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (line.indentation === 1) { // remote or specs
|
|
83
|
+
if (upperCaseLine.startsWith(REMOTE)) {
|
|
84
|
+
const remote = line.data.substring(REMOTE.length + ':'.length).trim();
|
|
85
|
+
if (remote) {
|
|
86
|
+
depContext.remote = remote;
|
|
87
|
+
group.repositories[depContext.repository].push(remote);
|
|
119
88
|
}
|
|
120
89
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
90
|
+
else if (upperCaseLine.startsWith(SPECS)) {
|
|
91
|
+
// TODO: for now we add the specs as boolean in meta
|
|
92
|
+
group.specs = true;
|
|
123
93
|
}
|
|
124
94
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
95
|
+
else {
|
|
96
|
+
const dep = parseDependencyLine(line, line.indentation === 3);
|
|
97
|
+
if (line.indentation === 2) { // Resolved Dependency
|
|
98
|
+
dep.remote = depContext.remote;
|
|
99
|
+
dep.repository = depContext.repository;
|
|
100
|
+
dependency = dep;
|
|
101
|
+
}
|
|
102
|
+
else { // Transitive Dependency
|
|
103
|
+
dependency.dependencies.push(dep);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (group && dependency && group.dependencies.indexOf(dependency) === -1) {
|
|
107
|
+
group.dependencies.push(dependency);
|
|
130
108
|
}
|
|
131
|
-
finally { if (e_2) throw e_2.error; }
|
|
132
109
|
}
|
|
133
110
|
result.groups.push(group);
|
|
134
111
|
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":"
|
|
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,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nC;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
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
"description": "Generate a dep tree given a collection of manifests",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "
|
|
6
|
+
"test": "jest",
|
|
7
7
|
"test-jest": "jest",
|
|
8
|
-
"test-node4": "npm build && node ./test/node4/index.js",
|
|
9
8
|
"lint": "tslint -p tsconfig.json",
|
|
10
9
|
"build": "tsc",
|
|
11
10
|
"build-watch": "tsc -w",
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
"author": "snyk.io",
|
|
20
19
|
"license": "Apache-2.0",
|
|
21
20
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
21
|
+
"node": ">=6"
|
|
23
22
|
},
|
|
24
23
|
"files": [
|
|
25
24
|
"bin",
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
"tslib": "^1.9.3"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
32
|
+
"@types/node": "^6.14.3",
|
|
34
33
|
"ts-node": "7.0.0",
|
|
35
34
|
"tslint": "5.11.0",
|
|
36
35
|
"typescript": "3.0.1",
|
|
@@ -38,5 +37,5 @@
|
|
|
38
37
|
"jest": "^23.6.0",
|
|
39
38
|
"ts-jest": "^23.10.5"
|
|
40
39
|
},
|
|
41
|
-
"version": "1.
|
|
40
|
+
"version": "1.6.0"
|
|
42
41
|
}
|