@theia/cli 1.18.0-next.124 → 1.18.0-next.129
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-plugins.d.ts","sourceRoot":"","sources":["../src/download-plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAIlF,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAC5B;CACJ;AAOD,OAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAY1D
|
|
1
|
+
{"version":3,"file":"download-plugins.d.ts","sourceRoot":"","sources":["../src/download-plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAIlF,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAC5B;CACJ;AAOD,OAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAY1D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAA8B,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAgFjG;AA8FD;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAO5E"}
|
package/lib/download-plugins.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
16
|
********************************************************************************/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.xfetch =
|
|
18
|
+
exports.xfetch = void 0;
|
|
19
19
|
const ovsx_client_1 = require("@theia/ovsx-client/lib/ovsx-client");
|
|
20
20
|
const safe_1 = require("colors/safe");
|
|
21
21
|
const decompress = require("decompress");
|
|
@@ -30,7 +30,6 @@ const util_1 = require("util");
|
|
|
30
30
|
const api_1 = require("@theia/application-package/lib/api");
|
|
31
31
|
const pipelineAsPromised = util_1.promisify(stream.pipeline);
|
|
32
32
|
temp.track();
|
|
33
|
-
exports.extensionPackCacheName = '.packs';
|
|
34
33
|
async function downloadPlugins(options = {}) {
|
|
35
34
|
const { packed = false, ignoreErrors = false, apiVersion = api_1.DEFAULT_SUPPORTED_API_VERSION, apiUrl = 'https://open-vsx.org/api' } = options;
|
|
36
35
|
// Collect the list of failures to be appended at the end of the script.
|
|
@@ -47,18 +46,12 @@ async function downloadPlugins(options = {}) {
|
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
48
|
try {
|
|
50
|
-
// Retrieve the cached extension-packs in order to not re-download them.
|
|
51
|
-
const extensionPackCachePath = path.resolve(pluginsDir, exports.extensionPackCacheName);
|
|
52
|
-
const cachedExtensionPacks = new Set(fs_1.existsSync(extensionPackCachePath)
|
|
53
|
-
? await fs_1.promises.readdir(extensionPackCachePath)
|
|
54
|
-
: []);
|
|
55
49
|
console.warn('--- downloading plugins ---');
|
|
56
50
|
// Download the raw plugins defined by the `theiaPlugins` property.
|
|
57
51
|
// This will include both "normal" plugins as well as "extension packs".
|
|
58
52
|
const downloads = [];
|
|
59
53
|
for (const [plugin, pluginUrl] of Object.entries(pck.theiaPlugins)) {
|
|
60
|
-
|
|
61
|
-
if (cachedExtensionPacks.has(plugin) || typeof pluginUrl !== 'string') {
|
|
54
|
+
if (typeof pluginUrl !== 'string') {
|
|
62
55
|
continue;
|
|
63
56
|
}
|
|
64
57
|
downloads.push(downloadPluginAsync(failures, plugin, pluginUrl, pluginsDir, packed));
|
|
@@ -67,10 +60,7 @@ async function downloadPlugins(options = {}) {
|
|
|
67
60
|
console.warn('--- collecting extension-packs ---');
|
|
68
61
|
const extensionPacks = await collectExtensionPacks(pluginsDir, excludedIds);
|
|
69
62
|
if (extensionPacks.size > 0) {
|
|
70
|
-
console.warn(`---
|
|
71
|
-
// Move extension-packs to `.packs`
|
|
72
|
-
await cacheExtensionPacks(pluginsDir, extensionPacks);
|
|
73
|
-
console.warn('--- resolving extension-packs ---');
|
|
63
|
+
console.warn(`--- resolving ${extensionPacks.size} extension-packs ---`);
|
|
74
64
|
const client = new ovsx_client_1.OVSXClient({ apiVersion, apiUrl });
|
|
75
65
|
// De-duplicate extension ids to only download each once:
|
|
76
66
|
const ids = new Set(Array.from(extensionPacks.values()).flat());
|
|
@@ -82,6 +72,21 @@ async function downloadPlugins(options = {}) {
|
|
|
82
72
|
}
|
|
83
73
|
}));
|
|
84
74
|
}
|
|
75
|
+
console.warn('--- collecting extension dependencies ---');
|
|
76
|
+
const pluginDependencies = await collectPluginDependencies(pluginsDir, excludedIds);
|
|
77
|
+
if (pluginDependencies.length > 0) {
|
|
78
|
+
console.warn(`--- resolving ${pluginDependencies.length} extension dependencies ---`);
|
|
79
|
+
const client = new ovsx_client_1.OVSXClient({ apiVersion, apiUrl });
|
|
80
|
+
// De-duplicate extension ids to only download each once:
|
|
81
|
+
const ids = new Set(pluginDependencies);
|
|
82
|
+
await Promise.all(Array.from(ids, async (id) => {
|
|
83
|
+
const extension = await client.getLatestCompatibleExtensionVersion(id);
|
|
84
|
+
const downloadUrl = extension === null || extension === void 0 ? void 0 : extension.files.download;
|
|
85
|
+
if (downloadUrl) {
|
|
86
|
+
await downloadPluginAsync(failures, id, downloadUrl, pluginsDir, packed, extension === null || extension === void 0 ? void 0 : extension.version);
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
91
|
finally {
|
|
87
92
|
temp.cleanupSync();
|
|
@@ -206,8 +211,7 @@ async function collectPackageJsonPaths(pluginDir) {
|
|
|
206
211
|
// Recursively fetch the list of extension `package.json` files.
|
|
207
212
|
for (const file of files) {
|
|
208
213
|
const filePath = path.join(pluginDir, file);
|
|
209
|
-
|
|
210
|
-
if (!filePath.startsWith(exports.extensionPackCacheName) && (await fs_1.promises.stat(filePath)).isDirectory()) {
|
|
214
|
+
if ((await fs_1.promises.stat(filePath)).isDirectory()) {
|
|
211
215
|
packageJsonPathList.push(...await collectPackageJsonPaths(filePath));
|
|
212
216
|
}
|
|
213
217
|
else if (path.basename(filePath) === 'package.json' && !path.dirname(filePath).includes('node_modules')) {
|
|
@@ -229,7 +233,7 @@ async function collectExtensionPacks(pluginDir, excludedIds) {
|
|
|
229
233
|
await Promise.all(packageJsonPaths.map(async (packageJsonPath) => {
|
|
230
234
|
const json = JSON.parse(await fs_1.promises.readFile(packageJsonPath, 'utf8'));
|
|
231
235
|
const extensionPack = json.extensionPack;
|
|
232
|
-
if (
|
|
236
|
+
if (Array.isArray(extensionPack)) {
|
|
233
237
|
extensionPackPaths.set(packageJsonPath, extensionPack.filter(id => {
|
|
234
238
|
if (excludedIds.has(id)) {
|
|
235
239
|
console.log(safe_1.yellow(`'${id}' referenced by '${json.name}' (ext pack) is excluded because of 'theiaPluginsExcludeIds'`));
|
|
@@ -242,51 +246,29 @@ async function collectExtensionPacks(pluginDir, excludedIds) {
|
|
|
242
246
|
return extensionPackPaths;
|
|
243
247
|
}
|
|
244
248
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* By moving the packs to a subdirectory it should make it invisible to the plugin system, only leaving
|
|
252
|
-
* the plugins that were installed under `pluginsDir` directly.
|
|
253
|
-
*
|
|
254
|
-
* @param extensionPacksPaths the list of extension-pack paths.
|
|
249
|
+
* Get the mapping of paths and their included plugin ids.
|
|
250
|
+
* - If an extension-pack references an explicitly excluded `id` the `id` will be omitted.
|
|
251
|
+
* @param pluginDir the plugin directory.
|
|
252
|
+
* @param excludedIds the list of plugin ids to exclude.
|
|
253
|
+
* @returns the mapping of extension-pack paths and their included plugin ids.
|
|
255
254
|
*/
|
|
256
|
-
async function
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
await Promise.all(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
255
|
+
async function collectPluginDependencies(pluginDir, excludedIds) {
|
|
256
|
+
const dependencyIds = [];
|
|
257
|
+
const packageJsonPaths = await collectPackageJsonPaths(pluginDir);
|
|
258
|
+
await Promise.all(packageJsonPaths.map(async (packageJsonPath) => {
|
|
259
|
+
const json = JSON.parse(await fs_1.promises.readFile(packageJsonPath, 'utf8'));
|
|
260
|
+
const extensionDependencies = json.extensionDependencies;
|
|
261
|
+
if (Array.isArray(extensionDependencies)) {
|
|
262
|
+
for (const dependency of extensionDependencies) {
|
|
263
|
+
if (excludedIds.has(dependency)) {
|
|
264
|
+
console.log(safe_1.yellow(`'${dependency}' referenced by '${json.name}' is excluded because of 'theiaPluginsExcludeIds'`));
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
dependencyIds.push(dependency);
|
|
268
|
+
}
|
|
270
269
|
}
|
|
271
270
|
}
|
|
272
|
-
catch (error) {
|
|
273
|
-
console.error(error);
|
|
274
|
-
}
|
|
275
271
|
}));
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Walk back to the root of an extension starting from its `package.json`. e.g.
|
|
279
|
-
*
|
|
280
|
-
* ```ts
|
|
281
|
-
* getExtensionRoot('/a/b/c', '/a/b/c/EXT/d/e/f/package.json') === '/a/b/c/EXT'
|
|
282
|
-
* ```
|
|
283
|
-
*/
|
|
284
|
-
function getExtensionRoot(root, packageJsonPath) {
|
|
285
|
-
root = path.resolve(root);
|
|
286
|
-
packageJsonPath = path.resolve(packageJsonPath);
|
|
287
|
-
if (!packageJsonPath.startsWith(root)) {
|
|
288
|
-
throw new Error(`unexpected paths:\n root: ${root}\n package.json: ${packageJsonPath}`);
|
|
289
|
-
}
|
|
290
|
-
return packageJsonPath.substr(0, packageJsonPath.indexOf(path.sep, root.length + 1));
|
|
272
|
+
return dependencyIds;
|
|
291
273
|
}
|
|
292
274
|
//# sourceMappingURL=download-plugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-plugins.js","sourceRoot":"","sources":["../src/download-plugins.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAWlF,oEAAgE;AAChE,sCAAiD;AACjD,yCAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"download-plugins.js","sourceRoot":"","sources":["../src/download-plugins.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAWlF,oEAAgE;AAChE,sCAAiD;AACjD,yCAAyC;AACzC,2BAAuD;AACvD,yDAAoD;AACpD,2CAA0D;AAC1D,6BAA6B;AAC7B,mDAAgD;AAChD,iCAAiC;AACjC,6BAA6B;AAC7B,+BAAiC;AACjC,4DAAmF;AAEnF,MAAM,kBAAkB,GAAG,gBAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEtD,IAAI,CAAC,KAAK,EAAE,CAAC;AA8BE,KAAK,UAAU,eAAe,CAAC,UAAkC,EAAE;IAC9E,MAAM,EACF,MAAM,GAAG,KAAK,EACd,YAAY,GAAG,KAAK,EACpB,UAAU,GAAG,mCAA6B,EAC1C,MAAM,GAAG,0BAA0B,EACtC,GAAG,OAAO,CAAC;IAEZ,wEAAwE;IACxE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,+DAA+D;IAC/D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AAE,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;QACpE,MAAM,qBAAqB,GAAY,IAAI,CAAC,qBAAqB,CAAC;QAClE,IAAI,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE;YACtC,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE;gBAC5C,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;oBAC7B,OAAO,CAAC,GAAG,CAAC,aAAM,CAAC,IAAI,UAAU,oBAAoB,IAAI,CAAC,IAAI,mDAAmD,CAAC,CAAC,CAAC;iBACvH;qBAAM;oBACH,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBAClC;aACJ;SACJ;IACL,CAAC,CAAC,CAAC,CAAC;IACJ,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/cli",
|
|
3
|
-
"version": "1.18.0-next.
|
|
3
|
+
"version": "1.18.0-next.129+bf00fd0fcf5",
|
|
4
4
|
"description": "Theia CLI.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"clean": "theiaext clean"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@theia/application-manager": "1.18.0-next.
|
|
33
|
-
"@theia/application-package": "1.18.0-next.
|
|
34
|
-
"@theia/localization-manager": "1.18.0-next.
|
|
35
|
-
"@theia/ovsx-client": "1.18.0-next.
|
|
32
|
+
"@theia/application-manager": "1.18.0-next.129+bf00fd0fcf5",
|
|
33
|
+
"@theia/application-package": "1.18.0-next.129+bf00fd0fcf5",
|
|
34
|
+
"@theia/localization-manager": "1.18.0-next.129+bf00fd0fcf5",
|
|
35
|
+
"@theia/ovsx-client": "1.18.0-next.129+bf00fd0fcf5",
|
|
36
36
|
"@types/chai": "^4.2.7",
|
|
37
37
|
"@types/mkdirp": "^0.5.2",
|
|
38
38
|
"@types/mocha": "^5.2.7",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/proxy-from-env": "^1.0.1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "bf00fd0fcf5b8153178b9bab05212da1ea9ceee8"
|
|
59
59
|
}
|
package/src/download-plugins.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare global {
|
|
|
26
26
|
import { OVSXClient } from '@theia/ovsx-client/lib/ovsx-client';
|
|
27
27
|
import { green, red, yellow } from 'colors/safe';
|
|
28
28
|
import * as decompress from 'decompress';
|
|
29
|
-
import { createWriteStream,
|
|
29
|
+
import { createWriteStream, promises as fs } from 'fs';
|
|
30
30
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
31
31
|
import fetch, { RequestInit, Response } from 'node-fetch';
|
|
32
32
|
import * as path from 'path';
|
|
@@ -40,8 +40,6 @@ const pipelineAsPromised = promisify(stream.pipeline);
|
|
|
40
40
|
|
|
41
41
|
temp.track();
|
|
42
42
|
|
|
43
|
-
export const extensionPackCacheName = '.packs';
|
|
44
|
-
|
|
45
43
|
/**
|
|
46
44
|
* Available options when downloading.
|
|
47
45
|
*/
|
|
@@ -97,32 +95,22 @@ export default async function downloadPlugins(options: DownloadPluginsOptions =
|
|
|
97
95
|
return;
|
|
98
96
|
}
|
|
99
97
|
try {
|
|
100
|
-
// Retrieve the cached extension-packs in order to not re-download them.
|
|
101
|
-
const extensionPackCachePath = path.resolve(pluginsDir, extensionPackCacheName);
|
|
102
|
-
const cachedExtensionPacks = new Set<string>(
|
|
103
|
-
existsSync(extensionPackCachePath)
|
|
104
|
-
? await fs.readdir(extensionPackCachePath)
|
|
105
|
-
: []
|
|
106
|
-
);
|
|
107
98
|
console.warn('--- downloading plugins ---');
|
|
108
99
|
// Download the raw plugins defined by the `theiaPlugins` property.
|
|
109
100
|
// This will include both "normal" plugins as well as "extension packs".
|
|
110
101
|
const downloads = [];
|
|
111
102
|
for (const [plugin, pluginUrl] of Object.entries(pck.theiaPlugins)) {
|
|
112
|
-
|
|
113
|
-
if (cachedExtensionPacks.has(plugin) || typeof pluginUrl !== 'string') {
|
|
103
|
+
if (typeof pluginUrl !== 'string') {
|
|
114
104
|
continue;
|
|
115
105
|
}
|
|
116
106
|
downloads.push(downloadPluginAsync(failures, plugin, pluginUrl, pluginsDir, packed));
|
|
117
107
|
}
|
|
118
108
|
await Promise.all(downloads);
|
|
109
|
+
|
|
119
110
|
console.warn('--- collecting extension-packs ---');
|
|
120
111
|
const extensionPacks = await collectExtensionPacks(pluginsDir, excludedIds);
|
|
121
112
|
if (extensionPacks.size > 0) {
|
|
122
|
-
console.warn(`---
|
|
123
|
-
// Move extension-packs to `.packs`
|
|
124
|
-
await cacheExtensionPacks(pluginsDir, extensionPacks);
|
|
125
|
-
console.warn('--- resolving extension-packs ---');
|
|
113
|
+
console.warn(`--- resolving ${extensionPacks.size} extension-packs ---`);
|
|
126
114
|
const client = new OVSXClient({ apiVersion, apiUrl });
|
|
127
115
|
// De-duplicate extension ids to only download each once:
|
|
128
116
|
const ids = new Set<string>(Array.from(extensionPacks.values()).flat());
|
|
@@ -134,6 +122,23 @@ export default async function downloadPlugins(options: DownloadPluginsOptions =
|
|
|
134
122
|
}
|
|
135
123
|
}));
|
|
136
124
|
}
|
|
125
|
+
|
|
126
|
+
console.warn('--- collecting extension dependencies ---');
|
|
127
|
+
const pluginDependencies = await collectPluginDependencies(pluginsDir, excludedIds);
|
|
128
|
+
if (pluginDependencies.length > 0) {
|
|
129
|
+
console.warn(`--- resolving ${pluginDependencies.length} extension dependencies ---`);
|
|
130
|
+
const client = new OVSXClient({ apiVersion, apiUrl });
|
|
131
|
+
// De-duplicate extension ids to only download each once:
|
|
132
|
+
const ids = new Set<string>(pluginDependencies);
|
|
133
|
+
await Promise.all(Array.from(ids, async id => {
|
|
134
|
+
const extension = await client.getLatestCompatibleExtensionVersion(id);
|
|
135
|
+
const downloadUrl = extension?.files.download;
|
|
136
|
+
if (downloadUrl) {
|
|
137
|
+
await downloadPluginAsync(failures, id, downloadUrl, pluginsDir, packed, extension?.version);
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
|
|
137
142
|
} finally {
|
|
138
143
|
temp.cleanupSync();
|
|
139
144
|
}
|
|
@@ -260,8 +265,7 @@ async function collectPackageJsonPaths(pluginDir: string): Promise<string[]> {
|
|
|
260
265
|
// Recursively fetch the list of extension `package.json` files.
|
|
261
266
|
for (const file of files) {
|
|
262
267
|
const filePath = path.join(pluginDir, file);
|
|
263
|
-
|
|
264
|
-
if (!filePath.startsWith(extensionPackCacheName) && (await fs.stat(filePath)).isDirectory()) {
|
|
268
|
+
if ((await fs.stat(filePath)).isDirectory()) {
|
|
265
269
|
packageJsonPathList.push(...await collectPackageJsonPaths(filePath));
|
|
266
270
|
} else if (path.basename(filePath) === 'package.json' && !path.dirname(filePath).includes('node_modules')) {
|
|
267
271
|
packageJsonPathList.push(filePath);
|
|
@@ -283,7 +287,7 @@ async function collectExtensionPacks(pluginDir: string, excludedIds: Set<string>
|
|
|
283
287
|
await Promise.all(packageJsonPaths.map(async packageJsonPath => {
|
|
284
288
|
const json = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
285
289
|
const extensionPack: unknown = json.extensionPack;
|
|
286
|
-
if (
|
|
290
|
+
if (Array.isArray(extensionPack)) {
|
|
287
291
|
extensionPackPaths.set(packageJsonPath, extensionPack.filter(id => {
|
|
288
292
|
if (excludedIds.has(id)) {
|
|
289
293
|
console.log(yellow(`'${id}' referenced by '${json.name}' (ext pack) is excluded because of 'theiaPluginsExcludeIds'`));
|
|
@@ -297,50 +301,27 @@ async function collectExtensionPacks(pluginDir: string, excludedIds: Set<string>
|
|
|
297
301
|
}
|
|
298
302
|
|
|
299
303
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* By moving the packs to a subdirectory it should make it invisible to the plugin system, only leaving
|
|
307
|
-
* the plugins that were installed under `pluginsDir` directly.
|
|
308
|
-
*
|
|
309
|
-
* @param extensionPacksPaths the list of extension-pack paths.
|
|
304
|
+
* Get the mapping of paths and their included plugin ids.
|
|
305
|
+
* - If an extension-pack references an explicitly excluded `id` the `id` will be omitted.
|
|
306
|
+
* @param pluginDir the plugin directory.
|
|
307
|
+
* @param excludedIds the list of plugin ids to exclude.
|
|
308
|
+
* @returns the mapping of extension-pack paths and their included plugin ids.
|
|
310
309
|
*/
|
|
311
|
-
async function
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
await Promise.all(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
await fs.rename(oldPath, newPath);
|
|
310
|
+
async function collectPluginDependencies(pluginDir: string, excludedIds: Set<string>): Promise<string[]> {
|
|
311
|
+
const dependencyIds: string[] = [];
|
|
312
|
+
const packageJsonPaths = await collectPackageJsonPaths(pluginDir);
|
|
313
|
+
await Promise.all(packageJsonPaths.map(async packageJsonPath => {
|
|
314
|
+
const json = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
315
|
+
const extensionDependencies: unknown = json.extensionDependencies;
|
|
316
|
+
if (Array.isArray(extensionDependencies)) {
|
|
317
|
+
for (const dependency of extensionDependencies) {
|
|
318
|
+
if (excludedIds.has(dependency)) {
|
|
319
|
+
console.log(yellow(`'${dependency}' referenced by '${json.name}' is excluded because of 'theiaPluginsExcludeIds'`));
|
|
320
|
+
} else {
|
|
321
|
+
dependencyIds.push(dependency);
|
|
322
|
+
}
|
|
325
323
|
}
|
|
326
|
-
} catch (error) {
|
|
327
|
-
console.error(error);
|
|
328
324
|
}
|
|
329
325
|
}));
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Walk back to the root of an extension starting from its `package.json`. e.g.
|
|
334
|
-
*
|
|
335
|
-
* ```ts
|
|
336
|
-
* getExtensionRoot('/a/b/c', '/a/b/c/EXT/d/e/f/package.json') === '/a/b/c/EXT'
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
function getExtensionRoot(root: string, packageJsonPath: string): string {
|
|
340
|
-
root = path.resolve(root);
|
|
341
|
-
packageJsonPath = path.resolve(packageJsonPath);
|
|
342
|
-
if (!packageJsonPath.startsWith(root)) {
|
|
343
|
-
throw new Error(`unexpected paths:\n root: ${root}\n package.json: ${packageJsonPath}`);
|
|
344
|
-
}
|
|
345
|
-
return packageJsonPath.substr(0, packageJsonPath.indexOf(path.sep, root.length + 1));
|
|
326
|
+
return dependencyIds;
|
|
346
327
|
}
|