@theia/cli 1.45.0 â 1.46.0-next.72
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/README.md +367 -367
- package/bin/theia +2 -2
- package/lib/check-dependencies.d.ts +12 -12
- package/lib/check-dependencies.js +268 -268
- package/lib/download-plugins.d.ts +28 -28
- package/lib/download-plugins.js +289 -289
- package/lib/run-test.d.ts +11 -11
- package/lib/run-test.js +78 -78
- package/lib/test-page.d.ts +17 -17
- package/lib/test-page.d.ts.map +1 -1
- package/lib/test-page.js +103 -102
- package/lib/test-page.js.map +1 -1
- package/lib/theia.d.ts +1 -1
- package/lib/theia.js +589 -589
- package/lib/theia.js.map +1 -1
- package/package.json +9 -8
- package/src/check-dependencies.ts +328 -328
- package/src/download-plugins.ts +357 -357
- package/src/run-test.ts +87 -87
- package/src/test-page.ts +138 -137
- package/src/theia.ts +686 -686
package/bin/theia
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require('../lib/theia')
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
require('../lib/theia')
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
interface CheckDependenciesOptions {
|
|
2
|
-
workspaces: string[] | undefined;
|
|
3
|
-
include: string[];
|
|
4
|
-
exclude: string[];
|
|
5
|
-
skipHoisted: boolean;
|
|
6
|
-
skipUniqueness: boolean;
|
|
7
|
-
skipSingleTheiaVersion: boolean;
|
|
8
|
-
onlyTheiaExtensions: boolean;
|
|
9
|
-
suppress: boolean;
|
|
10
|
-
}
|
|
11
|
-
export default function checkDependencies(options: CheckDependenciesOptions): void;
|
|
12
|
-
export {};
|
|
1
|
+
interface CheckDependenciesOptions {
|
|
2
|
+
workspaces: string[] | undefined;
|
|
3
|
+
include: string[];
|
|
4
|
+
exclude: string[];
|
|
5
|
+
skipHoisted: boolean;
|
|
6
|
+
skipUniqueness: boolean;
|
|
7
|
+
skipSingleTheiaVersion: boolean;
|
|
8
|
+
onlyTheiaExtensions: boolean;
|
|
9
|
+
suppress: boolean;
|
|
10
|
+
}
|
|
11
|
+
export default function checkDependencies(options: CheckDependenciesOptions): void;
|
|
12
|
+
export {};
|
|
13
13
|
//# sourceMappingURL=check-dependencies.d.ts.map
|
|
@@ -1,269 +1,269 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2022 STMicroelectronics and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const fs = require("fs");
|
|
19
|
-
const path = require("path");
|
|
20
|
-
const glob_1 = require("glob");
|
|
21
|
-
const log_update_1 = require("log-update");
|
|
22
|
-
const chalk = require("chalk");
|
|
23
|
-
const NODE_MODULES = 'node_modules';
|
|
24
|
-
const PACKAGE_JSON = 'package.json';
|
|
25
|
-
const logUpdate = (0, log_update_1.create)(process.stdout);
|
|
26
|
-
function checkDependencies(options) {
|
|
27
|
-
const workspaces = deriveWorkspaces(options);
|
|
28
|
-
logUpdate(`â
Found ${workspaces.length} workspaces`);
|
|
29
|
-
console.log('đ Collecting dependencies...');
|
|
30
|
-
const dependencies = findAllDependencies(workspaces, options);
|
|
31
|
-
logUpdate(`â
Found ${dependencies.length} dependencies`);
|
|
32
|
-
console.log('đ Analyzing dependencies...');
|
|
33
|
-
const issues = analyzeDependencies(dependencies, options);
|
|
34
|
-
if (issues.length <= 0) {
|
|
35
|
-
logUpdate('â
No issues were found');
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
logUpdate('đ Found ' + issues.length + ' issues');
|
|
39
|
-
printIssues(issues);
|
|
40
|
-
printHints(issues);
|
|
41
|
-
process.exit(options.suppress ? 0 : 1);
|
|
42
|
-
}
|
|
43
|
-
exports.default = checkDependencies;
|
|
44
|
-
function deriveWorkspaces(options) {
|
|
45
|
-
var _a;
|
|
46
|
-
const wsGlobs = (_a = options.workspaces) !== null && _a !== void 0 ? _a : readWorkspaceGlobsFromPackageJson();
|
|
47
|
-
const workspaces = [];
|
|
48
|
-
for (const wsGlob of wsGlobs) {
|
|
49
|
-
workspaces.push(...glob_1.glob.sync(wsGlob + '/'));
|
|
50
|
-
}
|
|
51
|
-
return workspaces;
|
|
52
|
-
}
|
|
53
|
-
function readWorkspaceGlobsFromPackageJson() {
|
|
54
|
-
var _a;
|
|
55
|
-
const rootPackageJson = path.join(process.cwd(), PACKAGE_JSON);
|
|
56
|
-
if (!fs.existsSync(rootPackageJson)) {
|
|
57
|
-
console.error('Directory does not contain a package.json with defined workspaces');
|
|
58
|
-
console.info('Run in the root of a Theia project or specify them via --workspaces');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
return (_a = require(rootPackageJson).workspaces) !== null && _a !== void 0 ? _a : [];
|
|
62
|
-
}
|
|
63
|
-
function findAllDependencies(workspaces, options) {
|
|
64
|
-
const dependencies = [];
|
|
65
|
-
dependencies.push(...findDependencies('.', options));
|
|
66
|
-
for (const workspace of workspaces) {
|
|
67
|
-
dependencies.push(...findDependencies(workspace, options));
|
|
68
|
-
}
|
|
69
|
-
return dependencies;
|
|
70
|
-
}
|
|
71
|
-
function findDependencies(workspace, options) {
|
|
72
|
-
const dependent = getPackageName(path.join(process.cwd(), workspace, PACKAGE_JSON));
|
|
73
|
-
const nodeModulesDir = path.join(workspace, NODE_MODULES);
|
|
74
|
-
const matchingPackageJsons = [];
|
|
75
|
-
options.include.forEach(include => glob_1.glob.sync(`${include}/${PACKAGE_JSON}`, {
|
|
76
|
-
cwd: nodeModulesDir,
|
|
77
|
-
ignore: [
|
|
78
|
-
`**/${NODE_MODULES}/**`,
|
|
79
|
-
`[^@]*/*/**/${PACKAGE_JSON}`,
|
|
80
|
-
`@*/*/*/**/${PACKAGE_JSON}`,
|
|
81
|
-
...options.exclude
|
|
82
|
-
] // user-specified exclude patterns
|
|
83
|
-
}).forEach(packageJsonPath => {
|
|
84
|
-
const dependency = toDependency(packageJsonPath, nodeModulesDir, dependent);
|
|
85
|
-
if (!options.onlyTheiaExtensions || dependency.isTheiaExtension) {
|
|
86
|
-
matchingPackageJsons.push(dependency);
|
|
87
|
-
}
|
|
88
|
-
const childNodeModules = path.join(nodeModulesDir, packageJsonPath, '..');
|
|
89
|
-
matchingPackageJsons.push(...findDependencies(childNodeModules, options));
|
|
90
|
-
}));
|
|
91
|
-
return matchingPackageJsons;
|
|
92
|
-
}
|
|
93
|
-
function toDependency(packageJsonPath, nodeModulesDir, dependent) {
|
|
94
|
-
const fullPackageJsonPath = path.join(process.cwd(), nodeModulesDir, packageJsonPath);
|
|
95
|
-
const name = getPackageName(fullPackageJsonPath);
|
|
96
|
-
const version = getPackageVersion(fullPackageJsonPath);
|
|
97
|
-
return {
|
|
98
|
-
name: name !== null && name !== void 0 ? name : packageJsonPath.replace('/' + PACKAGE_JSON, ''),
|
|
99
|
-
version: version !== null && version !== void 0 ? version : 'unknown',
|
|
100
|
-
path: path.relative(process.cwd(), fullPackageJsonPath),
|
|
101
|
-
hoisted: nodeModulesDir === NODE_MODULES,
|
|
102
|
-
dependent: dependent,
|
|
103
|
-
isTheiaExtension: isTheiaExtension(fullPackageJsonPath)
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function getPackageVersion(fullPackageJsonPath) {
|
|
107
|
-
try {
|
|
108
|
-
return require(fullPackageJsonPath).version;
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function getPackageName(fullPackageJsonPath) {
|
|
115
|
-
try {
|
|
116
|
-
return require(fullPackageJsonPath).name;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function isTheiaExtension(fullPackageJsonPath) {
|
|
123
|
-
try {
|
|
124
|
-
const theiaExtension = require(fullPackageJsonPath).theiaExtensions;
|
|
125
|
-
return theiaExtension ? true : false;
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function analyzeDependencies(packages, options) {
|
|
132
|
-
const issues = [];
|
|
133
|
-
if (!options.skipHoisted) {
|
|
134
|
-
issues.push(...findNotHoistedDependencies(packages, options));
|
|
135
|
-
}
|
|
136
|
-
if (!options.skipUniqueness) {
|
|
137
|
-
issues.push(...findDuplicateDependencies(packages, options));
|
|
138
|
-
}
|
|
139
|
-
if (!options.skipSingleTheiaVersion) {
|
|
140
|
-
issues.push(...findTheiaVersionMix(packages, options));
|
|
141
|
-
}
|
|
142
|
-
return issues;
|
|
143
|
-
}
|
|
144
|
-
function findNotHoistedDependencies(packages, options) {
|
|
145
|
-
const issues = [];
|
|
146
|
-
const nonHoistedPackages = packages.filter(p => p.hoisted === false);
|
|
147
|
-
for (const nonHoistedPackage of nonHoistedPackages) {
|
|
148
|
-
issues.push(createNonHoistedPackageIssue(nonHoistedPackage, options));
|
|
149
|
-
}
|
|
150
|
-
return issues;
|
|
151
|
-
}
|
|
152
|
-
function createNonHoistedPackageIssue(nonHoistedPackage, options) {
|
|
153
|
-
return {
|
|
154
|
-
issueType: 'not-hoisted',
|
|
155
|
-
package: nonHoistedPackage,
|
|
156
|
-
relatedPackages: [getHoistedPackageByName(nonHoistedPackage.name)],
|
|
157
|
-
severity: options.suppress ? 'warning' : 'error'
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function getHoistedPackageByName(name) {
|
|
161
|
-
return toDependency(path.join(name, PACKAGE_JSON), NODE_MODULES);
|
|
162
|
-
}
|
|
163
|
-
function findDuplicateDependencies(packages, options) {
|
|
164
|
-
const duplicates = [];
|
|
165
|
-
const packagesGroupedByName = new Map();
|
|
166
|
-
for (const currentPackage of packages) {
|
|
167
|
-
const name = currentPackage.name;
|
|
168
|
-
if (!packagesGroupedByName.has(name)) {
|
|
169
|
-
packagesGroupedByName.set(name, []);
|
|
170
|
-
}
|
|
171
|
-
const currentPackages = packagesGroupedByName.get(name);
|
|
172
|
-
currentPackages.push(currentPackage);
|
|
173
|
-
if (currentPackages.length > 1 && duplicates.indexOf(name) === -1) {
|
|
174
|
-
duplicates.push(name);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
duplicates.sort();
|
|
178
|
-
const issues = [];
|
|
179
|
-
for (const duplicate of duplicates) {
|
|
180
|
-
const duplicatePackages = packagesGroupedByName.get(duplicate);
|
|
181
|
-
if (duplicatePackages && duplicatePackages.length > 0) {
|
|
182
|
-
issues.push({
|
|
183
|
-
issueType: 'multiple-versions',
|
|
184
|
-
package: duplicatePackages.pop(),
|
|
185
|
-
relatedPackages: duplicatePackages,
|
|
186
|
-
severity: options.suppress ? 'warning' : 'error'
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return issues;
|
|
191
|
-
}
|
|
192
|
-
function findTheiaVersionMix(packages, options) {
|
|
193
|
-
// @theia/monaco-editor-core is following the versions of Monaco so it can't be part of this check
|
|
194
|
-
const theiaPackages = packages.filter(p => p.name.startsWith('@theia/') && !p.name.startsWith('@theia/monaco-editor-core'));
|
|
195
|
-
let theiaVersion = undefined;
|
|
196
|
-
let referenceTheiaPackage = undefined;
|
|
197
|
-
const packagesWithOtherVersion = [];
|
|
198
|
-
for (const theiaPackage of theiaPackages) {
|
|
199
|
-
if (!theiaVersion && theiaPackage.version) {
|
|
200
|
-
theiaVersion = theiaPackage.version;
|
|
201
|
-
referenceTheiaPackage = theiaPackage;
|
|
202
|
-
}
|
|
203
|
-
else if (theiaVersion !== theiaPackage.version) {
|
|
204
|
-
packagesWithOtherVersion.push(theiaPackage);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (referenceTheiaPackage && packagesWithOtherVersion.length > 0) {
|
|
208
|
-
return [{
|
|
209
|
-
issueType: 'theia-version-mix',
|
|
210
|
-
package: referenceTheiaPackage,
|
|
211
|
-
relatedPackages: packagesWithOtherVersion,
|
|
212
|
-
severity: 'error'
|
|
213
|
-
}];
|
|
214
|
-
}
|
|
215
|
-
return [];
|
|
216
|
-
}
|
|
217
|
-
function printIssues(issues) {
|
|
218
|
-
console.log();
|
|
219
|
-
const indent = issues.length.toString().length;
|
|
220
|
-
issues.forEach((issue, index) => {
|
|
221
|
-
printIssue(issue, index + 1, indent);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
function printIssue(issue, issueNumber, indent) {
|
|
225
|
-
const remainingIndent = indent - issueNumber.toString().length;
|
|
226
|
-
const indentString = ' '.repeat(remainingIndent + 1);
|
|
227
|
-
console.log(issueTitle(issue, issueNumber, indentString));
|
|
228
|
-
console.log(issueDetails(issue, ' ' + ' '.repeat(indent)));
|
|
229
|
-
console.log();
|
|
230
|
-
}
|
|
231
|
-
function issueTitle(issue, issueNumber, indent) {
|
|
232
|
-
var _a;
|
|
233
|
-
const dependent = issue.package.dependent ? ` in ${chalk.blueBright((_a = issue.package.dependent) !== null && _a !== void 0 ? _a : 'unknown')}` : '';
|
|
234
|
-
return chalk.bgWhiteBright.bold.black(`#${issueNumber}${indent}`) + ' ' + chalk.cyanBright(issue.package.name)
|
|
235
|
-
+ dependent + chalk.dim(` [${issue.issueType}]`);
|
|
236
|
-
}
|
|
237
|
-
function issueDetails(issue, indent) {
|
|
238
|
-
return indent + severity(issue) + ' ' + issueMessage(issue) + '\n'
|
|
239
|
-
+ indent + versionLine(issue.package) + '\n'
|
|
240
|
-
+ issue.relatedPackages.map(p => indent + versionLine(p)).join('\n');
|
|
241
|
-
}
|
|
242
|
-
function issueMessage(issue) {
|
|
243
|
-
if (issue.issueType === 'multiple-versions') {
|
|
244
|
-
return `Multiple versions of dependency ${chalk.bold(issue.package.name)} found.`;
|
|
245
|
-
}
|
|
246
|
-
else if (issue.issueType === 'theia-version-mix') {
|
|
247
|
-
return `Mix of ${chalk.bold('@theia/*')} versions found.`;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
return `Dependency ${chalk.bold(issue.package.name)} is not hoisted.`;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function severity(issue) {
|
|
254
|
-
return issue.severity === 'error' ? chalk.red('error') : chalk.yellow('warning');
|
|
255
|
-
}
|
|
256
|
-
function versionLine(pckg) {
|
|
257
|
-
return chalk.bold(pckg.version) + ' in ' + pckg.path;
|
|
258
|
-
}
|
|
259
|
-
function printHints(issues) {
|
|
260
|
-
console.log();
|
|
261
|
-
if (issues.find(i => i.issueType === 'theia-version-mix')) {
|
|
262
|
-
console.log('â A mix of Theia versions is very likely leading to a broken application.');
|
|
263
|
-
}
|
|
264
|
-
console.log(`âšī¸ Use ${chalk.bold('yarn why <package-name>')} to find out why those multiple versions of a package are pulled.`);
|
|
265
|
-
console.log('âšī¸ Try to resolve those issues by finding package versions along the dependency chain that depend on compatible versions.');
|
|
266
|
-
console.log(`âšī¸ Use ${chalk.bold('resolutions')} in your root package.json to force specific versions as a last resort.`);
|
|
267
|
-
console.log();
|
|
268
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2022 STMicroelectronics and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const fs = require("fs");
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const glob_1 = require("glob");
|
|
21
|
+
const log_update_1 = require("log-update");
|
|
22
|
+
const chalk = require("chalk");
|
|
23
|
+
const NODE_MODULES = 'node_modules';
|
|
24
|
+
const PACKAGE_JSON = 'package.json';
|
|
25
|
+
const logUpdate = (0, log_update_1.create)(process.stdout);
|
|
26
|
+
function checkDependencies(options) {
|
|
27
|
+
const workspaces = deriveWorkspaces(options);
|
|
28
|
+
logUpdate(`â
Found ${workspaces.length} workspaces`);
|
|
29
|
+
console.log('đ Collecting dependencies...');
|
|
30
|
+
const dependencies = findAllDependencies(workspaces, options);
|
|
31
|
+
logUpdate(`â
Found ${dependencies.length} dependencies`);
|
|
32
|
+
console.log('đ Analyzing dependencies...');
|
|
33
|
+
const issues = analyzeDependencies(dependencies, options);
|
|
34
|
+
if (issues.length <= 0) {
|
|
35
|
+
logUpdate('â
No issues were found');
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
logUpdate('đ Found ' + issues.length + ' issues');
|
|
39
|
+
printIssues(issues);
|
|
40
|
+
printHints(issues);
|
|
41
|
+
process.exit(options.suppress ? 0 : 1);
|
|
42
|
+
}
|
|
43
|
+
exports.default = checkDependencies;
|
|
44
|
+
function deriveWorkspaces(options) {
|
|
45
|
+
var _a;
|
|
46
|
+
const wsGlobs = (_a = options.workspaces) !== null && _a !== void 0 ? _a : readWorkspaceGlobsFromPackageJson();
|
|
47
|
+
const workspaces = [];
|
|
48
|
+
for (const wsGlob of wsGlobs) {
|
|
49
|
+
workspaces.push(...glob_1.glob.sync(wsGlob + '/'));
|
|
50
|
+
}
|
|
51
|
+
return workspaces;
|
|
52
|
+
}
|
|
53
|
+
function readWorkspaceGlobsFromPackageJson() {
|
|
54
|
+
var _a;
|
|
55
|
+
const rootPackageJson = path.join(process.cwd(), PACKAGE_JSON);
|
|
56
|
+
if (!fs.existsSync(rootPackageJson)) {
|
|
57
|
+
console.error('Directory does not contain a package.json with defined workspaces');
|
|
58
|
+
console.info('Run in the root of a Theia project or specify them via --workspaces');
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
return (_a = require(rootPackageJson).workspaces) !== null && _a !== void 0 ? _a : [];
|
|
62
|
+
}
|
|
63
|
+
function findAllDependencies(workspaces, options) {
|
|
64
|
+
const dependencies = [];
|
|
65
|
+
dependencies.push(...findDependencies('.', options));
|
|
66
|
+
for (const workspace of workspaces) {
|
|
67
|
+
dependencies.push(...findDependencies(workspace, options));
|
|
68
|
+
}
|
|
69
|
+
return dependencies;
|
|
70
|
+
}
|
|
71
|
+
function findDependencies(workspace, options) {
|
|
72
|
+
const dependent = getPackageName(path.join(process.cwd(), workspace, PACKAGE_JSON));
|
|
73
|
+
const nodeModulesDir = path.join(workspace, NODE_MODULES);
|
|
74
|
+
const matchingPackageJsons = [];
|
|
75
|
+
options.include.forEach(include => glob_1.glob.sync(`${include}/${PACKAGE_JSON}`, {
|
|
76
|
+
cwd: nodeModulesDir,
|
|
77
|
+
ignore: [
|
|
78
|
+
`**/${NODE_MODULES}/**`,
|
|
79
|
+
`[^@]*/*/**/${PACKAGE_JSON}`,
|
|
80
|
+
`@*/*/*/**/${PACKAGE_JSON}`,
|
|
81
|
+
...options.exclude
|
|
82
|
+
] // user-specified exclude patterns
|
|
83
|
+
}).forEach(packageJsonPath => {
|
|
84
|
+
const dependency = toDependency(packageJsonPath, nodeModulesDir, dependent);
|
|
85
|
+
if (!options.onlyTheiaExtensions || dependency.isTheiaExtension) {
|
|
86
|
+
matchingPackageJsons.push(dependency);
|
|
87
|
+
}
|
|
88
|
+
const childNodeModules = path.join(nodeModulesDir, packageJsonPath, '..');
|
|
89
|
+
matchingPackageJsons.push(...findDependencies(childNodeModules, options));
|
|
90
|
+
}));
|
|
91
|
+
return matchingPackageJsons;
|
|
92
|
+
}
|
|
93
|
+
function toDependency(packageJsonPath, nodeModulesDir, dependent) {
|
|
94
|
+
const fullPackageJsonPath = path.join(process.cwd(), nodeModulesDir, packageJsonPath);
|
|
95
|
+
const name = getPackageName(fullPackageJsonPath);
|
|
96
|
+
const version = getPackageVersion(fullPackageJsonPath);
|
|
97
|
+
return {
|
|
98
|
+
name: name !== null && name !== void 0 ? name : packageJsonPath.replace('/' + PACKAGE_JSON, ''),
|
|
99
|
+
version: version !== null && version !== void 0 ? version : 'unknown',
|
|
100
|
+
path: path.relative(process.cwd(), fullPackageJsonPath),
|
|
101
|
+
hoisted: nodeModulesDir === NODE_MODULES,
|
|
102
|
+
dependent: dependent,
|
|
103
|
+
isTheiaExtension: isTheiaExtension(fullPackageJsonPath)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function getPackageVersion(fullPackageJsonPath) {
|
|
107
|
+
try {
|
|
108
|
+
return require(fullPackageJsonPath).version;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function getPackageName(fullPackageJsonPath) {
|
|
115
|
+
try {
|
|
116
|
+
return require(fullPackageJsonPath).name;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function isTheiaExtension(fullPackageJsonPath) {
|
|
123
|
+
try {
|
|
124
|
+
const theiaExtension = require(fullPackageJsonPath).theiaExtensions;
|
|
125
|
+
return theiaExtension ? true : false;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function analyzeDependencies(packages, options) {
|
|
132
|
+
const issues = [];
|
|
133
|
+
if (!options.skipHoisted) {
|
|
134
|
+
issues.push(...findNotHoistedDependencies(packages, options));
|
|
135
|
+
}
|
|
136
|
+
if (!options.skipUniqueness) {
|
|
137
|
+
issues.push(...findDuplicateDependencies(packages, options));
|
|
138
|
+
}
|
|
139
|
+
if (!options.skipSingleTheiaVersion) {
|
|
140
|
+
issues.push(...findTheiaVersionMix(packages, options));
|
|
141
|
+
}
|
|
142
|
+
return issues;
|
|
143
|
+
}
|
|
144
|
+
function findNotHoistedDependencies(packages, options) {
|
|
145
|
+
const issues = [];
|
|
146
|
+
const nonHoistedPackages = packages.filter(p => p.hoisted === false);
|
|
147
|
+
for (const nonHoistedPackage of nonHoistedPackages) {
|
|
148
|
+
issues.push(createNonHoistedPackageIssue(nonHoistedPackage, options));
|
|
149
|
+
}
|
|
150
|
+
return issues;
|
|
151
|
+
}
|
|
152
|
+
function createNonHoistedPackageIssue(nonHoistedPackage, options) {
|
|
153
|
+
return {
|
|
154
|
+
issueType: 'not-hoisted',
|
|
155
|
+
package: nonHoistedPackage,
|
|
156
|
+
relatedPackages: [getHoistedPackageByName(nonHoistedPackage.name)],
|
|
157
|
+
severity: options.suppress ? 'warning' : 'error'
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function getHoistedPackageByName(name) {
|
|
161
|
+
return toDependency(path.join(name, PACKAGE_JSON), NODE_MODULES);
|
|
162
|
+
}
|
|
163
|
+
function findDuplicateDependencies(packages, options) {
|
|
164
|
+
const duplicates = [];
|
|
165
|
+
const packagesGroupedByName = new Map();
|
|
166
|
+
for (const currentPackage of packages) {
|
|
167
|
+
const name = currentPackage.name;
|
|
168
|
+
if (!packagesGroupedByName.has(name)) {
|
|
169
|
+
packagesGroupedByName.set(name, []);
|
|
170
|
+
}
|
|
171
|
+
const currentPackages = packagesGroupedByName.get(name);
|
|
172
|
+
currentPackages.push(currentPackage);
|
|
173
|
+
if (currentPackages.length > 1 && duplicates.indexOf(name) === -1) {
|
|
174
|
+
duplicates.push(name);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
duplicates.sort();
|
|
178
|
+
const issues = [];
|
|
179
|
+
for (const duplicate of duplicates) {
|
|
180
|
+
const duplicatePackages = packagesGroupedByName.get(duplicate);
|
|
181
|
+
if (duplicatePackages && duplicatePackages.length > 0) {
|
|
182
|
+
issues.push({
|
|
183
|
+
issueType: 'multiple-versions',
|
|
184
|
+
package: duplicatePackages.pop(),
|
|
185
|
+
relatedPackages: duplicatePackages,
|
|
186
|
+
severity: options.suppress ? 'warning' : 'error'
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return issues;
|
|
191
|
+
}
|
|
192
|
+
function findTheiaVersionMix(packages, options) {
|
|
193
|
+
// @theia/monaco-editor-core is following the versions of Monaco so it can't be part of this check
|
|
194
|
+
const theiaPackages = packages.filter(p => p.name.startsWith('@theia/') && !p.name.startsWith('@theia/monaco-editor-core'));
|
|
195
|
+
let theiaVersion = undefined;
|
|
196
|
+
let referenceTheiaPackage = undefined;
|
|
197
|
+
const packagesWithOtherVersion = [];
|
|
198
|
+
for (const theiaPackage of theiaPackages) {
|
|
199
|
+
if (!theiaVersion && theiaPackage.version) {
|
|
200
|
+
theiaVersion = theiaPackage.version;
|
|
201
|
+
referenceTheiaPackage = theiaPackage;
|
|
202
|
+
}
|
|
203
|
+
else if (theiaVersion !== theiaPackage.version) {
|
|
204
|
+
packagesWithOtherVersion.push(theiaPackage);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (referenceTheiaPackage && packagesWithOtherVersion.length > 0) {
|
|
208
|
+
return [{
|
|
209
|
+
issueType: 'theia-version-mix',
|
|
210
|
+
package: referenceTheiaPackage,
|
|
211
|
+
relatedPackages: packagesWithOtherVersion,
|
|
212
|
+
severity: 'error'
|
|
213
|
+
}];
|
|
214
|
+
}
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
function printIssues(issues) {
|
|
218
|
+
console.log();
|
|
219
|
+
const indent = issues.length.toString().length;
|
|
220
|
+
issues.forEach((issue, index) => {
|
|
221
|
+
printIssue(issue, index + 1, indent);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
function printIssue(issue, issueNumber, indent) {
|
|
225
|
+
const remainingIndent = indent - issueNumber.toString().length;
|
|
226
|
+
const indentString = ' '.repeat(remainingIndent + 1);
|
|
227
|
+
console.log(issueTitle(issue, issueNumber, indentString));
|
|
228
|
+
console.log(issueDetails(issue, ' ' + ' '.repeat(indent)));
|
|
229
|
+
console.log();
|
|
230
|
+
}
|
|
231
|
+
function issueTitle(issue, issueNumber, indent) {
|
|
232
|
+
var _a;
|
|
233
|
+
const dependent = issue.package.dependent ? ` in ${chalk.blueBright((_a = issue.package.dependent) !== null && _a !== void 0 ? _a : 'unknown')}` : '';
|
|
234
|
+
return chalk.bgWhiteBright.bold.black(`#${issueNumber}${indent}`) + ' ' + chalk.cyanBright(issue.package.name)
|
|
235
|
+
+ dependent + chalk.dim(` [${issue.issueType}]`);
|
|
236
|
+
}
|
|
237
|
+
function issueDetails(issue, indent) {
|
|
238
|
+
return indent + severity(issue) + ' ' + issueMessage(issue) + '\n'
|
|
239
|
+
+ indent + versionLine(issue.package) + '\n'
|
|
240
|
+
+ issue.relatedPackages.map(p => indent + versionLine(p)).join('\n');
|
|
241
|
+
}
|
|
242
|
+
function issueMessage(issue) {
|
|
243
|
+
if (issue.issueType === 'multiple-versions') {
|
|
244
|
+
return `Multiple versions of dependency ${chalk.bold(issue.package.name)} found.`;
|
|
245
|
+
}
|
|
246
|
+
else if (issue.issueType === 'theia-version-mix') {
|
|
247
|
+
return `Mix of ${chalk.bold('@theia/*')} versions found.`;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return `Dependency ${chalk.bold(issue.package.name)} is not hoisted.`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function severity(issue) {
|
|
254
|
+
return issue.severity === 'error' ? chalk.red('error') : chalk.yellow('warning');
|
|
255
|
+
}
|
|
256
|
+
function versionLine(pckg) {
|
|
257
|
+
return chalk.bold(pckg.version) + ' in ' + pckg.path;
|
|
258
|
+
}
|
|
259
|
+
function printHints(issues) {
|
|
260
|
+
console.log();
|
|
261
|
+
if (issues.find(i => i.issueType === 'theia-version-mix')) {
|
|
262
|
+
console.log('â A mix of Theia versions is very likely leading to a broken application.');
|
|
263
|
+
}
|
|
264
|
+
console.log(`âšī¸ Use ${chalk.bold('yarn why <package-name>')} to find out why those multiple versions of a package are pulled.`);
|
|
265
|
+
console.log('âšī¸ Try to resolve those issues by finding package versions along the dependency chain that depend on compatible versions.');
|
|
266
|
+
console.log(`âšī¸ Use ${chalk.bold('resolutions')} in your root package.json to force specific versions as a last resort.`);
|
|
267
|
+
console.log();
|
|
268
|
+
}
|
|
269
269
|
//# sourceMappingURL=check-dependencies.js.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { OVSXClient } from '@theia/ovsx-client';
|
|
2
|
-
import { RequestService } from '@theia/request';
|
|
3
|
-
/**
|
|
4
|
-
* Available options when downloading.
|
|
5
|
-
*/
|
|
6
|
-
export interface DownloadPluginsOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Determines if a plugin should be unpacked.
|
|
9
|
-
* Defaults to `false`.
|
|
10
|
-
*/
|
|
11
|
-
packed?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Determines if failures while downloading plugins should be ignored.
|
|
14
|
-
* Defaults to `false`.
|
|
15
|
-
*/
|
|
16
|
-
ignoreErrors?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* The supported vscode API version.
|
|
19
|
-
* Used to determine extension compatibility.
|
|
20
|
-
*/
|
|
21
|
-
apiVersion?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Fetch plugins in parallel
|
|
24
|
-
*/
|
|
25
|
-
parallel?: boolean;
|
|
26
|
-
rateLimit?: number;
|
|
27
|
-
}
|
|
28
|
-
export default function downloadPlugins(ovsxClient: OVSXClient, requestService: RequestService, options?: DownloadPluginsOptions): Promise<void>;
|
|
1
|
+
import { OVSXClient } from '@theia/ovsx-client';
|
|
2
|
+
import { RequestService } from '@theia/request';
|
|
3
|
+
/**
|
|
4
|
+
* Available options when downloading.
|
|
5
|
+
*/
|
|
6
|
+
export interface DownloadPluginsOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Determines if a plugin should be unpacked.
|
|
9
|
+
* Defaults to `false`.
|
|
10
|
+
*/
|
|
11
|
+
packed?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Determines if failures while downloading plugins should be ignored.
|
|
14
|
+
* Defaults to `false`.
|
|
15
|
+
*/
|
|
16
|
+
ignoreErrors?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The supported vscode API version.
|
|
19
|
+
* Used to determine extension compatibility.
|
|
20
|
+
*/
|
|
21
|
+
apiVersion?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Fetch plugins in parallel
|
|
24
|
+
*/
|
|
25
|
+
parallel?: boolean;
|
|
26
|
+
rateLimit?: number;
|
|
27
|
+
}
|
|
28
|
+
export default function downloadPlugins(ovsxClient: OVSXClient, requestService: RequestService, options?: DownloadPluginsOptions): Promise<void>;
|
|
29
29
|
//# sourceMappingURL=download-plugins.d.ts.map
|