web-ext 7.12.0 → 8.0.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 (66) hide show
  1. package/README.md +6 -8
  2. package/bin/web-ext.js +1 -1
  3. package/lib/cmd/build.js +1 -3
  4. package/lib/cmd/build.js.map +1 -1
  5. package/lib/cmd/docs.js +1 -0
  6. package/lib/cmd/docs.js.map +1 -1
  7. package/lib/cmd/dump-config.js +6 -0
  8. package/lib/cmd/dump-config.js.map +1 -0
  9. package/lib/cmd/index.js +16 -8
  10. package/lib/cmd/index.js.map +1 -1
  11. package/lib/cmd/lint.js +0 -8
  12. package/lib/cmd/lint.js.map +1 -1
  13. package/lib/cmd/run.js +0 -7
  14. package/lib/cmd/run.js.map +1 -1
  15. package/lib/cmd/sign.js +29 -85
  16. package/lib/cmd/sign.js.map +1 -1
  17. package/lib/config.js +53 -7
  18. package/lib/config.js.map +1 -1
  19. package/lib/errors.js.map +1 -1
  20. package/lib/extension-runners/chromium.js +11 -3
  21. package/lib/extension-runners/chromium.js.map +1 -1
  22. package/lib/extension-runners/firefox-android.js +15 -3
  23. package/lib/extension-runners/firefox-android.js.map +1 -1
  24. package/lib/extension-runners/firefox-desktop.js +7 -8
  25. package/lib/extension-runners/firefox-desktop.js.map +1 -1
  26. package/lib/extension-runners/index.js +2 -2
  27. package/lib/extension-runners/index.js.map +1 -1
  28. package/lib/firefox/index.js +1 -8
  29. package/lib/firefox/index.js.map +1 -1
  30. package/lib/firefox/package-identifiers.js +3 -1
  31. package/lib/firefox/package-identifiers.js.map +1 -1
  32. package/lib/firefox/preferences.js +0 -2
  33. package/lib/firefox/preferences.js.map +1 -1
  34. package/lib/firefox/rdp-client.js +10 -2
  35. package/lib/firefox/rdp-client.js.map +1 -1
  36. package/lib/firefox/remote.js +3 -2
  37. package/lib/firefox/remote.js.map +1 -1
  38. package/lib/main.js.map +1 -1
  39. package/lib/program.js +25 -48
  40. package/lib/program.js.map +1 -1
  41. package/lib/util/adb.js +15 -9
  42. package/lib/util/adb.js.map +1 -1
  43. package/lib/util/artifacts.js.map +1 -1
  44. package/lib/util/desktop-notifier.js.map +1 -1
  45. package/lib/util/file-exists.js +1 -0
  46. package/lib/util/file-exists.js.map +1 -1
  47. package/lib/util/file-filter.js +2 -0
  48. package/lib/util/file-filter.js.map +1 -1
  49. package/lib/util/is-directory.js.map +1 -1
  50. package/lib/util/logger.js +5 -5
  51. package/lib/util/logger.js.map +1 -1
  52. package/lib/util/manifest.js +1 -1
  53. package/lib/util/manifest.js.map +1 -1
  54. package/lib/util/promisify.js +0 -7
  55. package/lib/util/promisify.js.map +1 -1
  56. package/lib/util/stdin.js +0 -2
  57. package/lib/util/stdin.js.map +1 -1
  58. package/lib/util/submit-addon.js +214 -50
  59. package/lib/util/submit-addon.js.map +1 -1
  60. package/lib/util/temp-dir.js +2 -0
  61. package/lib/util/temp-dir.js.map +1 -1
  62. package/lib/util/updates.js.map +1 -1
  63. package/lib/watcher.js.map +1 -1
  64. package/package.json +36 -38
  65. package/lib/extension-runners/base.js +0 -2
  66. package/lib/extension-runners/base.js.map +0 -1
@@ -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","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 'disable-progress-bar': {\n describe: 'Disable the progress bar in sign-addon',\n demandOption: false,\n type: 'boolean',\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 (or deved). ' +\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;AAE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ACVH,IAAI,EAAE,SAAS;MACfK,OAAO,EAAE;IACX,CAAC;IACDqB,MAAM,EAAE;MACN3B,QAAQ,EAAE,sBAAsB;MAChCC,IAAI,EAAE,SAAS;MACfK,OAAO,EAAE;IACX,CAAC;IACDsB,UAAU,EAAE;MACV5B,QAAQ,EAAE,gDAAgD;MAC1DC,IAAI,EAAE,SAAS;MACfK,OAAO,EAAE;IACX,CAAC;IACD,aAAa,EAAE;MACbN,QAAQ,EACN,6DAA6D,GAC7D,2CAA2C;MAC7CC,IAAI,EAAE,SAAS;MACfK,OAAO,EAAE;IACX,CAAC;IACDuB,MAAM,EAAE;MACN7B,QAAQ,EAAE,gCAAgC;MAC1CC,IAAI,EAAE,SAAS;MACfK,OAAO,EAAE;IACX,CAAC;IACD,iBAAiB,EAAEP;EACrB,CAAC,CAAC,CACDjG,OAAO,CACN,MAAM,EACN,6CAA6C,EAC7CF,QAAQ,CAACkI,IAAI,EACb,CAAC,CACH,CAAC;EAEH,OAAOhC,OAAO,CAACpC,OAAO,CAAC;IAAEC,UAAU;IAAE,GAAGkC;EAAW,CAAC,CAAC;AACvD"}
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","absolutePackageDir","commands","shouldExitProgram","verboseEnabled","options","programArgv","demandedOptions","constructor","argv","process","cwd","slice","yargsInstance","parserConfiguration","strict","wrap","terminalWidth","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","getDemandedOptions","args","err","message","startsWith","configDiscovery","noConfigDiscovery","reload","noReload","input","noInput","ignoreFiles","length","startUrl","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","Array","isArray","main","runOptions","program","usage","help","alias","recommendCommands","describe","default","requiresArg","type","coerce","arg","normalize","hidden","build","filename","dumpConfig","sign","timeout","channel","run","target","choices","firefox","pref","devtools","lint","output","metadata","pretty","privileged","boring","docs"],"sources":["../src/program.js"],"sourcesContent":["import 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\nexport const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir;\n yargs;\n commands;\n shouldExitProgram;\n verboseEnabled;\n options;\n programArgv;\n demandedOptions;\n\n constructor(argv, { absolutePackageDir = process.cwd() } = {}) {\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(name, description, executor, commandOptions = {}) {\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) {\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, version) {\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() {\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 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) {\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) {\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 } = {}) {\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.debug(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`,\n );\n }\n\n for (const configFileName of configFiles) {\n const configObject = await 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\n\nexport async function defaultVersionGetter(\n absolutePackageDir,\n { globalEnv = defaultGlobalEnv } = {},\n) {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData = 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\nexport function throwUsageErrorIfArray(errorMessage) {\n return (value) => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir,\n {\n getVersion = defaultVersionGetter,\n commands = defaultCommands,\n argv,\n runOptions = {},\n } = {},\n) {\n const program = new Program(argv, { absolutePackageDir });\n const version = await getVersion(absolutePackageDir);\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 'dump-config',\n 'Run config discovery and dump the resulting config data as JSON',\n commands.dumpConfig,\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: 'Submission API URL prefix',\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-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 timeout: {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n 'approval-timeout': {\n describe:\n 'Number of milliseconds to wait for approval before giving up. ' +\n 'Set to 0 to disable waiting for approval. Fallback to `timeout` if not set.',\n type: 'number',\n },\n channel: {\n describe:\n \"The channel for which to sign the addon. Either 'listed' or 'unlisted'.\",\n demandOption: true,\n type: 'string',\n },\n 'amo-metadata': {\n describe:\n 'Path to a JSON file containing an object with metadata to be passed to the API. ' +\n 'See https://addons-server.readthedocs.io/en/latest/topics/api/addons.html for details.',\n type: 'string',\n },\n 'upload-source-code': {\n describe:\n 'Path to an archive file containing human readable source code of this submission, ' +\n 'if the code in --source-dir has been processed to make it unreadable. ' +\n 'See https://extensionworkshop.com/documentation/publish/source-code-submission/ for ' +\n 'details.',\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 (or deved). ' +\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 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 })\n .command(\n 'docs',\n 'Open the web-ext documentation in a brow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D,QAAQ,EACN,6DAA6D,GAC7D,2CAA2C;MAC7CG,IAAI,EAAE,SAAS;MACfF,OAAO,EAAE;IACX,CAAC;IACDwB,MAAM,EAAE;MACNzB,QAAQ,EAAE,gCAAgC;MAC1CG,IAAI,EAAE,SAAS;MACfF,OAAO,EAAE;IACX;EACF,CAAC,CAAC,CACDpG,OAAO,CACN,MAAM,EACN,6CAA6C,EAC7ChB,QAAQ,CAAC6I,IAAI,EACb,CAAC,CACH,CAAC;EAEH,OAAO/B,OAAO,CAACtC,OAAO,CAAC;IAAEC,UAAU;IAAE,GAAGoC;EAAW,CAAC,CAAC;AACvD","ignoreList":[]}
package/lib/util/adb.js CHANGED
@@ -6,6 +6,7 @@ export const DEVICE_DIR_BASE = '/data/local/tmp/';
6
6
  export const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-';
7
7
  const defaultADB = ADBKit.default;
8
8
  const log = createLogger(import.meta.url);
9
+
9
10
  // Helper function used to raise an UsageError when the adb binary has not been found.
10
11
  async function wrapADBCall(asyncFn) {
11
12
  try {
@@ -18,13 +19,15 @@ async function wrapADBCall(asyncFn) {
18
19
  }
19
20
  }
20
21
  export default class ADBUtils {
21
- // TODO: better flow typing here.
22
+ params;
23
+ adb;
24
+ adbClient;
22
25
 
23
26
  // Map<deviceId -> artifactsDir>
24
-
27
+ artifactsDirMap;
25
28
  // Toggled when the user wants to abort the RDP Unix Socket discovery loop
26
29
  // while it is still executing.
27
-
30
+ userAbortDiscovery;
28
31
  constructor(params) {
29
32
  this.params = params;
30
33
  const {
@@ -176,20 +179,23 @@ export default class ADBUtils {
176
179
  apkComponent = `.${apkComponent}`;
177
180
  }
178
181
 
179
- // if `apk` is a browser package or the `apk` has a
180
- // browser package prefix: prepend the package identifier
181
- // before `apkComponent`
182
+ // If `apk` is a browser package or the `apk` has a browser package prefix:
183
+ // prepend the package identifier before `apkComponent`.
182
184
  if (apkComponent.startsWith('.')) {
183
185
  for (const browser of packageIdentifiers) {
184
186
  if (apk === browser || apk.startsWith(`${browser}.`)) {
185
187
  apkComponent = browser + apkComponent;
188
+ break;
186
189
  }
187
190
  }
188
191
  }
189
192
 
190
- // if `apkComponent` starts with a '.', then adb will expand
191
- // the following to: `${apk}/${apk}.${apkComponent}`
192
- const component = `${apk}/${apkComponent}`;
193
+ // If `apkComponent` starts with a '.', then adb will expand the following
194
+ // to: `${apk}/${apk}.${apkComponent}`
195
+ let component = `${apk}`;
196
+ if (apkComponent) {
197
+ component += `/${apkComponent}`;
198
+ }
193
199
  await wrapADBCall(async () => {
194
200
  try {
195
201
  // TODO: once Fenix (release) uses Android 13, we can get rid of this
@@ -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","getCurrentUser","currentUser","userId","parseInt","trim","isNaN","discoverInstalledFirefoxAPKs","firefoxApk","pmList","split","line","replace","filter","browser","startsWith","amForceStopAPK","apk","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","category","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 getCurrentUser(deviceId: string): Promise<number> {\n log.debug(`Retrieving current user on ${deviceId}`);\n const currentUser = await this.runShellCommand(deviceId, [\n 'am',\n 'get-current-user',\n ]);\n\n const userId = parseInt(currentUser.trim());\n if (isNaN(userId)) {\n throw new WebExtError(`Unable to retrieve current user on ${deviceId}`);\n }\n\n return userId;\n }\n\n async discoverInstalledFirefoxAPKs(\n deviceId: string,\n firefoxApk?: string\n ): Promise<Array<string>> {\n const userId = await this.getCurrentUser(deviceId);\n\n log.debug(`Listing installed Firefox APKs on ${deviceId}`);\n const pmList = await this.runShellCommand(deviceId, [\n 'pm',\n 'list',\n 'packages',\n '--user',\n `${userId}`,\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 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 try {\n // TODO: once Fenix (release) uses Android 13, we can get rid of this\n // call and only use the second call in the `catch` block.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.activity.MAIN',\n component,\n extras,\n });\n } catch {\n // Android 13+ requires a different action/category but we still need\n // to support older Fenix builds.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.intent.action.MAIN',\n category: 'android.intent.category.LAUNCHER',\n component,\n extras,\n });\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,oB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CAACuD,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,IAAIP,cAAc,CAACG,MAAM,GAAG,CAAC,EAAE;MAC7B,MAAM,IAAI/G,WAAW,CACnB,mCAAmC,GAChC,GAAEoC,IAAI,CAACC,SAAS,CAACuE,cAAc,CAAE,EACtC,CAAC;IACH;IAEA,OAAOA,cAAc,CAAC,CAAC,CAAC;EAC1B;EAEA,MAAMQ,YAAYA,CAACnF,QAAgB,EAAEoF,MAAc,EAAEC,KAAa,EAAE;IAClE,MAAM;MAAE9F;IAAU,CAAC,GAAG,IAAI;;IAE1B;IACA;IACAhB,GAAG,CAAC2B,KAAK,CAAE,+BAA8BF,QAAS,KAAIoF,MAAO,OAAMC,KAAM,EAAC,CAAC;IAE3E,MAAM1G,WAAW,CAAC,YAAY;MAC5B,MAAMY,SAAS,CAACc,SAAS,CAACL,QAAQ,CAAC,CAACsF,OAAO,CAACD,KAAK,EAAED,MAAM,CAAC;IAC5D,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,eAAeG,cAAcA,CAACnG,MAAe,EAA0B;EAC5E,MAAMoG,QAAQ,GAAG,IAAIxG,QAAQ,CAAC;IAAEI;EAAO,CAAC,CAAC;EACzC,OAAOoG,QAAQ,CAAC5E,eAAe,CAAC,CAAC;AACnC;AAEA,OAAO,eAAe6E,kBAAkBA,CACtCzF,QAAgB,EAChBZ,MAAe,EACS;EACxB,MAAMoG,QAAQ,GAAG,IAAIxG,QAAQ,CAAC;IAAEI;EAAO,CAAC,CAAC;EACzC,OAAOoG,QAAQ,CAAChE,4BAA4B,CAACxB,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","params","adb","adbClient","artifactsDirMap","userAbortDiscovery","constructor","adbBin","adbHost","adbPort","createClient","bin","host","port","Map","runShellCommand","deviceId","cmd","debug","JSON","stringify","getDevice","shell","then","util","readAll","res","toString","discoverDevices","devices","listDevices","map","dev","id","getCurrentUser","currentUser","userId","parseInt","trim","isNaN","discoverInstalledFirefoxAPKs","firefoxApk","pmList","split","line","replace","filter","browser","startsWith","amForceStopAPK","apk","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","category","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":["import 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\n// Helper function used to raise an UsageError when the adb binary has not been found.\nasync function wrapADBCall(asyncFn) {\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;\n adb;\n adbClient;\n\n // Map<deviceId -> artifactsDir>\n artifactsDirMap;\n // Toggled when the user wants to abort the RDP Unix Socket discovery loop\n // while it is still executing.\n userAbortDiscovery;\n\n constructor(params) {\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(deviceId, cmd) {\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() {\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 getCurrentUser(deviceId) {\n log.debug(`Retrieving current user on ${deviceId}`);\n\n const currentUser = await this.runShellCommand(deviceId, [\n 'am',\n 'get-current-user',\n ]);\n\n const userId = parseInt(currentUser.trim());\n if (isNaN(userId)) {\n throw new WebExtError(`Unable to retrieve current user on ${deviceId}`);\n }\n return userId;\n }\n\n async discoverInstalledFirefoxAPKs(deviceId, firefoxApk) {\n const userId = await this.getCurrentUser(deviceId);\n\n log.debug(`Listing installed Firefox APKs on ${deviceId}`);\n const pmList = await this.runShellCommand(deviceId, [\n 'pm',\n 'list',\n 'packages',\n '--user',\n `${userId}`,\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 amForceStopAPK(deviceId, apk) {\n await this.runShellCommand(deviceId, ['am', 'force-stop', apk]);\n }\n\n async getOrCreateArtifactsDir(deviceId) {\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(deviceId, removeArtifactDirs = false) {\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) {\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(deviceId, localPath, devicePath) {\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(deviceId, apk, apkComponent, deviceProfileDir) {\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 browser package prefix:\n // prepend the package identifier before `apkComponent`.\n if (apkComponent.startsWith('.')) {\n for (const browser of packageIdentifiers) {\n if (apk === browser || apk.startsWith(`${browser}.`)) {\n apkComponent = browser + apkComponent;\n break;\n }\n }\n }\n\n // If `apkComponent` starts with a '.', then adb will expand the following\n // to: `${apk}/${apk}.${apkComponent}`\n let component = `${apk}`;\n if (apkComponent) {\n component += `/${apkComponent}`;\n }\n\n await wrapADBCall(async () => {\n try {\n // TODO: once Fenix (release) uses Android 13, we can get rid of this\n // call and only use the second call in the `catch` block.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.activity.MAIN',\n component,\n extras,\n });\n } catch {\n // Android 13+ requires a different action/category but we still need\n // to support older Fenix builds.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.intent.action.MAIN',\n category: 'android.intent.category.LAUNCHER',\n component,\n extras,\n });\n }\n });\n }\n\n setUserAbortDiscovery(value) {\n this.userAbortDiscovery = value;\n }\n\n async discoverRDPUnixSocket(\n deviceId,\n apk,\n { maxDiscoveryTime, retryInterval } = {},\n ) {\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, remote, local) {\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) {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverDevices();\n}\n\nexport async function listADBFirefoxAPKs(deviceId, adbBin) {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverInstalledFirefoxAPKs(deviceId);\n}\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,sBAAsB;AAEzC,SAAS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ACxD","ignoreList":[]}
@@ -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 }\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,mBAAmBA,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,CAAC,CAAC,EAAE;MACxB,MAAM,IAAIhB,UAAU,CACjB,oBAAmBW,YAAa,qCACnC,CAAC;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,oBACJ,CAAC;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,EAChC,CAAC;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,EACxC,CAAC;QACH,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":["import { 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 = fs.access.bind(fs);\n\nexport async function prepareArtifactsDir(\n artifactsDir,\n {\n asyncMkdirp = defaultAsyncMkdirp,\n asyncFsAccess = defaultAsyncFsAccess,\n } = {},\n) {\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":"AAAA,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,oBAAoB,GAAGT,EAAE,CAACU,MAAM,CAACC,IAAI,CAACX,EAAE,CAAC;AAE/C,OAAO,eAAeY,mBAAmBA,CACvCC,YAAY,EACZ;EACEC,WAAW,GAAGb,kBAAkB;EAChCc,aAAa,GAAGN;AAClB,CAAC,GAAG,CAAC,CAAC,EACN;EACA,IAAI;IACF,MAAMO,KAAK,GAAG,MAAMhB,EAAE,CAACiB,IAAI,CAACJ,YAAY,CAAC;IACzC,IAAI,CAACG,KAAK,CAACE,WAAW,CAAC,CAAC,EAAE;MACxB,MAAM,IAAIhB,UAAU,CAClB,oBAAoBW,YAAY,qCAClC,CAAC;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,CAClB,oBAAoBW,YAAY,8BAA8B,GAC5D,oBACJ,CAAC;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,CAClB,kCAAkCW,YAAY,qBAAqB,GACjE,sBAAsBQ,KAAK,EAC/B,CAAC;IACH,CAAC,MAAM,IAAIlB,eAAe,CAAC,QAAQ,EAAEkB,KAAK,CAAC,EAAE;MAC3C;MACA,IAAI;QACFhB,GAAG,CAACiB,KAAK,CAAC,iCAAiCT,YAAY,EAAE,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,CAClB,kCAAkCW,YAAY,gBAAgB,GAC5D,2BAA2BU,QAAQ,EACvC,CAAC;QACH,CAAC,MAAM;UACL,MAAMA,QAAQ;QAChB;MACF;IACF,CAAC,MAAM;MACL,MAAMF,KAAK;IACb;EACF;EAEA,OAAOR,YAAY;AACrB","ignoreList":[]}
@@ -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 { 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,uBAAuBA,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,EAChE,CAAC;QACDH,MAAM,CAACE,GAAG,CAAC;MACb,CAAC,MAAM;QACLH,OAAO,CAAC,CAAC;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":["import defaultNotifier from 'node-notifier';\n\nimport { createLogger } from './logger.js';\n\nconst defaultLog = createLogger(import.meta.url);\n\nexport function showDesktopNotification(\n { title, message, icon },\n { notifier = defaultNotifier, log = defaultLog } = {},\n) {\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":"AAAA,OAAOA,eAAe,MAAM,eAAe;AAE3C,SAASC,YAAY,QAAQ,aAAa;AAE1C,MAAMC,UAAU,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAEhD,OAAO,SAASC,uBAAuBA,CACrC;EAAEC,KAAK;EAAEC,OAAO;EAAEC;AAAK,CAAC,EACxB;EAAEC,QAAQ,GAAGV,eAAe;EAAEW,GAAG,GAAGT;AAAW,CAAC,GAAG,CAAC,CAAC,EACrD;EACA,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,CACP,2BAA2BF,GAAG,CAACR,OAAO,GAAG,GAAG,cAAcS,GAAG,EAC/D,CAAC;QACDH,MAAM,CAACE,GAAG,CAAC;MACb,CAAC,MAAM;QACLH,OAAO,CAAC,CAAC;MACX;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import { fs } from 'mz';
2
2
  import { isErrorWithCode } from '../errors.js';
3
+
3
4
  /*
4
5
  * Resolves true if the path is a readable file.
5
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"file-exists.js","names":["fs","isErrorWithCode","fileExists","path","fileIsReadable","f","access","constants","R_OK","stat","isFile","error"],"sources":["../../src/util/file-exists.js"],"sourcesContent":["/* @flow */\nimport { fs } from 'mz';\n\nimport { isErrorWithCode } from '../errors.js';\n\ntype FileExistsOptions = {\n fileIsReadable: (filePath: string) => Promise<boolean>,\n};\n\n/*\n * Resolves true if the path is a readable file.\n *\n * Usage:\n *\n * const exists = await fileExists(filePath);\n * if (exists) {\n * // ...\n * }\n *\n * */\nexport default async function fileExists(\n path: string,\n {\n fileIsReadable = (f) => fs.access(f, fs.constants.R_OK),\n }: FileExistsOptions = {}\n): Promise<boolean> {\n try {\n await fileIsReadable(path);\n const stat = await fs.stat(path);\n return stat.isFile();\n } catch (error) {\n if (isErrorWithCode(['EACCES', 'ENOENT'], error)) {\n return false;\n }\n throw error;\n }\n}\n"],"mappings":"AACA,SAASA,EAAE,QAAQ,IAAI;AAEvB,SAASC,eAAe,QAAQ,cAAc;AAM9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,UAAUA,CACtCC,IAAY,EACZ;EACEC,cAAc,GAAIC,CAAC,IAAKL,EAAE,CAACM,MAAM,CAACD,CAAC,EAAEL,EAAE,CAACO,SAAS,CAACC,IAAI;AACrC,CAAC,GAAG,CAAC,CAAC,EACP;EAClB,IAAI;IACF,MAAMJ,cAAc,CAACD,IAAI,CAAC;IAC1B,MAAMM,IAAI,GAAG,MAAMT,EAAE,CAACS,IAAI,CAACN,IAAI,CAAC;IAChC,OAAOM,IAAI,CAACC,MAAM,CAAC,CAAC;EACtB,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,IAAIV,eAAe,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAEU,KAAK,CAAC,EAAE;MAChD,OAAO,KAAK;IACd;IACA,MAAMA,KAAK;EACb;AACF"}
1
+ {"version":3,"file":"file-exists.js","names":["fs","isErrorWithCode","fileExists","path","fileIsReadable","f","access","constants","R_OK","stat","isFile","error"],"sources":["../../src/util/file-exists.js"],"sourcesContent":["import { fs } from 'mz';\n\nimport { isErrorWithCode } from '../errors.js';\n\n/*\n * Resolves true if the path is a readable file.\n *\n * Usage:\n *\n * const exists = await fileExists(filePath);\n * if (exists) {\n * // ...\n * }\n *\n * */\nexport default async function fileExists(\n path,\n { fileIsReadable = (f) => fs.access(f, fs.constants.R_OK) } = {},\n) {\n try {\n await fileIsReadable(path);\n const stat = await fs.stat(path);\n return stat.isFile();\n } catch (error) {\n if (isErrorWithCode(['EACCES', 'ENOENT'], error)) {\n return false;\n }\n throw error;\n }\n}\n"],"mappings":"AAAA,SAASA,EAAE,QAAQ,IAAI;AAEvB,SAASC,eAAe,QAAQ,cAAc;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,UAAUA,CACtCC,IAAI,EACJ;EAAEC,cAAc,GAAIC,CAAC,IAAKL,EAAE,CAACM,MAAM,CAACD,CAAC,EAAEL,EAAE,CAACO,SAAS,CAACC,IAAI;AAAE,CAAC,GAAG,CAAC,CAAC,EAChE;EACA,IAAI;IACF,MAAMJ,cAAc,CAACD,IAAI,CAAC;IAC1B,MAAMM,IAAI,GAAG,MAAMT,EAAE,CAACS,IAAI,CAACN,IAAI,CAAC;IAChC,OAAOM,IAAI,CAACC,MAAM,CAAC,CAAC;EACtB,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,IAAIV,eAAe,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAEU,KAAK,CAAC,EAAE;MAChD,OAAO,KAAK;IACd;IACA,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
@@ -22,6 +22,8 @@ export const isSubPath = (src, target) => {
22
22
  * Allows or ignores files.
23
23
  */
24
24
  export class FileFilter {
25
+ filesToIgnore;
26
+ sourceDir;
25
27
  constructor({
26
28
  baseIgnoredPatterns = ['**/*.xpi', '**/*.zip', '**/.*',
27
29
  // any hidden file and folder
@@ -1 +1 @@
1
- {"version":3,"file":"file-filter.js","names":["path","multimatch","createLogger","log","import","meta","url","isSubPath","src","target","relate","relative","startsWith","sep","FileFilter","constructor","baseIgnoredPatterns","ignoreFiles","sourceDir","artifactsDir","resolve","filesToIgnore","addToIgnoreList","debug","join","resolveWithSourceDir","file","resolvedPath","files","charAt","resolvedFile","substr","push","wantFile","filePath","matches","length","createFileFilter","params"],"sources":["../../src/util/file-filter.js"],"sourcesContent":["/* @flow */\nimport path from 'path';\n\nimport multimatch from 'multimatch';\n\nimport { createLogger } from './logger.js';\n\nconst log = createLogger(import.meta.url);\n\n// check if target is a sub directory of src\nexport const isSubPath = (src: string, target: string): boolean => {\n const relate = path.relative(src, target);\n // same dir\n if (!relate) {\n return false;\n }\n if (relate === '..') {\n return false;\n }\n return !relate.startsWith(`..${path.sep}`);\n};\n\n// FileFilter types and implementation.\n\nexport type FileFilterOptions = {\n baseIgnoredPatterns?: Array<string>,\n ignoreFiles?: Array<string>,\n sourceDir: string,\n artifactsDir?: string,\n};\n\n/*\n * Allows or ignores files.\n */\nexport class FileFilter {\n filesToIgnore: Array<string>;\n sourceDir: string;\n\n constructor({\n baseIgnoredPatterns = [\n '**/*.xpi',\n '**/*.zip',\n '**/.*', // any hidden file and folder\n '**/.*/**/*', // and the content inside hidden folder\n '**/node_modules',\n '**/node_modules/**/*',\n ],\n ignoreFiles = [],\n sourceDir,\n artifactsDir,\n }: FileFilterOptions = {}) {\n sourceDir = path.resolve(sourceDir);\n\n this.filesToIgnore = [];\n this.sourceDir = sourceDir;\n\n this.addToIgnoreList(baseIgnoredPatterns);\n if (ignoreFiles) {\n this.addToIgnoreList(ignoreFiles);\n }\n if (artifactsDir && isSubPath(sourceDir, artifactsDir)) {\n artifactsDir = path.resolve(artifactsDir);\n log.debug(\n `Ignoring artifacts directory \"${artifactsDir}\" ` +\n 'and all its subdirectories'\n );\n this.addToIgnoreList([artifactsDir, path.join(artifactsDir, '**', '*')]);\n }\n }\n\n /**\n * Resolve relative path to absolute path with sourceDir.\n */\n resolveWithSourceDir(file: string): string {\n const resolvedPath = path.resolve(this.sourceDir, file);\n log.debug(\n `Resolved path ${file} with sourceDir ${this.sourceDir} ` +\n `to ${resolvedPath}`\n );\n return resolvedPath;\n }\n\n /**\n * Insert more files into filesToIgnore array.\n */\n addToIgnoreList(files: Array<string>) {\n for (const file of files) {\n if (file.charAt(0) === '!') {\n const resolvedFile = this.resolveWithSourceDir(file.substr(1));\n this.filesToIgnore.push(`!${resolvedFile}`);\n } else {\n this.filesToIgnore.push(this.resolveWithSourceDir(file));\n }\n }\n }\n\n /*\n * Returns true if the file is wanted.\n *\n * If filePath does not start with a slash, it will be treated as a path\n * relative to sourceDir when matching it against all configured\n * ignore-patterns.\n *\n * Example: this is called by zipdir as wantFile(filePath) for each\n * file in the folder that is being archived.\n */\n wantFile(filePath: string): boolean {\n const resolvedPath = this.resolveWithSourceDir(filePath);\n const matches = multimatch(resolvedPath, this.filesToIgnore);\n if (matches.length > 0) {\n log.debug(`FileFilter: ignoring file ${resolvedPath}`);\n return false;\n }\n return true;\n }\n}\n\n// a helper function to make mocking easier\n\nexport const createFileFilter = (params: FileFilterOptions): FileFilter =>\n new FileFilter(params);\n\nexport type FileFilterCreatorFn = typeof createFileFilter;\n"],"mappings":"AACA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,aAAa;AAE1C,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;;AAEzC;AACA,OAAO,MAAMC,SAAS,GAAGA,CAACC,GAAW,EAAEC,MAAc,KAAc;EACjE,MAAMC,MAAM,GAAGV,IAAI,CAACW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AI,CAAC;IACvDvB,GAAG,CAACoB,KAAK,CACN,iBAAgBG,IAAK,mBAAkB,IAAI,CAACR,SAAU,GAAE,GACtD,MAAKS,YAAa,EACvB,CAAC;IACD,OAAOA,YAAY;EACrB;;EAEA;AACF;AACA;EACEL,eAAeA,CAACM,KAAoB,EAAE;IACpC,KAAK,MAAMF,IAAI,IAAIE,KAAK,EAAE;MACxB,IAAIF,IAAI,CAACG,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QAC1B,MAAMC,YAAY,GAAG,IAAI,CAACL,oBAAoB,CAACC,IAAI,CAACK,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAI,CAACV,aAAa,CAACW,IAAI,CAAE,IAAGF,YAAa,EAAC,CAAC;MAC7C,CAAC,MAAM;QACL,IAAI,CAACT,aAAa,CAACW,IAAI,CAAC,IAAI,CAACP,oBAAoB,CAACC,IAAI,CAAC,CAAC;MAC1D;IACF;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEO,QAAQA,CAACC,QAAgB,EAAW;IAClC,MAAMP,YAAY,GAAG,IAAI,CAACF,oBAAoB,CAACS,QAAQ,CAAC;IACxD,MAAMC,OAAO,GAAGlC,UAAU,CAAC0B,YAAY,EAAE,IAAI,CAACN,aAAa,CAAC;IAC5D,IAAIc,OAAO,CAACC,MAAM,GAAG,CAAC,EAAE;MACtBjC,GAAG,CAACoB,KAAK,CAAE,6BAA4BI,YAAa,EAAC,CAAC;MACtD,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb;AACF;;AAEA;;AAEA,OAAO,MAAMU,gBAAgB,GAAIC,MAAyB,IACxD,IAAIxB,UAAU,CAACwB,MAAM,CAAC"}
1
+ {"version":3,"file":"file-filter.js","names":["path","multimatch","createLogger","log","import","meta","url","isSubPath","src","target","relate","relative","startsWith","sep","FileFilter","filesToIgnore","sourceDir","constructor","baseIgnoredPatterns","ignoreFiles","artifactsDir","resolve","addToIgnoreList","debug","join","resolveWithSourceDir","file","resolvedPath","files","charAt","resolvedFile","substr","push","wantFile","filePath","matches","length","createFileFilter","params"],"sources":["../../src/util/file-filter.js"],"sourcesContent":["import path from 'path';\n\nimport multimatch from 'multimatch';\n\nimport { createLogger } from './logger.js';\n\nconst log = createLogger(import.meta.url);\n\n// check if target is a sub directory of src\nexport const isSubPath = (src, target) => {\n const relate = path.relative(src, target);\n // same dir\n if (!relate) {\n return false;\n }\n if (relate === '..') {\n return false;\n }\n return !relate.startsWith(`..${path.sep}`);\n};\n\n// FileFilter types and implementation.\n\n/*\n * Allows or ignores files.\n */\nexport class FileFilter {\n filesToIgnore;\n sourceDir;\n\n constructor({\n baseIgnoredPatterns = [\n '**/*.xpi',\n '**/*.zip',\n '**/.*', // any hidden file and folder\n '**/.*/**/*', // and the content inside hidden folder\n '**/node_modules',\n '**/node_modules/**/*',\n ],\n ignoreFiles = [],\n sourceDir,\n artifactsDir,\n } = {}) {\n sourceDir = path.resolve(sourceDir);\n\n this.filesToIgnore = [];\n this.sourceDir = sourceDir;\n\n this.addToIgnoreList(baseIgnoredPatterns);\n if (ignoreFiles) {\n this.addToIgnoreList(ignoreFiles);\n }\n if (artifactsDir && isSubPath(sourceDir, artifactsDir)) {\n artifactsDir = path.resolve(artifactsDir);\n log.debug(\n `Ignoring artifacts directory \"${artifactsDir}\" ` +\n 'and all its subdirectories',\n );\n this.addToIgnoreList([artifactsDir, path.join(artifactsDir, '**', '*')]);\n }\n }\n\n /**\n * Resolve relative path to absolute path with sourceDir.\n */\n resolveWithSourceDir(file) {\n const resolvedPath = path.resolve(this.sourceDir, file);\n log.debug(\n `Resolved path ${file} with sourceDir ${this.sourceDir} ` +\n `to ${resolvedPath}`,\n );\n return resolvedPath;\n }\n\n /**\n * Insert more files into filesToIgnore array.\n */\n addToIgnoreList(files) {\n for (const file of files) {\n if (file.charAt(0) === '!') {\n const resolvedFile = this.resolveWithSourceDir(file.substr(1));\n this.filesToIgnore.push(`!${resolvedFile}`);\n } else {\n this.filesToIgnore.push(this.resolveWithSourceDir(file));\n }\n }\n }\n\n /*\n * Returns true if the file is wanted.\n *\n * If filePath does not start with a slash, it will be treated as a path\n * relative to sourceDir when matching it against all configured\n * ignore-patterns.\n *\n * Example: this is called by zipdir as wantFile(filePath) for each\n * file in the folder that is being archived.\n */\n wantFile(filePath) {\n const resolvedPath = this.resolveWithSourceDir(filePath);\n const matches = multimatch(resolvedPath, this.filesToIgnore);\n if (matches.length > 0) {\n log.debug(`FileFilter: ignoring file ${resolvedPath}`);\n return false;\n }\n return true;\n }\n}\n\n// a helper function to make mocking easier\n\nexport const createFileFilter = (params) => new FileFilter(params);\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,aAAa;AAE1C,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;;AAEzC;AACA,OAAO,MAAMC,SAAS,GAAGA,CAACC,GAAG,EAAEC,MAAM,KAAK;EACxC,MAAMC,MAAM,GAAGV,IAAI,CAACW,QAAQ,CAACH,GAAG,EAAEC,MAAM,CAAC;EACzC;EACA,IAAI,CAACC,MAAM,EAAE;IACX,OAAO,KAAK;EACd;EACA,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO,KAAK;EACd;EACA,OAAO,CAACA,MAAM,CAACE,UAAU,CAAC,KAAKZ,IAAI,CAACa,GAAG,EAAE,CAAC;AAC5C,CAAC;;AAED;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,CAAC;EACtBC,aAAa;EACbC,SAAS;EAETC,WAAWA,CAAC;IACVC,mBAAmB,GAAG,CACpB,UAAU,EACV,UAAU,EACV,OAAO;IAAE;IACT,YAAY;IAAE;IACd,iBAAiB,EACjB,sBAAsB,CACvB;IACDC,WAAW,GAAG,EAAE;IAChBH,SAAS;IACTI;EACF,CAAC,GAAG,CAAC,CAAC,EAAE;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Aa,CAACiB,IAAI,CAAC,IAAI,CAACP,oBAAoB,CAACC,IAAI,CAAC,CAAC;MAC1D;IACF;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEO,QAAQA,CAACC,QAAQ,EAAE;IACjB,MAAMP,YAAY,GAAG,IAAI,CAACF,oBAAoB,CAACS,QAAQ,CAAC;IACxD,MAAMC,OAAO,GAAGlC,UAAU,CAAC0B,YAAY,EAAE,IAAI,CAACZ,aAAa,CAAC;IAC5D,IAAIoB,OAAO,CAACC,MAAM,GAAG,CAAC,EAAE;MACtBjC,GAAG,CAACoB,KAAK,CAAC,6BAA6BI,YAAY,EAAE,CAAC;MACtD,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb;AACF;;AAEA;;AAEA,OAAO,MAAMU,gBAAgB,GAAIC,MAAM,IAAK,IAAIxB,UAAU,CAACwB,MAAM,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"is-directory.js","names":["fs","onlyErrorsWithCode","isDirectory","path","stat","then","stats","catch"],"sources":["../../src/util/is-directory.js"],"sourcesContent":["/* @flow */\nimport { fs } from 'mz';\n\nimport { onlyErrorsWithCode } from '../errors.js';\n\n/*\n * Resolves true if the path is a readable directory.\n *\n * Usage:\n *\n * isDirectory('/some/path')\n * .then((dirExists) => {\n * // dirExists will be true or false.\n * });\n *\n * */\nexport default function isDirectory(path: string): Promise<boolean> {\n return fs\n .stat(path)\n .then((stats) => stats.isDirectory())\n .catch(\n onlyErrorsWithCode(['ENOENT', 'ENOTDIR'], () => {\n return false;\n })\n );\n}\n"],"mappings":"AACA,SAASA,EAAE,QAAQ,IAAI;AAEvB,SAASC,kBAAkB,QAAQ,cAAc;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAACC,IAAY,EAAoB;EAClE,OAAOH,EAAE,CACNI,IAAI,CAACD,IAAI,CAAC,CACVE,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACJ,WAAW,CAAC,CAAC,CAAC,CACpCK,KAAK,CACJN,kBAAkB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM;IAC9C,OAAO,KAAK;EACd,CAAC,CACH,CAAC;AACL"}
1
+ {"version":3,"file":"is-directory.js","names":["fs","onlyErrorsWithCode","isDirectory","path","stat","then","stats","catch"],"sources":["../../src/util/is-directory.js"],"sourcesContent":["import { fs } from 'mz';\n\nimport { onlyErrorsWithCode } from '../errors.js';\n\n/*\n * Resolves true if the path is a readable directory.\n *\n * Usage:\n *\n * isDirectory('/some/path')\n * .then((dirExists) => {\n * // dirExists will be true or false.\n * });\n *\n * */\nexport default function isDirectory(path) {\n return fs\n .stat(path)\n .then((stats) => stats.isDirectory())\n .catch(\n onlyErrorsWithCode(['ENOENT', 'ENOTDIR'], () => {\n return false;\n }),\n );\n}\n"],"mappings":"AAAA,SAASA,EAAE,QAAQ,IAAI;AAEvB,SAASC,kBAAkB,QAAQ,cAAc;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAACC,IAAI,EAAE;EACxC,OAAOH,EAAE,CACNI,IAAI,CAACD,IAAI,CAAC,CACVE,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACJ,WAAW,CAAC,CAAC,CAAC,CACpCK,KAAK,CACJN,kBAAkB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM;IAC9C,OAAO,KAAK;EACd,CAAC,CACH,CAAC;AACL","ignoreList":[]}
@@ -1,11 +1,9 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import bunyan, { nameFromLevel, createLogger as defaultLogCreator } from 'bunyan';
3
-
4
- // Bunyan-related Flow types
5
-
6
- // ConsoleStream types and implementation.
7
-
8
3
  export class ConsoleStream {
4
+ verbose;
5
+ isCapturing;
6
+ capturedMessages;
9
7
  constructor({
10
8
  verbose = false
11
9
  } = {}) {
@@ -32,6 +30,8 @@ export class ConsoleStream {
32
30
  const msg = this.format(packet);
33
31
  if (this.isCapturing) {
34
32
  this.capturedMessages.push(msg);
33
+ } else if (packet.level > bunyan.INFO) {
34
+ localProcess.stderr.write(msg);
35
35
  } else {
36
36
  localProcess.stdout.write(msg);
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","names":["fileURLToPath","bunyan","nameFromLevel","createLogger","defaultLogCreator","ConsoleStream","constructor","verbose","isCapturing","capturedMessages","format","name","msg","level","prefix","makeVerbose","write","packet","localProcess","process","thisLevel","TRACE","INFO","push","stdout","startCapturing","stopCapturing","flushCapturedLogs","consoleStream","moduleURL","createBunyanLog","replace","streams","type","stream"],"sources":["../../src/util/logger.js"],"sourcesContent":["/* @flow */\nimport { fileURLToPath } from 'url';\n\nimport bunyan, {\n nameFromLevel,\n createLogger as defaultLogCreator,\n} from 'bunyan';\n\n// Bunyan-related Flow types\n\nexport type TRACE = 10;\nexport type DEBUG = 20;\nexport type INFO = 30;\nexport type WARN = 40;\nexport type ERROR = 50;\nexport type FATAL = 60;\n\nexport type BunyanLogLevel = TRACE | DEBUG | INFO | WARN | ERROR | FATAL;\n\nexport type BunyanLogEntry = {|\n name: string,\n msg: string,\n level: BunyanLogLevel,\n|};\n\nexport type Logger = {\n debug: (msg: string, ...args: any) => void,\n error: (msg: string, ...args: any) => void,\n info: (msg: string, ...args: any) => void,\n warn: (msg: string, ...args: any) => void,\n};\n\n// ConsoleStream types and implementation.\n\nexport type ConsoleStreamParams = {\n verbose?: boolean,\n};\n\nexport type ConsoleOptions = {\n localProcess?: typeof process,\n};\n\nexport class ConsoleStream {\n verbose: boolean;\n isCapturing: boolean;\n capturedMessages: Array<string>;\n\n constructor({ verbose = false }: ConsoleStreamParams = {}) {\n this.verbose = verbose;\n this.isCapturing = false;\n this.capturedMessages = [];\n }\n\n format({ name, msg, level }: BunyanLogEntry): string {\n const prefix = this.verbose ? `[${name}][${nameFromLevel[level]}] ` : '';\n return `${prefix}${msg}\\n`;\n }\n\n makeVerbose() {\n this.verbose = true;\n }\n\n write(\n packet: BunyanLogEntry,\n { localProcess = process }: ConsoleOptions = {}\n ): void {\n const thisLevel: BunyanLogLevel = this.verbose ? bunyan.TRACE : bunyan.INFO;\n if (packet.level >= thisLevel) {\n const msg = this.format(packet);\n if (this.isCapturing) {\n this.capturedMessages.push(msg);\n } else {\n localProcess.stdout.write(msg);\n }\n }\n }\n\n startCapturing() {\n this.isCapturing = true;\n }\n\n stopCapturing() {\n this.isCapturing = false;\n this.capturedMessages = [];\n }\n\n flushCapturedLogs({ localProcess = process }: ConsoleOptions = {}) {\n for (const msg of this.capturedMessages) {\n localProcess.stdout.write(msg);\n }\n this.capturedMessages = [];\n }\n}\n\nexport const consoleStream: ConsoleStream = new ConsoleStream();\n\n// createLogger types and implementation.\n\nexport type BunyanStreamConfig = {\n type: string,\n stream: ConsoleStream,\n};\n\nexport type CreateBunyanLogParams = {\n name: string,\n level: BunyanLogLevel,\n streams: Array<BunyanStreamConfig>,\n};\n\nexport type CreateBunyanLogFn = (params: CreateBunyanLogParams) => Logger;\n\nexport type CreateLoggerOptions = {\n createBunyanLog: CreateBunyanLogFn,\n};\n\nexport function createLogger(\n moduleURL?: string,\n { createBunyanLog = defaultLogCreator }: CreateLoggerOptions = {}\n): Logger {\n return createBunyanLog({\n // Strip the leading src/ from file names (which is in all file names) to\n // make the name less redundant.\n name: moduleURL\n ? fileURLToPath(moduleURL).replace(/^src\\//, '')\n : 'unknown-module',\n // Capture all log levels and let the stream filter them.\n level: bunyan.TRACE,\n streams: [\n {\n type: 'raw',\n stream: consoleStream,\n },\n ],\n });\n}\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,KAAK;AAEnC,OAAOC,MAAM,IACXC,aAAa,EACbC,YAAY,IAAIC,iBAAiB,QAC5B,QAAQ;;AAEf;;AAwBA;;AAUA,OAAO,MAAMC,aAAa,CAAC;EAKzBC,WAAWA,CAAC;IAAEC,OAAO,GA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GAAG,IAAI,IAAI,CAACH,gBAAgB,EAAE;MACvCS,YAAY,CAACM,MAAM,CAACR,KAAK,CAACJ,GAAG,CAAC;IAChC;IACA,IAAI,CAACH,gBAAgB,GAAG,EAAE;EAC5B;AACF;AAEA,OAAO,MAAMmB,aAA4B,GAAG,IAAIvB,aAAa,CAAC,CAAC;;AAE/D;;AAmBA,OAAO,SAASF,YAAYA,CAC1B0B,SAAkB,EAClB;EAAEC,eAAe,GAAG1B;AAAuC,CAAC,GAAG,CAAC,CAAC,EACzD;EACR,OAAO0B,eAAe,CAAC;IACrB;IACA;IACAnB,IAAI,EAAEkB,SAAS,GACX7B,aAAa,CAAC6B,SAAS,CAAC,CAACE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GAC9C,gBAAgB;IACpB;IACAlB,KAAK,EAAEZ,MAAM,CAACoB,KAAK;IACnBW,OAAO,EAAE,CACP;MACEC,IAAI,EAAE,KAAK;MACXC,MAAM,EAAEN;IACV,CAAC;EAEL,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"logger.js","names":["fileURLToPath","bunyan","nameFromLevel","createLogger","defaultLogCreator","ConsoleStream","verbose","isCapturing","capturedMessages","constructor","format","name","msg","level","prefix","makeVerbose","write","packet","localProcess","process","thisLevel","TRACE","INFO","push","stderr","stdout","startCapturing","stopCapturing","flushCapturedLogs","consoleStream","moduleURL","createBunyanLog","replace","streams","type","stream"],"sources":["../../src/util/logger.js"],"sourcesContent":["import { fileURLToPath } from 'url';\n\nimport bunyan, {\n nameFromLevel,\n createLogger as defaultLogCreator,\n} from 'bunyan';\n\nexport class ConsoleStream {\n verbose;\n isCapturing;\n capturedMessages;\n\n constructor({ verbose = false } = {}) {\n this.verbose = verbose;\n this.isCapturing = false;\n this.capturedMessages = [];\n }\n\n format({ name, msg, level }) {\n const prefix = this.verbose ? `[${name}][${nameFromLevel[level]}] ` : '';\n return `${prefix}${msg}\\n`;\n }\n\n makeVerbose() {\n this.verbose = true;\n }\n\n write(packet, { localProcess = process } = {}) {\n const thisLevel = this.verbose ? bunyan.TRACE : bunyan.INFO;\n if (packet.level >= thisLevel) {\n const msg = this.format(packet);\n if (this.isCapturing) {\n this.capturedMessages.push(msg);\n } else if (packet.level > bunyan.INFO) {\n localProcess.stderr.write(msg);\n } else {\n localProcess.stdout.write(msg);\n }\n }\n }\n\n startCapturing() {\n this.isCapturing = true;\n }\n\n stopCapturing() {\n this.isCapturing = false;\n this.capturedMessages = [];\n }\n\n flushCapturedLogs({ localProcess = process } = {}) {\n for (const msg of this.capturedMessages) {\n localProcess.stdout.write(msg);\n }\n this.capturedMessages = [];\n }\n}\n\nexport const consoleStream = new ConsoleStream();\n\n// createLogger types and implementation.\n\nexport function createLogger(\n moduleURL,\n { createBunyanLog = defaultLogCreator } = {},\n) {\n return createBunyanLog({\n // Strip the leading src/ from file names (which is in all file names) to\n // make the name less redundant.\n name: moduleURL\n ? fileURLToPath(moduleURL).replace(/^src\\//, '')\n : 'unknown-module',\n // Capture all log levels and let the stream filter them.\n level: bunyan.TRACE,\n streams: [\n {\n type: 'raw',\n stream: consoleStream,\n },\n ],\n });\n}\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,KAAK;AAEnC,OAAOC,MAAM,IACXC,aAAa,EACbC,YAAY,IAAIC,iBAAiB,QAC5B,QAAQ;AAEf,OAAO,MAAMC,aAAa,CAAC;EACzBC,OAAO;EACPC,WAAW;EACXC,gBAAgB;EAEhBC,WAAWA,CAAC;IAAEH,OAAO,GAAG;EAAM,CAAC,GAAG,CAAC,CAAC,EAAE;IACpC,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,WAAW,GAAG,KAAK;IACxB,IAAI,CAACC,gBAAgB,GAAG,EAAE;EAC5B;EAEAE,MAAMA,CAAC;IAAEC,IAAI;IAAEC,GAAG;IAAEC;EAAM,CAAC,EAAE;IAC3B,MAAMC,MAAM,GAAG,IAAI,CAACR,OAAO,GAAG,IAAIK,IAAI,KAAKT,aAAa,CA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