web-ext 7.3.1 → 7.5.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 (71) hide show
  1. package/README.md +43 -37
  2. package/index.js +1 -1
  3. package/lib/cmd/build.js +0 -1
  4. package/lib/cmd/build.js.map +1 -1
  5. package/lib/cmd/docs.js +0 -1
  6. package/lib/cmd/docs.js.map +1 -1
  7. package/lib/cmd/index.js +0 -3
  8. package/lib/cmd/index.js.map +1 -1
  9. package/lib/cmd/lint.js +2 -3
  10. package/lib/cmd/lint.js.map +1 -1
  11. package/lib/cmd/run.js +1 -2
  12. package/lib/cmd/run.js.map +1 -1
  13. package/lib/cmd/sign.js +11 -4
  14. package/lib/cmd/sign.js.map +1 -1
  15. package/lib/config.js +0 -1
  16. package/lib/config.js.map +1 -1
  17. package/lib/errors.js +0 -1
  18. package/lib/errors.js.map +1 -1
  19. package/lib/extension-runners/base.js +0 -2
  20. package/lib/extension-runners/base.js.map +1 -1
  21. package/lib/extension-runners/chromium.js +0 -3
  22. package/lib/extension-runners/chromium.js.map +1 -1
  23. package/lib/extension-runners/firefox-android.js +0 -3
  24. package/lib/extension-runners/firefox-android.js.map +1 -1
  25. package/lib/extension-runners/firefox-desktop.js +0 -4
  26. package/lib/extension-runners/firefox-desktop.js.map +1 -1
  27. package/lib/extension-runners/index.js +0 -2
  28. package/lib/extension-runners/index.js.map +1 -1
  29. package/lib/firefox/index.js +6 -7
  30. package/lib/firefox/index.js.map +1 -1
  31. package/lib/firefox/package-identifiers.js +0 -2
  32. package/lib/firefox/package-identifiers.js.map +1 -1
  33. package/lib/firefox/preferences.js +0 -1
  34. package/lib/firefox/preferences.js.map +1 -1
  35. package/lib/firefox/rdp-client.js +0 -1
  36. package/lib/firefox/rdp-client.js.map +1 -1
  37. package/lib/firefox/remote.js +0 -1
  38. package/lib/firefox/remote.js.map +1 -1
  39. package/lib/main.js +0 -1
  40. package/lib/main.js.map +1 -1
  41. package/lib/program.js +25 -22
  42. package/lib/program.js.map +1 -1
  43. package/lib/util/adb.js +0 -1
  44. package/lib/util/adb.js.map +1 -1
  45. package/lib/util/artifacts.js +0 -1
  46. package/lib/util/artifacts.js.map +1 -1
  47. package/lib/util/desktop-notifier.js +0 -1
  48. package/lib/util/desktop-notifier.js.map +1 -1
  49. package/lib/util/file-exists.js +0 -1
  50. package/lib/util/file-exists.js.map +1 -1
  51. package/lib/util/file-filter.js +0 -1
  52. package/lib/util/file-filter.js.map +1 -1
  53. package/lib/util/is-directory.js +0 -1
  54. package/lib/util/is-directory.js.map +1 -1
  55. package/lib/util/logger.js +0 -1
  56. package/lib/util/logger.js.map +1 -1
  57. package/lib/util/manifest.js +0 -1
  58. package/lib/util/manifest.js.map +1 -1
  59. package/lib/util/promisify.js +0 -2
  60. package/lib/util/promisify.js.map +1 -1
  61. package/lib/util/stdin.js +0 -2
  62. package/lib/util/stdin.js.map +1 -1
  63. package/lib/util/submit-addon.js +12 -4
  64. package/lib/util/submit-addon.js.map +1 -1
  65. package/lib/util/temp-dir.js +0 -1
  66. package/lib/util/temp-dir.js.map +1 -1
  67. package/lib/util/updates.js +0 -1
  68. package/lib/util/updates.js.map +1 -1
  69. package/lib/watcher.js +0 -1
  70. package/lib/watcher.js.map +1 -1
  71. package/package.json +28 -23
package/lib/program.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  import os from 'os';
3
2
  import path from 'path';
4
3
  import { readFileSync } from 'fs';
@@ -17,6 +16,8 @@ const envPrefix = 'WEB_EXT';
17
16
  // Default to "development" (the value actually assigned will be interpolated
18
17
  // by babel-plugin-transform-inline-environment-variables).
19
18
  const defaultGlobalEnv = "production" || 'development';
19
+ export const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';
20
+
20
21
  /*
21
22
  * The command line program.
22
23
  */
@@ -216,7 +217,8 @@ export class Program {
216
217
  this.enableVerboseMode(logStream, version);
217
218
  }
218
219
  let adjustedArgv = {
219
- ...argv
220
+ ...argv,
221
+ webextVersion: version
220
222
  };
221
223
  try {
222
224
  if (cmd === undefined) {
@@ -360,7 +362,7 @@ Example: $0 --help run.
360
362
  requiresArg: true,
361
363
  type: 'string'
362
364
  },
363
- 'verbose': {
365
+ verbose: {
364
366
  alias: 'v',
365
367
  describe: 'Show verbose output',
366
368
  type: 'boolean',
@@ -381,14 +383,14 @@ Example: $0 --help run.
381
383
  type: 'boolean',
382
384
  demandOption: false
383
385
  },
384
- 'input': {
386
+ input: {
385
387
  // This option is defined to make yargs to accept the --no-input
386
388
  // defined above, but we hide it from the yargs help output.
387
389
  hidden: true,
388
390
  type: 'boolean',
389
391
  demandOption: false
390
392
  },
391
- 'config': {
393
+ config: {
392
394
  alias: 'c',
393
395
  describe: 'Path to a CommonJS config file to set ' + 'option defaults',
394
396
  default: undefined,
@@ -408,7 +410,7 @@ Example: $0 --help run.
408
410
  describe: 'Watch for file changes and re-build as needed',
409
411
  type: 'boolean'
410
412
  },
411
- 'filename': {
413
+ filename: {
412
414
  alias: 'n',
413
415
  describe: 'Name of the created extension package file.',
414
416
  default: undefined,
@@ -426,7 +428,7 @@ Example: $0 --help run.
426
428
  }).command('sign', 'Sign the extension so it can be installed in Firefox', commands.sign, {
427
429
  'amo-base-url': {
428
430
  describe: 'Signing API URL prefix - only used with `use-submission-api`',
429
- default: 'https://addons.mozilla.org/api/v5',
431
+ default: AMO_BASE_URL,
430
432
  demandOption: true,
431
433
  type: 'string'
432
434
  },
@@ -456,24 +458,25 @@ Example: $0 --help run.
456
458
  demandOption: false,
457
459
  type: 'boolean'
458
460
  },
459
- 'id': {
461
+ id: {
460
462
  describe: 'A custom ID for the extension. This has no effect if the ' + 'extension already declares an explicit ID in its manifest.',
461
463
  demandOption: false,
462
464
  type: 'string'
463
465
  },
464
- 'timeout': {
466
+ timeout: {
465
467
  describe: 'Number of milliseconds to wait before giving up',
466
468
  type: 'number'
467
469
  },
468
- 'channel': {
469
- describe: 'The channel for which to sign the addon. Either ' + '\'listed\' or \'unlisted\''
470
+ channel: {
471
+ describe: 'The channel for which to sign the addon. Either ' + "'listed' or 'unlisted'",
472
+ type: 'string'
470
473
  },
471
474
  'amo-metadata': {
472
475
  describe: 'Path to a JSON file containing an object with metadata ' + 'to be passed to the API. ' + 'See https://addons-server.readthedocs.io' + '/en/latest/topics/api/addons.html for details. ' + 'Only used with `use-submission-api`',
473
476
  type: 'string'
474
477
  }
475
478
  }).command('run', 'Run the extension', commands.run, {
476
- 'target': {
479
+ target: {
477
480
  alias: 't',
478
481
  describe: 'The extensions runners to enable. Specify this option ' + 'multiple times to run against multiple targets.',
479
482
  default: 'firefox-desktop',
@@ -481,7 +484,7 @@ Example: $0 --help run.
481
484
  type: 'array',
482
485
  choices: ['firefox-desktop', 'firefox-android', 'chromium']
483
486
  },
484
- 'firefox': {
487
+ firefox: {
485
488
  alias: ['f', 'firefox-binary'],
486
489
  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. ' + 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' + '`org.mozilla.firefox` is the application ID.',
487
490
  demandOption: false,
@@ -513,7 +516,7 @@ Example: $0 --help run.
513
516
  demandOption: false,
514
517
  type: 'boolean'
515
518
  },
516
- 'reload': {
519
+ reload: {
517
520
  describe: 'Reload the extension when source files change.' + 'Disable with --no-reload.',
518
521
  demandOption: false,
519
522
  default: true,
@@ -535,7 +538,7 @@ Example: $0 --help run.
535
538
  demandOption: false,
536
539
  type: 'boolean'
537
540
  },
538
- 'pref': {
541
+ pref: {
539
542
  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
543
  demandOption: false,
541
544
  requiresArg: true,
@@ -548,7 +551,7 @@ Example: $0 --help run.
548
551
  demandOption: false,
549
552
  type: 'array'
550
553
  },
551
- 'devtools': {
554
+ devtools: {
552
555
  describe: 'Open the DevTools for the installed add-on ' + '(Firefox 106 and later)',
553
556
  demandOption: false,
554
557
  type: 'boolean'
@@ -559,7 +562,7 @@ Example: $0 --help run.
559
562
  demandOption: false,
560
563
  type: 'boolean'
561
564
  },
562
- 'args': {
565
+ args: {
563
566
  alias: ['arg'],
564
567
  describe: 'Additional CLI options passed to the Browser binary',
565
568
  demandOption: false,
@@ -616,14 +619,14 @@ Example: $0 --help run.
616
619
  requiresArg: true
617
620
  }
618
621
  }).command('lint', 'Validate the extension source', commands.lint, {
619
- 'output': {
622
+ output: {
620
623
  alias: 'o',
621
624
  describe: 'The type of output to generate',
622
625
  type: 'string',
623
626
  default: 'text',
624
627
  choices: ['json', 'text']
625
628
  },
626
- 'metadata': {
629
+ metadata: {
627
630
  describe: 'Output only metadata as JSON',
628
631
  type: 'boolean',
629
632
  default: false
@@ -634,12 +637,12 @@ Example: $0 --help run.
634
637
  type: 'boolean',
635
638
  default: false
636
639
  },
637
- 'pretty': {
640
+ pretty: {
638
641
  describe: 'Prettify JSON output',
639
642
  type: 'boolean',
640
643
  default: false
641
644
  },
642
- 'privileged': {
645
+ privileged: {
643
646
  describe: 'Treat your extension as a privileged extension',
644
647
  type: 'boolean',
645
648
  default: false
@@ -649,7 +652,7 @@ Example: $0 --help run.
649
652
  type: 'boolean',
650
653
  default: false
651
654
  },
652
- 'boring': {
655
+ boring: {
653
656
  describe: 'Disables colorful shell output',
654
657
  type: 'boolean',
655
658
  default: false
@@ -1 +1 @@
1
- {"version":3,"file":"program.js","names":["os","path","readFileSync","camelCase","decamelize","yargs","Parser","yargsParser","defaultCommands","UsageError","createLogger","consoleStream","defaultLogStream","coerceCLICustomPreference","checkForUpdates","defaultUpdateChecker","discoverConfigFiles","defaultConfigDiscovery","loadJSConfigFile","defaultLoadJSConfigFile","applyConfigToArgv","defaultApplyConfigToArgv","log","import","meta","url","envPrefix","defaultGlobalEnv","Program","constructor","argv","absolutePackageDir","process","cwd","slice","programArgv","yargsInstance","verboseEnabled","shouldExitProgram","parserConfiguration","strict","wrap","terminalWidth","commands","options","command","name","description","executor","commandOptions","yargsForCmd","demandCommand","undefined","exitProcess","env","setGlobalOptions","Object","keys","forEach","key","global","demandOption","enableVerboseMode","logStream","version","makeVerbose","info","getArguments","validationInstance","getInternalMethods","getValidationInstance","requiredArguments","demandedOptions","getDemandedOptions","args","err","message","startsWith","configDiscovery","noConfigDiscovery","reload","noReload","input","noInput","ignoreFiles","length","startUrl","Array","isArray","firefoxPreview","checkRequiredArguments","adjustedArgv","cleanupProcessEnvConfigs","systemProcess","cmd","_","toOptionKey","k","replace","separator","filter","optKey","globalOpt","cmdOpt","debug","execute","getVersion","defaultVersionGetter","globalEnv","runCommand","verbose","configFiles","discoveredConfigs","push","config","resolve","niceFileList","map","f","homedir","join","configFileName","configObject","argvFromCLI","error","stack","String","code","exit","packageData","JSON","parse","git","branch","long","throwUsageErrorIfArray","errorMessage","value","main","runOptions","program","firefoxPreviewOption","describe","type","usage","help","alias","recommendCommands","default","requiresArg","coerce","arg","normalize","hidden","build","sign","run","choices","lint","docs"],"sources":["../src/program.js"],"sourcesContent":["/* @flow */\nimport os from 'os';\nimport path from 'path';\nimport {readFileSync} from 'fs';\n\nimport camelCase from 'camelcase';\nimport decamelize from 'decamelize';\nimport yargs from 'yargs';\nimport { Parser as yargsParser } from 'yargs/helpers';\n\nimport defaultCommands from './cmd/index.js';\nimport {UsageError} from './errors.js';\nimport {\n createLogger,\n consoleStream as defaultLogStream,\n} from './util/logger.js';\nimport {coerceCLICustomPreference} from './firefox/preferences.js';\nimport {checkForUpdates as defaultUpdateChecker} from './util/updates.js';\nimport {\n discoverConfigFiles as defaultConfigDiscovery,\n loadJSConfigFile as defaultLoadJSConfigFile,\n applyConfigToArgv as defaultApplyConfigToArgv,\n} from './config.js';\n\nconst log = createLogger(import.meta.url);\nconst envPrefix = 'WEB_EXT';\n// Default to \"development\" (the value actually assigned will be interpolated\n// by babel-plugin-transform-inline-environment-variables).\nconst defaultGlobalEnv = process.env.WEBEXT_BUILD_ENV || 'development';\n\n\ntype ProgramOptions = {\n absolutePackageDir?: string,\n}\n\nexport type VersionGetterFn = (absolutePackageDir: string) => Promise<string>;\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype ExecuteOptions = {\n checkForUpdates?: Function,\n systemProcess?: typeof process,\n logStream?: typeof defaultLogStream,\n getVersion?: VersionGetterFn,\n applyConfigToArgv?: typeof defaultApplyConfigToArgv,\n discoverConfigFiles?: typeof defaultConfigDiscovery,\n loadJSConfigFile?: typeof defaultLoadJSConfigFile,\n shouldExitProgram?: boolean,\n globalEnv?: string | void,\n}\n\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir: string;\n yargs: any;\n commands: { [key: string]: Function };\n shouldExitProgram: boolean;\n verboseEnabled: boolean;\n options: Object;\n programArgv: Array<string>;\n demandedOptions: Object;\n\n constructor(\n argv: ?Array<string>,\n {\n absolutePackageDir = process.cwd(),\n }: ProgramOptions = {}\n ) {\n // This allows us to override the process argv which is useful for\n // testing.\n // NOTE: process.argv.slice(2) removes the path to node and web-ext\n // executables from the process.argv array.\n argv = argv || process.argv.slice(2);\n this.programArgv = argv;\n\n // NOTE: always initialize yargs explicitly with the package dir\n // to avoid side-effects due to yargs looking for its configuration\n // section from a package.json file stored in an arbitrary directory\n // (e.g. in tests yargs would end up loading yargs config from the\n // mocha package.json). web-ext package.json doesn't contain any yargs\n // section as it is deprecated and we configure yargs using\n // yargs.parserConfiguration. See web-ext#469 for rationale.\n const yargsInstance = yargs(argv, absolutePackageDir);\n\n this.absolutePackageDir = absolutePackageDir;\n this.verboseEnabled = false;\n this.shouldExitProgram = true;\n\n this.yargs = yargsInstance;\n this.yargs.parserConfiguration({\n 'boolean-negation': true,\n });\n this.yargs.strict();\n this.yargs.wrap(this.yargs.terminalWidth());\n\n this.commands = {};\n this.options = {};\n }\n\n command(\n name: string, description: string, executor: Function,\n commandOptions: Object = {}\n ): Program {\n this.options[camelCase(name)] = commandOptions;\n\n this.yargs.command(name, description, (yargsForCmd) => {\n if (!commandOptions) {\n return;\n }\n return yargsForCmd\n // Make sure the user does not add any extra commands. For example,\n // this would be a mistake because lint does not accept arguments:\n // web-ext lint ./src/path/to/file.js\n .demandCommand(0, 0, undefined,\n 'This command does not take any arguments')\n .strict()\n .exitProcess(this.shouldExitProgram)\n // Calling env() will be unnecessary after\n // https://github.com/yargs/yargs/issues/486 is fixed\n .env(envPrefix)\n .options(commandOptions);\n });\n this.commands[name] = executor;\n return this;\n }\n\n setGlobalOptions(options: Object): Program {\n // This is a convenience for setting global options.\n // An option is only global (i.e. available to all sub commands)\n // with the `global` flag so this makes sure every option has it.\n this.options = {...this.options, ...options};\n Object.keys(options).forEach((key) => {\n options[key].global = true;\n if (options[key].demandOption === undefined) {\n // By default, all options should be \"demanded\" otherwise\n // yargs.strict() will think they are missing when declared.\n options[key].demandOption = true;\n }\n });\n this.yargs.options(options);\n return this;\n }\n\n enableVerboseMode(\n logStream: typeof defaultLogStream,\n version: string\n ): void {\n if (this.verboseEnabled) {\n return;\n }\n\n logStream.makeVerbose();\n log.info('Version:', version);\n this.verboseEnabled = true;\n }\n\n // Retrieve the yargs argv object and apply any further fix needed\n // on the output of the yargs options parsing.\n getArguments(): Object {\n // To support looking up required parameters via config files, we need to\n // temporarily disable the requiredArguments validation. Otherwise yargs\n // would exit early. Validation is enforced by the checkRequiredArguments()\n // method, after reading configuration files.\n //\n // This is an undocumented internal API of yargs! Unit tests to avoid\n // regressions are located at: tests/functional/test.cli.sign.js\n //\n // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930\n const validationInstance =\n this.yargs.getInternalMethods().getValidationInstance();\n const { requiredArguments } = validationInstance;\n // Initialize demandedOptions (which is going to be set to an object with one\n // property for each mandatory global options, then the arrow function below\n // will receive as its demandedOptions parameter a new one that also includes\n // all mandatory options for the sub command selected).\n this.demandedOptions = this.yargs.getDemandedOptions();\n validationInstance.requiredArguments = (args, demandedOptions) => {\n this.demandedOptions = demandedOptions;\n };\n let argv;\n try {\n argv = this.yargs.argv;\n } catch (err) {\n if (err.name === 'YError' &&\n err.message.startsWith('Unknown argument: ')) {\n throw new UsageError(err.message);\n }\n throw err;\n }\n validationInstance.requiredArguments = requiredArguments;\n\n // Yargs boolean options doesn't define the no* counterpart\n // with negate-boolean on Yargs 15. Define as expected by the\n // web-ext execute method.\n if (argv.configDiscovery != null) {\n argv.noConfigDiscovery = !argv.configDiscovery;\n }\n if (argv.reload != null) {\n argv.noReload = !argv.reload;\n }\n\n // Yargs doesn't accept --no-input as a valid option if there isn't a\n // --input option defined to be negated, to fix that the --input is\n // defined and hidden from the yargs help output and we define here\n // the negated argument name that we expect to be set in the parsed\n // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).\n if (argv.input != null) {\n argv.noInput = !argv.input;\n }\n\n // Replacement for the \"requiresArg: true\" parameter until the following bug\n // is fixed: https://github.com/yargs/yargs/issues/1098\n if (argv.ignoreFiles && !argv.ignoreFiles.length) {\n throw new UsageError('Not enough arguments following: ignore-files');\n }\n\n if (argv.startUrl && !argv.startUrl.length) {\n throw new UsageError('Not enough arguments following: start-url');\n }\n\n if (Array.isArray(argv.firefoxPreview) && !argv.firefoxPreview.length) {\n argv.firefoxPreview = ['mv3'];\n }\n\n return argv;\n }\n\n // getArguments() disables validation of required parameters, to allow us to\n // read parameters from config files first. Before the program continues, it\n // must call checkRequiredArguments() to ensure that required parameters are\n // defined (in the CLI or in a config file).\n checkRequiredArguments(adjustedArgv: Object): void {\n const validationInstance =\n this.yargs.getInternalMethods().getValidationInstance();\n validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);\n }\n\n // Remove WEB_EXT_* environment vars that are not a global cli options\n // or an option supported by the current command (See #793).\n cleanupProcessEnvConfigs(systemProcess: typeof process) {\n const cmd = yargsParser(this.programArgv)._[0];\n const env = systemProcess.env || {};\n const toOptionKey = (k) => decamelize(\n camelCase(k.replace(envPrefix, '')), {separator: '-'}\n );\n\n if (cmd) {\n Object.keys(env)\n .filter((k) => k.startsWith(envPrefix))\n .forEach((k) => {\n const optKey = toOptionKey(k);\n const globalOpt = this.options[optKey];\n const cmdOpt = this.options[cmd] && this.options[cmd][optKey];\n\n if (!globalOpt && !cmdOpt) {\n log.debug(`Environment ${k} not supported by web-ext ${cmd}`);\n delete env[k];\n }\n });\n }\n }\n\n async execute(\n {\n checkForUpdates = defaultUpdateChecker,\n systemProcess = process,\n logStream = defaultLogStream,\n getVersion = defaultVersionGetter,\n applyConfigToArgv = defaultApplyConfigToArgv,\n discoverConfigFiles = defaultConfigDiscovery,\n loadJSConfigFile = defaultLoadJSConfigFile,\n shouldExitProgram = true,\n globalEnv = defaultGlobalEnv,\n }: ExecuteOptions = {}\n ): Promise<void> {\n this.shouldExitProgram = shouldExitProgram;\n this.yargs.exitProcess(this.shouldExitProgram);\n\n this.cleanupProcessEnvConfigs(systemProcess);\n const argv = this.getArguments();\n\n const cmd = argv._[0];\n\n const version = await getVersion(this.absolutePackageDir);\n const runCommand = this.commands[cmd];\n\n if (argv.verbose) {\n this.enableVerboseMode(logStream, version);\n }\n\n let adjustedArgv = {...argv};\n\n try {\n if (cmd === undefined) {\n throw new UsageError('No sub-command was specified in the args');\n }\n if (!runCommand) {\n throw new UsageError(`Unknown command: ${cmd}`);\n }\n if (globalEnv === 'production') {\n checkForUpdates({version});\n }\n\n const configFiles = [];\n\n if (argv.configDiscovery) {\n log.debug(\n 'Discovering config files. ' +\n 'Set --no-config-discovery to disable');\n const discoveredConfigs = await discoverConfigFiles();\n configFiles.push(...discoveredConfigs);\n } else {\n log.debug('Not discovering config files');\n }\n\n if (argv.config) {\n configFiles.push(path.resolve(argv.config));\n }\n\n if (configFiles.length) {\n const niceFileList = configFiles\n .map((f) => f.replace(process.cwd(), '.'))\n .map((f) => f.replace(os.homedir(), '~'))\n .join(', ');\n log.info(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`);\n }\n\n configFiles.forEach((configFileName) => {\n const configObject = loadJSConfigFile(configFileName);\n adjustedArgv = applyConfigToArgv({\n argv: adjustedArgv,\n argvFromCLI: argv,\n configFileName,\n configObject,\n options: this.options,\n });\n });\n\n if (adjustedArgv.verbose) {\n // Ensure that the verbose is enabled when specified in a config file.\n this.enableVerboseMode(logStream, version);\n }\n\n this.checkRequiredArguments(adjustedArgv);\n\n await runCommand(adjustedArgv, {shouldExitProgram});\n\n } catch (error) {\n if (!(error instanceof UsageError) || adjustedArgv.verbose) {\n log.error(`\\n${error.stack}\\n`);\n } else {\n log.error(`\\n${String(error)}\\n`);\n }\n if (error.code) {\n log.error(`Error code: ${error.code}\\n`);\n }\n\n log.debug(`Command executed: ${cmd}`);\n\n if (this.shouldExitProgram) {\n systemProcess.exit(1);\n } else {\n throw error;\n }\n }\n }\n}\n\n//A defintion of type of argument for defaultVersionGetter\ntype VersionGetterOptions = {\n globalEnv?: string,\n};\n\nexport async function defaultVersionGetter(\n absolutePackageDir: string,\n {globalEnv = defaultGlobalEnv}: VersionGetterOptions = {}\n): Promise<string> {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData: any = readFileSync(\n path.join(absolutePackageDir, 'package.json'));\n return JSON.parse(packageData).version;\n } else {\n log.debug('Getting version from the git revision');\n // This branch is only reached during development.\n // git-rev-sync is in devDependencies, and lazily imported using require.\n // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916\n // eslint-disable-next-line import/no-extraneous-dependencies\n const git = await import('git-rev-sync');\n return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;\n }\n}\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype MainParams = {\n getVersion?: VersionGetterFn,\n commands?: Object,\n argv: Array<any>,\n runOptions?: Object,\n}\n\nexport function throwUsageErrorIfArray(errorMessage: string): any {\n return (value: any): any => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir: string,\n {\n getVersion = defaultVersionGetter, commands = defaultCommands, argv,\n runOptions = {},\n }: MainParams = {}\n): Promise<any> {\n const program = new Program(argv, {absolutePackageDir});\n const version = await getVersion(absolutePackageDir);\n\n // This is an option shared by some commands but not all of them, hence why\n // it isn't a global option.\n const firefoxPreviewOption = {\n describe: 'Turn on developer preview features in Firefox' +\n ' (defaults to \"mv3\")',\n demandOption: false,\n type: 'array',\n };\n\n // yargs uses magic camel case expansion to expose options on the\n // final argv object. For example, the 'artifacts-dir' option is alternatively\n // available as argv.artifactsDir.\n program.yargs\n .usage(`Usage: $0 [options] command\n\nOption values can also be set by declaring an environment variable prefixed\nwith $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as\n--source-dir=/path.\n\nTo view specific help for any given command, add the command name.\nExample: $0 --help run.\n`)\n .help('help')\n .alias('h', 'help')\n .env(envPrefix)\n .version(version)\n .demandCommand(1, 'You must specify a command')\n .strict()\n .recommendCommands();\n\n program.setGlobalOptions({\n 'source-dir': {\n alias: 's',\n describe: 'Web extension source directory.',\n default: process.cwd(),\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg != null ? path.resolve(arg) : undefined,\n },\n 'artifacts-dir': {\n alias: 'a',\n describe: 'Directory where artifacts will be saved.',\n default: path.join(process.cwd(), 'web-ext-artifacts'),\n normalize: true,\n requiresArg: true,\n type: 'string',\n },\n 'verbose': {\n alias: 'v',\n describe: 'Show verbose output',\n type: 'boolean',\n demandOption: false,\n },\n 'ignore-files': {\n alias: 'i',\n describe: 'A list of glob patterns to define which files should be ' +\n 'ignored. (Example: --ignore-files=path/to/first.js ' +\n 'path/to/second.js \"**/*.log\")',\n demandOption: false,\n // The following option prevents yargs>=11 from parsing multiple values,\n // so the minimum value requirement is enforced in execute instead.\n // Upstream bug: https://github.com/yargs/yargs/issues/1098\n // requiresArg: true,\n type: 'array',\n },\n 'no-input': {\n describe: 'Disable all features that require standard input',\n type: 'boolean',\n demandOption: false,\n },\n 'input': {\n // This option is defined to make yargs to accept the --no-input\n // defined above, but we hide it from the yargs help output.\n hidden: true,\n type: 'boolean',\n demandOption: false,\n },\n 'config': {\n alias: 'c',\n describe: 'Path to a CommonJS config file to set ' +\n 'option defaults',\n default: undefined,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n },\n 'config-discovery': {\n describe: 'Discover config files in home directory and ' +\n 'working directory. Disable with --no-config-discovery.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n });\n\n program\n .command(\n 'build',\n 'Create an extension package from source',\n commands.build, {\n 'as-needed': {\n describe: 'Watch for file changes and re-build as needed',\n type: 'boolean',\n },\n 'filename': {\n alias: 'n',\n describe: 'Name of the created extension package file.',\n default: undefined,\n normalize: false,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg == null ?\n undefined : throwUsageErrorIfArray(\n 'Multiple --filename/-n option are not allowed'\n )(arg),\n },\n 'overwrite-dest': {\n alias: 'o',\n describe: 'Overwrite destination package if it exists.',\n type: 'boolean',\n },\n })\n .command(\n 'sign',\n 'Sign the extension so it can be installed in Firefox',\n commands.sign, {\n 'amo-base-url': {\n describe:\n 'Signing API URL prefix - only used with `use-submission-api`',\n default: 'https://addons.mozilla.org/api/v5',\n demandOption: true,\n type: 'string',\n },\n 'api-key': {\n describe: 'API key (JWT issuer) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-secret': {\n describe: 'API secret (JWT secret) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-url-prefix': {\n describe: 'Signing API URL prefix',\n default: 'https://addons.mozilla.org/api/v4',\n demandOption: true,\n type: 'string',\n },\n 'api-proxy': {\n describe:\n 'Use a proxy to access the signing API. ' +\n 'Example: https://yourproxy:6000 ',\n demandOption: false,\n type: 'string',\n },\n 'use-submission-api': {\n describe:\n 'Sign using the addon submission API',\n demandOption: false,\n type: 'boolean',\n },\n 'id': {\n describe:\n 'A custom ID for the extension. This has no effect if the ' +\n 'extension already declares an explicit ID in its manifest.',\n demandOption: false,\n type: 'string',\n },\n 'timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n 'channel': {\n describe: 'The channel for which to sign the addon. Either ' +\n '\\'listed\\' or \\'unlisted\\'',\n },\n 'amo-metadata': {\n describe: 'Path to a JSON file containing an object with metadata ' +\n 'to be passed to the API. ' +\n 'See https://addons-server.readthedocs.io' +\n '/en/latest/topics/api/addons.html for details. ' +\n 'Only used with `use-submission-api`',\n type: 'string',\n },\n })\n .command('run', 'Run the extension', commands.run, {\n 'target': {\n alias: 't',\n describe: 'The extensions runners to enable. Specify this option ' +\n 'multiple times to run against multiple targets.',\n default: 'firefox-desktop',\n demandOption: false,\n type: 'array',\n choices: ['firefox-desktop', 'firefox-android', 'chromium'],\n },\n 'firefox': {\n alias: ['f', 'firefox-binary'],\n describe: 'Path or alias to a Firefox executable such as firefox-bin ' +\n 'or firefox.exe. ' +\n 'If not specified, the default Firefox will be used. ' +\n 'You can specify the following aliases in lieu of a path: ' +\n 'firefox, beta, nightly, firefoxdeveloperedition. ' +\n 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' +\n '`org.mozilla.firefox` is the application ID.',\n demandOption: false,\n type: 'string',\n },\n 'firefox-profile': {\n alias: 'p',\n describe: 'Run Firefox using a copy of this profile. The profile ' +\n 'can be specified as a directory or a name, such as one ' +\n 'you would see in the Profile Manager. If not specified, ' +\n 'a new temporary profile will be created.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-binary': {\n describe: 'Path or alias to a Chromium executable such as ' +\n 'google-chrome, google-chrome.exe or opera.exe etc. ' +\n 'If not specified, the default Google Chrome will be used.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-profile': {\n describe: 'Path to a custom Chromium profile',\n demandOption: false,\n type: 'string',\n },\n 'profile-create-if-missing': {\n describe: 'Create the profile directory if it does not already exist',\n demandOption: false,\n type: 'boolean',\n },\n 'keep-profile-changes': {\n describe: 'Run Firefox directly in custom profile. Any changes to ' +\n 'the profile will be saved.',\n demandOption: false,\n type: 'boolean',\n },\n 'reload': {\n describe: 'Reload the extension when source files change.' +\n 'Disable with --no-reload.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n 'watch-file': {\n alias: ['watch-files'],\n describe: 'Reload the extension only when the contents of this' +\n ' file changes. This is useful if you use a custom' +\n ' build process for your extension',\n demandOption: false,\n type: 'array',\n },\n 'watch-ignored': {\n describe: 'Paths and globs patterns that should not be ' +\n 'watched for changes. This is useful if you want ' +\n 'to explicitly prevent web-ext from watching part ' +\n 'of the extension directory tree, ' +\n 'e.g. the node_modules folder.',\n demandOption: false,\n type: 'array',\n },\n 'pre-install': {\n describe: 'Pre-install the extension into the profile before ' +\n 'startup. This is only needed to support older versions ' +\n 'of Firefox.',\n demandOption: false,\n type: 'boolean',\n },\n 'pref': {\n describe: 'Launch firefox with a custom preference ' +\n '(example: --pref=general.useragent.locale=fr-FR). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) => arg != null ?\n coerceCLICustomPreference(arg) : undefined,\n },\n 'start-url': {\n alias: ['u', 'url'],\n describe: 'Launch firefox at specified page',\n demandOption: false,\n type: 'array',\n },\n 'devtools': {\n describe: 'Open the DevTools for the installed add-on ' +\n '(Firefox 106 and later)',\n demandOption: false,\n type: 'boolean',\n },\n 'browser-console': {\n alias: ['bc'],\n describe: 'Open the DevTools Browser Console.',\n demandOption: false,\n type: 'boolean',\n },\n 'args': {\n alias: ['arg'],\n describe: 'Additional CLI options passed to the Browser binary',\n demandOption: false,\n type: 'array',\n },\n 'firefox-preview': firefoxPreviewOption,\n // Firefox for Android CLI options.\n 'adb-bin': {\n describe: 'Specify a custom path to the adb binary',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-host': {\n describe: 'Connect to adb on the specified host',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-port': {\n describe: 'Connect to adb on the specified port',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-device': {\n alias: ['android-device'],\n describe: 'Connect to the specified adb device name',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-discovery-timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n demandOption: false,\n type: 'number',\n requiresArg: true,\n },\n 'adb-remove-old-artifacts': {\n describe: 'Remove old artifacts directories from the adb device',\n demandOption: false,\n type: 'boolean',\n },\n 'firefox-apk': {\n describe: (\n 'Run a specific Firefox for Android APK. ' +\n 'Example: org.mozilla.fennec_aurora'\n ),\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'firefox-apk-component': {\n describe:\n 'Run a specific Android Component (defaults to <firefox-apk>/.App)',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n })\n .command('lint', 'Validate the extension source', commands.lint, {\n 'output': {\n alias: 'o',\n describe: 'The type of output to generate',\n type: 'string',\n default: 'text',\n choices: ['json', 'text'],\n },\n 'metadata': {\n describe: 'Output only metadata as JSON',\n type: 'boolean',\n default: false,\n },\n 'warnings-as-errors': {\n describe: 'Treat warnings as errors by exiting non-zero for warnings',\n alias: 'w',\n type: 'boolean',\n default: false,\n },\n 'pretty': {\n describe: 'Prettify JSON output',\n type: 'boolean',\n default: false,\n },\n 'privileged': {\n describe: 'Treat your extension as a privileged extension',\n type: 'boolean',\n default: false,\n },\n 'self-hosted': {\n describe:\n 'Your extension will be self-hosted. This disables messages ' +\n 'related to hosting on addons.mozilla.org.',\n type: 'boolean',\n default: false,\n },\n 'boring': {\n describe: 'Disables colorful shell output',\n type: 'boolean',\n default: false,\n },\n 'firefox-preview': firefoxPreviewOption,\n })\n .command('docs', 'Open the web-ext documentation in a browser',\n commands.docs, {});\n\n return program.execute({getVersion, ...runOptions});\n}\n"],"mappings":";AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAAQC,YAAY,QAAO,IAAI;AAE/B,OAAOC,SAAS,MAAM,WA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AAQ,EAAE;MACRN,QAAQ,EAAE,gCAAgC;MAC1CC,IAAI,EAAE,SAAS;MACfK,OAAO,EAAE;IACX,CAAC;IACD,iBAAiB,EAAEP;EACrB,CAAC,CAAC,CACDhG,OAAO,CAAC,MAAM,EAAE,6CAA6C,EACrDF,QAAQ,CAACoH,IAAI,EAAE,CAAC,CAAC,CAAC;EAE7B,OAAOnB,OAAO,CAACnC,OAAO,CAAC;IAACC,UAAU;IAAE,GAAGiC;EAAU,CAAC,CAAC;AACrD"}
1
+ {"version":3,"file":"program.js","names":["os","path","readFileSync","camelCase","decamelize","yargs","Parser","yargsParser","defaultCommands","UsageError","createLogger","consoleStream","defaultLogStream","coerceCLICustomPreference","checkForUpdates","defaultUpdateChecker","discoverConfigFiles","defaultConfigDiscovery","loadJSConfigFile","defaultLoadJSConfigFile","applyConfigToArgv","defaultApplyConfigToArgv","log","import","meta","url","envPrefix","defaultGlobalEnv","AMO_BASE_URL","Program","constructor","argv","absolutePackageDir","process","cwd","slice","programArgv","yargsInstance","verboseEnabled","shouldExitProgram","parserConfiguration","strict","wrap","terminalWidth","commands","options","command","name","description","executor","commandOptions","yargsForCmd","demandCommand","undefined","exitProcess","env","setGlobalOptions","Object","keys","forEach","key","global","demandOption","enableVerboseMode","logStream","version","makeVerbose","info","getArguments","validationInstance","getInternalMethods","getValidationInstance","requiredArguments","demandedOptions","getDemandedOptions","args","err","message","startsWith","configDiscovery","noConfigDiscovery","reload","noReload","input","noInput","ignoreFiles","length","startUrl","Array","isArray","firefoxPreview","checkRequiredArguments","adjustedArgv","cleanupProcessEnvConfigs","systemProcess","cmd","_","toOptionKey","k","replace","separator","filter","optKey","globalOpt","cmdOpt","debug","execute","getVersion","defaultVersionGetter","globalEnv","runCommand","verbose","webextVersion","configFiles","discoveredConfigs","push","config","resolve","niceFileList","map","f","homedir","join","configFileName","configObject","argvFromCLI","error","stack","String","code","exit","packageData","JSON","parse","git","branch","long","throwUsageErrorIfArray","errorMessage","value","main","runOptions","program","firefoxPreviewOption","describe","type","usage","help","alias","recommendCommands","default","requiresArg","coerce","arg","normalize","hidden","build","filename","sign","id","timeout","channel","run","target","choices","firefox","pref","devtools","lint","output","metadata","pretty","privileged","boring","docs"],"sources":["../src/program.js"],"sourcesContent":["/* @flow */\nimport os from 'os';\nimport path from 'path';\nimport { readFileSync } from 'fs';\n\nimport camelCase from 'camelcase';\nimport decamelize from 'decamelize';\nimport yargs from 'yargs';\nimport { Parser as yargsParser } from 'yargs/helpers';\n\nimport defaultCommands from './cmd/index.js';\nimport { UsageError } from './errors.js';\nimport {\n createLogger,\n consoleStream as defaultLogStream,\n} from './util/logger.js';\nimport { coerceCLICustomPreference } from './firefox/preferences.js';\nimport { checkForUpdates as defaultUpdateChecker } from './util/updates.js';\nimport {\n discoverConfigFiles as defaultConfigDiscovery,\n loadJSConfigFile as defaultLoadJSConfigFile,\n applyConfigToArgv as defaultApplyConfigToArgv,\n} from './config.js';\n\nconst log = createLogger(import.meta.url);\nconst envPrefix = 'WEB_EXT';\n// Default to \"development\" (the value actually assigned will be interpolated\n// by babel-plugin-transform-inline-environment-variables).\nconst defaultGlobalEnv = process.env.WEBEXT_BUILD_ENV || 'development';\n\ntype ProgramOptions = {\n absolutePackageDir?: string,\n};\n\nexport type VersionGetterFn = (absolutePackageDir: string) => Promise<string>;\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype ExecuteOptions = {\n checkForUpdates?: Function,\n systemProcess?: typeof process,\n logStream?: typeof defaultLogStream,\n getVersion?: VersionGetterFn,\n applyConfigToArgv?: typeof defaultApplyConfigToArgv,\n discoverConfigFiles?: typeof defaultConfigDiscovery,\n loadJSConfigFile?: typeof defaultLoadJSConfigFile,\n shouldExitProgram?: boolean,\n globalEnv?: string | void,\n};\n\nexport const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir: string;\n yargs: any;\n commands: { [key: string]: Function };\n shouldExitProgram: boolean;\n verboseEnabled: boolean;\n options: Object;\n programArgv: Array<string>;\n demandedOptions: Object;\n\n constructor(\n argv: ?Array<string>,\n { absolutePackageDir = process.cwd() }: ProgramOptions = {}\n ) {\n // This allows us to override the process argv which is useful for\n // testing.\n // NOTE: process.argv.slice(2) removes the path to node and web-ext\n // executables from the process.argv array.\n argv = argv || process.argv.slice(2);\n this.programArgv = argv;\n\n // NOTE: always initialize yargs explicitly with the package dir\n // to avoid side-effects due to yargs looking for its configuration\n // section from a package.json file stored in an arbitrary directory\n // (e.g. in tests yargs would end up loading yargs config from the\n // mocha package.json). web-ext package.json doesn't contain any yargs\n // section as it is deprecated and we configure yargs using\n // yargs.parserConfiguration. See web-ext#469 for rationale.\n const yargsInstance = yargs(argv, absolutePackageDir);\n\n this.absolutePackageDir = absolutePackageDir;\n this.verboseEnabled = false;\n this.shouldExitProgram = true;\n\n this.yargs = yargsInstance;\n this.yargs.parserConfiguration({\n 'boolean-negation': true,\n });\n this.yargs.strict();\n this.yargs.wrap(this.yargs.terminalWidth());\n\n this.commands = {};\n this.options = {};\n }\n\n command(\n name: string,\n description: string,\n executor: Function,\n commandOptions: Object = {}\n ): Program {\n this.options[camelCase(name)] = commandOptions;\n\n this.yargs.command(name, description, (yargsForCmd) => {\n if (!commandOptions) {\n return;\n }\n return (\n yargsForCmd\n // Make sure the user does not add any extra commands. For example,\n // this would be a mistake because lint does not accept arguments:\n // web-ext lint ./src/path/to/file.js\n .demandCommand(\n 0,\n 0,\n undefined,\n 'This command does not take any arguments'\n )\n .strict()\n .exitProcess(this.shouldExitProgram)\n // Calling env() will be unnecessary after\n // https://github.com/yargs/yargs/issues/486 is fixed\n .env(envPrefix)\n .options(commandOptions)\n );\n });\n this.commands[name] = executor;\n return this;\n }\n\n setGlobalOptions(options: Object): Program {\n // This is a convenience for setting global options.\n // An option is only global (i.e. available to all sub commands)\n // with the `global` flag so this makes sure every option has it.\n this.options = { ...this.options, ...options };\n Object.keys(options).forEach((key) => {\n options[key].global = true;\n if (options[key].demandOption === undefined) {\n // By default, all options should be \"demanded\" otherwise\n // yargs.strict() will think they are missing when declared.\n options[key].demandOption = true;\n }\n });\n this.yargs.options(options);\n return this;\n }\n\n enableVerboseMode(logStream: typeof defaultLogStream, version: string): void {\n if (this.verboseEnabled) {\n return;\n }\n\n logStream.makeVerbose();\n log.info('Version:', version);\n this.verboseEnabled = true;\n }\n\n // Retrieve the yargs argv object and apply any further fix needed\n // on the output of the yargs options parsing.\n getArguments(): Object {\n // To support looking up required parameters via config files, we need to\n // temporarily disable the requiredArguments validation. Otherwise yargs\n // would exit early. Validation is enforced by the checkRequiredArguments()\n // method, after reading configuration files.\n //\n // This is an undocumented internal API of yargs! Unit tests to avoid\n // regressions are located at: tests/functional/test.cli.sign.js\n //\n // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930\n const validationInstance = this.yargs\n .getInternalMethods()\n .getValidationInstance();\n const { requiredArguments } = validationInstance;\n // Initialize demandedOptions (which is going to be set to an object with one\n // property for each mandatory global options, then the arrow function below\n // will receive as its demandedOptions parameter a new one that also includes\n // all mandatory options for the sub command selected).\n this.demandedOptions = this.yargs.getDemandedOptions();\n validationInstance.requiredArguments = (args, demandedOptions) => {\n this.demandedOptions = demandedOptions;\n };\n let argv;\n try {\n argv = this.yargs.argv;\n } catch (err) {\n if (\n err.name === 'YError' &&\n err.message.startsWith('Unknown argument: ')\n ) {\n throw new UsageError(err.message);\n }\n throw err;\n }\n validationInstance.requiredArguments = requiredArguments;\n\n // Yargs boolean options doesn't define the no* counterpart\n // with negate-boolean on Yargs 15. Define as expected by the\n // web-ext execute method.\n if (argv.configDiscovery != null) {\n argv.noConfigDiscovery = !argv.configDiscovery;\n }\n if (argv.reload != null) {\n argv.noReload = !argv.reload;\n }\n\n // Yargs doesn't accept --no-input as a valid option if there isn't a\n // --input option defined to be negated, to fix that the --input is\n // defined and hidden from the yargs help output and we define here\n // the negated argument name that we expect to be set in the parsed\n // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).\n if (argv.input != null) {\n argv.noInput = !argv.input;\n }\n\n // Replacement for the \"requiresArg: true\" parameter until the following bug\n // is fixed: https://github.com/yargs/yargs/issues/1098\n if (argv.ignoreFiles && !argv.ignoreFiles.length) {\n throw new UsageError('Not enough arguments following: ignore-files');\n }\n\n if (argv.startUrl && !argv.startUrl.length) {\n throw new UsageError('Not enough arguments following: start-url');\n }\n\n if (Array.isArray(argv.firefoxPreview) && !argv.firefoxPreview.length) {\n argv.firefoxPreview = ['mv3'];\n }\n\n return argv;\n }\n\n // getArguments() disables validation of required parameters, to allow us to\n // read parameters from config files first. Before the program continues, it\n // must call checkRequiredArguments() to ensure that required parameters are\n // defined (in the CLI or in a config file).\n checkRequiredArguments(adjustedArgv: Object): void {\n const validationInstance = this.yargs\n .getInternalMethods()\n .getValidationInstance();\n validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);\n }\n\n // Remove WEB_EXT_* environment vars that are not a global cli options\n // or an option supported by the current command (See #793).\n cleanupProcessEnvConfigs(systemProcess: typeof process) {\n const cmd = yargsParser(this.programArgv)._[0];\n const env = systemProcess.env || {};\n const toOptionKey = (k) =>\n decamelize(camelCase(k.replace(envPrefix, '')), { separator: '-' });\n\n if (cmd) {\n Object.keys(env)\n .filter((k) => k.startsWith(envPrefix))\n .forEach((k) => {\n const optKey = toOptionKey(k);\n const globalOpt = this.options[optKey];\n const cmdOpt = this.options[cmd] && this.options[cmd][optKey];\n\n if (!globalOpt && !cmdOpt) {\n log.debug(`Environment ${k} not supported by web-ext ${cmd}`);\n delete env[k];\n }\n });\n }\n }\n\n async execute({\n checkForUpdates = defaultUpdateChecker,\n systemProcess = process,\n logStream = defaultLogStream,\n getVersion = defaultVersionGetter,\n applyConfigToArgv = defaultApplyConfigToArgv,\n discoverConfigFiles = defaultConfigDiscovery,\n loadJSConfigFile = defaultLoadJSConfigFile,\n shouldExitProgram = true,\n globalEnv = defaultGlobalEnv,\n }: ExecuteOptions = {}): Promise<void> {\n this.shouldExitProgram = shouldExitProgram;\n this.yargs.exitProcess(this.shouldExitProgram);\n\n this.cleanupProcessEnvConfigs(systemProcess);\n const argv = this.getArguments();\n\n const cmd = argv._[0];\n\n const version = await getVersion(this.absolutePackageDir);\n const runCommand = this.commands[cmd];\n\n if (argv.verbose) {\n this.enableVerboseMode(logStream, version);\n }\n\n let adjustedArgv = { ...argv, webextVersion: version };\n\n try {\n if (cmd === undefined) {\n throw new UsageError('No sub-command was specified in the args');\n }\n if (!runCommand) {\n throw new UsageError(`Unknown command: ${cmd}`);\n }\n if (globalEnv === 'production') {\n checkForUpdates({ version });\n }\n\n const configFiles = [];\n\n if (argv.configDiscovery) {\n log.debug(\n 'Discovering config files. ' + 'Set --no-config-discovery to disable'\n );\n const discoveredConfigs = await discoverConfigFiles();\n configFiles.push(...discoveredConfigs);\n } else {\n log.debug('Not discovering config files');\n }\n\n if (argv.config) {\n configFiles.push(path.resolve(argv.config));\n }\n\n if (configFiles.length) {\n const niceFileList = configFiles\n .map((f) => f.replace(process.cwd(), '.'))\n .map((f) => f.replace(os.homedir(), '~'))\n .join(', ');\n log.info(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`\n );\n }\n\n configFiles.forEach((configFileName) => {\n const configObject = loadJSConfigFile(configFileName);\n adjustedArgv = applyConfigToArgv({\n argv: adjustedArgv,\n argvFromCLI: argv,\n configFileName,\n configObject,\n options: this.options,\n });\n });\n\n if (adjustedArgv.verbose) {\n // Ensure that the verbose is enabled when specified in a config file.\n this.enableVerboseMode(logStream, version);\n }\n\n this.checkRequiredArguments(adjustedArgv);\n\n await runCommand(adjustedArgv, { shouldExitProgram });\n } catch (error) {\n if (!(error instanceof UsageError) || adjustedArgv.verbose) {\n log.error(`\\n${error.stack}\\n`);\n } else {\n log.error(`\\n${String(error)}\\n`);\n }\n if (error.code) {\n log.error(`Error code: ${error.code}\\n`);\n }\n\n log.debug(`Command executed: ${cmd}`);\n\n if (this.shouldExitProgram) {\n systemProcess.exit(1);\n } else {\n throw error;\n }\n }\n }\n}\n\n//A defintion of type of argument for defaultVersionGetter\ntype VersionGetterOptions = {\n globalEnv?: string,\n};\n\nexport async function defaultVersionGetter(\n absolutePackageDir: string,\n { globalEnv = defaultGlobalEnv }: VersionGetterOptions = {}\n): Promise<string> {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData: any = readFileSync(\n path.join(absolutePackageDir, 'package.json')\n );\n return JSON.parse(packageData).version;\n } else {\n log.debug('Getting version from the git revision');\n // This branch is only reached during development.\n // git-rev-sync is in devDependencies, and lazily imported using require.\n // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916\n // eslint-disable-next-line import/no-extraneous-dependencies\n const git = await import('git-rev-sync');\n return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;\n }\n}\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype MainParams = {\n getVersion?: VersionGetterFn,\n commands?: Object,\n argv: Array<any>,\n runOptions?: Object,\n};\n\nexport function throwUsageErrorIfArray(errorMessage: string): any {\n return (value: any): any => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir: string,\n {\n getVersion = defaultVersionGetter,\n commands = defaultCommands,\n argv,\n runOptions = {},\n }: MainParams = {}\n): Promise<any> {\n const program = new Program(argv, { absolutePackageDir });\n const version = await getVersion(absolutePackageDir);\n\n // This is an option shared by some commands but not all of them, hence why\n // it isn't a global option.\n const firefoxPreviewOption = {\n describe:\n 'Turn on developer preview features in Firefox' + ' (defaults to \"mv3\")',\n demandOption: false,\n type: 'array',\n };\n\n // yargs uses magic camel case expansion to expose options on the\n // final argv object. For example, the 'artifacts-dir' option is alternatively\n // available as argv.artifactsDir.\n program.yargs\n .usage(\n `Usage: $0 [options] command\n\nOption values can also be set by declaring an environment variable prefixed\nwith $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as\n--source-dir=/path.\n\nTo view specific help for any given command, add the command name.\nExample: $0 --help run.\n`\n )\n .help('help')\n .alias('h', 'help')\n .env(envPrefix)\n .version(version)\n .demandCommand(1, 'You must specify a command')\n .strict()\n .recommendCommands();\n\n program.setGlobalOptions({\n 'source-dir': {\n alias: 's',\n describe: 'Web extension source directory.',\n default: process.cwd(),\n requiresArg: true,\n type: 'string',\n coerce: (arg) => (arg != null ? path.resolve(arg) : undefined),\n },\n 'artifacts-dir': {\n alias: 'a',\n describe: 'Directory where artifacts will be saved.',\n default: path.join(process.cwd(), 'web-ext-artifacts'),\n normalize: true,\n requiresArg: true,\n type: 'string',\n },\n verbose: {\n alias: 'v',\n describe: 'Show verbose output',\n type: 'boolean',\n demandOption: false,\n },\n 'ignore-files': {\n alias: 'i',\n describe:\n 'A list of glob patterns to define which files should be ' +\n 'ignored. (Example: --ignore-files=path/to/first.js ' +\n 'path/to/second.js \"**/*.log\")',\n demandOption: false,\n // The following option prevents yargs>=11 from parsing multiple values,\n // so the minimum value requirement is enforced in execute instead.\n // Upstream bug: https://github.com/yargs/yargs/issues/1098\n // requiresArg: true,\n type: 'array',\n },\n 'no-input': {\n describe: 'Disable all features that require standard input',\n type: 'boolean',\n demandOption: false,\n },\n input: {\n // This option is defined to make yargs to accept the --no-input\n // defined above, but we hide it from the yargs help output.\n hidden: true,\n type: 'boolean',\n demandOption: false,\n },\n config: {\n alias: 'c',\n describe: 'Path to a CommonJS config file to set ' + 'option defaults',\n default: undefined,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n },\n 'config-discovery': {\n describe:\n 'Discover config files in home directory and ' +\n 'working directory. Disable with --no-config-discovery.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n });\n\n program\n .command(\n 'build',\n 'Create an extension package from source',\n commands.build,\n {\n 'as-needed': {\n describe: 'Watch for file changes and re-build as needed',\n type: 'boolean',\n },\n filename: {\n alias: 'n',\n describe: 'Name of the created extension package file.',\n default: undefined,\n normalize: false,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n coerce: (arg) =>\n arg == null\n ? undefined\n : throwUsageErrorIfArray(\n 'Multiple --filename/-n option are not allowed'\n )(arg),\n },\n 'overwrite-dest': {\n alias: 'o',\n describe: 'Overwrite destination package if it exists.',\n type: 'boolean',\n },\n }\n )\n .command(\n 'sign',\n 'Sign the extension so it can be installed in Firefox',\n commands.sign,\n {\n 'amo-base-url': {\n describe:\n 'Signing API URL prefix - only used with `use-submission-api`',\n default: AMO_BASE_URL,\n demandOption: true,\n type: 'string',\n },\n 'api-key': {\n describe: 'API key (JWT issuer) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-secret': {\n describe: 'API secret (JWT secret) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-url-prefix': {\n describe: 'Signing API URL prefix',\n default: 'https://addons.mozilla.org/api/v4',\n demandOption: true,\n type: 'string',\n },\n 'api-proxy': {\n describe:\n 'Use a proxy to access the signing API. ' +\n 'Example: https://yourproxy:6000 ',\n demandOption: false,\n type: 'string',\n },\n 'use-submission-api': {\n describe: 'Sign using the addon submission API',\n demandOption: false,\n type: 'boolean',\n },\n id: {\n describe:\n 'A custom ID for the extension. This has no effect if the ' +\n 'extension already declares an explicit ID in its manifest.',\n demandOption: false,\n type: 'string',\n },\n timeout: {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n channel: {\n describe:\n 'The channel for which to sign the addon. Either ' +\n \"'listed' or 'unlisted'\",\n type: 'string',\n },\n 'amo-metadata': {\n describe:\n 'Path to a JSON file containing an object with metadata ' +\n 'to be passed to the API. ' +\n 'See https://addons-server.readthedocs.io' +\n '/en/latest/topics/api/addons.html for details. ' +\n 'Only used with `use-submission-api`',\n type: 'string',\n },\n }\n )\n .command('run', 'Run the extension', commands.run, {\n target: {\n alias: 't',\n describe:\n 'The extensions runners to enable. Specify this option ' +\n 'multiple times to run against multiple targets.',\n default: 'firefox-desktop',\n demandOption: false,\n type: 'array',\n choices: ['firefox-desktop', 'firefox-android', 'chromium'],\n },\n firefox: {\n alias: ['f', 'firefox-binary'],\n describe:\n 'Path or alias to a Firefox executable such as firefox-bin ' +\n 'or firefox.exe. ' +\n 'If not specified, the default Firefox will be used. ' +\n 'You can specify the following aliases in lieu of a path: ' +\n 'firefox, beta, nightly, firefoxdeveloperedition. ' +\n 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' +\n '`org.mozilla.firefox` is the application ID.',\n demandOption: false,\n type: 'string',\n },\n 'firefox-profile': {\n alias: 'p',\n describe:\n 'Run Firefox using a copy of this profile. The profile ' +\n 'can be specified as a directory or a name, such as one ' +\n 'you would see in the Profile Manager. If not specified, ' +\n 'a new temporary profile will be created.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-binary': {\n describe:\n 'Path or alias to a Chromium executable such as ' +\n 'google-chrome, google-chrome.exe or opera.exe etc. ' +\n 'If not specified, the default Google Chrome will be used.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-profile': {\n describe: 'Path to a custom Chromium profile',\n demandOption: false,\n type: 'string',\n },\n 'profile-create-if-missing': {\n describe: 'Create the profile directory if it does not already exist',\n demandOption: false,\n type: 'boolean',\n },\n 'keep-profile-changes': {\n describe:\n 'Run Firefox directly in custom profile. Any changes to ' +\n 'the profile will be saved.',\n demandOption: false,\n type: 'boolean',\n },\n reload: {\n describe:\n 'Reload the extension when source files change.' +\n 'Disable with --no-reload.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n 'watch-file': {\n alias: ['watch-files'],\n describe:\n 'Reload the extension only when the contents of this' +\n ' file changes. This is useful if you use a custom' +\n ' build process for your extension',\n demandOption: false,\n type: 'array',\n },\n 'watch-ignored': {\n describe:\n 'Paths and globs patterns that should not be ' +\n 'watched for changes. This is useful if you want ' +\n 'to explicitly prevent web-ext from watching part ' +\n 'of the extension directory tree, ' +\n 'e.g. the node_modules folder.',\n demandOption: false,\n type: 'array',\n },\n 'pre-install': {\n describe:\n 'Pre-install the extension into the profile before ' +\n 'startup. This is only needed to support older versions ' +\n 'of Firefox.',\n demandOption: false,\n type: 'boolean',\n },\n pref: {\n describe:\n 'Launch firefox with a custom preference ' +\n '(example: --pref=general.useragent.locale=fr-FR). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) =>\n arg != null ? coerceCLICustomPreference(arg) : undefined,\n },\n 'start-url': {\n alias: ['u', 'url'],\n describe: 'Launch firefox at specified page',\n demandOption: false,\n type: 'array',\n },\n devtools: {\n describe:\n 'Open the DevTools for the installed add-on ' +\n '(Firefox 106 and later)',\n demandOption: false,\n type: 'boolean',\n },\n 'browser-console': {\n alias: ['bc'],\n describe: 'Open the DevTools Browser Console.',\n demandOption: false,\n type: 'boolean',\n },\n args: {\n alias: ['arg'],\n describe: 'Additional CLI options passed to the Browser binary',\n demandOption: false,\n type: 'array',\n },\n 'firefox-preview': firefoxPreviewOption,\n // Firefox for Android CLI options.\n 'adb-bin': {\n describe: 'Specify a custom path to the adb binary',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-host': {\n describe: 'Connect to adb on the specified host',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-port': {\n describe: 'Connect to adb on the specified port',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-device': {\n alias: ['android-device'],\n describe: 'Connect to the specified adb device name',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-discovery-timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n demandOption: false,\n type: 'number',\n requiresArg: true,\n },\n 'adb-remove-old-artifacts': {\n describe: 'Remove old artifacts directories from the adb device',\n demandOption: false,\n type: 'boolean',\n },\n 'firefox-apk': {\n describe:\n 'Run a specific Firefox for Android APK. ' +\n 'Example: org.mozilla.fennec_aurora',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'firefox-apk-component': {\n describe:\n 'Run a specific Android Component (defaults to <firefox-apk>/.App)',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n })\n .command('lint', 'Validate the extension source', commands.lint, {\n output: {\n alias: 'o',\n describe: 'The type of output to generate',\n type: 'string',\n default: 'text',\n choices: ['json', 'text'],\n },\n metadata: {\n describe: 'Output only metadata as JSON',\n type: 'boolean',\n default: false,\n },\n 'warnings-as-errors': {\n describe: 'Treat warnings as errors by exiting non-zero for warnings',\n alias: 'w',\n type: 'boolean',\n default: false,\n },\n pretty: {\n describe: 'Prettify JSON output',\n type: 'boolean',\n default: false,\n },\n privileged: {\n describe: 'Treat your extension as a privileged extension',\n type: 'boolean',\n default: false,\n },\n 'self-hosted': {\n describe:\n 'Your extension will be self-hosted. This disables messages ' +\n 'related to hosting on addons.mozilla.org.',\n type: 'boolean',\n default: false,\n },\n boring: {\n describe: 'Disables colorful shell output',\n type: 'boolean',\n default: false,\n },\n 'firefox-preview': firefoxPreviewOption,\n })\n .command(\n 'docs',\n 'Open the web-ext documentation in a browser',\n commands.docs,\n {}\n );\n\n return program.execute({ getVersion, ...runOptions });\n}\n"],"mappings":"AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,YAAY,QAAQ,IAAI;AAEjC,OAAOC,SAAS,MAAM,WAAW;AACjC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,IAAIC,WAAW,QAAQ,eAAe;AAErD,OAAOC,eAAe,MAAM,gBAAgB;AAC5C,SAASC,UAAU,QAAQ,aAAa;AACxC,SACEC,YAAY,EACZC,aAAa,IAAIC,gBAAgB,QAC5B,kBAAkB;AACzB,SAASC,yBAAyB,QAAQ,0BAA0B;AACpE,SAASC,eAAe,IAAIC,oBAAoB,QAAQ,mBAAmB;AAC3E,SACEC,mBAAmB,IAAIC,sBAAsB,EAC7CC,gBAAgB,IAAIC,uBAAuB,EAC3CC,iBAAiB,IAAIC,wBAAwB,QACxC,aAAa;AAEpB,M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.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  import ADBKit from '@devicefarmer/adbkit';
3
2
  import { isErrorWithCode, UsageError, WebExtError } from '../errors.js';
4
3
  import { createLogger } from '../util/logger.js';
@@ -1 +1 @@
1
- {"version":3,"file":"adb.js","names":["ADBKit","isErrorWithCode","UsageError","WebExtError","createLogger","packageIdentifiers","defaultApkComponents","DEVICE_DIR_BASE","ARTIFACTS_DIR_PREFIX","defaultADB","default","log","import","meta","url","wrapADBCall","asyncFn","error","message","includes","ADBUtils","constructor","params","adb","adbBin","adbHost","adbPort","adbClient","createClient","bin","host","port","artifactsDirMap","Map","userAbortDiscovery","runShellCommand","deviceId","cmd","debug","JSON","stringify","getDevice","shell","then","util","readAll","res","toString","discoverDevices","devices","listDevices","map","dev","id","discoverInstalledFirefoxAPKs","firefoxApk","pmList","split","line","replace","trim","filter","browser","startsWith","getAndroidVersionNumber","androidVersion","androidVersionNumber","parseInt","isNaN","ensureRequiredAPKRuntimePermissions","apk","permissions","permissionsMap","perm","pmDumpLogs","amForceStopAPK","getOrCreateArtifactsDir","artifactsDir","get","Date","now","testDirOut","set","detectOrRemoveOldArtifacts","removeArtifactDirs","files","readdir","found","file","isDirectory","name","clearArtifactsDir","delete","pushFile","localPath","devicePath","push","transfer","Promise","resolve","on","startFirefoxAPK","apkComponent","deviceProfileDir","extras","key","value","component","startActivity","wait","action","setUserAbortDiscovery","discoverRDPUnixSocket","maxDiscoveryTime","retryInterval","rdpUnixSockets","discoveryStartedAt","msg","length","info","endsWith","setTimeout","pop","setupForward","remote","local","forward","listADBDevices","adbUtils","listADBFirefoxAPKs"],"sources":["../../src/util/adb.js"],"sourcesContent":["/* @flow */\nimport ADBKit from '@devicefarmer/adbkit';\n\nimport {\n isErrorWithCode,\n UsageError,\n WebExtError,\n} from '../errors.js';\nimport {createLogger} from '../util/logger.js';\nimport packageIdentifiers, {\n defaultApkComponents,\n} from '../firefox/package-identifiers.js';\n\nexport const DEVICE_DIR_BASE = '/data/local/tmp/';\nexport const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-';\n\nconst defaultADB = ADBKit.default;\n\nconst log = createLogger(import.meta.url);\n\nexport type ADBUtilsParams = {|\n adb?: typeof defaultADB,\n // ADB configs.\n adbBin?: string,\n adbHost?: string,\n adbPort?: string,\n adbDevice?: string,\n|};\n\nexport type DiscoveryParams = {\n maxDiscoveryTime: number,\n retryInterval: number,\n};\n\n// Helper function used to raise an UsageError when the adb binary has not been found.\nasync function wrapADBCall(asyncFn: (...any) => Promise<any>): Promise<any> {\n try {\n return await asyncFn();\n } catch (error) {\n if (isErrorWithCode('ENOENT', error) &&\n error.message.includes('spawn adb')) {\n throw new UsageError(\n 'No adb executable has been found. ' +\n 'You can Use --adb-bin, --adb-host/--adb-port ' +\n 'to configure it manually if needed.');\n }\n\n throw error;\n }\n}\n\nexport default class ADBUtils {\n params: ADBUtilsParams;\n adb: typeof defaultADB;\n adbClient: any; // TODO: better flow typing here.\n\n // Map<deviceId -> artifactsDir>\n artifactsDirMap: Map<string, string>;\n // Toggled when the user wants to abort the RDP Unix Socket discovery loop\n // while it is still executing.\n userAbortDiscovery: boolean;\n\n constructor(params: ADBUtilsParams) {\n this.params = params;\n\n const {\n adb,\n adbBin,\n adbHost,\n adbPort,\n } = params;\n\n this.adb = adb || defaultADB;\n\n this.adbClient = this.adb.createClient({\n bin: adbBin,\n host: adbHost,\n port: adbPort,\n });\n\n this.artifactsDirMap = new Map();\n\n this.userAbortDiscovery = false;\n }\n\n runShellCommand(\n deviceId: string, cmd: string | Array<string>\n ): Promise<string> {\n const {adb, adbClient} = this;\n\n log.debug(`Run adb shell command on ${deviceId}: ${JSON.stringify(cmd)}`);\n\n return wrapADBCall(async () => {\n return await adbClient.getDevice(deviceId).shell(cmd).then(\n adb.util.readAll\n );\n }).then((res) => res.toString());\n }\n\n async discoverDevices(): Promise<Array<string>> {\n const {adbClient} = this;\n\n let devices = [];\n\n log.debug('Listing android devices');\n devices = await wrapADBCall(async () => adbClient.listDevices());\n\n return devices.map((dev) => dev.id);\n }\n\n async discoverInstalledFirefoxAPKs(\n deviceId: string,\n firefoxApk?: string\n ): Promise<Array<string>> {\n log.debug(`Listing installed Firefox APKs on ${deviceId}`);\n\n const pmList = await this.runShellCommand(deviceId, [\n 'pm', 'list', 'packages',\n ]);\n\n return pmList.split('\\n')\n .map((line) => line.replace('package:', '').trim())\n .filter((line) => {\n // Look for an exact match if firefoxApk is defined.\n if (firefoxApk) {\n return line === firefoxApk;\n }\n // Match any package name that starts with the package name of a Firefox for Android browser.\n for (const browser of packageIdentifiers) {\n if (line.startsWith(browser)) {\n return true;\n }\n }\n\n return false;\n });\n }\n\n async getAndroidVersionNumber(deviceId: string): Promise<number> {\n const androidVersion = (await this.runShellCommand(deviceId, [\n 'getprop', 'ro.build.version.sdk',\n ])).trim();\n\n const androidVersionNumber = parseInt(androidVersion);\n\n // No need to check the granted runtime permissions on Android versions < Lollypop.\n if (isNaN(androidVersionNumber)) {\n throw new WebExtError(\n 'Unable to discovery android version on ' +\n `${deviceId}: ${androidVersion}`\n );\n }\n\n return androidVersionNumber;\n }\n\n // Raise an UsageError when the given APK does not have the required runtime permissions.\n async ensureRequiredAPKRuntimePermissions(\n deviceId: string, apk: string, permissions: Array<string>\n ): Promise<void> {\n const permissionsMap = {};\n\n // Initialize every permission to false in the permissions map.\n for (const perm of permissions) {\n permissionsMap[perm] = false;\n }\n\n // Retrieve the permissions information for the given apk.\n const pmDumpLogs = (await this.runShellCommand(deviceId, [\n 'pm', 'dump', apk,\n ])).split('\\n');\n\n // Set to true the required permissions that have been granted.\n for (const line of pmDumpLogs) {\n for (const perm of permissions) {\n if (line.includes(`${perm}: granted=true`) ||\n line.includes(`${perm}, granted=true`)) {\n permissionsMap[perm] = true;\n }\n }\n }\n\n for (const perm of permissions) {\n if (!permissionsMap[perm]) {\n throw new UsageError(\n `Required ${perm} has not be granted for ${apk}. ` +\n 'Please grant them using the Android Settings ' +\n 'or using the following adb command:\\n' +\n `\\t adb shell pm grant ${apk} ${perm}\\n`\n );\n }\n }\n }\n\n async amForceStopAPK(deviceId: string, apk: string): Promise<void> {\n await this.runShellCommand(deviceId, [\n 'am', 'force-stop', apk,\n ]);\n }\n\n async getOrCreateArtifactsDir(deviceId: string): Promise<string> {\n let artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (artifactsDir) {\n return artifactsDir;\n }\n\n artifactsDir = `${DEVICE_DIR_BASE}${ARTIFACTS_DIR_PREFIX}${Date.now()}`;\n\n const testDirOut = (await this.runShellCommand(\n deviceId, `test -d ${artifactsDir} ; echo $?`\n )).trim();\n\n if (testDirOut !== '1') {\n throw new WebExtError(\n `Cannot create artifacts directory ${artifactsDir} ` +\n `because it exists on ${deviceId}.`\n );\n }\n\n await this.runShellCommand(deviceId, ['mkdir', '-p', artifactsDir]);\n\n this.artifactsDirMap.set(deviceId, artifactsDir);\n\n return artifactsDir;\n }\n\n async detectOrRemoveOldArtifacts(\n deviceId: string, removeArtifactDirs?: boolean = false\n ): Promise<boolean> {\n const {adbClient} = this;\n\n log.debug('Checking adb device for existing web-ext artifacts dirs');\n\n return wrapADBCall(async () => {\n const files = await adbClient.getDevice(deviceId).readdir(\n DEVICE_DIR_BASE\n );\n let found = false;\n\n for (const file of files) {\n if (!file.isDirectory() ||\n !file.name.startsWith(ARTIFACTS_DIR_PREFIX)) {\n continue;\n }\n\n // Return earlier if we only need to warn the user that some\n // existing artifacts dirs have been found on the adb device.\n if (!removeArtifactDirs) {\n return true;\n }\n\n found = true;\n\n const artifactsDir = `${DEVICE_DIR_BASE}${file.name}`;\n\n log.debug(\n `Removing artifacts directory ${artifactsDir} from device ${deviceId}`\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n return found;\n });\n }\n\n async clearArtifactsDir(deviceId: string): Promise<void> {\n const artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (!artifactsDir) {\n // nothing to do here.\n return;\n }\n\n this.artifactsDirMap.delete(deviceId);\n\n log.debug(\n `Removing ${artifactsDir} artifacts directory on ${deviceId} device`\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n async pushFile(\n deviceId: string, localPath: string, devicePath: string\n ): Promise<void> {\n const {adbClient} = this;\n\n log.debug(`Pushing ${localPath} to ${devicePath} on ${deviceId}`);\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).push(localPath, devicePath)\n .then(function(transfer) {\n return new Promise((resolve) => {\n transfer.on('end', resolve);\n });\n });\n });\n }\n\n async startFirefoxAPK(\n deviceId: string,\n apk: string,\n apkComponent: ?string,\n deviceProfileDir: string,\n ): Promise<void> {\n const {adbClient} = this;\n\n log.debug(\n `Starting ${apk} on ${deviceId}`\n );\n\n // Fenix does ignore the -profile parameter, on the contrary Fennec\n // would run using the given path as the profile to be used during\n // this execution.\n const extras = [{\n key: 'args',\n value: `-profile ${deviceProfileDir}`,\n }];\n\n if (!apkComponent) {\n apkComponent = '.App';\n if (defaultApkComponents[apk]) {\n apkComponent = defaultApkComponents[apk];\n }\n } else if (!apkComponent.includes('.')) {\n apkComponent = `.${apkComponent}`;\n }\n\n // if `apk` is a browser package or the `apk` has a\n // browser package prefix: prepend the package identifier\n // before `apkComponent`\n if (apkComponent.startsWith('.')) {\n for (const browser of packageIdentifiers) {\n if (apk === browser || apk.startsWith(`${browser}.`)) {\n apkComponent = browser + apkComponent;\n }\n }\n }\n\n // if `apkComponent` starts with a '.', then adb will expand\n // the following to: `${apk}/${apk}.${apkComponent}`\n const component = `${apk}/${apkComponent}`;\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.activity.MAIN',\n component,\n extras,\n });\n });\n }\n\n setUserAbortDiscovery(value: boolean) {\n this.userAbortDiscovery = value;\n }\n\n async discoverRDPUnixSocket(\n deviceId: string, apk: string,\n {maxDiscoveryTime, retryInterval}: DiscoveryParams = {}\n ): Promise<string> {\n let rdpUnixSockets = [];\n\n const discoveryStartedAt = Date.now();\n const msg = (\n `Waiting for ${apk} Remote Debugging Server...` +\n '\\nMake sure to enable \"Remote Debugging via USB\" ' +\n 'from Settings -> Developer Tools if it is not yet enabled.'\n );\n\n while (rdpUnixSockets.length === 0) {\n log.info(msg);\n if (this.userAbortDiscovery) {\n throw new UsageError(\n 'Exiting Firefox Remote Debugging socket discovery on user request'\n );\n }\n\n if (Date.now() - discoveryStartedAt > maxDiscoveryTime) {\n throw new WebExtError(\n 'Timeout while waiting for the Android Firefox Debugger Socket'\n );\n }\n\n rdpUnixSockets = (await this.runShellCommand(deviceId, [\n 'cat', '/proc/net/unix',\n ])).split('\\n').filter((line) => {\n // The RDP unix socket is expected to be a path in the form:\n // /data/data/org.mozilla.fennec_rpl/firefox-debugger-socket\n return line.trim().endsWith(`${apk}/firefox-debugger-socket`);\n });\n\n if (rdpUnixSockets.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, retryInterval));\n }\n }\n\n // Convert into an array of unix socket filenames.\n rdpUnixSockets = rdpUnixSockets.map((line) => {\n return line.trim().split(/\\s/).pop();\n });\n\n if (rdpUnixSockets.length > 1) {\n throw new WebExtError(\n 'Unexpected multiple RDP sockets: ' +\n `${JSON.stringify(rdpUnixSockets)}`\n );\n }\n\n return rdpUnixSockets[0];\n }\n\n async setupForward(deviceId: string, remote: string, local: string) {\n const {adbClient} = this;\n\n // TODO(rpl): we should use adb.listForwards and reuse the existing one if any (especially\n // because adbkit doesn't seem to support `adb forward --remote` yet).\n log.debug(`Configuring ADB forward for ${deviceId}: ${remote} -> ${local}`);\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).forward(local, remote);\n });\n }\n}\n\nexport async function listADBDevices(adbBin?: string): Promise<Array<string>> {\n const adbUtils = new ADBUtils({adbBin});\n return adbUtils.discoverDevices();\n}\n\nexport async function listADBFirefoxAPKs(\n deviceId: string,\n adbBin?: string\n): Promise<Array<string>> {\n const adbUtils = new ADBUtils({adbBin});\n return adbUtils.discoverInstalled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;IAC5D,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,eAAeG,cAAc,CAACvG,MAAe,EAA0B;EAC5E,MAAMwG,QAAQ,GAAG,IAAI5G,QAAQ,CAAC;IAACI;EAAM,CAAC,CAAC;EACvC,OAAOwG,QAAQ,CAAChF,eAAe,EAAE;AACnC;AAEA,OAAO,eAAeiF,kBAAkB,CACtC7F,QAAgB,EAChBZ,MAAe,EACS;EACxB,MAAMwG,QAAQ,GAAG,IAAI5G,QAAQ,CAAC;IAACI;EAAM,CAAC,CAAC;EACvC,OAAOwG,QAAQ,CAAC1E,4BAA4B,CAAClB,QAAQ,CAAC;AACxD"}
1
+ {"version":3,"file":"adb.js","names":["ADBKit","isErrorWithCode","UsageError","WebExtError","createLogger","packageIdentifiers","defaultApkComponents","DEVICE_DIR_BASE","ARTIFACTS_DIR_PREFIX","defaultADB","default","log","import","meta","url","wrapADBCall","asyncFn","error","message","includes","ADBUtils","constructor","params","adb","adbBin","adbHost","adbPort","adbClient","createClient","bin","host","port","artifactsDirMap","Map","userAbortDiscovery","runShellCommand","deviceId","cmd","debug","JSON","stringify","getDevice","shell","then","util","readAll","res","toString","discoverDevices","devices","listDevices","map","dev","id","discoverInstalledFirefoxAPKs","firefoxApk","pmList","split","line","replace","trim","filter","browser","startsWith","getAndroidVersionNumber","androidVersion","androidVersionNumber","parseInt","isNaN","ensureRequiredAPKRuntimePermissions","apk","permissions","permissionsMap","perm","pmDumpLogs","amForceStopAPK","getOrCreateArtifactsDir","artifactsDir","get","Date","now","testDirOut","set","detectOrRemoveOldArtifacts","removeArtifactDirs","files","readdir","found","file","isDirectory","name","clearArtifactsDir","delete","pushFile","localPath","devicePath","push","transfer","Promise","resolve","on","startFirefoxAPK","apkComponent","deviceProfileDir","extras","key","value","component","startActivity","wait","action","setUserAbortDiscovery","discoverRDPUnixSocket","maxDiscoveryTime","retryInterval","rdpUnixSockets","discoveryStartedAt","msg","length","info","endsWith","setTimeout","pop","setupForward","remote","local","forward","listADBDevices","adbUtils","listADBFirefoxAPKs"],"sources":["../../src/util/adb.js"],"sourcesContent":["/* @flow */\nimport ADBKit from '@devicefarmer/adbkit';\n\nimport { isErrorWithCode, UsageError, WebExtError } from '../errors.js';\nimport { createLogger } from '../util/logger.js';\nimport packageIdentifiers, {\n defaultApkComponents,\n} from '../firefox/package-identifiers.js';\n\nexport const DEVICE_DIR_BASE = '/data/local/tmp/';\nexport const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-';\n\nconst defaultADB = ADBKit.default;\n\nconst log = createLogger(import.meta.url);\n\nexport type ADBUtilsParams = {|\n adb?: typeof defaultADB,\n // ADB configs.\n adbBin?: string,\n adbHost?: string,\n adbPort?: string,\n adbDevice?: string,\n|};\n\nexport type DiscoveryParams = {\n maxDiscoveryTime: number,\n retryInterval: number,\n};\n\n// Helper function used to raise an UsageError when the adb binary has not been found.\nasync function wrapADBCall(asyncFn: (...any) => Promise<any>): Promise<any> {\n try {\n return await asyncFn();\n } catch (error) {\n if (\n isErrorWithCode('ENOENT', error) &&\n error.message.includes('spawn adb')\n ) {\n throw new UsageError(\n 'No adb executable has been found. ' +\n 'You can Use --adb-bin, --adb-host/--adb-port ' +\n 'to configure it manually if needed.'\n );\n }\n\n throw error;\n }\n}\n\nexport default class ADBUtils {\n params: ADBUtilsParams;\n adb: typeof defaultADB;\n adbClient: any; // TODO: better flow typing here.\n\n // Map<deviceId -> artifactsDir>\n artifactsDirMap: Map<string, string>;\n // Toggled when the user wants to abort the RDP Unix Socket discovery loop\n // while it is still executing.\n userAbortDiscovery: boolean;\n\n constructor(params: ADBUtilsParams) {\n this.params = params;\n\n const { adb, adbBin, adbHost, adbPort } = params;\n\n this.adb = adb || defaultADB;\n\n this.adbClient = this.adb.createClient({\n bin: adbBin,\n host: adbHost,\n port: adbPort,\n });\n\n this.artifactsDirMap = new Map();\n\n this.userAbortDiscovery = false;\n }\n\n runShellCommand(\n deviceId: string,\n cmd: string | Array<string>\n ): Promise<string> {\n const { adb, adbClient } = this;\n\n log.debug(`Run adb shell command on ${deviceId}: ${JSON.stringify(cmd)}`);\n\n return wrapADBCall(async () => {\n return await adbClient\n .getDevice(deviceId)\n .shell(cmd)\n .then(adb.util.readAll);\n }).then((res) => res.toString());\n }\n\n async discoverDevices(): Promise<Array<string>> {\n const { adbClient } = this;\n\n let devices = [];\n\n log.debug('Listing android devices');\n devices = await wrapADBCall(async () => adbClient.listDevices());\n\n return devices.map((dev) => dev.id);\n }\n\n async discoverInstalledFirefoxAPKs(\n deviceId: string,\n firefoxApk?: string\n ): Promise<Array<string>> {\n log.debug(`Listing installed Firefox APKs on ${deviceId}`);\n\n const pmList = await this.runShellCommand(deviceId, [\n 'pm',\n 'list',\n 'packages',\n ]);\n\n return pmList\n .split('\\n')\n .map((line) => line.replace('package:', '').trim())\n .filter((line) => {\n // Look for an exact match if firefoxApk is defined.\n if (firefoxApk) {\n return line === firefoxApk;\n }\n // Match any package name that starts with the package name of a Firefox for Android browser.\n for (const browser of packageIdentifiers) {\n if (line.startsWith(browser)) {\n return true;\n }\n }\n\n return false;\n });\n }\n\n async getAndroidVersionNumber(deviceId: string): Promise<number> {\n const androidVersion = (\n await this.runShellCommand(deviceId, ['getprop', 'ro.build.version.sdk'])\n ).trim();\n\n const androidVersionNumber = parseInt(androidVersion);\n\n // No need to check the granted runtime permissions on Android versions < Lollypop.\n if (isNaN(androidVersionNumber)) {\n throw new WebExtError(\n 'Unable to discovery android version on ' +\n `${deviceId}: ${androidVersion}`\n );\n }\n\n return androidVersionNumber;\n }\n\n // Raise an UsageError when the given APK does not have the required runtime permissions.\n async ensureRequiredAPKRuntimePermissions(\n deviceId: string,\n apk: string,\n permissions: Array<string>\n ): Promise<void> {\n const permissionsMap = {};\n\n // Initialize every permission to false in the permissions map.\n for (const perm of permissions) {\n permissionsMap[perm] = false;\n }\n\n // Retrieve the permissions information for the given apk.\n const pmDumpLogs = (\n await this.runShellCommand(deviceId, ['pm', 'dump', apk])\n ).split('\\n');\n\n // Set to true the required permissions that have been granted.\n for (const line of pmDumpLogs) {\n for (const perm of permissions) {\n if (\n line.includes(`${perm}: granted=true`) ||\n line.includes(`${perm}, granted=true`)\n ) {\n permissionsMap[perm] = true;\n }\n }\n }\n\n for (const perm of permissions) {\n if (!permissionsMap[perm]) {\n throw new UsageError(\n `Required ${perm} has not be granted for ${apk}. ` +\n 'Please grant them using the Android Settings ' +\n 'or using the following adb command:\\n' +\n `\\t adb shell pm grant ${apk} ${perm}\\n`\n );\n }\n }\n }\n\n async amForceStopAPK(deviceId: string, apk: string): Promise<void> {\n await this.runShellCommand(deviceId, ['am', 'force-stop', apk]);\n }\n\n async getOrCreateArtifactsDir(deviceId: string): Promise<string> {\n let artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (artifactsDir) {\n return artifactsDir;\n }\n\n artifactsDir = `${DEVICE_DIR_BASE}${ARTIFACTS_DIR_PREFIX}${Date.now()}`;\n\n const testDirOut = (\n await this.runShellCommand(deviceId, `test -d ${artifactsDir} ; echo $?`)\n ).trim();\n\n if (testDirOut !== '1') {\n throw new WebExtError(\n `Cannot create artifacts directory ${artifactsDir} ` +\n `because it exists on ${deviceId}.`\n );\n }\n\n await this.runShellCommand(deviceId, ['mkdir', '-p', artifactsDir]);\n\n this.artifactsDirMap.set(deviceId, artifactsDir);\n\n return artifactsDir;\n }\n\n async detectOrRemoveOldArtifacts(\n deviceId: string,\n removeArtifactDirs?: boolean = false\n ): Promise<boolean> {\n const { adbClient } = this;\n\n log.debug('Checking adb device for existing web-ext artifacts dirs');\n\n return wrapADBCall(async () => {\n const files = await adbClient\n .getDevice(deviceId)\n .readdir(DEVICE_DIR_BASE);\n let found = false;\n\n for (const file of files) {\n if (\n !file.isDirectory() ||\n !file.name.startsWith(ARTIFACTS_DIR_PREFIX)\n ) {\n continue;\n }\n\n // Return earlier if we only need to warn the user that some\n // existing artifacts dirs have been found on the adb device.\n if (!removeArtifactDirs) {\n return true;\n }\n\n found = true;\n\n const artifactsDir = `${DEVICE_DIR_BASE}${file.name}`;\n\n log.debug(\n `Removing artifacts directory ${artifactsDir} from device ${deviceId}`\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n return found;\n });\n }\n\n async clearArtifactsDir(deviceId: string): Promise<void> {\n const artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (!artifactsDir) {\n // nothing to do here.\n return;\n }\n\n this.artifactsDirMap.delete(deviceId);\n\n log.debug(\n `Removing ${artifactsDir} artifacts directory on ${deviceId} device`\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n async pushFile(\n deviceId: string,\n localPath: string,\n devicePath: string\n ): Promise<void> {\n const { adbClient } = this;\n\n log.debug(`Pushing ${localPath} to ${devicePath} on ${deviceId}`);\n\n await wrapADBCall(async () => {\n await adbClient\n .getDevice(deviceId)\n .push(localPath, devicePath)\n .then(function (transfer) {\n return new Promise((resolve) => {\n transfer.on('end', resolve);\n });\n });\n });\n }\n\n async startFirefoxAPK(\n deviceId: string,\n apk: string,\n apkComponent: ?string,\n deviceProfileDir: string\n ): Promise<void> {\n const { adbClient } = this;\n\n log.debug(`Starting ${apk} on ${deviceId}`);\n\n // Fenix does ignore the -profile parameter, on the contrary Fennec\n // would run using the given path as the profile to be used during\n // this execution.\n const extras = [\n {\n key: 'args',\n value: `-profile ${deviceProfileDir}`,\n },\n ];\n\n if (!apkComponent) {\n apkComponent = '.App';\n if (defaultApkComponents[apk]) {\n apkComponent = defaultApkComponents[apk];\n }\n } else if (!apkComponent.includes('.')) {\n apkComponent = `.${apkComponent}`;\n }\n\n // if `apk` is a browser package or the `apk` has a\n // browser package prefix: prepend the package identifier\n // before `apkComponent`\n if (apkComponent.startsWith('.')) {\n for (const browser of packageIdentifiers) {\n if (apk === browser || apk.startsWith(`${browser}.`)) {\n apkComponent = browser + apkComponent;\n }\n }\n }\n\n // if `apkComponent` starts with a '.', then adb will expand\n // the following to: `${apk}/${apk}.${apkComponent}`\n const component = `${apk}/${apkComponent}`;\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.activity.MAIN',\n component,\n extras,\n });\n });\n }\n\n setUserAbortDiscovery(value: boolean) {\n this.userAbortDiscovery = value;\n }\n\n async discoverRDPUnixSocket(\n deviceId: string,\n apk: string,\n { maxDiscoveryTime, retryInterval }: DiscoveryParams = {}\n ): Promise<string> {\n let rdpUnixSockets = [];\n\n const discoveryStartedAt = Date.now();\n const msg =\n `Waiting for ${apk} Remote Debugging Server...` +\n '\\nMake sure to enable \"Remote Debugging via USB\" ' +\n 'from Settings -> Developer Tools if it is not yet enabled.';\n\n while (rdpUnixSockets.length === 0) {\n log.info(msg);\n if (this.userAbortDiscovery) {\n throw new UsageError(\n 'Exiting Firefox Remote Debugging socket discovery on user request'\n );\n }\n\n if (Date.now() - discoveryStartedAt > maxDiscoveryTime) {\n throw new WebExtError(\n 'Timeout while waiting for the Android Firefox Debugger Socket'\n );\n }\n\n rdpUnixSockets = (\n await this.runShellCommand(deviceId, ['cat', '/proc/net/unix'])\n )\n .split('\\n')\n .filter((line) => {\n // The RDP unix socket is expected to be a path in the form:\n // /data/data/org.mozilla.fennec_rpl/firefox-debugger-socket\n return line.trim().endsWith(`${apk}/firefox-debugger-socket`);\n });\n\n if (rdpUnixSockets.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, retryInterval));\n }\n }\n\n // Convert into an array of unix socket filenames.\n rdpUnixSockets = rdpUnixSockets.map((line) => {\n return line.trim().split(/\\s/).pop();\n });\n\n if (rdpUnixSockets.length > 1) {\n throw new WebExtError(\n 'Unexpected multiple RDP sockets: ' +\n `${JSON.stringify(rdpUnixSockets)}`\n );\n }\n\n return rdpUnixSockets[0];\n }\n\n async setupForward(deviceId: string, remote: string, local: string) {\n const { adbClient } = this;\n\n // TODO(rpl): we should use adb.listForwards and reuse the existing one if any (especially\n // because adbkit doesn't seem to support `adb forward --remote` yet).\n log.debug(`Configuring ADB forward for ${deviceId}: ${remote} -> ${local}`);\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).forward(local, remote);\n });\n }\n}\n\nexport async function listADBDevices(adbBin?: string): Promise<Array<string>> {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverDevices();\n}\n\nexport async function listADBFirefoxAPKs(\n deviceId: string,\n adbBin?: string\n): Promise<Array<string>> {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverInstalledFirefoxAPKs(deviceId);\n}\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,sBAAsB;AAEzC,SAASC,eAAe,EAAEC,UAAU,EAAEC,WAAW,QAAQ,cAAc;AACvE,SAASC,YAAY,QAAQ,mBAAmB;AAChD,OAAOC,kBAAkB,IACvBC,oBAAoB,QACf,mCAAmC;AAE1C,OAAO,MAAMC,eAAe,GAAG,kBAAkB;AACjD,OAAO,MAAMC,oBAAoB,GAAG,oBAAoB;AAExD,MAAMC,UAAU,GAAGT,MAAM,CAACU,OAAO;AAEjC,MAAMC,GAAG,GAAGP,YAAY,CAACQ,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAgBzC;AACA,eAAeC,WAAW,CAACC,OAAiC,EAAgB;EAC1E,IAAI;IACF,OAAO,MAAMA,OAAO,EAAE;EACxB,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,IACEhB,eAAe,CAAC,QAAQ,EAAEgB,KAAK,CAAC,IAChCA,KAAK,CAACC,OAAO,CAACC,QAAQ,CAAC,WAAW,CAAC,EACnC;MACA,MAAM,IAAIjB,UAAU,CAClB,oCAAoC,GAClC,+CAA+C,GAC/C,qCAAqC,CACxC;IACH;IAEA,MAAMe,KAAK;EACb;AACF;AAEA,eAAe,MAAMG,QAAQ,CAAC;EAGZ;;EAEhB;;EAEA;EACA;;EAGAC,WAAW,CAACC,MAAsB,EAAE;IAClC,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAM;MAAEC,GAAG;MAAEC,MAAM;MAAEC,OAAO;MAAE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,KAAa,EAAE;IAClE,MAAM;MAAElG;IAAU,CAAC,GAAG,IAAI;;IAE1B;IACA;IACAhB,GAAG,CAAC2B,KAAK,CAAE,+BAA8BF,QAAS,KAAIwF,MAAO,OAAMC,KAAM,EAAC,CAAC;IAE3E,MAAM9G,WAAW,CAAC,YAAY;MAC5B,MAAMY,SAAS,CAACc,SAAS,CAACL,QAAQ,CAAC,CAAC0F,OAAO,CAACD,KAAK,EAAED,MAAM,CAAC;IAC5D,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,eAAeG,cAAc,CAACvG,MAAe,EAA0B;EAC5E,MAAMwG,QAAQ,GAAG,IAAI5G,QAAQ,CAAC;IAAEI;EAAO,CAAC,CAAC;EACzC,OAAOwG,QAAQ,CAAChF,eAAe,EAAE;AACnC;AAEA,OAAO,eAAeiF,kBAAkB,CACtC7F,QAAgB,EAChBZ,MAAe,EACS;EACxB,MAAMwG,QAAQ,GAAG,IAAI5G,QAAQ,CAAC;IAAEI;EAAO,CAAC,CAAC;EACzC,OAAOwG,QAAQ,CAAC1E,4BAA4B,CAAClB,QAAQ,CAAC;AACxD"}
@@ -1,4 +1,3 @@
1
-
2
1
  import { fs } from 'mz';
3
2
  import defaultAsyncMkdirp from 'mkdirp';
4
3
  import { UsageError, isErrorWithCode } from '../errors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["fs","defaultAsyncMkdirp","UsageError","isErrorWithCode","createLogger","log","import","meta","url","defaultAsyncFsAccess","access","bind","prepareArtifactsDir","artifactsDir","asyncMkdirp","asyncFsAccess","stats","stat","isDirectory","W_OK","accessErr","error","debug","mkdirErr"],"sources":["../../src/util/artifacts.js"],"sourcesContent":["/* @flow */\nimport {fs} from 'mz';\nimport defaultAsyncMkdirp from 'mkdirp';\n\nimport {UsageError, isErrorWithCode} from '../errors.js';\nimport {createLogger} from './logger.js';\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsAccess: typeof fs.access = fs.access.bind(fs);\n\ntype PrepareArtifactsDirOptions = {\n asyncMkdirp?: typeof defaultAsyncMkdirp,\n asyncFsAccess?: typeof defaultAsyncFsAccess,\n}\n\nexport async function prepareArtifactsDir(\n artifactsDir: string,\n {\n asyncMkdirp = defaultAsyncMkdirp,\n asyncFsAccess = defaultAsyncFsAccess,\n }: PrepareArtifactsDirOptions = {},\n): Promise<string> {\n try {\n const stats = await fs.stat(artifactsDir);\n if (!stats.isDirectory()) {\n throw new UsageError(\n `--artifacts-dir=\"${artifactsDir}\" exists but it is not a directory.`);\n }\n // If the artifactsDir already exists, check that we have the write permissions on it.\n try {\n await asyncFsAccess(artifactsDir, fs.W_OK);\n } catch (accessErr) {\n if (isErrorWithCode('EACCES', accessErr)) {\n throw new UsageError(\n `--artifacts-dir=\"${artifactsDir}\" exists but the user lacks ` +\n 'permissions on it.');\n } else {\n throw accessErr;\n }\n }\n } catch (error) {\n if (isErrorWithCode('EACCES', error)) {\n // Handle errors when the artifactsDir cannot be accessed.\n throw new UsageError(\n `Cannot access --artifacts-dir=\"${artifactsDir}\" because the user ` +\n `lacks permissions: ${error}`);\n } else if (isErrorWithCode('ENOENT', error)) {\n // Create the artifact dir if it doesn't exist yet.\n try {\n log.debug(`Creating artifacts directory: ${artifactsDir}`);\n await asyncMkdirp(artifactsDir);\n } catch (mkdirErr) {\n if (isErrorWithCode('EACCES', mkdirErr)) {\n // Handle errors when the artifactsDir cannot be created for lack of permissions.\n throw new UsageError(\n `Cannot create --artifacts-dir=\"${artifactsDir}\" because the ` +\n `user lacks permissions: ${mkdirErr}`);\n } else {\n throw mkdirErr;\n }\n }\n } else {\n throw error;\n }\n }\n\n return artifactsDir;\n}\n"],"mappings":";AACA,SAAQA,EAAE,QAAO,IAAI;AACrB,OAAOC,kBAAkB,MAAM,QAAQ;AAEvC,SAAQC,UAAU,EAAEC,eAAe,QAAO,cAAc;AACxD,SAAQC,YAAY,QAAO,aAAa;AAExC,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI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rB,UAAU,CACjB,kCAAiCW,YAAa,gBAAe,GAC7D,2BAA0BU,QAAS,EAAC,CAAC;QAC1C,CAAC,MAAM;UACL,MAAMA,QAAQ;QAChB;MACF;IACF,CAAC,MAAM;MACL,MAAMF,KAAK;IACb;EACF;EAEA,OAAOR,YAAY;AACrB"}
1
+ {"version":3,"file":"artifacts.js","names":["fs","defaultAsyncMkdirp","UsageError","isErrorWithCode","createLogger","log","import","meta","url","defaultAsyncFsAccess","access","bind","prepareArtifactsDir","artifactsDir","asyncMkdirp","asyncFsAccess","stats","stat","isDirectory","W_OK","accessErr","error","debug","mkdirErr"],"sources":["../../src/util/artifacts.js"],"sourcesContent":["/* @flow */\nimport { fs } from 'mz';\nimport defaultAsyncMkdirp from 'mkdirp';\n\nimport { UsageError, isErrorWithCode } from '../errors.js';\nimport { createLogger } from './logger.js';\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsAccess: typeof fs.access = fs.access.bind(fs);\n\ntype PrepareArtifactsDirOptions = {\n asyncMkdirp?: typeof defaultAsyncMkdirp,\n asyncFsAccess?: typeof defaultAsyncFsAccess,\n};\n\nexport async function prepareArtifactsDir(\n artifactsDir: string,\n {\n asyncMkdirp = defaultAsyncMkdirp,\n asyncFsAccess = defaultAsyncFsAccess,\n }: PrepareArtifactsDirOptions = {}\n): Promise<string> {\n try {\n const stats = await fs.stat(artifactsDir);\n if (!stats.isDirectory()) {\n throw new UsageError(\n `--artifacts-dir=\"${artifactsDir}\" exists but it is not a directory.`\n );\n }\n // If the artifactsDir already exists, check that we have the write permissions on it.\n try {\n await asyncFsAccess(artifactsDir, fs.W_OK);\n } catch (accessErr) {\n if (isErrorWithCode('EACCES', accessErr)) {\n throw new UsageError(\n `--artifacts-dir=\"${artifactsDir}\" exists but the user lacks ` +\n 'permissions on it.'\n );\n } else {\n throw accessErr;\n }\n }\n } catch (error) {\n if (isErrorWithCode('EACCES', error)) {\n // Handle errors when the artifactsDir cannot be accessed.\n throw new UsageError(\n `Cannot access --artifacts-dir=\"${artifactsDir}\" because the user ` +\n `lacks permissions: ${error}`\n );\n } else if (isErrorWithCode('ENOENT', error)) {\n // Create the artifact dir if it doesn't exist yet.\n try {\n log.debug(`Creating artifacts directory: ${artifactsDir}`);\n await asyncMkdirp(artifactsDir);\n } catch (mkdirErr) {\n if (isErrorWithCode('EACCES', mkdirErr)) {\n // Handle errors when the artifactsDir cannot be created for lack of permissions.\n throw new UsageError(\n `Cannot create --artifacts-dir=\"${artifactsDir}\" because the ` +\n `user lacks permissions: ${mkdirErr}`\n );\n } else {\n throw mkdirErr;\n }\n }\n } else {\n throw error;\n }\n }\n\n return artifactsDir;\n}\n"],"mappings":"AACA,SAASA,EAAE,QAAQ,IAAI;AACvB,OAAOC,kBAAkB,MAAM,QAAQ;AAEvC,SAASC,UAAU,EAAEC,eAAe,QAAQ,cAAc;AAC1D,SAASC,YAAY,QAAQ,aAAa;AAE1C,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAEzC,MAAMC,oBAAsC,GAAGT,EAAE,CAACU,MAAM,CAACC,IAAI,CAACX,EAAE,CAAC;AAOjE,OAAO,eAAeY,mBAAmB,CACvCC,YAAoB,EACpB;EACEC,WAAW,GAAGb,kBAAkB;EAChCc,aAAa,GAAGN;AACU,CAAC,GAAG,CAAC,CAAC,EACjB;EACjB,IAAI;IACF,MAAMO,KAAK,GAAG,MAAMhB,EAAE,CAACiB,IAAI,CAACJ,YAAY,CAAC;IACzC,IAAI,CAACG,KAAK,CAACE,WAAW,EAAE,EAAE;MACxB,MAAM,IAAIhB,UAAU,CACjB,oBAAmBW,YAAa,qCAAoC,CACtE;IACH;IACA;IACA,IAAI;MACF,MAAME,aAAa,CAACF,YAAY,EAAEb,EAAE,CAACmB,IAAI,CAAC;IAC5C,CAAC,CAAC,OAAOC,SAAS,EAAE;MAClB,IAAIjB,eAAe,CAAC,QAAQ,EAAEiB,SAAS,CAAC,EAAE;QACxC,MAAM,IAAIlB,UAAU,CACjB,oBAAmBW,YAAa,8BAA6B,GAC5D,oBAAoB,CACvB;MACH,CAAC,MAAM;QACL,MAAMO,SAAS;MACjB;IACF;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,IAAIlB,eAAe,CAAC,QAAQ,EAAEkB,KAAK,CAAC,EAAE;MACpC;MACA,MAAM,IAAInB,UAAU,CACjB,kCAAiCW,YAAa,qBAAoB,GAChE,sBAAqBQ,KAAM,EAAC,CAChC;IACH,CAAC,MAAM,IAAIlB,eAAe,CAAC,QAAQ,EAAEkB,KAAK,CAAC,EAAE;MAC3C;MACA,IAAI;QACFhB,GAAG,CAACiB,KAAK,CAAE,iCAAgCT,YAAa,EAAC,CAAC;QAC1D,MAAMC,WAAW,CAACD,YAAY,CAAC;MACjC,CAAC,CAAC,OAAOU,QAAQ,EAAE;QACjB,IAAIpB,eAAe,CAAC,QAAQ,EAAEoB,QAAQ,CAAC,EAAE;UACvC;UACA,MAAM,IAAIrB,UAAU,CACjB,kCAAiCW,YAAa,gBAAe,GAC3D,2BAA0BU,QAAS,EAAC,CACxC;QACH,CAAC,MAAM;UACL,MAAMA,QAAQ;QAChB;MACF;IACF,CAAC,MAAM;MACL,MAAMF,KAAK;IACb;EACF;EAEA,OAAOR,YAAY;AACrB"}
@@ -1,4 +1,3 @@
1
-
2
1
  import defaultNotifier from 'node-notifier';
3
2
  import { createLogger } from './logger.js';
4
3
  const defaultLog = createLogger(import.meta.url);
@@ -1 +1 @@
1
- {"version":3,"file":"desktop-notifier.js","names":["defaultNotifier","createLogger","defaultLog","import","meta","url","showDesktopNotification","title","message","icon","notifier","log","Promise","resolve","reject","notify","err","res","debug"],"sources":["../../src/util/desktop-notifier.js"],"sourcesContent":["/* @flow */\nimport defaultNotifier from 'node-notifier';\n\nimport {createLogger} from './logger.js';\nimport type {Logger} from './logger';\n\nconst defaultLog = createLogger(import.meta.url);\n\nexport type DesktopNotificationsParams = {|\n title: string,\n message: string,\n icon?: string,\n|};\n\nexport type DesktopNotificationsOptions = {\n notifier?: typeof defaultNotifier,\n log?: Logger,\n};\n\nexport function showDesktopNotification(\n {\n title, message, icon,\n }: DesktopNotificationsParams,\n {\n notifier = defaultNotifier,\n log = defaultLog,\n }: DesktopNotificationsOptions = {}\n): Promise<void> {\n\n return new Promise((resolve, reject) => {\n notifier.notify({title, message, icon}, (err, res) => {\n if (err) {\n log.debug(`Desktop notifier error: ${err.message},` +\n ` response: ${res}`);\n reject(err);\n } else {\n resolve();\n }\n });\n });\n}\n"],"mappings":";AACA,OAAOA,eAAe,MAAM,eAAe;AAE3C,SAAQC,YAAY,QAAO,aAAa;AAGxC,MAAMC,UAAU,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAahD,OAAO,SAASC,uBAAuB,CACrC;EACEC,KAAK;EAAEC,OAAO;EAAEC;AACU,CAAC,EAC7B;EACEC,QAAQ,GAAGV,eAAe;EAC1BW,GAAG,GAAGT;AACqB,CAAC,GAAG,CAAC,CAAC,EACpB;EAEf,OAAO,IAAIU,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtCJ,QAAQ,CAACK,MAAM,CAAC;MAACR,KAAK;MAAEC,OAAO;MAAEC;IAAI,CAAC,EAAE,CAACO,GAAG,EAAEC,GAAG,KAAK;MACpD,IAAID,GAAG,EAAE;QACPL,GAAG,CAACO,KAAK,CAAE,2BAA0BF,GAAG,CAACR,OAAQ,GAAE,GACzC,cAAaS,GAAI,EAAC,CAAC;QAC7BH,MAAM,CAACE,GAAG,CAAC;MACb,CAAC,MAAM;QACLH,OAAO,EAAE;MACX;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"desktop-notifier.js","names":["defaultNotifier","createLogger","defaultLog","import","meta","url","showDesktopNotification","title","message","icon","notifier","log","Promise","resolve","reject","notify","err","res","debug"],"sources":["../../src/util/desktop-notifier.js"],"sourcesContent":["/* @flow */\nimport defaultNotifier from 'node-notifier';\n\nimport { createLogger } from './logger.js';\nimport type { Logger } from './logger';\n\nconst defaultLog = createLogger(import.meta.url);\n\nexport type DesktopNotificationsParams = {|\n title: string,\n message: string,\n icon?: string,\n|};\n\nexport type DesktopNotificationsOptions = {\n notifier?: typeof defaultNotifier,\n log?: Logger,\n};\n\nexport function showDesktopNotification(\n { title, message, icon }: DesktopNotificationsParams,\n {\n notifier = defaultNotifier,\n log = defaultLog,\n }: DesktopNotificationsOptions = {}\n): Promise<void> {\n return new Promise((resolve, reject) => {\n notifier.notify({ title, message, icon }, (err, res) => {\n if (err) {\n log.debug(\n `Desktop notifier error: ${err.message},` + ` response: ${res}`\n );\n reject(err);\n } else {\n resolve();\n }\n });\n });\n}\n"],"mappings":"AACA,OAAOA,eAAe,MAAM,eAAe;AAE3C,SAASC,YAAY,QAAQ,aAAa;AAG1C,MAAMC,UAAU,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAahD,OAAO,SAASC,uBAAuB,CACrC;EAAEC,KAAK;EAAEC,OAAO;EAAEC;AAAiC,CAAC,EACpD;EACEC,QAAQ,GAAGV,eAAe;EAC1BW,GAAG,GAAGT;AACqB,CAAC,GAAG,CAAC,CAAC,EACpB;EACf,OAAO,IAAIU,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtCJ,QAAQ,CAACK,MAAM,CAAC;MAAER,KAAK;MAAEC,OAAO;MAAEC;IAAK,CAAC,EAAE,CAACO,GAAG,EAAEC,GAAG,KAAK;MACtD,IAAID,GAAG,EAAE;QACPL,GAAG,CAACO,KAAK,CACN,2BAA0BF,GAAG,CAACR,OAAQ,GAAE,GAAI,cAAaS,GAAI,EAAC,CAChE;QACDH,MAAM,CAACE,GAAG,CAAC;MACb,CAAC,MAAM;QACLH,OAAO,EAAE;MACX;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ"}
@@ -1,4 +1,3 @@
1
-
2
1
  import { fs } from 'mz';
3
2
  import { isErrorWithCode } from '../errors.js';
4
3
  /*