@theia/cli 1.34.2 → 1.34.3

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/lib/theia.js CHANGED
@@ -1,531 +1,531 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 TypeFox 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 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 temp = require("temp");
21
- const yargs = require("yargs");
22
- const yargsFactory = require("yargs/yargs");
23
- const application_manager_1 = require("@theia/application-manager");
24
- const application_package_1 = require("@theia/application-package");
25
- const check_dependencies_1 = require("./check-dependencies");
26
- const download_plugins_1 = require("./download-plugins");
27
- const run_test_1 = require("./run-test");
28
- const localization_manager_1 = require("@theia/localization-manager");
29
- process.on('unhandledRejection', (reason, promise) => {
30
- throw reason;
31
- });
32
- process.on('uncaughtException', error => {
33
- if (error) {
34
- console.error('Uncaught Exception: ', error.toString());
35
- if (error.stack) {
36
- console.error(error.stack);
37
- }
38
- }
39
- process.exit(1);
40
- });
41
- theiaCli();
42
- function toStringArray(argv) {
43
- return argv === undefined
44
- ? undefined
45
- : argv.map(arg => String(arg));
46
- }
47
- function rebuildCommand(command, target) {
48
- return {
49
- command,
50
- describe: `Rebuild/revert native node modules for "${target}"`,
51
- builder: {
52
- 'cacheRoot': {
53
- type: 'string',
54
- describe: 'Root folder where to store the .browser_modules cache'
55
- },
56
- 'modules': {
57
- alias: 'm',
58
- type: 'array',
59
- describe: 'List of modules to rebuild/revert'
60
- },
61
- 'forceAbi': {
62
- type: 'number',
63
- describe: 'The Node ABI version to rebuild for'
64
- }
65
- },
66
- handler: ({ cacheRoot, modules, forceAbi }) => {
67
- // Note: `modules` is actually `string[] | undefined`.
68
- if (modules) {
69
- // It is ergonomic to pass arguments as --modules="a,b,c,..."
70
- // but yargs doesn't parse it this way by default.
71
- const flattened = [];
72
- for (const value of modules) {
73
- if (value.includes(',')) {
74
- flattened.push(...value.split(',').map(mod => mod.trim()));
75
- }
76
- else {
77
- flattened.push(value);
78
- }
79
- }
80
- modules = flattened;
81
- }
82
- (0, application_manager_1.rebuild)(target, { cacheRoot, modules, forceAbi });
83
- }
84
- };
85
- }
86
- function defineCommonOptions(cli) {
87
- return cli
88
- .option('app-target', {
89
- description: 'The target application type. Overrides `theia.target` in the application\'s package.json',
90
- choices: ['browser', 'electron'],
91
- });
92
- }
93
- async function theiaCli() {
94
- const { version } = await fs.promises.readFile(path.join(__dirname, '../package.json'), 'utf8').then(JSON.parse);
95
- yargs.scriptName('theia').version(version);
96
- const projectPath = process.cwd();
97
- // Create a sub `yargs` parser to read `app-target` without
98
- // affecting the global `yargs` instance used by the CLI.
99
- const { appTarget } = defineCommonOptions(yargsFactory()).help(false).parse();
100
- const manager = new application_manager_1.ApplicationPackageManager({ projectPath, appTarget });
101
- const localizationManager = new localization_manager_1.LocalizationManager();
102
- const { target } = manager.pck;
103
- defineCommonOptions(yargs)
104
- .command({
105
- command: 'start [theia-args...]',
106
- describe: `Start the ${target} backend`,
107
- // Disable this command's `--help` option so that it is forwarded to Theia's CLI
108
- builder: cli => cli.help(false),
109
- handler: async ({ theiaArgs }) => {
110
- manager.start(toStringArray(theiaArgs));
111
- }
112
- })
113
- .command({
114
- command: 'clean',
115
- describe: `Clean for the ${target} target`,
116
- handler: async () => {
117
- await manager.clean();
118
- }
119
- })
120
- .command({
121
- command: 'copy',
122
- describe: 'Copy various files from `src-gen` to `lib`',
123
- handler: async () => {
124
- await manager.copy();
125
- }
126
- })
127
- .command({
128
- command: 'generate',
129
- describe: `Generate various files for the ${target} target`,
130
- builder: cli => application_manager_1.ApplicationPackageManager.defineGeneratorOptions(cli),
131
- handler: async ({ mode, splitFrontend }) => {
132
- await manager.generate({ mode, splitFrontend });
133
- }
134
- })
135
- .command({
136
- command: 'build [webpack-args...]',
137
- describe: `Generate and bundle the ${target} frontend using webpack`,
138
- builder: cli => application_manager_1.ApplicationPackageManager.defineGeneratorOptions(cli)
139
- .option('webpack-help', {
140
- boolean: true,
141
- description: 'Display Webpack\'s help',
142
- default: false
143
- }),
144
- handler: async ({ mode, splitFrontend, webpackHelp, webpackArgs = [] }) => {
145
- await manager.build(webpackHelp
146
- ? ['--help']
147
- : [
148
- // Forward the `mode` argument to Webpack too:
149
- '--mode', mode,
150
- ...toStringArray(webpackArgs)
151
- ], { mode, splitFrontend });
152
- }
153
- })
154
- .command(rebuildCommand('rebuild', target))
155
- .command(rebuildCommand('rebuild:browser', 'browser'))
156
- .command(rebuildCommand('rebuild:electron', 'electron'))
157
- .command({
158
- command: 'check:hoisted',
159
- describe: 'Check that all dependencies are hoisted',
160
- builder: {
161
- 'suppress': {
162
- alias: 's',
163
- describe: 'Suppress exiting with failure code',
164
- boolean: true,
165
- default: false
166
- }
167
- },
168
- handler: ({ suppress }) => {
169
- (0, check_dependencies_1.default)({
170
- workspaces: ['packages/*'],
171
- include: ['**'],
172
- exclude: ['.bin/**', '.cache/**'],
173
- skipHoisted: false,
174
- skipUniqueness: true,
175
- skipSingleTheiaVersion: true,
176
- suppress
177
- });
178
- }
179
- })
180
- .command({
181
- command: 'check:theia-version',
182
- describe: 'Check that all dependencies have been resolved to the same Theia version',
183
- builder: {
184
- 'suppress': {
185
- alias: 's',
186
- describe: 'Suppress exiting with failure code',
187
- boolean: true,
188
- default: false
189
- }
190
- },
191
- handler: ({ suppress }) => {
192
- (0, check_dependencies_1.default)({
193
- workspaces: undefined,
194
- include: ['@theia/**'],
195
- exclude: [],
196
- skipHoisted: true,
197
- skipUniqueness: false,
198
- skipSingleTheiaVersion: false,
199
- suppress
200
- });
201
- }
202
- })
203
- .command({
204
- command: 'check:dependencies',
205
- describe: 'Check uniqueness of dependency versions or whether they are hoisted',
206
- builder: {
207
- 'workspaces': {
208
- alias: 'w',
209
- describe: 'Glob patterns of workspaces to analyze, relative to `cwd`',
210
- array: true,
211
- defaultDescription: 'All glob patterns listed in the package.json\'s workspaces',
212
- demandOption: false
213
- },
214
- 'include': {
215
- alias: 'i',
216
- describe: 'Glob pattern of dependencies\' package names to be included, e.g. -i "@theia/**"',
217
- array: true,
218
- default: ['**']
219
- },
220
- 'exclude': {
221
- alias: 'e',
222
- describe: 'Glob pattern of dependencies\' package names to be excluded',
223
- array: true,
224
- defaultDescription: 'None',
225
- default: []
226
- },
227
- 'skip-hoisted': {
228
- alias: 'h',
229
- describe: 'Skip checking whether dependencies are hoisted',
230
- boolean: true,
231
- default: false
232
- },
233
- 'skip-uniqueness': {
234
- alias: 'u',
235
- describe: 'Skip checking whether all dependencies are resolved to a unique version',
236
- boolean: true,
237
- default: false
238
- },
239
- 'skip-single-theia-version': {
240
- alias: 't',
241
- describe: 'Skip checking whether all @theia/* dependencies are resolved to a single version',
242
- boolean: true,
243
- default: false
244
- },
245
- 'suppress': {
246
- alias: 's',
247
- describe: 'Suppress exiting with failure code',
248
- boolean: true,
249
- default: false
250
- }
251
- },
252
- handler: ({ workspaces, include, exclude, skipHoisted, skipUniqueness, skipSingleTheiaVersion, suppress }) => {
253
- (0, check_dependencies_1.default)({
254
- workspaces,
255
- include,
256
- exclude,
257
- skipHoisted,
258
- skipUniqueness,
259
- skipSingleTheiaVersion,
260
- suppress
261
- });
262
- }
263
- })
264
- .command({
265
- command: 'download:plugins',
266
- describe: 'Download defined external plugins',
267
- builder: {
268
- 'packed': {
269
- alias: 'p',
270
- describe: 'Controls whether to pack or unpack plugins',
271
- boolean: true,
272
- default: false,
273
- },
274
- 'ignore-errors': {
275
- alias: 'i',
276
- describe: 'Ignore errors while downloading plugins',
277
- boolean: true,
278
- default: false,
279
- },
280
- 'api-version': {
281
- alias: 'v',
282
- describe: 'Supported API version for plugins',
283
- default: application_package_1.DEFAULT_SUPPORTED_API_VERSION
284
- },
285
- 'api-url': {
286
- alias: 'u',
287
- describe: 'Open-VSX Registry API URL',
288
- default: 'https://open-vsx.org/api'
289
- },
290
- 'parallel': {
291
- describe: 'Download in parallel',
292
- boolean: true,
293
- default: true
294
- },
295
- 'rate-limit': {
296
- describe: 'Amount of maximum open-vsx requests per second',
297
- number: true,
298
- default: 15
299
- },
300
- 'proxy-url': {
301
- describe: 'Proxy URL'
302
- },
303
- 'proxy-authentification': {
304
- describe: 'Proxy authentification information'
305
- },
306
- 'strict-ssl': {
307
- describe: 'Whether to enable strict SSL mode',
308
- boolean: true,
309
- default: false
310
- }
311
- },
312
- handler: async (args) => {
313
- await (0, download_plugins_1.default)(args);
314
- },
315
- })
316
- .command({
317
- command: 'nls-localize [languages...]',
318
- describe: 'Localize json files using the DeepL API',
319
- builder: {
320
- 'file': {
321
- alias: 'f',
322
- describe: 'The source file which should be translated',
323
- demandOption: true
324
- },
325
- 'deepl-key': {
326
- alias: 'k',
327
- describe: 'DeepL key used for API access. See https://www.deepl.com/docs-api for more information',
328
- demandOption: true
329
- },
330
- 'free-api': {
331
- describe: 'Indicates whether the specified DeepL API key belongs to the free API',
332
- boolean: true,
333
- default: false,
334
- },
335
- 'source-language': {
336
- alias: 's',
337
- describe: 'The source language of the translation file'
338
- }
339
- },
340
- handler: async ({ freeApi, deeplKey, file, sourceLanguage, languages = [] }) => {
341
- await localizationManager.localize({
342
- sourceFile: file,
343
- freeApi: freeApi !== null && freeApi !== void 0 ? freeApi : true,
344
- authKey: deeplKey,
345
- targetLanguages: languages,
346
- sourceLanguage
347
- });
348
- }
349
- })
350
- .command({
351
- command: 'nls-extract',
352
- describe: 'Extract translation key/value pairs from source code',
353
- builder: {
354
- 'output': {
355
- alias: 'o',
356
- describe: 'Output file for the extracted translations',
357
- demandOption: true
358
- },
359
- 'root': {
360
- alias: 'r',
361
- describe: 'The directory which contains the source code',
362
- default: '.'
363
- },
364
- 'merge': {
365
- alias: 'm',
366
- describe: 'Whether to merge new with existing translation values',
367
- boolean: true,
368
- default: false
369
- },
370
- 'exclude': {
371
- alias: 'e',
372
- describe: 'Allows to exclude translation keys starting with this value'
373
- },
374
- 'files': {
375
- alias: 'f',
376
- describe: 'Glob pattern matching the files to extract from (starting from --root).',
377
- array: true
378
- },
379
- 'logs': {
380
- alias: 'l',
381
- describe: 'File path to a log file'
382
- },
383
- 'quiet': {
384
- alias: 'q',
385
- describe: 'Prevents errors from being logged to console',
386
- boolean: true,
387
- default: false
388
- }
389
- },
390
- handler: async (options) => {
391
- await (0, localization_manager_1.extract)(options);
392
- }
393
- })
394
- .command({
395
- command: 'test [theia-args...]',
396
- builder: {
397
- 'test-inspect': {
398
- describe: 'Whether to auto-open a DevTools panel for test page.',
399
- boolean: true,
400
- default: false
401
- },
402
- 'test-extension': {
403
- describe: 'Test file extension(s) to load',
404
- array: true,
405
- default: ['js']
406
- },
407
- 'test-file': {
408
- describe: 'Specify test file(s) to be loaded prior to root suite execution',
409
- array: true,
410
- default: []
411
- },
412
- 'test-ignore': {
413
- describe: 'Ignore test file(s) or glob pattern(s)',
414
- array: true,
415
- default: []
416
- },
417
- 'test-recursive': {
418
- describe: 'Look for tests in subdirectories',
419
- boolean: true,
420
- default: false
421
- },
422
- 'test-sort': {
423
- describe: 'Sort test files',
424
- boolean: true,
425
- default: false
426
- },
427
- 'test-spec': {
428
- describe: 'One or more test files, directories, or globs to test',
429
- array: true,
430
- default: ['test']
431
- },
432
- 'test-coverage': {
433
- describe: 'Report test coverage consumable by istanbul',
434
- boolean: true,
435
- default: false
436
- }
437
- },
438
- handler: async ({ testInspect, testExtension, testFile, testIgnore, testRecursive, testSort, testSpec, testCoverage, theiaArgs }) => {
439
- if (!process.env.THEIA_CONFIG_DIR) {
440
- process.env.THEIA_CONFIG_DIR = temp.track().mkdirSync('theia-test-config-dir');
441
- }
442
- await (0, run_test_1.default)({
443
- start: () => new Promise((resolve, reject) => {
444
- const serverProcess = manager.start(toStringArray(theiaArgs));
445
- serverProcess.on('message', resolve);
446
- serverProcess.on('error', reject);
447
- serverProcess.on('close', (code, signal) => reject(`Server process exited unexpectedly: ${code !== null && code !== void 0 ? code : signal}`));
448
- }),
449
- launch: {
450
- args: ['--no-sandbox'],
451
- devtools: testInspect
452
- },
453
- files: {
454
- extension: testExtension,
455
- file: testFile,
456
- ignore: testIgnore,
457
- recursive: testRecursive,
458
- sort: testSort,
459
- spec: testSpec
460
- },
461
- coverage: testCoverage
462
- });
463
- }
464
- })
465
- .command({
466
- command: 'ffmpeg:replace [ffmpeg-path]',
467
- describe: '',
468
- builder: {
469
- 'electronDist': {
470
- description: 'Electron distribution location.',
471
- },
472
- 'electronVersion': {
473
- description: 'Electron version for which to pull the "clean" ffmpeg library.',
474
- },
475
- 'ffmpegPath': {
476
- description: 'Absolute path to the ffmpeg shared library.',
477
- },
478
- 'platform': {
479
- description: 'Dictates where the library is located within the Electron distribution.',
480
- choices: ['darwin', 'linux', 'win32'],
481
- },
482
- },
483
- handler: async (options) => {
484
- const ffmpeg = await Promise.resolve().then(() => require('@theia/ffmpeg'));
485
- await ffmpeg.replaceFfmpeg(options);
486
- },
487
- })
488
- .command({
489
- command: 'ffmpeg:check [ffmpeg-path]',
490
- describe: '(electron-only) Check that ffmpeg doesn\'t contain proprietary codecs',
491
- builder: {
492
- 'electronDist': {
493
- description: 'Electron distribution location',
494
- },
495
- 'ffmpegPath': {
496
- describe: 'Absolute path to the ffmpeg shared library',
497
- },
498
- 'json': {
499
- description: 'Output the found codecs as JSON on stdout',
500
- boolean: true,
501
- },
502
- 'platform': {
503
- description: 'Dictates where the library is located within the Electron distribution',
504
- choices: ['darwin', 'linux', 'win32'],
505
- },
506
- },
507
- handler: async (options) => {
508
- const ffmpeg = await Promise.resolve().then(() => require('@theia/ffmpeg'));
509
- await ffmpeg.checkFfmpeg(options);
510
- },
511
- })
512
- .parserConfiguration({
513
- 'unknown-options-as-args': true,
514
- })
515
- .strictCommands()
516
- .demandCommand(1, 'Please run a command')
517
- .fail((msg, err, cli) => {
518
- process.exitCode = 1;
519
- if (err) {
520
- // One of the handlers threw an error:
521
- console.error(err);
522
- }
523
- else {
524
- // Yargs detected a problem with commands and/or arguments while parsing:
525
- cli.showHelp();
526
- console.error(msg);
527
- }
528
- })
529
- .parse();
530
- }
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 TypeFox 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 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 temp = require("temp");
21
+ const yargs = require("yargs");
22
+ const yargsFactory = require("yargs/yargs");
23
+ const application_manager_1 = require("@theia/application-manager");
24
+ const application_package_1 = require("@theia/application-package");
25
+ const check_dependencies_1 = require("./check-dependencies");
26
+ const download_plugins_1 = require("./download-plugins");
27
+ const run_test_1 = require("./run-test");
28
+ const localization_manager_1 = require("@theia/localization-manager");
29
+ process.on('unhandledRejection', (reason, promise) => {
30
+ throw reason;
31
+ });
32
+ process.on('uncaughtException', error => {
33
+ if (error) {
34
+ console.error('Uncaught Exception: ', error.toString());
35
+ if (error.stack) {
36
+ console.error(error.stack);
37
+ }
38
+ }
39
+ process.exit(1);
40
+ });
41
+ theiaCli();
42
+ function toStringArray(argv) {
43
+ return argv === undefined
44
+ ? undefined
45
+ : argv.map(arg => String(arg));
46
+ }
47
+ function rebuildCommand(command, target) {
48
+ return {
49
+ command,
50
+ describe: `Rebuild/revert native node modules for "${target}"`,
51
+ builder: {
52
+ 'cacheRoot': {
53
+ type: 'string',
54
+ describe: 'Root folder where to store the .browser_modules cache'
55
+ },
56
+ 'modules': {
57
+ alias: 'm',
58
+ type: 'array',
59
+ describe: 'List of modules to rebuild/revert'
60
+ },
61
+ 'forceAbi': {
62
+ type: 'number',
63
+ describe: 'The Node ABI version to rebuild for'
64
+ }
65
+ },
66
+ handler: ({ cacheRoot, modules, forceAbi }) => {
67
+ // Note: `modules` is actually `string[] | undefined`.
68
+ if (modules) {
69
+ // It is ergonomic to pass arguments as --modules="a,b,c,..."
70
+ // but yargs doesn't parse it this way by default.
71
+ const flattened = [];
72
+ for (const value of modules) {
73
+ if (value.includes(',')) {
74
+ flattened.push(...value.split(',').map(mod => mod.trim()));
75
+ }
76
+ else {
77
+ flattened.push(value);
78
+ }
79
+ }
80
+ modules = flattened;
81
+ }
82
+ (0, application_manager_1.rebuild)(target, { cacheRoot, modules, forceAbi });
83
+ }
84
+ };
85
+ }
86
+ function defineCommonOptions(cli) {
87
+ return cli
88
+ .option('app-target', {
89
+ description: 'The target application type. Overrides `theia.target` in the application\'s package.json',
90
+ choices: ['browser', 'electron'],
91
+ });
92
+ }
93
+ async function theiaCli() {
94
+ const { version } = await fs.promises.readFile(path.join(__dirname, '../package.json'), 'utf8').then(JSON.parse);
95
+ yargs.scriptName('theia').version(version);
96
+ const projectPath = process.cwd();
97
+ // Create a sub `yargs` parser to read `app-target` without
98
+ // affecting the global `yargs` instance used by the CLI.
99
+ const { appTarget } = defineCommonOptions(yargsFactory()).help(false).parse();
100
+ const manager = new application_manager_1.ApplicationPackageManager({ projectPath, appTarget });
101
+ const localizationManager = new localization_manager_1.LocalizationManager();
102
+ const { target } = manager.pck;
103
+ defineCommonOptions(yargs)
104
+ .command({
105
+ command: 'start [theia-args...]',
106
+ describe: `Start the ${target} backend`,
107
+ // Disable this command's `--help` option so that it is forwarded to Theia's CLI
108
+ builder: cli => cli.help(false),
109
+ handler: async ({ theiaArgs }) => {
110
+ manager.start(toStringArray(theiaArgs));
111
+ }
112
+ })
113
+ .command({
114
+ command: 'clean',
115
+ describe: `Clean for the ${target} target`,
116
+ handler: async () => {
117
+ await manager.clean();
118
+ }
119
+ })
120
+ .command({
121
+ command: 'copy',
122
+ describe: 'Copy various files from `src-gen` to `lib`',
123
+ handler: async () => {
124
+ await manager.copy();
125
+ }
126
+ })
127
+ .command({
128
+ command: 'generate',
129
+ describe: `Generate various files for the ${target} target`,
130
+ builder: cli => application_manager_1.ApplicationPackageManager.defineGeneratorOptions(cli),
131
+ handler: async ({ mode, splitFrontend }) => {
132
+ await manager.generate({ mode, splitFrontend });
133
+ }
134
+ })
135
+ .command({
136
+ command: 'build [webpack-args...]',
137
+ describe: `Generate and bundle the ${target} frontend using webpack`,
138
+ builder: cli => application_manager_1.ApplicationPackageManager.defineGeneratorOptions(cli)
139
+ .option('webpack-help', {
140
+ boolean: true,
141
+ description: 'Display Webpack\'s help',
142
+ default: false
143
+ }),
144
+ handler: async ({ mode, splitFrontend, webpackHelp, webpackArgs = [] }) => {
145
+ await manager.build(webpackHelp
146
+ ? ['--help']
147
+ : [
148
+ // Forward the `mode` argument to Webpack too:
149
+ '--mode', mode,
150
+ ...toStringArray(webpackArgs)
151
+ ], { mode, splitFrontend });
152
+ }
153
+ })
154
+ .command(rebuildCommand('rebuild', target))
155
+ .command(rebuildCommand('rebuild:browser', 'browser'))
156
+ .command(rebuildCommand('rebuild:electron', 'electron'))
157
+ .command({
158
+ command: 'check:hoisted',
159
+ describe: 'Check that all dependencies are hoisted',
160
+ builder: {
161
+ 'suppress': {
162
+ alias: 's',
163
+ describe: 'Suppress exiting with failure code',
164
+ boolean: true,
165
+ default: false
166
+ }
167
+ },
168
+ handler: ({ suppress }) => {
169
+ (0, check_dependencies_1.default)({
170
+ workspaces: ['packages/*'],
171
+ include: ['**'],
172
+ exclude: ['.bin/**', '.cache/**'],
173
+ skipHoisted: false,
174
+ skipUniqueness: true,
175
+ skipSingleTheiaVersion: true,
176
+ suppress
177
+ });
178
+ }
179
+ })
180
+ .command({
181
+ command: 'check:theia-version',
182
+ describe: 'Check that all dependencies have been resolved to the same Theia version',
183
+ builder: {
184
+ 'suppress': {
185
+ alias: 's',
186
+ describe: 'Suppress exiting with failure code',
187
+ boolean: true,
188
+ default: false
189
+ }
190
+ },
191
+ handler: ({ suppress }) => {
192
+ (0, check_dependencies_1.default)({
193
+ workspaces: undefined,
194
+ include: ['@theia/**'],
195
+ exclude: [],
196
+ skipHoisted: true,
197
+ skipUniqueness: false,
198
+ skipSingleTheiaVersion: false,
199
+ suppress
200
+ });
201
+ }
202
+ })
203
+ .command({
204
+ command: 'check:dependencies',
205
+ describe: 'Check uniqueness of dependency versions or whether they are hoisted',
206
+ builder: {
207
+ 'workspaces': {
208
+ alias: 'w',
209
+ describe: 'Glob patterns of workspaces to analyze, relative to `cwd`',
210
+ array: true,
211
+ defaultDescription: 'All glob patterns listed in the package.json\'s workspaces',
212
+ demandOption: false
213
+ },
214
+ 'include': {
215
+ alias: 'i',
216
+ describe: 'Glob pattern of dependencies\' package names to be included, e.g. -i "@theia/**"',
217
+ array: true,
218
+ default: ['**']
219
+ },
220
+ 'exclude': {
221
+ alias: 'e',
222
+ describe: 'Glob pattern of dependencies\' package names to be excluded',
223
+ array: true,
224
+ defaultDescription: 'None',
225
+ default: []
226
+ },
227
+ 'skip-hoisted': {
228
+ alias: 'h',
229
+ describe: 'Skip checking whether dependencies are hoisted',
230
+ boolean: true,
231
+ default: false
232
+ },
233
+ 'skip-uniqueness': {
234
+ alias: 'u',
235
+ describe: 'Skip checking whether all dependencies are resolved to a unique version',
236
+ boolean: true,
237
+ default: false
238
+ },
239
+ 'skip-single-theia-version': {
240
+ alias: 't',
241
+ describe: 'Skip checking whether all @theia/* dependencies are resolved to a single version',
242
+ boolean: true,
243
+ default: false
244
+ },
245
+ 'suppress': {
246
+ alias: 's',
247
+ describe: 'Suppress exiting with failure code',
248
+ boolean: true,
249
+ default: false
250
+ }
251
+ },
252
+ handler: ({ workspaces, include, exclude, skipHoisted, skipUniqueness, skipSingleTheiaVersion, suppress }) => {
253
+ (0, check_dependencies_1.default)({
254
+ workspaces,
255
+ include,
256
+ exclude,
257
+ skipHoisted,
258
+ skipUniqueness,
259
+ skipSingleTheiaVersion,
260
+ suppress
261
+ });
262
+ }
263
+ })
264
+ .command({
265
+ command: 'download:plugins',
266
+ describe: 'Download defined external plugins',
267
+ builder: {
268
+ 'packed': {
269
+ alias: 'p',
270
+ describe: 'Controls whether to pack or unpack plugins',
271
+ boolean: true,
272
+ default: false,
273
+ },
274
+ 'ignore-errors': {
275
+ alias: 'i',
276
+ describe: 'Ignore errors while downloading plugins',
277
+ boolean: true,
278
+ default: false,
279
+ },
280
+ 'api-version': {
281
+ alias: 'v',
282
+ describe: 'Supported API version for plugins',
283
+ default: application_package_1.DEFAULT_SUPPORTED_API_VERSION
284
+ },
285
+ 'api-url': {
286
+ alias: 'u',
287
+ describe: 'Open-VSX Registry API URL',
288
+ default: 'https://open-vsx.org/api'
289
+ },
290
+ 'parallel': {
291
+ describe: 'Download in parallel',
292
+ boolean: true,
293
+ default: true
294
+ },
295
+ 'rate-limit': {
296
+ describe: 'Amount of maximum open-vsx requests per second',
297
+ number: true,
298
+ default: 15
299
+ },
300
+ 'proxy-url': {
301
+ describe: 'Proxy URL'
302
+ },
303
+ 'proxy-authentification': {
304
+ describe: 'Proxy authentification information'
305
+ },
306
+ 'strict-ssl': {
307
+ describe: 'Whether to enable strict SSL mode',
308
+ boolean: true,
309
+ default: false
310
+ }
311
+ },
312
+ handler: async (args) => {
313
+ await (0, download_plugins_1.default)(args);
314
+ },
315
+ })
316
+ .command({
317
+ command: 'nls-localize [languages...]',
318
+ describe: 'Localize json files using the DeepL API',
319
+ builder: {
320
+ 'file': {
321
+ alias: 'f',
322
+ describe: 'The source file which should be translated',
323
+ demandOption: true
324
+ },
325
+ 'deepl-key': {
326
+ alias: 'k',
327
+ describe: 'DeepL key used for API access. See https://www.deepl.com/docs-api for more information',
328
+ demandOption: true
329
+ },
330
+ 'free-api': {
331
+ describe: 'Indicates whether the specified DeepL API key belongs to the free API',
332
+ boolean: true,
333
+ default: false,
334
+ },
335
+ 'source-language': {
336
+ alias: 's',
337
+ describe: 'The source language of the translation file'
338
+ }
339
+ },
340
+ handler: async ({ freeApi, deeplKey, file, sourceLanguage, languages = [] }) => {
341
+ await localizationManager.localize({
342
+ sourceFile: file,
343
+ freeApi: freeApi !== null && freeApi !== void 0 ? freeApi : true,
344
+ authKey: deeplKey,
345
+ targetLanguages: languages,
346
+ sourceLanguage
347
+ });
348
+ }
349
+ })
350
+ .command({
351
+ command: 'nls-extract',
352
+ describe: 'Extract translation key/value pairs from source code',
353
+ builder: {
354
+ 'output': {
355
+ alias: 'o',
356
+ describe: 'Output file for the extracted translations',
357
+ demandOption: true
358
+ },
359
+ 'root': {
360
+ alias: 'r',
361
+ describe: 'The directory which contains the source code',
362
+ default: '.'
363
+ },
364
+ 'merge': {
365
+ alias: 'm',
366
+ describe: 'Whether to merge new with existing translation values',
367
+ boolean: true,
368
+ default: false
369
+ },
370
+ 'exclude': {
371
+ alias: 'e',
372
+ describe: 'Allows to exclude translation keys starting with this value'
373
+ },
374
+ 'files': {
375
+ alias: 'f',
376
+ describe: 'Glob pattern matching the files to extract from (starting from --root).',
377
+ array: true
378
+ },
379
+ 'logs': {
380
+ alias: 'l',
381
+ describe: 'File path to a log file'
382
+ },
383
+ 'quiet': {
384
+ alias: 'q',
385
+ describe: 'Prevents errors from being logged to console',
386
+ boolean: true,
387
+ default: false
388
+ }
389
+ },
390
+ handler: async (options) => {
391
+ await (0, localization_manager_1.extract)(options);
392
+ }
393
+ })
394
+ .command({
395
+ command: 'test [theia-args...]',
396
+ builder: {
397
+ 'test-inspect': {
398
+ describe: 'Whether to auto-open a DevTools panel for test page.',
399
+ boolean: true,
400
+ default: false
401
+ },
402
+ 'test-extension': {
403
+ describe: 'Test file extension(s) to load',
404
+ array: true,
405
+ default: ['js']
406
+ },
407
+ 'test-file': {
408
+ describe: 'Specify test file(s) to be loaded prior to root suite execution',
409
+ array: true,
410
+ default: []
411
+ },
412
+ 'test-ignore': {
413
+ describe: 'Ignore test file(s) or glob pattern(s)',
414
+ array: true,
415
+ default: []
416
+ },
417
+ 'test-recursive': {
418
+ describe: 'Look for tests in subdirectories',
419
+ boolean: true,
420
+ default: false
421
+ },
422
+ 'test-sort': {
423
+ describe: 'Sort test files',
424
+ boolean: true,
425
+ default: false
426
+ },
427
+ 'test-spec': {
428
+ describe: 'One or more test files, directories, or globs to test',
429
+ array: true,
430
+ default: ['test']
431
+ },
432
+ 'test-coverage': {
433
+ describe: 'Report test coverage consumable by istanbul',
434
+ boolean: true,
435
+ default: false
436
+ }
437
+ },
438
+ handler: async ({ testInspect, testExtension, testFile, testIgnore, testRecursive, testSort, testSpec, testCoverage, theiaArgs }) => {
439
+ if (!process.env.THEIA_CONFIG_DIR) {
440
+ process.env.THEIA_CONFIG_DIR = temp.track().mkdirSync('theia-test-config-dir');
441
+ }
442
+ await (0, run_test_1.default)({
443
+ start: () => new Promise((resolve, reject) => {
444
+ const serverProcess = manager.start(toStringArray(theiaArgs));
445
+ serverProcess.on('message', resolve);
446
+ serverProcess.on('error', reject);
447
+ serverProcess.on('close', (code, signal) => reject(`Server process exited unexpectedly: ${code !== null && code !== void 0 ? code : signal}`));
448
+ }),
449
+ launch: {
450
+ args: ['--no-sandbox'],
451
+ devtools: testInspect
452
+ },
453
+ files: {
454
+ extension: testExtension,
455
+ file: testFile,
456
+ ignore: testIgnore,
457
+ recursive: testRecursive,
458
+ sort: testSort,
459
+ spec: testSpec
460
+ },
461
+ coverage: testCoverage
462
+ });
463
+ }
464
+ })
465
+ .command({
466
+ command: 'ffmpeg:replace [ffmpeg-path]',
467
+ describe: '',
468
+ builder: {
469
+ 'electronDist': {
470
+ description: 'Electron distribution location.',
471
+ },
472
+ 'electronVersion': {
473
+ description: 'Electron version for which to pull the "clean" ffmpeg library.',
474
+ },
475
+ 'ffmpegPath': {
476
+ description: 'Absolute path to the ffmpeg shared library.',
477
+ },
478
+ 'platform': {
479
+ description: 'Dictates where the library is located within the Electron distribution.',
480
+ choices: ['darwin', 'linux', 'win32'],
481
+ },
482
+ },
483
+ handler: async (options) => {
484
+ const ffmpeg = await Promise.resolve().then(() => require('@theia/ffmpeg'));
485
+ await ffmpeg.replaceFfmpeg(options);
486
+ },
487
+ })
488
+ .command({
489
+ command: 'ffmpeg:check [ffmpeg-path]',
490
+ describe: '(electron-only) Check that ffmpeg doesn\'t contain proprietary codecs',
491
+ builder: {
492
+ 'electronDist': {
493
+ description: 'Electron distribution location',
494
+ },
495
+ 'ffmpegPath': {
496
+ describe: 'Absolute path to the ffmpeg shared library',
497
+ },
498
+ 'json': {
499
+ description: 'Output the found codecs as JSON on stdout',
500
+ boolean: true,
501
+ },
502
+ 'platform': {
503
+ description: 'Dictates where the library is located within the Electron distribution',
504
+ choices: ['darwin', 'linux', 'win32'],
505
+ },
506
+ },
507
+ handler: async (options) => {
508
+ const ffmpeg = await Promise.resolve().then(() => require('@theia/ffmpeg'));
509
+ await ffmpeg.checkFfmpeg(options);
510
+ },
511
+ })
512
+ .parserConfiguration({
513
+ 'unknown-options-as-args': true,
514
+ })
515
+ .strictCommands()
516
+ .demandCommand(1, 'Please run a command')
517
+ .fail((msg, err, cli) => {
518
+ process.exitCode = 1;
519
+ if (err) {
520
+ // One of the handlers threw an error:
521
+ console.error(err);
522
+ }
523
+ else {
524
+ // Yargs detected a problem with commands and/or arguments while parsing:
525
+ cli.showHelp();
526
+ console.error(msg);
527
+ }
528
+ })
529
+ .parse();
530
+ }
531
531
  //# sourceMappingURL=theia.js.map