web-ext 6.7.0 → 7.1.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.
Files changed (94) hide show
  1. package/README.md +17 -8
  2. package/bin/web-ext.js +13 -0
  3. package/index.js +12 -0
  4. package/lib/cmd/build.js +226 -0
  5. package/lib/cmd/build.js.map +1 -0
  6. package/lib/cmd/docs.js +16 -0
  7. package/lib/cmd/docs.js.map +1 -0
  8. package/lib/cmd/index.js +47 -0
  9. package/lib/cmd/index.js.map +1 -0
  10. package/lib/cmd/lint.js +50 -0
  11. package/lib/cmd/lint.js.map +1 -0
  12. package/lib/cmd/run.js +199 -0
  13. package/lib/cmd/run.js.map +1 -0
  14. package/lib/cmd/sign.js +140 -0
  15. package/lib/cmd/sign.js.map +1 -0
  16. package/lib/config.js +144 -0
  17. package/lib/config.js.map +1 -0
  18. package/{src → lib}/errors.js +26 -35
  19. package/lib/errors.js.map +1 -0
  20. package/lib/extension-runners/base.js +2 -0
  21. package/lib/extension-runners/base.js.map +1 -0
  22. package/{src → lib}/extension-runners/chromium.js +121 -178
  23. package/lib/extension-runners/chromium.js.map +1 -0
  24. package/{src → lib}/extension-runners/firefox-android.js +168 -326
  25. package/lib/extension-runners/firefox-android.js.map +1 -0
  26. package/{src → lib}/extension-runners/firefox-desktop.js +73 -114
  27. package/lib/extension-runners/firefox-desktop.js.map +1 -0
  28. package/lib/extension-runners/index.js +311 -0
  29. package/lib/extension-runners/index.js.map +1 -0
  30. package/lib/firefox/index.js +362 -0
  31. package/lib/firefox/index.js.map +1 -0
  32. package/lib/firefox/package-identifiers.js +5 -0
  33. package/lib/firefox/package-identifiers.js.map +1 -0
  34. package/{src → lib}/firefox/preferences.js +27 -70
  35. package/lib/firefox/preferences.js.map +1 -0
  36. package/{src → lib}/firefox/rdp-client.js +98 -105
  37. package/lib/firefox/rdp-client.js.map +1 -0
  38. package/{src → lib}/firefox/remote.js +55 -129
  39. package/lib/firefox/remote.js.map +1 -0
  40. package/lib/main.js +9 -0
  41. package/lib/main.js.map +1 -0
  42. package/lib/program.js +663 -0
  43. package/lib/program.js.map +1 -0
  44. package/lib/util/adb.js +322 -0
  45. package/lib/util/adb.js.map +1 -0
  46. package/lib/util/artifacts.js +52 -0
  47. package/lib/util/artifacts.js.map +1 -0
  48. package/lib/util/desktop-notifier.js +27 -0
  49. package/lib/util/desktop-notifier.js.map +1 -0
  50. package/{src → lib}/util/file-exists.js +7 -14
  51. package/lib/util/file-exists.js.map +1 -0
  52. package/{src → lib}/util/file-filter.js +31 -59
  53. package/lib/util/file-filter.js.map +1 -0
  54. package/lib/util/is-directory.js +20 -0
  55. package/lib/util/is-directory.js.map +1 -0
  56. package/lib/util/logger.js +79 -0
  57. package/lib/util/logger.js.map +1 -0
  58. package/{src → lib}/util/manifest.js +18 -50
  59. package/lib/util/manifest.js.map +1 -0
  60. package/{src → lib}/util/promisify.js +6 -9
  61. package/lib/util/promisify.js.map +1 -0
  62. package/{src → lib}/util/stdin.js +3 -7
  63. package/lib/util/stdin.js.map +1 -0
  64. package/{src → lib}/util/temp-dir.js +47 -52
  65. package/lib/util/temp-dir.js.map +1 -0
  66. package/lib/util/updates.js +16 -0
  67. package/lib/util/updates.js.map +1 -0
  68. package/lib/watcher.js +78 -0
  69. package/lib/watcher.js.map +1 -0
  70. package/package.json +50 -52
  71. package/CODE_OF_CONDUCT.md +0 -10
  72. package/bin/web-ext +0 -7
  73. package/dist/web-ext.js +0 -2
  74. package/index.mjs +0 -13
  75. package/src/cmd/build.js +0 -319
  76. package/src/cmd/docs.js +0 -33
  77. package/src/cmd/index.js +0 -57
  78. package/src/cmd/lint.js +0 -102
  79. package/src/cmd/run.js +0 -266
  80. package/src/cmd/sign.js +0 -198
  81. package/src/config.js +0 -187
  82. package/src/extension-runners/base.js +0 -40
  83. package/src/extension-runners/index.js +0 -381
  84. package/src/firefox/index.js +0 -541
  85. package/src/firefox/package-identifiers.js +0 -14
  86. package/src/main.js +0 -19
  87. package/src/program.js +0 -765
  88. package/src/util/adb.js +0 -433
  89. package/src/util/artifacts.js +0 -69
  90. package/src/util/desktop-notifier.js +0 -41
  91. package/src/util/is-directory.js +0 -23
  92. package/src/util/logger.js +0 -131
  93. package/src/util/updates.js +0 -21
  94. package/src/watcher.js +0 -114
package/lib/program.js ADDED
@@ -0,0 +1,663 @@
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import { readFileSync } from 'fs';
4
+ import camelCase from 'camelcase';
5
+ import decamelize from 'decamelize';
6
+ import yargs from 'yargs';
7
+ import { Parser as yargsParser } from 'yargs/helpers';
8
+ import defaultCommands from './cmd/index.js';
9
+ import { UsageError } from './errors.js';
10
+ import { createLogger, consoleStream as defaultLogStream } from './util/logger.js';
11
+ import { coerceCLICustomPreference } from './firefox/preferences.js';
12
+ import { checkForUpdates as defaultUpdateChecker } from './util/updates.js';
13
+ import { discoverConfigFiles as defaultConfigDiscovery, loadJSConfigFile as defaultLoadJSConfigFile, applyConfigToArgv as defaultApplyConfigToArgv } from './config.js';
14
+ const log = createLogger(import.meta.url);
15
+ const envPrefix = 'WEB_EXT'; // Default to "development" (the value actually assigned will be interpolated
16
+ // by babel-plugin-transform-inline-environment-variables).
17
+
18
+ const defaultGlobalEnv = "production" || 'development';
19
+
20
+ /*
21
+ * The command line program.
22
+ */
23
+ export class Program {
24
+ constructor(argv, {
25
+ absolutePackageDir = process.cwd()
26
+ } = {}) {
27
+ // This allows us to override the process argv which is useful for
28
+ // testing.
29
+ // NOTE: process.argv.slice(2) removes the path to node and web-ext
30
+ // executables from the process.argv array.
31
+ argv = argv || process.argv.slice(2);
32
+ this.programArgv = argv; // NOTE: always initialize yargs explicitly with the package dir
33
+ // to avoid side-effects due to yargs looking for its configuration
34
+ // section from a package.json file stored in an arbitrary directory
35
+ // (e.g. in tests yargs would end up loading yargs config from the
36
+ // mocha package.json). web-ext package.json doesn't contain any yargs
37
+ // section as it is deprecated and we configure yargs using
38
+ // yargs.parserConfiguration. See web-ext#469 for rationale.
39
+
40
+ const yargsInstance = yargs(argv, absolutePackageDir);
41
+ this.absolutePackageDir = absolutePackageDir;
42
+ this.verboseEnabled = false;
43
+ this.shouldExitProgram = true;
44
+ this.yargs = yargsInstance;
45
+ this.yargs.parserConfiguration({
46
+ 'boolean-negation': true
47
+ });
48
+ this.yargs.strict();
49
+ this.yargs.wrap(this.yargs.terminalWidth());
50
+ this.commands = {};
51
+ this.options = {};
52
+ }
53
+
54
+ command(name, description, executor, commandOptions = {}) {
55
+ this.options[camelCase(name)] = commandOptions;
56
+ this.yargs.command(name, description, yargsForCmd => {
57
+ if (!commandOptions) {
58
+ return;
59
+ }
60
+
61
+ return yargsForCmd // Make sure the user does not add any extra commands. For example,
62
+ // this would be a mistake because lint does not accept arguments:
63
+ // web-ext lint ./src/path/to/file.js
64
+ .demandCommand(0, 0, undefined, 'This command does not take any arguments').strict().exitProcess(this.shouldExitProgram) // Calling env() will be unnecessary after
65
+ // https://github.com/yargs/yargs/issues/486 is fixed
66
+ .env(envPrefix).options(commandOptions);
67
+ });
68
+ this.commands[name] = executor;
69
+ return this;
70
+ }
71
+
72
+ setGlobalOptions(options) {
73
+ // This is a convenience for setting global options.
74
+ // An option is only global (i.e. available to all sub commands)
75
+ // with the `global` flag so this makes sure every option has it.
76
+ this.options = { ...this.options,
77
+ ...options
78
+ };
79
+ Object.keys(options).forEach(key => {
80
+ options[key].global = true;
81
+
82
+ if (options[key].demandOption === undefined) {
83
+ // By default, all options should be "demanded" otherwise
84
+ // yargs.strict() will think they are missing when declared.
85
+ options[key].demandOption = true;
86
+ }
87
+ });
88
+ this.yargs.options(options);
89
+ return this;
90
+ }
91
+
92
+ enableVerboseMode(logStream, version) {
93
+ if (this.verboseEnabled) {
94
+ return;
95
+ }
96
+
97
+ logStream.makeVerbose();
98
+ log.info('Version:', version);
99
+ this.verboseEnabled = true;
100
+ } // Retrieve the yargs argv object and apply any further fix needed
101
+ // on the output of the yargs options parsing.
102
+
103
+
104
+ getArguments() {
105
+ // To support looking up required parameters via config files, we need to
106
+ // temporarily disable the requiredArguments validation. Otherwise yargs
107
+ // would exit early. Validation is enforced by the checkRequiredArguments()
108
+ // method, after reading configuration files.
109
+ //
110
+ // This is an undocumented internal API of yargs! Unit tests to avoid
111
+ // regressions are located at: tests/functional/test.cli.sign.js
112
+ //
113
+ // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930
114
+ const validationInstance = this.yargs.getInternalMethods().getValidationInstance();
115
+ const {
116
+ requiredArguments
117
+ } = validationInstance; // Initialize demandedOptions (which is going to be set to an object with one
118
+ // property for each mandatory global options, then the arrow function below
119
+ // will receive as its demandedOptions parameter a new one that also includes
120
+ // all mandatory options for the sub command selected).
121
+
122
+ this.demandedOptions = this.yargs.getDemandedOptions();
123
+
124
+ validationInstance.requiredArguments = (args, demandedOptions) => {
125
+ this.demandedOptions = demandedOptions;
126
+ };
127
+
128
+ let argv;
129
+
130
+ try {
131
+ argv = this.yargs.argv;
132
+ } catch (err) {
133
+ if (err.name === 'YError' && err.message.startsWith('Unknown argument: ')) {
134
+ throw new UsageError(err.message);
135
+ }
136
+
137
+ throw err;
138
+ }
139
+
140
+ validationInstance.requiredArguments = requiredArguments; // Yargs boolean options doesn't define the no* counterpart
141
+ // with negate-boolean on Yargs 15. Define as expected by the
142
+ // web-ext execute method.
143
+
144
+ if (argv.configDiscovery != null) {
145
+ argv.noConfigDiscovery = !argv.configDiscovery;
146
+ }
147
+
148
+ if (argv.reload != null) {
149
+ argv.noReload = !argv.reload;
150
+ } // Yargs doesn't accept --no-input as a valid option if there isn't a
151
+ // --input option defined to be negated, to fix that the --input is
152
+ // defined and hidden from the yargs help output and we define here
153
+ // the negated argument name that we expect to be set in the parsed
154
+ // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).
155
+
156
+
157
+ if (argv.input != null) {
158
+ argv.noInput = !argv.input;
159
+ } // Replacement for the "requiresArg: true" parameter until the following bug
160
+ // is fixed: https://github.com/yargs/yargs/issues/1098
161
+
162
+
163
+ if (argv.ignoreFiles && !argv.ignoreFiles.length) {
164
+ throw new UsageError('Not enough arguments following: ignore-files');
165
+ }
166
+
167
+ if (argv.startUrl && !argv.startUrl.length) {
168
+ throw new UsageError('Not enough arguments following: start-url');
169
+ }
170
+
171
+ return argv;
172
+ } // getArguments() disables validation of required parameters, to allow us to
173
+ // read parameters from config files first. Before the program continues, it
174
+ // must call checkRequiredArguments() to ensure that required parameters are
175
+ // defined (in the CLI or in a config file).
176
+
177
+
178
+ checkRequiredArguments(adjustedArgv) {
179
+ const validationInstance = this.yargs.getInternalMethods().getValidationInstance();
180
+ validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);
181
+ } // Remove WEB_EXT_* environment vars that are not a global cli options
182
+ // or an option supported by the current command (See #793).
183
+
184
+
185
+ cleanupProcessEnvConfigs(systemProcess) {
186
+ const cmd = yargsParser(this.programArgv)._[0];
187
+
188
+ const env = systemProcess.env || {};
189
+
190
+ const toOptionKey = k => decamelize(camelCase(k.replace(envPrefix, '')), {
191
+ separator: '-'
192
+ });
193
+
194
+ if (cmd) {
195
+ Object.keys(env).filter(k => k.startsWith(envPrefix)).forEach(k => {
196
+ const optKey = toOptionKey(k);
197
+ const globalOpt = this.options[optKey];
198
+ const cmdOpt = this.options[cmd] && this.options[cmd][optKey];
199
+
200
+ if (!globalOpt && !cmdOpt) {
201
+ log.debug(`Environment ${k} not supported by web-ext ${cmd}`);
202
+ delete env[k];
203
+ }
204
+ });
205
+ }
206
+ }
207
+
208
+ async execute({
209
+ checkForUpdates = defaultUpdateChecker,
210
+ systemProcess = process,
211
+ logStream = defaultLogStream,
212
+ getVersion = defaultVersionGetter,
213
+ applyConfigToArgv = defaultApplyConfigToArgv,
214
+ discoverConfigFiles = defaultConfigDiscovery,
215
+ loadJSConfigFile = defaultLoadJSConfigFile,
216
+ shouldExitProgram = true,
217
+ globalEnv = defaultGlobalEnv
218
+ } = {}) {
219
+ this.shouldExitProgram = shouldExitProgram;
220
+ this.yargs.exitProcess(this.shouldExitProgram);
221
+ this.cleanupProcessEnvConfigs(systemProcess);
222
+ const argv = this.getArguments();
223
+ const cmd = argv._[0];
224
+ const version = await getVersion(this.absolutePackageDir);
225
+ const runCommand = this.commands[cmd];
226
+
227
+ if (argv.verbose) {
228
+ this.enableVerboseMode(logStream, version);
229
+ }
230
+
231
+ let adjustedArgv = { ...argv
232
+ };
233
+
234
+ try {
235
+ if (cmd === undefined) {
236
+ throw new UsageError('No sub-command was specified in the args');
237
+ }
238
+
239
+ if (!runCommand) {
240
+ throw new UsageError(`Unknown command: ${cmd}`);
241
+ }
242
+
243
+ if (globalEnv === 'production') {
244
+ checkForUpdates({
245
+ version
246
+ });
247
+ }
248
+
249
+ const configFiles = [];
250
+
251
+ if (argv.configDiscovery) {
252
+ log.debug('Discovering config files. ' + 'Set --no-config-discovery to disable');
253
+ const discoveredConfigs = await discoverConfigFiles();
254
+ configFiles.push(...discoveredConfigs);
255
+ } else {
256
+ log.debug('Not discovering config files');
257
+ }
258
+
259
+ if (argv.config) {
260
+ configFiles.push(path.resolve(argv.config));
261
+ }
262
+
263
+ if (configFiles.length) {
264
+ const niceFileList = configFiles.map(f => f.replace(process.cwd(), '.')).map(f => f.replace(os.homedir(), '~')).join(', ');
265
+ log.info('Applying config file' + `${configFiles.length !== 1 ? 's' : ''}: ` + `${niceFileList}`);
266
+ }
267
+
268
+ configFiles.forEach(configFileName => {
269
+ const configObject = loadJSConfigFile(configFileName);
270
+ adjustedArgv = applyConfigToArgv({
271
+ argv: adjustedArgv,
272
+ argvFromCLI: argv,
273
+ configFileName,
274
+ configObject,
275
+ options: this.options
276
+ });
277
+ });
278
+
279
+ if (adjustedArgv.verbose) {
280
+ // Ensure that the verbose is enabled when specified in a config file.
281
+ this.enableVerboseMode(logStream, version);
282
+ }
283
+
284
+ this.checkRequiredArguments(adjustedArgv);
285
+ await runCommand(adjustedArgv, {
286
+ shouldExitProgram
287
+ });
288
+ } catch (error) {
289
+ if (!(error instanceof UsageError) || adjustedArgv.verbose) {
290
+ log.error(`\n${error.stack}\n`);
291
+ } else {
292
+ log.error(`\n${String(error)}\n`);
293
+ }
294
+
295
+ if (error.code) {
296
+ log.error(`Error code: ${error.code}\n`);
297
+ }
298
+
299
+ log.debug(`Command executed: ${cmd}`);
300
+
301
+ if (this.shouldExitProgram) {
302
+ systemProcess.exit(1);
303
+ } else {
304
+ throw error;
305
+ }
306
+ }
307
+ }
308
+
309
+ } //A defintion of type of argument for defaultVersionGetter
310
+
311
+ export async function defaultVersionGetter(absolutePackageDir, {
312
+ globalEnv = defaultGlobalEnv
313
+ } = {}) {
314
+ if (globalEnv === 'production') {
315
+ log.debug('Getting the version from package.json');
316
+ const packageData = readFileSync(path.join(absolutePackageDir, 'package.json'));
317
+ return JSON.parse(packageData).version;
318
+ } else {
319
+ log.debug('Getting version from the git revision'); // This branch is only reached during development.
320
+ // git-rev-sync is in devDependencies, and lazily imported using require.
321
+ // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916
322
+ // eslint-disable-next-line import/no-extraneous-dependencies
323
+
324
+ const git = await import('git-rev-sync');
325
+ return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;
326
+ }
327
+ } // TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed
328
+
329
+ export function throwUsageErrorIfArray(errorMessage) {
330
+ return value => {
331
+ if (Array.isArray(value)) {
332
+ throw new UsageError(errorMessage);
333
+ }
334
+
335
+ return value;
336
+ };
337
+ }
338
+ export async function main(absolutePackageDir, {
339
+ getVersion = defaultVersionGetter,
340
+ commands = defaultCommands,
341
+ argv,
342
+ runOptions = {}
343
+ } = {}) {
344
+ const program = new Program(argv, {
345
+ absolutePackageDir
346
+ });
347
+ const version = await getVersion(absolutePackageDir); // yargs uses magic camel case expansion to expose options on the
348
+ // final argv object. For example, the 'artifacts-dir' option is alternatively
349
+ // available as argv.artifactsDir.
350
+
351
+ program.yargs.usage(`Usage: $0 [options] command
352
+
353
+ Option values can also be set by declaring an environment variable prefixed
354
+ with $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as
355
+ --source-dir=/path.
356
+
357
+ To view specific help for any given command, add the command name.
358
+ Example: $0 --help run.
359
+ `).help('help').alias('h', 'help').env(envPrefix).version(version).demandCommand(1, 'You must specify a command').strict().recommendCommands();
360
+ program.setGlobalOptions({
361
+ 'source-dir': {
362
+ alias: 's',
363
+ describe: 'Web extension source directory.',
364
+ default: process.cwd(),
365
+ requiresArg: true,
366
+ type: 'string',
367
+ coerce: arg => arg != null ? path.resolve(arg) : undefined
368
+ },
369
+ 'artifacts-dir': {
370
+ alias: 'a',
371
+ describe: 'Directory where artifacts will be saved.',
372
+ default: path.join(process.cwd(), 'web-ext-artifacts'),
373
+ normalize: true,
374
+ requiresArg: true,
375
+ type: 'string'
376
+ },
377
+ 'verbose': {
378
+ alias: 'v',
379
+ describe: 'Show verbose output',
380
+ type: 'boolean',
381
+ demandOption: false
382
+ },
383
+ 'ignore-files': {
384
+ alias: 'i',
385
+ describe: 'A list of glob patterns to define which files should be ' + 'ignored. (Example: --ignore-files=path/to/first.js ' + 'path/to/second.js "**/*.log")',
386
+ demandOption: false,
387
+ // The following option prevents yargs>=11 from parsing multiple values,
388
+ // so the minimum value requirement is enforced in execute instead.
389
+ // Upstream bug: https://github.com/yargs/yargs/issues/1098
390
+ // requiresArg: true,
391
+ type: 'array'
392
+ },
393
+ 'no-input': {
394
+ describe: 'Disable all features that require standard input',
395
+ type: 'boolean',
396
+ demandOption: false
397
+ },
398
+ 'input': {
399
+ // This option is defined to make yargs to accept the --no-input
400
+ // defined above, but we hide it from the yargs help output.
401
+ hidden: true,
402
+ type: 'boolean',
403
+ demandOption: false
404
+ },
405
+ 'config': {
406
+ alias: 'c',
407
+ describe: 'Path to a CommonJS config file to set ' + 'option defaults',
408
+ default: undefined,
409
+ demandOption: false,
410
+ requiresArg: true,
411
+ type: 'string'
412
+ },
413
+ 'config-discovery': {
414
+ describe: 'Discover config files in home directory and ' + 'working directory. Disable with --no-config-discovery.',
415
+ demandOption: false,
416
+ default: true,
417
+ type: 'boolean'
418
+ }
419
+ });
420
+ program.command('build', 'Create an extension package from source', commands.build, {
421
+ 'as-needed': {
422
+ describe: 'Watch for file changes and re-build as needed',
423
+ type: 'boolean'
424
+ },
425
+ 'filename': {
426
+ alias: 'n',
427
+ describe: 'Name of the created extension package file.',
428
+ default: undefined,
429
+ normalize: false,
430
+ demandOption: false,
431
+ requiresArg: true,
432
+ type: 'string',
433
+ coerce: arg => arg == null ? undefined : throwUsageErrorIfArray('Multiple --filename/-n option are not allowed')(arg)
434
+ },
435
+ 'overwrite-dest': {
436
+ alias: 'o',
437
+ describe: 'Overwrite destination package if it exists.',
438
+ type: 'boolean'
439
+ }
440
+ }).command('sign', 'Sign the extension so it can be installed in Firefox', commands.sign, {
441
+ 'api-key': {
442
+ describe: 'API key (JWT issuer) from addons.mozilla.org',
443
+ demandOption: true,
444
+ type: 'string'
445
+ },
446
+ 'api-secret': {
447
+ describe: 'API secret (JWT secret) from addons.mozilla.org',
448
+ demandOption: true,
449
+ type: 'string'
450
+ },
451
+ 'api-url-prefix': {
452
+ describe: 'Signing API URL prefix',
453
+ default: 'https://addons.mozilla.org/api/v4',
454
+ demandOption: true,
455
+ type: 'string'
456
+ },
457
+ 'api-proxy': {
458
+ describe: 'Use a proxy to access the signing API. ' + 'Example: https://yourproxy:6000 ',
459
+ demandOption: false,
460
+ type: 'string'
461
+ },
462
+ 'id': {
463
+ describe: 'A custom ID for the extension. This has no effect if the ' + 'extension already declares an explicit ID in its manifest.',
464
+ demandOption: false,
465
+ type: 'string'
466
+ },
467
+ 'timeout': {
468
+ describe: 'Number of milliseconds to wait before giving up',
469
+ type: 'number'
470
+ },
471
+ 'channel': {
472
+ describe: 'The channel for which to sign the addon. Either ' + '\'listed\' or \'unlisted\'',
473
+ type: 'string'
474
+ }
475
+ }).command('run', 'Run the extension', commands.run, {
476
+ 'target': {
477
+ alias: 't',
478
+ describe: 'The extensions runners to enable. Specify this option ' + 'multiple times to run against multiple targets.',
479
+ default: 'firefox-desktop',
480
+ demandOption: false,
481
+ type: 'array',
482
+ choices: ['firefox-desktop', 'firefox-android', 'chromium']
483
+ },
484
+ 'firefox': {
485
+ alias: ['f', 'firefox-binary'],
486
+ describe: 'Path or alias to a Firefox executable such as firefox-bin ' + 'or firefox.exe. ' + 'If not specified, the default Firefox will be used. ' + 'You can specify the following aliases in lieu of a path: ' + 'firefox, beta, nightly, firefoxdeveloperedition.',
487
+ demandOption: false,
488
+ type: 'string'
489
+ },
490
+ 'firefox-profile': {
491
+ alias: 'p',
492
+ describe: 'Run Firefox using a copy of this profile. The profile ' + 'can be specified as a directory or a name, such as one ' + 'you would see in the Profile Manager. If not specified, ' + 'a new temporary profile will be created.',
493
+ demandOption: false,
494
+ type: 'string'
495
+ },
496
+ 'chromium-binary': {
497
+ describe: 'Path or alias to a Chromium executable such as ' + 'google-chrome, google-chrome.exe or opera.exe etc. ' + 'If not specified, the default Google Chrome will be used.',
498
+ demandOption: false,
499
+ type: 'string'
500
+ },
501
+ 'chromium-profile': {
502
+ describe: 'Path to a custom Chromium profile',
503
+ demandOption: false,
504
+ type: 'string'
505
+ },
506
+ 'profile-create-if-missing': {
507
+ describe: 'Create the profile directory if it does not already exist',
508
+ demandOption: false,
509
+ type: 'boolean'
510
+ },
511
+ 'keep-profile-changes': {
512
+ describe: 'Run Firefox directly in custom profile. Any changes to ' + 'the profile will be saved.',
513
+ demandOption: false,
514
+ type: 'boolean'
515
+ },
516
+ 'reload': {
517
+ describe: 'Reload the extension when source files change.' + 'Disable with --no-reload.',
518
+ demandOption: false,
519
+ default: true,
520
+ type: 'boolean'
521
+ },
522
+ 'watch-file': {
523
+ alias: ['watch-files'],
524
+ describe: 'Reload the extension only when the contents of this' + ' file changes. This is useful if you use a custom' + ' build process for your extension',
525
+ demandOption: false,
526
+ type: 'array'
527
+ },
528
+ 'watch-ignored': {
529
+ describe: 'Paths and globs patterns that should not be ' + 'watched for changes. This is useful if you want ' + 'to explicitly prevent web-ext from watching part ' + 'of the extension directory tree, ' + 'e.g. the node_modules folder.',
530
+ demandOption: false,
531
+ type: 'array'
532
+ },
533
+ 'pre-install': {
534
+ describe: 'Pre-install the extension into the profile before ' + 'startup. This is only needed to support older versions ' + 'of Firefox.',
535
+ demandOption: false,
536
+ type: 'boolean'
537
+ },
538
+ 'pref': {
539
+ describe: 'Launch firefox with a custom preference ' + '(example: --pref=general.useragent.locale=fr-FR). ' + 'You can repeat this option to set more than one ' + 'preference.',
540
+ demandOption: false,
541
+ requiresArg: true,
542
+ type: 'array',
543
+ coerce: arg => arg != null ? coerceCLICustomPreference(arg) : undefined
544
+ },
545
+ 'start-url': {
546
+ alias: ['u', 'url'],
547
+ describe: 'Launch firefox at specified page',
548
+ demandOption: false,
549
+ type: 'array'
550
+ },
551
+ 'browser-console': {
552
+ alias: ['bc'],
553
+ describe: 'Open the DevTools Browser Console.',
554
+ demandOption: false,
555
+ type: 'boolean'
556
+ },
557
+ 'args': {
558
+ alias: ['arg'],
559
+ describe: 'Additional CLI options passed to the Browser binary',
560
+ demandOption: false,
561
+ type: 'array'
562
+ },
563
+ 'firefox-preview': {
564
+ describe: 'Turn on developer preview features in Firefox',
565
+ demandOption: false,
566
+ default: ['mv3'],
567
+ type: 'array'
568
+ },
569
+ // Firefox for Android CLI options.
570
+ 'adb-bin': {
571
+ describe: 'Specify a custom path to the adb binary',
572
+ demandOption: false,
573
+ type: 'string',
574
+ requiresArg: true
575
+ },
576
+ 'adb-host': {
577
+ describe: 'Connect to adb on the specified host',
578
+ demandOption: false,
579
+ type: 'string',
580
+ requiresArg: true
581
+ },
582
+ 'adb-port': {
583
+ describe: 'Connect to adb on the specified port',
584
+ demandOption: false,
585
+ type: 'string',
586
+ requiresArg: true
587
+ },
588
+ 'adb-device': {
589
+ alias: ['android-device'],
590
+ describe: 'Connect to the specified adb device name',
591
+ demandOption: false,
592
+ type: 'string',
593
+ requiresArg: true
594
+ },
595
+ 'adb-discovery-timeout': {
596
+ describe: 'Number of milliseconds to wait before giving up',
597
+ demandOption: false,
598
+ type: 'number',
599
+ requiresArg: true
600
+ },
601
+ 'adb-remove-old-artifacts': {
602
+ describe: 'Remove old artifacts directories from the adb device',
603
+ demandOption: false,
604
+ type: 'boolean'
605
+ },
606
+ 'firefox-apk': {
607
+ describe: 'Run a specific Firefox for Android APK. ' + 'Example: org.mozilla.fennec_aurora',
608
+ demandOption: false,
609
+ type: 'string',
610
+ requiresArg: true
611
+ },
612
+ 'firefox-apk-component': {
613
+ describe: 'Run a specific Android Component (defaults to <firefox-apk>/.App)',
614
+ demandOption: false,
615
+ type: 'string',
616
+ requiresArg: true
617
+ }
618
+ }).command('lint', 'Validate the extension source', commands.lint, {
619
+ 'output': {
620
+ alias: 'o',
621
+ describe: 'The type of output to generate',
622
+ type: 'string',
623
+ default: 'text',
624
+ choices: ['json', 'text']
625
+ },
626
+ 'metadata': {
627
+ describe: 'Output only metadata as JSON',
628
+ type: 'boolean',
629
+ default: false
630
+ },
631
+ 'warnings-as-errors': {
632
+ describe: 'Treat warnings as errors by exiting non-zero for warnings',
633
+ alias: 'w',
634
+ type: 'boolean',
635
+ default: false
636
+ },
637
+ 'pretty': {
638
+ describe: 'Prettify JSON output',
639
+ type: 'boolean',
640
+ default: false
641
+ },
642
+ 'privileged': {
643
+ describe: 'Treat your extension as a privileged extension',
644
+ type: 'boolean',
645
+ default: false
646
+ },
647
+ 'self-hosted': {
648
+ describe: 'Your extension will be self-hosted. This disables messages ' + 'related to hosting on addons.mozilla.org.',
649
+ type: 'boolean',
650
+ default: false
651
+ },
652
+ 'boring': {
653
+ describe: 'Disables colorful shell output',
654
+ type: 'boolean',
655
+ default: false
656
+ }
657
+ }).command('docs', 'Open the web-ext documentation in a browser', commands.docs, {});
658
+ return program.execute({
659
+ getVersion,
660
+ ...runOptions
661
+ });
662
+ }
663
+ //# sourceMappingURL=program.js.map