web-ext 7.0.0 → 7.2.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.
- package/lib/cmd/run.js +9 -1
- package/lib/cmd/run.js.map +1 -1
- package/lib/extension-runners/firefox-desktop.js +2 -1
- package/lib/extension-runners/firefox-desktop.js.map +1 -1
- package/lib/firefox/index.js +22 -1
- package/lib/firefox/index.js.map +1 -1
- package/lib/program.js +10 -1
- package/lib/program.js.map +1 -1
- package/package.json +18 -19
package/lib/cmd/run.js
CHANGED
|
@@ -28,6 +28,7 @@ export default async function run({
|
|
|
28
28
|
startUrl,
|
|
29
29
|
target,
|
|
30
30
|
args,
|
|
31
|
+
firefoxPreview = [],
|
|
31
32
|
// Android CLI options.
|
|
32
33
|
adbBin,
|
|
33
34
|
adbHost,
|
|
@@ -62,7 +63,14 @@ export default async function run({
|
|
|
62
63
|
// object containing one or more preferences.
|
|
63
64
|
|
|
64
65
|
|
|
65
|
-
const customPrefs = pref
|
|
66
|
+
const customPrefs = { ...pref
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (firefoxPreview.includes('mv3')) {
|
|
70
|
+
log.info('Configuring Firefox preferences for Manifest V3');
|
|
71
|
+
customPrefs['extensions.manifestV3.enabled'] = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
const manifestData = await getValidatedManifest(sourceDir);
|
|
67
75
|
const profileDir = firefoxProfile || chromiumProfile;
|
|
68
76
|
|
package/lib/cmd/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","names":["fs","defaultBuildExtension","showDesktopNotification","defaultDesktopNotifications","defaultFirefoxApp","connectWithMaxRetries","defaultFirefoxClient","createLogger","defaultGetValidatedManifest","UsageError","createExtensionRunner","defaultReloadStrategy","MultiExtensionRunner","DefaultMultiExtensionRunner","log","import","meta","url","run","artifactsDir","browserConsole","pref","firefox","firefoxProfile","profileCreateIfMissing","keepProfileChanges","ignoreFiles","noInput","noReload","preInstall","sourceDir","watchFile","watchIgnored","startUrl","target","args","adbBin","adbHost","adbPort","adbDevice","adbDiscoveryTimeout","adbRemoveOldArtifacts","firefoxApk","firefoxApkComponent","chromiumBinary","chromiumProfile","buildExtension","desktopNotifications","firefoxApp","firefoxClient","reloadStrategy","getValidatedManifest","info","Array","isArray","every","el","customPrefs","manifestData","profileDir","isDir","existsSync","mkdir","runners","commonRunnerParams","extensions","length","includes","firefoxDesktopRunnerParams","firefoxBinary","profilePath","firefoxDesktopRunner","params","push","firefoxAndroidRunnerParams","buildSourceDir","extensionSourceDir","tmpArtifactsDir","asNeeded","showReadyMessage","firefoxAndroidRunner","chromiumRunnerParams","chromiumRunner","extensionRunner"],"sources":["../../src/cmd/run.js"],"sourcesContent":["/* @flow */\nimport { fs } from 'mz';\n\nimport defaultBuildExtension from './build.js';\nimport {\n showDesktopNotification as defaultDesktopNotifications,\n} from '../util/desktop-notifier.js';\nimport * as defaultFirefoxApp from '../firefox/index.js';\nimport {\n connectWithMaxRetries as defaultFirefoxClient,\n} from '../firefox/remote.js';\nimport {createLogger} from '../util/logger.js';\nimport defaultGetValidatedManifest from '../util/manifest.js';\nimport {UsageError} from '../errors.js';\nimport {\n createExtensionRunner,\n defaultReloadStrategy,\n MultiExtensionRunner as DefaultMultiExtensionRunner,\n} from '../extension-runners/index.js';\n// Import objects that are only used as Flow types.\nimport type {FirefoxPreferences} from '../firefox/preferences.js';\n\nconst log = createLogger(import.meta.url);\n\n\n// Run command types and implementation.\n\nexport type CmdRunParams = {|\n artifactsDir: string,\n browserConsole: boolean,\n pref?: FirefoxPreferences,\n firefox: string,\n firefoxProfile?: string,\n profileCreateIfMissing?: boolean,\n ignoreFiles?: Array<string>,\n keepProfileChanges: boolean,\n noInput?: boolean,\n noReload: boolean,\n preInstall: boolean,\n sourceDir: string,\n watchFile?: Array<string>,\n watchIgnored?: Array<string>,\n startUrl?: Array<string>,\n target?: Array<string>,\n args?: Array<string>,\n\n // Android CLI options.\n adbBin?: string,\n adbHost?: string,\n adbPort?: string,\n adbDevice?: string,\n adbDiscoveryTimeout?: number,\n adbRemoveOldArtifacts?: boolean,\n firefoxApk?: string,\n firefoxApkComponent?: string,\n\n // Chromium Desktop CLI options.\n chromiumBinary?: string,\n chromiumProfile?: string,\n|};\n\nexport type CmdRunOptions = {\n buildExtension: typeof defaultBuildExtension,\n desktopNotifications: typeof defaultDesktopNotifications,\n firefoxApp: typeof defaultFirefoxApp,\n firefoxClient: typeof defaultFirefoxClient,\n reloadStrategy: typeof defaultReloadStrategy,\n shouldExitProgram?: boolean,\n MultiExtensionRunner?: typeof DefaultMultiExtensionRunner,\n getValidatedManifest?: typeof defaultGetValidatedManifest,\n};\n\nexport default async function run(\n {\n artifactsDir,\n browserConsole = false,\n pref,\n firefox,\n firefoxProfile,\n profileCreateIfMissing,\n keepProfileChanges = false,\n ignoreFiles,\n noInput = false,\n noReload = false,\n preInstall = false,\n sourceDir,\n watchFile,\n watchIgnored,\n startUrl,\n target,\n args,\n // Android CLI options.\n adbBin,\n adbHost,\n adbPort,\n adbDevice,\n adbDiscoveryTimeout,\n adbRemoveOldArtifacts,\n firefoxApk,\n firefoxApkComponent,\n // Chromium CLI options.\n chromiumBinary,\n chromiumProfile,\n }: CmdRunParams,\n {\n buildExtension = defaultBuildExtension,\n desktopNotifications = defaultDesktopNotifications,\n firefoxApp = defaultFirefoxApp,\n firefoxClient = defaultFirefoxClient,\n reloadStrategy = defaultReloadStrategy,\n MultiExtensionRunner = DefaultMultiExtensionRunner,\n getValidatedManifest = defaultGetValidatedManifest,\n }: CmdRunOptions = {}): Promise<DefaultMultiExtensionRunner> {\n\n log.info(`Running web extension from ${sourceDir}`);\n if (preInstall) {\n log.info('Disabled auto-reloading because it\\'s not possible with ' +\n '--pre-install');\n noReload = true;\n }\n\n if (watchFile != null && (!Array.isArray(watchFile) ||\n !watchFile.every((el) => typeof el === 'string'))) {\n throw new UsageError('Unexpected watchFile type');\n }\n\n // Create an alias for --pref since it has been transformed into an\n // object containing one or more preferences.\n const customPrefs = pref;\n const manifestData = await getValidatedManifest(sourceDir);\n\n const profileDir = firefoxProfile || chromiumProfile;\n\n if (profileCreateIfMissing) {\n if (!profileDir) {\n throw new UsageError(\n '--profile-create-if-missing requires ' +\n '--firefox-profile or --chromium-profile'\n );\n }\n const isDir = fs.existsSync(profileDir);\n if (isDir) {\n log.info(`Profile directory ${profileDir} already exists`);\n } else {\n log.info(`Profile directory not found. Creating directory ${profileDir}`);\n await fs.mkdir(profileDir);\n }\n }\n\n const runners = [];\n\n const commonRunnerParams = {\n // Common options.\n extensions: [{sourceDir, manifestData}],\n keepProfileChanges,\n startUrl,\n args,\n desktopNotifications,\n };\n\n if (!target || target.length === 0 || target.includes('firefox-desktop')) {\n const firefoxDesktopRunnerParams = {\n ...commonRunnerParams,\n\n // Firefox specific CLI options.\n firefoxBinary: firefox,\n profilePath: firefoxProfile,\n customPrefs,\n browserConsole,\n preInstall,\n\n // Firefox runner injected dependencies.\n firefoxApp,\n firefoxClient,\n };\n\n const firefoxDesktopRunner = await createExtensionRunner({\n target: 'firefox-desktop',\n params: firefoxDesktopRunnerParams,\n });\n runners.push(firefoxDesktopRunner);\n }\n\n if (target && target.includes('firefox-android')) {\n const firefoxAndroidRunnerParams = {\n ...commonRunnerParams,\n\n // Firefox specific CLI options.\n profilePath: firefoxProfile,\n customPrefs,\n browserConsole,\n preInstall,\n firefoxApk,\n firefoxApkComponent,\n adbDevice,\n adbHost,\n adbPort,\n adbBin,\n adbDiscoveryTimeout,\n adbRemoveOldArtifacts,\n\n // Injected dependencies.\n firefoxApp,\n firefoxClient,\n desktopNotifications: defaultDesktopNotifications,\n buildSourceDir: (extensionSourceDir: string, tmpArtifactsDir: string) => {\n return buildExtension({\n sourceDir: extensionSourceDir,\n ignoreFiles,\n asNeeded: false,\n // Use a separate temporary directory for building the extension zip file\n // that we are going to upload on the android device.\n artifactsDir: tmpArtifactsDir,\n }, {\n // Suppress the message usually logged by web-ext build.\n showReadyMessage: false,\n });\n },\n };\n\n const firefoxAndroidRunner = await createExtensionRunner({\n target: 'firefox-android',\n params: firefoxAndroidRunnerParams,\n });\n runners.push(firefoxAndroidRunner);\n }\n\n if (target && target.includes('chromium')) {\n const chromiumRunnerParams = {\n ...commonRunnerParams,\n chromiumBinary,\n chromiumProfile,\n };\n\n const chromiumRunner = await createExtensionRunner({\n target: 'chromium',\n params: chromiumRunnerParams,\n });\n runners.push(chromiumRunner);\n }\n\n const extensionRunner = new MultiExtensionRunner({\n desktopNotifications,\n runners,\n });\n\n await extensionRunner.run();\n\n if (noReload) {\n log.info('Automatic extension reloading has been disabled');\n } else {\n log.info('The extension will reload if any source file changes');\n\n reloadStrategy({\n extensionRunner,\n sourceDir,\n watchFile,\n watchIgnored,\n artifactsDir,\n ignoreFiles,\n noInput,\n });\n }\n\n return extensionRunner;\n}\n"],"mappings":"AACA,SAASA,EAAT,QAAmB,IAAnB;AAEA,OAAOC,qBAAP,MAAkC,YAAlC;AACA,SACEC,uBAAuB,IAAIC,2BAD7B,QAEO,6BAFP;AAGA,OAAO,KAAKC,iBAAZ,MAAmC,qBAAnC;AACA,SACEC,qBAAqB,IAAIC,oBAD3B,QAEO,sBAFP;AAGA,SAAQC,YAAR,QAA2B,mBAA3B;AACA,OAAOC,2BAAP,MAAwC,qBAAxC;AACA,SAAQC,UAAR,QAAyB,cAAzB;AACA,SACEC,qBADF,EAEEC,qBAFF,EAGEC,oBAAoB,IAAIC,2BAH1B,QAIO,+BAJP,C,CAKA;;AAGA,MAAMC,GAAG,GAAGP,YAAY,CAACQ,MAAM,CAACC,IAAP,CAAYC,GAAb,CAAxB,C,CAGA;;AA+CA,eAAe,eAAeC,GAAf,CACb;EACEC,YADF;EAEEC,cAAc,GAAG,KAFnB;EAGEC,IAHF;EAIEC,OAJF;EAKEC,cALF;EAMEC,sBANF;EAOEC,kBAAkB,GAAG,KAPvB;EAQEC,WARF;EASEC,OAAO,GAAG,KATZ;EAUEC,QAAQ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SAFa;MAGbC,SAHa;MAIbC,YAJa;MAKbb,YALa;MAMbO,WANa;MAObC;IAPa,CAAD,CAAd;EASD;;EAED,OAAOwD,eAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"run.js","names":["fs","defaultBuildExtension","showDesktopNotification","defaultDesktopNotifications","defaultFirefoxApp","connectWithMaxRetries","defaultFirefoxClient","createLogger","defaultGetValidatedManifest","UsageError","createExtensionRunner","defaultReloadStrategy","MultiExtensionRunner","DefaultMultiExtensionRunner","log","import","meta","url","run","artifactsDir","browserConsole","pref","firefox","firefoxProfile","profileCreateIfMissing","keepProfileChanges","ignoreFiles","noInput","noReload","preInstall","sourceDir","watchFile","watchIgnored","startUrl","target","args","firefoxPreview","adbBin","adbHost","adbPort","adbDevice","adbDiscoveryTimeout","adbRemoveOldArtifacts","firefoxApk","firefoxApkComponent","chromiumBinary","chromiumProfile","buildExtension","desktopNotifications","firefoxApp","firefoxClient","reloadStrategy","getValidatedManifest","info","Array","isArray","every","el","customPrefs","includes","manifestData","profileDir","isDir","existsSync","mkdir","runners","commonRunnerParams","extensions","length","firefoxDesktopRunnerParams","firefoxBinary","profilePath","firefoxDesktopRunner","params","push","firefoxAndroidRunnerParams","buildSourceDir","extensionSourceDir","tmpArtifactsDir","asNeeded","showReadyMessage","firefoxAndroidRunner","chromiumRunnerParams","chromiumRunner","extensionRunner"],"sources":["../../src/cmd/run.js"],"sourcesContent":["/* @flow */\nimport { fs } from 'mz';\n\nimport defaultBuildExtension from './build.js';\nimport {\n showDesktopNotification as defaultDesktopNotifications,\n} from '../util/desktop-notifier.js';\nimport * as defaultFirefoxApp from '../firefox/index.js';\nimport {\n connectWithMaxRetries as defaultFirefoxClient,\n} from '../firefox/remote.js';\nimport {createLogger} from '../util/logger.js';\nimport defaultGetValidatedManifest from '../util/manifest.js';\nimport {UsageError} from '../errors.js';\nimport {\n createExtensionRunner,\n defaultReloadStrategy,\n MultiExtensionRunner as DefaultMultiExtensionRunner,\n} from '../extension-runners/index.js';\n// Import objects that are only used as Flow types.\nimport type {FirefoxPreferences} from '../firefox/preferences.js';\n\nconst log = createLogger(import.meta.url);\n\n\n// Run command types and implementation.\n\nexport type CmdRunParams = {|\n artifactsDir: string,\n browserConsole: boolean,\n pref?: FirefoxPreferences,\n firefox: string,\n firefoxProfile?: string,\n profileCreateIfMissing?: boolean,\n ignoreFiles?: Array<string>,\n keepProfileChanges: boolean,\n noInput?: boolean,\n noReload: boolean,\n preInstall: boolean,\n sourceDir: string,\n watchFile?: Array<string>,\n watchIgnored?: Array<string>,\n startUrl?: Array<string>,\n target?: Array<string>,\n args?: Array<string>,\n firefoxPreview: Array<string>,\n\n // Android CLI options.\n adbBin?: string,\n adbHost?: string,\n adbPort?: string,\n adbDevice?: string,\n adbDiscoveryTimeout?: number,\n adbRemoveOldArtifacts?: boolean,\n firefoxApk?: string,\n firefoxApkComponent?: string,\n\n // Chromium Desktop CLI options.\n chromiumBinary?: string,\n chromiumProfile?: string,\n|};\n\nexport type CmdRunOptions = {\n buildExtension: typeof defaultBuildExtension,\n desktopNotifications: typeof defaultDesktopNotifications,\n firefoxApp: typeof defaultFirefoxApp,\n firefoxClient: typeof defaultFirefoxClient,\n reloadStrategy: typeof defaultReloadStrategy,\n shouldExitProgram?: boolean,\n MultiExtensionRunner?: typeof DefaultMultiExtensionRunner,\n getValidatedManifest?: typeof defaultGetValidatedManifest,\n};\n\nexport default async function run(\n {\n artifactsDir,\n browserConsole = false,\n pref,\n firefox,\n firefoxProfile,\n profileCreateIfMissing,\n keepProfileChanges = false,\n ignoreFiles,\n noInput = false,\n noReload = false,\n preInstall = false,\n sourceDir,\n watchFile,\n watchIgnored,\n startUrl,\n target,\n args,\n firefoxPreview = [],\n // Android CLI options.\n adbBin,\n adbHost,\n adbPort,\n adbDevice,\n adbDiscoveryTimeout,\n adbRemoveOldArtifacts,\n firefoxApk,\n firefoxApkComponent,\n // Chromium CLI options.\n chromiumBinary,\n chromiumProfile,\n }: CmdRunParams,\n {\n buildExtension = defaultBuildExtension,\n desktopNotifications = defaultDesktopNotifications,\n firefoxApp = defaultFirefoxApp,\n firefoxClient = defaultFirefoxClient,\n reloadStrategy = defaultReloadStrategy,\n MultiExtensionRunner = DefaultMultiExtensionRunner,\n getValidatedManifest = defaultGetValidatedManifest,\n }: CmdRunOptions = {}): Promise<DefaultMultiExtensionRunner> {\n\n log.info(`Running web extension from ${sourceDir}`);\n if (preInstall) {\n log.info('Disabled auto-reloading because it\\'s not possible with ' +\n '--pre-install');\n noReload = true;\n }\n\n if (watchFile != null && (!Array.isArray(watchFile) ||\n !watchFile.every((el) => typeof el === 'string'))) {\n throw new UsageError('Unexpected watchFile type');\n }\n\n // Create an alias for --pref since it has been transformed into an\n // object containing one or more preferences.\n const customPrefs: FirefoxPreferences = {...pref};\n if (firefoxPreview.includes('mv3')) {\n log.info('Configuring Firefox preferences for Manifest V3');\n customPrefs['extensions.manifestV3.enabled'] = true;\n }\n\n const manifestData = await getValidatedManifest(sourceDir);\n\n const profileDir = firefoxProfile || chromiumProfile;\n\n if (profileCreateIfMissing) {\n if (!profileDir) {\n throw new UsageError(\n '--profile-create-if-missing requires ' +\n '--firefox-profile or --chromium-profile'\n );\n }\n const isDir = fs.existsSync(profileDir);\n if (isDir) {\n log.info(`Profile directory ${profileDir} already exists`);\n } else {\n log.info(`Profile directory not found. Creating directory ${profileDir}`);\n await fs.mkdir(profileDir);\n }\n }\n\n const runners = [];\n\n const commonRunnerParams = {\n // Common options.\n extensions: [{sourceDir, manifestData}],\n keepProfileChanges,\n startUrl,\n args,\n desktopNotifications,\n };\n\n if (!target || target.length === 0 || target.includes('firefox-desktop')) {\n const firefoxDesktopRunnerParams = {\n ...commonRunnerParams,\n\n // Firefox specific CLI options.\n firefoxBinary: firefox,\n profilePath: firefoxProfile,\n customPrefs,\n browserConsole,\n preInstall,\n\n // Firefox runner injected dependencies.\n firefoxApp,\n firefoxClient,\n };\n\n const firefoxDesktopRunner = await createExtensionRunner({\n target: 'firefox-desktop',\n params: firefoxDesktopRunnerParams,\n });\n runners.push(firefoxDesktopRunner);\n }\n\n if (target && target.includes('firefox-android')) {\n const firefoxAndroidRunnerParams = {\n ...commonRunnerParams,\n\n // Firefox specific CLI options.\n profilePath: firefoxProfile,\n customPrefs,\n browserConsole,\n preInstall,\n firefoxApk,\n firefoxApkComponent,\n adbDevice,\n adbHost,\n adbPort,\n adbBin,\n adbDiscoveryTimeout,\n adbRemoveOldArtifacts,\n\n // Injected dependencies.\n firefoxApp,\n firefoxClient,\n desktopNotifications: defaultDesktopNotifications,\n buildSourceDir: (extensionSourceDir: string, tmpArtifactsDir: string) => {\n return buildExtension({\n sourceDir: extensionSourceDir,\n ignoreFiles,\n asNeeded: false,\n // Use a separate temporary directory for building the extension zip file\n // that we are going to upload on the android device.\n artifactsDir: tmpArtifactsDir,\n }, {\n // Suppress the message usually logged by web-ext build.\n showReadyMessage: false,\n });\n },\n };\n\n const firefoxAndroidRunner = await createExtensionRunner({\n target: 'firefox-android',\n params: firefoxAndroidRunnerParams,\n });\n runners.push(firefoxAndroidRunner);\n }\n\n if (target && target.includes('chromium')) {\n const chromiumRunnerParams = {\n ...commonRunnerParams,\n chromiumBinary,\n chromiumProfile,\n };\n\n const chromiumRunner = await createExtensionRunner({\n target: 'chromium',\n params: chromiumRunnerParams,\n });\n runners.push(chromiumRunner);\n }\n\n const extensionRunner = new MultiExtensionRunner({\n desktopNotifications,\n runners,\n });\n\n await extensionRunner.run();\n\n if (noReload) {\n log.info('Automatic extension reloading has been disabled');\n } else {\n log.info('The extension will reload if any source file changes');\n\n reloadStrategy({\n extensionRunner,\n sourceDir,\n watchFile,\n watchIgnored,\n artifactsDir,\n ignoreFiles,\n noInput,\n });\n }\n\n return extensionRunner;\n}\n"],"mappings":"AACA,SAASA,EAAT,QAAmB,IAAnB;AAEA,OAAOC,qBAAP,MAAkC,YAAlC;AACA,SACEC,uBAAuB,IAAIC,2BAD7B,QAEO,6BAFP;AAGA,OAAO,KAAKC,iBAAZ,MAAm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,EAAE,iBAD+C;MAEvDuC,MAAM,EAAEE;IAF+C,CAAD,CAAxD;IAIAV,OAAO,CAACS,IAAR,CAAaO,oBAAb;EACD;;EAED,IAAI/C,MAAM,IAAIA,MAAM,CAACyB,QAAP,CAAgB,UAAhB,CAAd,EAA2C;IACzC,MAAMuB,oBAAoB,GAAG,EAC3B,GAAGhB,kBADwB;MAE3BrB,cAF2B;MAG3BC;IAH2B,CAA7B;IAMA,MAAMqC,cAAc,GAAG,MAAMzE,qBAAqB,CAAC;MACjDwB,MAAM,EAAE,UADyC;MAEjDuC,MAAM,EAAES;IAFyC,CAAD,CAAlD;IAIAjB,OAAO,CAACS,IAAR,CAAaS,cAAb;EACD;;EAED,MAAMC,eAAe,GAAG,IAAIxE,oBAAJ,CAAyB;IAC/CoC,oBAD+C;IAE/CiB;EAF+C,CAAzB,CAAxB;EAKA,MAAMmB,eAAe,CAAClE,GAAhB,EAAN;;EAEA,IAAIU,QAAJ,EAAc;IACZd,GAAG,CAACuC,IAAJ,CAAS,iDAAT;EACD,CAFD,MAEO;IACLvC,GAAG,CAACuC,IAAJ,CAAS,sDAAT;IAEAF,cAAc,CAAC;MACbiC,eADa;MAEbtD,SAFa;MAGbC,SAHa;MAIbC,YAJa;MAKbb,YALa;MAMbO,WANa;MAObC;IAPa,CAAD,CAAd;EASD;;EAED,OAAOyD,eAAP;AACD"}
|
|
@@ -205,7 +205,8 @@ export class FirefoxDesktopExtensionRunner {
|
|
|
205
205
|
|
|
206
206
|
this.runningInfo = await firefoxApp.run(this.profile, {
|
|
207
207
|
firefoxBinary,
|
|
208
|
-
binaryArgs
|
|
208
|
+
binaryArgs,
|
|
209
|
+
extensions
|
|
209
210
|
});
|
|
210
211
|
this.runningInfo.firefox.on('close', () => {
|
|
211
212
|
for (const cleanupCb of this.cleanupCallbacks) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firefox-desktop.js","names":["MultiExtensionsReloadError","RemoteTempInstallNotSupported","WebExtError","defaultFirefoxApp","connectWithMaxRetries","defaultFirefoxConnector","createLogger","log","import","meta","url","FirefoxDesktopExtensionRunner","constructor","params","reloadableExtensions","Map","cleanupCallbacks","Set","getName","run","setupProfileDir","startFirefoxInstance","reloadAllExtensions","runnerName","reloadErrors","sourceDir","extensions","res","reloadExtensionBySourceDir","reloadError","Error","set","size","extensionSourceDir","addonId","get","remoteFirefox","reloadAddon","error","registerCleanup","fn","add","exit","runningInfo","firefox","kill","customPrefs","keepProfileChanges","preInstall","profilePath","firefoxApp","debug","profile","useProfile","copyProfile","createProfile","extension","installExtension","asProxy","extensionPath","manifestData","browserConsole","firefoxBinary","startUrl","firefoxClient","args","binaryArgs","push","urls","Array","isArray","on","cleanupCb","port","debuggerPort","installTemporaryAddon","then","installResult","addon","id","String"],"sources":["../../src/extension-runners/firefox-desktop.js"],"sourcesContent":["/* @flow */\n\n/**\n * This module provide an ExtensionRunner subclass that manage an extension executed\n * in a Firefox for Desktop instance.\n */\n\n// Import flow types from npm dependencies.\nimport type FirefoxProfile from 'firefox-profile';\n\nimport {\n MultiExtensionsReloadError,\n RemoteTempInstallNotSupported,\n WebExtError,\n} from '../errors.js';\nimport * as defaultFirefoxApp from '../firefox/index.js';\nimport {\n connectWithMaxRetries as defaultFirefoxConnector,\n} from '../firefox/remote.js';\nimport {createLogger} from '../util/logger.js';\n// Import flow types from project files.\nimport type {\n FirefoxRDPResponseAddon,\n RemoteFirefox,\n} from '../firefox/remote';\nimport type {\n ExtensionRunnerParams,\n ExtensionRunnerReloadResult,\n} from './base';\nimport type {FirefoxPreferences} from '../firefox/preferences';\nimport type {FirefoxInfo} from '../firefox/index'; // eslint-disable-line import/named\n\ntype FirefoxDesktopSpecificRunnerParams = {|\n customPrefs?: FirefoxPreferences,\n browserConsole: boolean,\n firefoxBinary: string,\n preInstall: boolean,\n\n // Firefox desktop injected dependencies.\n firefoxApp: typeof defaultFirefoxApp,\n firefoxClient: typeof defaultFirefoxConnector,\n|};\n\nexport type FirefoxDesktopExtensionRunnerParams = {|\n ...ExtensionRunnerParams,\n // Firefox desktop CLI params.\n ...FirefoxDesktopSpecificRunnerParams,\n|};\n\nconst log = createLogger(import.meta.url);\n\n\n/**\n * Implements an IExtensionRunner which manages a Firefox Desktop instance.\n */\nexport class FirefoxDesktopExtensionRunner {\n cleanupCallbacks: Set<Function>;\n params: FirefoxDesktopExtensionRunnerParams;\n profile: FirefoxProfile;\n // Map extensions sourceDir to their related addon ids.\n reloadableExtensions: Map<string, string>;\n remoteFirefox: RemoteFirefox;\n runningInfo: FirefoxInfo;\n\n constructor(params: FirefoxDesktopExtensionRunnerParams) {\n this.params = params;\n\n this.reloadableExtensions = new Map();\n this.cleanupCallbacks = new Set();\n }\n\n // Method exported from the IExtensionRunner interface.\n\n /**\n * Returns the runner name.\n */\n getName(): string {\n return 'Firefox Desktop';\n }\n\n /**\n * Setup the Firefox Profile and run a Firefox Desktop instance.\n */\n async run(): Promise<void> {\n // Get a firefox profile with the custom Prefs set (a new or a cloned one).\n // Pre-install extensions as proxy if needed (and disable auto-reload if you do)\n await this.setupProfileDir();\n\n // (if reload is enabled):\n // - Connect to the firefox instance on RDP\n // - Install any extension if needed (if not installed as proxy)\n // - Keep track of the extension id assigned in a map with the sourceDir as a key\n await this.startFirefoxInstance();\n }\n\n /**\n * Reloads all the extensions, collect any reload error and resolves to\n * an array composed by a single ExtensionRunnerReloadResult object.\n */\n async reloadAllExtensions(): Promise<Array<ExtensionRunnerReloadResult>> {\n const runnerName = this.getName();\n const reloadErrors = new Map();\n for (const {sourceDir} of this.params.extensions) {\n const [res] = await this.reloadExtensionBySourceDir(sourceDir);\n if (res.reloadError instanceof Error) {\n reloadErrors.set(sourceDir, res.reloadError);\n }\n }\n\n if (reloadErrors.size > 0) {\n return [{\n runnerName,\n reloadError: new MultiExtensionsReloadError(reloadErrors),\n }];\n }\n\n return [{runnerName}];\n }\n\n /**\n * Reloads a single extension, collect any reload error and resolves to\n * an array composed by a single ExtensionRunnerReloadResult object.\n */\n async reloadExtensionBySourceDir(\n extensionSourceDir: string\n ): Promise<Array<ExtensionRunnerReloadResult>> {\n const runnerName = this.getName();\n const addonId = this.reloadableExtensions.get(extensionSourceDir);\n\n if (!addonId) {\n return [{\n sourceDir: extensionSourceDir,\n reloadError: new WebExtError(\n 'Extension not reloadable: ' +\n `no addonId has been mapped to \"${extensionSourceDir}\"`\n ),\n runnerName,\n }];\n }\n\n try {\n await this.remoteFirefox.reloadAddon(addonId);\n } catch (error) {\n return [{\n sourceDir: extensionSourceDir,\n reloadError: error,\n runnerName,\n }];\n }\n\n return [{runnerName, sourceDir: extensionSourceDir}];\n }\n\n /**\n * Register a callback to be called when the runner has been exited\n * (e.g. the Firefox instance exits or the user has requested web-ext\n * to exit).\n */\n registerCleanup(fn: Function): void {\n this.cleanupCallbacks.add(fn);\n }\n\n /**\n * Exits the runner, by closing the managed Firefox instance.\n */\n async exit(): Promise<void> {\n if (!this.runningInfo || !this.runningInfo.firefox) {\n throw new WebExtError('No firefox instance is currently running');\n }\n\n this.runningInfo.firefox.kill();\n }\n\n // Private helper methods.\n\n async setupProfileDir() {\n const {\n customPrefs,\n extensions,\n keepProfileChanges,\n preInstall,\n profilePath,\n firefoxApp,\n } = this.params;\n\n if (profilePath) {\n if (keepProfileChanges) {\n log.debug(`Using Firefox profile from ${profilePath}`);\n this.profile = await firefoxApp.useProfile(profilePath, {customPrefs});\n } else {\n log.debug(`Copying Firefox profile from ${profilePath}`);\n this.profile = await firefoxApp.copyProfile(profilePath, {customPrefs});\n }\n } else {\n log.debug('Creating new Firefox profile');\n this.profile = await firefoxApp.createProfile({customPrefs});\n }\n\n // preInstall the extensions if needed.\n if (preInstall) {\n for (const extension of extensions) {\n await firefoxApp.installExtension({\n asProxy: true,\n extensionPath: extension.sourceDir,\n manifestData: extension.manifestData,\n profile: this.profile,\n });\n }\n }\n }\n\n async startFirefoxInstance() {\n const {\n browserConsole,\n extensions,\n firefoxBinary,\n preInstall,\n startUrl,\n firefoxApp,\n firefoxClient,\n args,\n } = this.params;\n\n const binaryArgs = [];\n\n if (browserConsole) {\n binaryArgs.push('-jsconsole');\n }\n if (startUrl) {\n const urls = Array.isArray(startUrl) ? startUrl : [startUrl];\n for (const url of urls) {\n binaryArgs.push('--url', url);\n }\n }\n\n if (args) {\n binaryArgs.push(...args);\n }\n\n this.runningInfo = await firefoxApp.run(this.profile, {\n firefoxBinary, binaryArgs,\n });\n\n this.runningInfo.firefox.on('close', () => {\n for (const cleanupCb of this.cleanupCallbacks) {\n try {\n cleanupCb();\n } catch (error) {\n log.error(`Exception on executing cleanup callback: ${error}`);\n }\n }\n });\n\n if (!preInstall) {\n const remoteFirefox = this.remoteFirefox = await firefoxClient({\n port: this.runningInfo.debuggerPort,\n });\n\n // Install all the temporary addons.\n for (const extension of extensions) {\n try {\n const addonId = await (\n remoteFirefox.installTemporaryAddon(extension.sourceDir)\n .then((installResult: FirefoxRDPResponseAddon) => {\n return installResult.addon.id;\n })\n );\n\n if (!addonId) {\n throw new WebExtError(\n 'Unexpected missing addonId in the installAsTemporaryAddon result'\n );\n }\n\n this.reloadableExtensions.set(extension.sourceDir, addonId);\n } catch (error) {\n if (error instanceof RemoteTempInstallNotSupported) {\n log.debug(`Caught: ${String(error)}`);\n throw new WebExtError(\n 'Temporary add-on installation is not supported in this version' +\n ' of Firefox (you need Firefox 49 or higher). For older Firefox' +\n ' versions, use --pre-install'\n );\n } else {\n throw error;\n }\n }\n }\n }\n }\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;AAEA;AAGA,SACEA,0BADF,EAEEC,6BAFF,EAGEC,WAHF,QAIO,cAJP;AAKA,OAAO,KAAKC,iBAAZ,MAAmC,qBAAnC;AACA,SACEC,qBAAqB,IAAIC,uBAD3B,QAEO,sBAFP;AAGA,SAAQC,YAAR,QAA2B,mBAA3B,C,CACA;;AA6BA,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAP,CAAYC,GAAb,CAAxB;AAGA;AACA;AACA;;AACA,O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IACF;EACF;;AA1OwC"}
|
|
1
|
+
{"version":3,"file":"firefox-desktop.js","names":["MultiExtensionsReloadError","RemoteTempInstallNotSupported","WebExtError","defaultFirefoxApp","connectWithMaxRetries","defaultFirefoxConnector","createLogger","log","import","meta","url","FirefoxDesktopExtensionRunner","constructor","params","reloadableExtensions","Map","cleanupCallbacks","Set","getName","run","setupProfileDir","startFirefoxInstance","reloadAllExtensions","runnerName","reloadErrors","sourceDir","extensions","res","reloadExtensionBySourceDir","reloadError","Error","set","size","extensionSourceDir","addonId","get","remoteFirefox","reloadAddon","error","registerCleanup","fn","add","exit","runningInfo","firefox","kill","customPrefs","keepProfileChanges","preInstall","profilePath","firefoxApp","debug","profile","useProfile","copyProfile","createProfile","extension","installExtension","asProxy","extensionPath","manifestData","browserConsole","firefoxBinary","startUrl","firefoxClient","args","binaryArgs","push","urls","Array","isArray","on","cleanupCb","port","debuggerPort","installTemporaryAddon","then","installResult","addon","id","String"],"sources":["../../src/extension-runners/firefox-desktop.js"],"sourcesContent":["/* @flow */\n\n/**\n * This module provide an ExtensionRunner subclass that manage an extension executed\n * in a Firefox for Desktop instance.\n */\n\n// Import flow types from npm dependencies.\nimport type FirefoxProfile from 'firefox-profile';\n\nimport {\n MultiExtensionsReloadError,\n RemoteTempInstallNotSupported,\n WebExtError,\n} from '../errors.js';\nimport * as defaultFirefoxApp from '../firefox/index.js';\nimport {\n connectWithMaxRetries as defaultFirefoxConnector,\n} from '../firefox/remote.js';\nimport {createLogger} from '../util/logger.js';\n// Import flow types from project files.\nimport type {\n FirefoxRDPResponseAddon,\n RemoteFirefox,\n} from '../firefox/remote';\nimport type {\n ExtensionRunnerParams,\n ExtensionRunnerReloadResult,\n} from './base';\nimport type {FirefoxPreferences} from '../firefox/preferences';\nimport type {FirefoxInfo} from '../firefox/index'; // eslint-disable-line import/named\n\ntype FirefoxDesktopSpecificRunnerParams = {|\n customPrefs?: FirefoxPreferences,\n browserConsole: boolean,\n firefoxBinary: string,\n preInstall: boolean,\n\n // Firefox desktop injected dependencies.\n firefoxApp: typeof defaultFirefoxApp,\n firefoxClient: typeof defaultFirefoxConnector,\n|};\n\nexport type FirefoxDesktopExtensionRunnerParams = {|\n ...ExtensionRunnerParams,\n // Firefox desktop CLI params.\n ...FirefoxDesktopSpecificRunnerParams,\n|};\n\nconst log = createLogger(import.meta.url);\n\n\n/**\n * Implements an IExtensionRunner which manages a Firefox Desktop instance.\n */\nexport class FirefoxDesktopExtensionRunner {\n cleanupCallbacks: Set<Function>;\n params: FirefoxDesktopExtensionRunnerParams;\n profile: FirefoxProfile;\n // Map extensions sourceDir to their related addon ids.\n reloadableExtensions: Map<string, string>;\n remoteFirefox: RemoteFirefox;\n runningInfo: FirefoxInfo;\n\n constructor(params: FirefoxDesktopExtensionRunnerParams) {\n this.params = params;\n\n this.reloadableExtensions = new Map();\n this.cleanupCallbacks = new Set();\n }\n\n // Method exported from the IExtensionRunner interface.\n\n /**\n * Returns the runner name.\n */\n getName(): string {\n return 'Firefox Desktop';\n }\n\n /**\n * Setup the Firefox Profile and run a Firefox Desktop instance.\n */\n async run(): Promise<void> {\n // Get a firefox profile with the custom Prefs set (a new or a cloned one).\n // Pre-install extensions as proxy if needed (and disable auto-reload if you do)\n await this.setupProfileDir();\n\n // (if reload is enabled):\n // - Connect to the firefox instance on RDP\n // - Install any extension if needed (if not installed as proxy)\n // - Keep track of the extension id assigned in a map with the sourceDir as a key\n await this.startFirefoxInstance();\n }\n\n /**\n * Reloads all the extensions, collect any reload error and resolves to\n * an array composed by a single ExtensionRunnerReloadResult object.\n */\n async reloadAllExtensions(): Promise<Array<ExtensionRunnerReloadResult>> {\n const runnerName = this.getName();\n const reloadErrors = new Map();\n for (const {sourceDir} of this.params.extensions) {\n const [res] = await this.reloadExtensionBySourceDir(sourceDir);\n if (res.reloadError instanceof Error) {\n reloadErrors.set(sourceDir, res.reloadError);\n }\n }\n\n if (reloadErrors.size > 0) {\n return [{\n runnerName,\n reloadError: new MultiExtensionsReloadError(reloadErrors),\n }];\n }\n\n return [{runnerName}];\n }\n\n /**\n * Reloads a single extension, collect any reload error and resolves to\n * an array composed by a single ExtensionRunnerReloadResult object.\n */\n async reloadExtensionBySourceDir(\n extensionSourceDir: string\n ): Promise<Array<ExtensionRunnerReloadResult>> {\n const runnerName = this.getName();\n const addonId = this.reloadableExtensions.get(extensionSourceDir);\n\n if (!addonId) {\n return [{\n sourceDir: extensionSourceDir,\n reloadError: new WebExtError(\n 'Extension not reloadable: ' +\n `no addonId has been mapped to \"${extensionSourceDir}\"`\n ),\n runnerName,\n }];\n }\n\n try {\n await this.remoteFirefox.reloadAddon(addonId);\n } catch (error) {\n return [{\n sourceDir: extensionSourceDir,\n reloadError: error,\n runnerName,\n }];\n }\n\n return [{runnerName, sourceDir: extensionSourceDir}];\n }\n\n /**\n * Register a callback to be called when the runner has been exited\n * (e.g. the Firefox instance exits or the user has requested web-ext\n * to exit).\n */\n registerCleanup(fn: Function): void {\n this.cleanupCallbacks.add(fn);\n }\n\n /**\n * Exits the runner, by closing the managed Firefox instance.\n */\n async exit(): Promise<void> {\n if (!this.runningInfo || !this.runningInfo.firefox) {\n throw new WebExtError('No firefox instance is currently running');\n }\n\n this.runningInfo.firefox.kill();\n }\n\n // Private helper methods.\n\n async setupProfileDir() {\n const {\n customPrefs,\n extensions,\n keepProfileChanges,\n preInstall,\n profilePath,\n firefoxApp,\n } = this.params;\n\n if (profilePath) {\n if (keepProfileChanges) {\n log.debug(`Using Firefox profile from ${profilePath}`);\n this.profile = await firefoxApp.useProfile(profilePath, {customPrefs});\n } else {\n log.debug(`Copying Firefox profile from ${profilePath}`);\n this.profile = await firefoxApp.copyProfile(profilePath, {customPrefs});\n }\n } else {\n log.debug('Creating new Firefox profile');\n this.profile = await firefoxApp.createProfile({customPrefs});\n }\n\n // preInstall the extensions if needed.\n if (preInstall) {\n for (const extension of extensions) {\n await firefoxApp.installExtension({\n asProxy: true,\n extensionPath: extension.sourceDir,\n manifestData: extension.manifestData,\n profile: this.profile,\n });\n }\n }\n }\n\n async startFirefoxInstance() {\n const {\n browserConsole,\n extensions,\n firefoxBinary,\n preInstall,\n startUrl,\n firefoxApp,\n firefoxClient,\n args,\n } = this.params;\n\n const binaryArgs = [];\n\n if (browserConsole) {\n binaryArgs.push('-jsconsole');\n }\n if (startUrl) {\n const urls = Array.isArray(startUrl) ? startUrl : [startUrl];\n for (const url of urls) {\n binaryArgs.push('--url', url);\n }\n }\n\n if (args) {\n binaryArgs.push(...args);\n }\n\n this.runningInfo = await firefoxApp.run(this.profile, {\n firefoxBinary,\n binaryArgs,\n extensions,\n });\n\n this.runningInfo.firefox.on('close', () => {\n for (const cleanupCb of this.cleanupCallbacks) {\n try {\n cleanupCb();\n } catch (error) {\n log.error(`Exception on executing cleanup callback: ${error}`);\n }\n }\n });\n\n if (!preInstall) {\n const remoteFirefox = this.remoteFirefox = await firefoxClient({\n port: this.runningInfo.debuggerPort,\n });\n\n // Install all the temporary addons.\n for (const extension of extensions) {\n try {\n const addonId = await (\n remoteFirefox.installTemporaryAddon(extension.sourceDir)\n .then((installResult: FirefoxRDPResponseAddon) => {\n return installResult.addon.id;\n })\n );\n\n if (!addonId) {\n throw new WebExtError(\n 'Unexpected missing addonId in the installAsTemporaryAddon result'\n );\n }\n\n this.reloadableExtensions.set(extension.sourceDir, addonId);\n } catch (error) {\n if (error instanceof RemoteTempInstallNotSupported) {\n log.debug(`Caught: ${String(error)}`);\n throw new WebExtError(\n 'Temporary add-on installation is not supported in this version' +\n ' of Firefox (you need Firefox 49 or higher). For older Firefox' +\n ' versions, use --pre-install'\n );\n } else {\n throw error;\n }\n }\n }\n }\n }\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;AAEA;AAGA,SACEA,0BADF,EAEEC,6BAFF,EAGEC,WAHF,QAIO,cAJP;AAKA,OAAO,KAAKC,iBAAZ,MAAmC,qBAAnC;AACA,SACEC,qBAAqB,IAAIC,uBAD3B,QAEO,sBAFP;AAGA,SAAQC,YAAR,QAA2B,mBA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AD,CAAQ,EAAnC;YACA,MAAM,IAAIpC,WAAJ,CACJ,mEACA,gEADA,GAEA,8BAHI,CAAN;UAKD,CAPD,MAOO;YACL,MAAMoC,KAAN;UACD;QACF;MACF;IACF;EACF;;AA5OwC"}
|
package/lib/firefox/index.js
CHANGED
|
@@ -27,14 +27,35 @@ export async function run(profile, {
|
|
|
27
27
|
fxRunner = defaultFxRunner,
|
|
28
28
|
findRemotePort = defaultRemotePortFinder,
|
|
29
29
|
firefoxBinary,
|
|
30
|
-
binaryArgs
|
|
30
|
+
binaryArgs,
|
|
31
|
+
extensions
|
|
31
32
|
} = {}) {
|
|
32
33
|
log.debug(`Running Firefox with profile at ${profile.path()}`);
|
|
33
34
|
const remotePort = await findRemotePort();
|
|
35
|
+
|
|
36
|
+
if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {
|
|
37
|
+
const flatpakAppId = firefoxBinary.substring(8);
|
|
38
|
+
log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`); // This should be resolved by the fx-runner.
|
|
39
|
+
|
|
40
|
+
firefoxBinary = 'flatpak';
|
|
41
|
+
binaryArgs = ['run', `--filesystem=${profile.path()}`, ...extensions.map(({
|
|
42
|
+
sourceDir
|
|
43
|
+
}) => `--filesystem=${sourceDir}:ro`), // We need to share the network namespace because we want to connect to
|
|
44
|
+
// Firefox with the remote protocol. There is no way to tell flatpak to
|
|
45
|
+
// only expose a port AFAIK.
|
|
46
|
+
'--share=network', // Kill the entire sandbox when the launching process dies, which is what
|
|
47
|
+
// we want since exiting web-ext involves `kill` and the process executed
|
|
48
|
+
// here is `flatpak run`.
|
|
49
|
+
'--die-with-parent', flatpakAppId].concat(...(binaryArgs || []));
|
|
50
|
+
}
|
|
51
|
+
|
|
34
52
|
const results = await fxRunner({
|
|
35
53
|
// if this is falsey, fxRunner tries to find the default one.
|
|
36
54
|
'binary': firefoxBinary,
|
|
37
55
|
'binary-args': binaryArgs,
|
|
56
|
+
// For Flatpak we need to respect the order of the command arguments because
|
|
57
|
+
// we have arguments for Flapack (first) and then Firefox.
|
|
58
|
+
'binary-args-first': firefoxBinary === 'flatpak',
|
|
38
59
|
// This ensures a new instance of Firefox is created. It has nothing
|
|
39
60
|
// to do with the devtools remote debugger.
|
|
40
61
|
'no-remote': true,
|
package/lib/firefox/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["nodeFs","path","promisify","default","defaultFxRunner","FirefoxProfile","fs","fromEvent","isDirectory","isErrorWithCode","UsageError","WebExtError","getPrefs","defaultPrefGetter","getManifestId","findFreeTcpPort","defaultRemotePortFinder","createLogger","log","import","meta","url","defaultAsyncFsStat","stat","bind","defaultUserProfileCopier","copyFromUserProfile","defaultFirefoxEnv","XPCOM_DEBUG_BREAK","NS_TRACE_MALLOC_DISABLE_STACKS","run","profile","fxRunner","findRemotePort","firefoxBinary","binaryArgs","debug","remotePort","results","process","env","firefox","binary","args","join","on","error","info","stderr","data","toString","trim","stdout","debuggerPort","DEFAULT_PROFILES_NAMES","isDefaultProfile","profilePathOrName","ProfileFinder","Finder","fsStat","includes","baseProfileDir","locateUserDirectory","profilesIniPath","finder","readProfiles","normalizedProfileDirPath","normalize","resolve","sep","profiles","Name","Default","profileFullPath","IsRelative","Path","configureProfile","app","customPrefs","prefs","Object","keys","forEach","pref","setPreference","length","customPrefsStr","JSON","stringify","custom","updatePreferences","Promise","defaultCreateProfileFinder","userDirectoryPath","FxProfile","getPath","profileName","hasProfileName","filter","profileDef","warn","useProfile","profilePath","configureThisProfile","isFirefoxDefaultProfile","createProfileFinder","isForbiddenProfile","destinationDirectory","getProfilePath","profileIsDirPath","createProfile","copyProfile","profileDirectory","copy","copyByName","dirExists","name","installExtension","asProxy","manifestData","extensionPath","asyncFsStat","extensionsDir","mkdir","id","isDir","destPath","writeStream","createWriteStream","write","end","readStream","createReadStream","pipe","all"],"sources":["../../src/firefox/index.js"],"sourcesContent":["/* @flow */\nimport nodeFs from 'fs';\nimport path from 'path';\nimport {promisify} from 'util';\n\nimport {default as defaultFxRunner} from 'fx-runner';\nimport FirefoxProfile from 'firefox-profile';\nimport {fs} from 'mz';\nimport fromEvent from 'promise-toolbox/fromEvent';\n\nimport isDirectory from '../util/is-directory.js';\nimport {isErrorWithCode, UsageError, WebExtError} from '../errors.js';\nimport {getPrefs as defaultPrefGetter} from './preferences.js';\nimport {getManifestId} from '../util/manifest.js';\nimport {findFreeTcpPort as defaultRemotePortFinder} from './remote.js';\nimport {createLogger} from '../util/logger.js';\n// Import flow types\nimport type {\n PreferencesAppName,\n PreferencesGetterFn,\n FirefoxPreferences,\n} from './preferences';\nimport type {ExtensionManifest} from '../util/manifest.js';\n\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsStat: typeof fs.stat = fs.stat.bind(fs);\n\nconst defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;\n\nexport const defaultFirefoxEnv = {\n XPCOM_DEBUG_BREAK: 'stack',\n NS_TRACE_MALLOC_DISABLE_STACKS: '1',\n};\n\n// defaultRemotePortFinder types and implementation.\n\n\nexport type RemotePortFinderFn =\n () => Promise<number>;\n\n// Declare the needed 'fx-runner' module flow types.\n\nexport type FirefoxRunnerParams = {|\n binary: ?string,\n profile?: string,\n 'new-instance'?: boolean,\n 'no-remote'?: boolean,\n 'foreground'?: boolean,\n 'listen': number,\n 'binary-args'?: Array<string> | string,\n 'env'?: {\n // This match the flowtype signature for process.env (and prevent flow\n // from complaining about differences between their type signature)\n [key: string]: string | void\n },\n 'verbose'?: boolean,\n|};\n\nexport interface FirefoxProcess extends events$EventEmitter {\n stderr: events$EventEmitter;\n stdout: events$EventEmitter;\n kill: Function;\n}\n\nexport type FirefoxRunnerResults = {|\n process: FirefoxProcess,\n binary: string,\n args: Array<string>,\n|}\n\nexport type FirefoxRunnerFn =\n (params: FirefoxRunnerParams) => Promise<FirefoxRunnerResults>;\n\n\nexport type FirefoxInfo = {|\n firefox: FirefoxProcess,\n debuggerPort: number,\n|}\n\n// Run command types and implementaion.\n\nexport type FirefoxRunOptions = {\n fxRunner?: FirefoxRunnerFn,\n findRemotePort?: RemotePortFinderFn,\n firefoxBinary?: string,\n binaryArgs?: Array<string>,\n args?: Array<any>,\n};\n\n/*\n * Runs Firefox with the given profile object and resolves a promise on exit.\n */\nexport async function run(\n profile: FirefoxProfile,\n {\n fxRunner = defaultFxRunner,\n findRemotePort = defaultRemotePortFinder,\n firefoxBinary, binaryArgs,\n }: FirefoxRunOptions = {}\n): Promise<FirefoxInfo> {\n\n log.debug(`Running Firefox with profile at ${profile.path()}`);\n\n const remotePort = await findRemotePort();\n\n const results = await fxRunner({\n // if this is falsey, fxRunner tries to find the default one.\n 'binary': firefoxBinary,\n 'binary-args': binaryArgs,\n // This ensures a new instance of Firefox is created. It has nothing\n // to do with the devtools remote debugger.\n 'no-remote': true,\n 'listen': remotePort,\n 'foreground': true,\n 'profile': profile.path(),\n 'env': {\n ...process.env,\n ...defaultFirefoxEnv,\n },\n 'verbose': true,\n });\n\n const firefox = results.process;\n\n log.debug(`Executing Firefox binary: ${results.binary}`);\n log.debug(`Firefox args: ${results.args.join(' ')}`);\n\n firefox.on('error', (error) => {\n // TODO: show a nice error when it can't find Firefox.\n // if (/No such file/.test(err) || err.code === 'ENOENT') {\n log.error(`Firefox error: ${error}`);\n throw error;\n });\n\n log.info(\n 'Use --verbose or open Tools > Web Developer > Browser Console ' +\n 'to see logging');\n\n firefox.stderr.on('data', (data) => {\n log.debug(`Firefox stderr: ${data.toString().trim()}`);\n });\n\n firefox.stdout.on('data', (data) => {\n log.debug(`Firefox stdout: ${data.toString().trim()}`);\n });\n\n firefox.on('close', () => {\n log.debug('Firefox closed');\n });\n\n return { firefox, debuggerPort: remotePort };\n}\n\n\n// isDefaultProfile types and implementation.\n\nconst DEFAULT_PROFILES_NAMES = [\n 'default',\n 'dev-edition-default',\n];\n\nexport type IsDefaultProfileFn = (\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder,\n fsStat?: typeof fs.stat,\n) => Promise<boolean>;\n\n/*\n * Tests if a profile is a default Firefox profile (both as a profile name or\n * profile path).\n *\n * Returns a promise that resolves to true if the profile is one of default Firefox profile.\n */\nexport async function isDefaultProfile(\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder = FirefoxProfile.Finder,\n fsStat?: typeof fs.stat = fs.stat,\n): Promise<boolean> {\n if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {\n return true;\n }\n\n const baseProfileDir = ProfileFinder.locateUserDirectory();\n const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');\n try {\n await fsStat(profilesIniPath);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`profiles.ini not found: ${error}`);\n\n // No profiles exist yet, default to false (the default profile name contains a\n // random generated component).\n return false;\n }\n\n // Re-throw any unexpected exception.\n throw error;\n }\n\n // Check for profile dir path.\n const finder = new ProfileFinder(baseProfileDir);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n\n await readProfiles();\n\n const normalizedProfileDirPath = path.normalize(\n path.join(path.resolve(profilePathOrName), path.sep)\n );\n\n for (const profile of finder.profiles) {\n // Check if the profile dir path or name is one of the default profiles\n // defined in the profiles.ini file.\n if (DEFAULT_PROFILES_NAMES.includes(profile.Name) ||\n profile.Default === '1') {\n let profileFullPath;\n\n // Check for profile name.\n if (profile.Name === profilePathOrName) {\n return true;\n }\n\n // Check for profile path.\n if (profile.IsRelative === '1') {\n profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);\n } else {\n profileFullPath = path.join(profile.Path, path.sep);\n }\n\n if (path.normalize(profileFullPath) === normalizedProfileDirPath) {\n return true;\n }\n }\n }\n\n // Profile directory not found.\n return false;\n}\n\n// configureProfile types and implementation.\n\nexport type ConfigureProfileOptions = {\n app?: PreferencesAppName,\n getPrefs?: PreferencesGetterFn,\n customPrefs?: FirefoxPreferences,\n};\n\nexport type ConfigureProfileFn = (\n profile: FirefoxProfile,\n options?: ConfigureProfileOptions\n) => Promise<FirefoxProfile>;\n\n/*\n * Configures a profile with common preferences that are required to\n * activate extension development.\n *\n * Returns a promise that resolves with the original profile object.\n */\nexport function configureProfile(\n profile: FirefoxProfile,\n {\n app = 'firefox',\n getPrefs = defaultPrefGetter,\n customPrefs = {},\n }: ConfigureProfileOptions = {},\n): Promise<FirefoxProfile> {\n // Set default preferences. Some of these are required for the add-on to\n // operate, such as disabling signatures.\n const prefs = getPrefs(app);\n Object.keys(prefs).forEach((pref) => {\n profile.setPreference(pref, prefs[pref]);\n });\n if (Object.keys(customPrefs).length > 0) {\n const customPrefsStr = JSON.stringify(customPrefs, null, 2);\n log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);\n Object.keys(customPrefs).forEach((custom) => {\n profile.setPreference(custom, customPrefs[custom]);\n });\n }\n profile.updatePreferences();\n return Promise.resolve(profile);\n}\n\nexport type getProfileFn = (profileName: string) => Promise<string | void>;\n\nexport type CreateProfileFinderParams = {\n userDirectoryPath?: string,\n FxProfile?: typeof FirefoxProfile\n}\n\nexport function defaultCreateProfileFinder(\n {\n userDirectoryPath,\n FxProfile = FirefoxProfile,\n }: CreateProfileFinderParams = {}\n): getProfileFn {\n const finder = new FxProfile.Finder(userDirectoryPath);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n const getPath = promisify((...args) => finder.getPath(...args));\n return async (profileName: string): Promise<string | void> => {\n try {\n await readProfiles();\n const hasProfileName = finder.profiles.filter(\n (profileDef) => profileDef.Name === profileName).length !== 0;\n if (hasProfileName) {\n return await getPath(profileName);\n }\n } catch (error) {\n if (!isErrorWithCode('ENOENT', error)) {\n throw error;\n }\n log.warn('Unable to find Firefox profiles.ini');\n }\n };\n}\n\n// useProfile types and implementation.\n\nexport type UseProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n isFirefoxDefaultProfile?: IsDefaultProfileFn,\n customPrefs?: FirefoxPreferences,\n createProfileFinder?: typeof defaultCreateProfileFinder,\n};\n\n// Use the target path as a Firefox profile without cloning it\n\nexport async function useProfile(\n profilePath: string,\n {\n app,\n configureThisProfile = configureProfile,\n isFirefoxDefaultProfile = isDefaultProfile,\n customPrefs = {},\n createProfileFinder = defaultCreateProfileFinder,\n }: UseProfileParams = {},\n): Promise<FirefoxProfile> {\n const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);\n if (isForbiddenProfile) {\n throw new UsageError(\n 'Cannot use --keep-profile-changes on a default profile' +\n ` (\"${profilePath}\")` +\n ' because web-ext will make it insecure and unsuitable for daily use.' +\n '\\nSee https://github.com/mozilla/web-ext/issues/1005'\n );\n }\n\n let destinationDirectory;\n const getProfilePath = createProfileFinder();\n\n const profileIsDirPath = await isDirectory(profilePath);\n if (profileIsDirPath) {\n log.debug(`Using profile directory \"${profilePath}\"`);\n destinationDirectory = profilePath;\n } else {\n log.debug(`Assuming ${profilePath} is a named profile`);\n destinationDirectory = await getProfilePath(profilePath);\n if (!destinationDirectory) {\n throw new UsageError(\n `The request \"${profilePath}\" profile name ` +\n 'cannot be resolved to a profile path'\n );\n }\n }\n\n const profile = new FirefoxProfile({destinationDirectory});\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// createProfile types and implementation.\n\nexport type CreateProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Creates a new temporary profile and resolves with the profile object.\n *\n * The profile will be deleted when the system process exits.\n */\nexport async function createProfile(\n {\n app,\n configureThisProfile = configureProfile,\n customPrefs = {},\n }: CreateProfileParams = {},\n): Promise<FirefoxProfile> {\n const profile = new FirefoxProfile();\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// copyProfile types and implementation.\n\nexport type CopyProfileOptions = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n copyFromUserProfile?: Function,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Copies an existing Firefox profile and creates a new temporary profile.\n * The new profile will be configured with some preferences required to\n * activate extension development.\n *\n * It resolves with the new profile object.\n *\n * The temporary profile will be deleted when the system process exits.\n *\n * The existing profile can be specified as a directory path or a name of\n * one that exists in the current user's Firefox directory.\n */\nexport async function copyProfile(\n profileDirectory: string,\n {\n app,\n configureThisProfile = configureProfile,\n copyFromUserProfile = defaultUserProfileCopier,\n customPrefs = {},\n }: CopyProfileOptions = {},\n): Promise<FirefoxProfile> {\n\n const copy = promisify(FirefoxProfile.copy);\n const copyByName = promisify(copyFromUserProfile);\n\n try {\n const dirExists = await isDirectory(profileDirectory);\n\n let profile;\n\n if (dirExists) {\n log.debug(`Copying profile directory from \"${profileDirectory}\"`);\n profile = await copy({profileDirectory});\n } else {\n log.debug(`Assuming ${profileDirectory} is a named profile`);\n profile = await copyByName({name: profileDirectory});\n }\n\n return configureThisProfile(profile, {app, customPrefs});\n } catch (error) {\n throw new WebExtError(\n `Could not copy Firefox profile from ${profileDirectory}: ${error}`);\n }\n}\n\n\n// installExtension types and implementation.\n\nexport type InstallExtensionParams = {|\n asProxy?: boolean,\n manifestData: ExtensionManifest,\n profile: FirefoxProfile,\n extensionPath: string,\n asyncFsStat?: typeof defaultAsyncFsStat,\n|};\n\n/*\n * Installs an extension into the given Firefox profile object.\n * Resolves when complete.\n *\n * The extension is copied into a special location and you need to turn\n * on some preferences to allow this. See extensions.autoDisableScopes in\n * ./preferences.js.\n *\n * When asProxy is true, a special proxy file will be installed. This is a\n * text file that contains the path to the extension source.\n */\nexport async function installExtension(\n {\n asProxy = false,\n manifestData,\n profile,\n extensionPath,\n asyncFsStat = defaultAsyncFsStat,\n }: InstallExtensionParams): Promise<any> {\n // This more or less follows\n // https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531\n // (which is broken for web extensions).\n // TODO: maybe uplift a patch that supports web extensions instead?\n\n if (!profile.extensionsDir) {\n throw new WebExtError('profile.extensionsDir was unexpectedly empty');\n }\n\n try {\n await asyncFsStat(profile.extensionsDir);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`Creating extensions directory: ${profile.extensionsDir}`);\n await fs.mkdir(profile.extensionsDir);\n } else {\n throw error;\n }\n }\n\n const id = getManifestId(manifestData);\n if (!id) {\n throw new UsageError(\n 'An explicit extension ID is required when installing to ' +\n 'a profile (applications.gecko.id not found in manifest.json)');\n }\n\n if (asProxy) {\n log.debug(`Installing as an extension proxy; source: ${extensionPath}`);\n\n const isDir = await isDirectory(extensionPath);\n if (!isDir) {\n throw new WebExtError(\n 'proxy install: extensionPath must be the extension source ' +\n `directory; got: ${extensionPath}`);\n }\n\n // Write a special extension proxy file containing the source\n // directory. See:\n // https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file\n const destPath = path.join(profile.extensionsDir, `${id}`);\n const writeStream = nodeFs.createWriteStream(destPath);\n writeStream.write(extensionPath);\n writeStream.end();\n return await fromEvent(writeStream, 'close');\n } else {\n // Write the XPI file to the profile.\n const readStream = nodeFs.createReadStream(extensionPath);\n const destPath = path.join(profile.extensionsDir, `${id}.xpi`);\n const writeStream = nodeFs.createWriteStream(destPath);\n\n log.debug(`Installing extension from ${extensionPath} to ${destPath}`);\n readStream.pipe(writeStream);\n\n return await Promise.all([\n fromEvent(readStream, 'close'),\n fromEvent(writeStream, 'close'),\n ]);\n }\n}\n"],"mappings":"AACA,OAAOA,MAAP,MAAmB,IAAnB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAAQC,SAAR,QAAwB,MAAxB;AAEA,SAAQC,OAAO,IAAIC,eAAnB,QAAyC,WAAzC;AACA,OAAOC,cAAP,MAA2B,iBAA3B;AACA,SAAQC,EAAR,QAAiB,IAAjB;AACA,OAAOC,SAAP,MAAsB,2BAAtB;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,SAAQC,eAAR,EAAyBC,UAAzB,EAAqCC,WAArC,QAAuD,cAAvD;AACA,SAAQC,QAAQ,IAAIC,iBAApB,QAA4C,kBAA5C;AACA,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2C,GAAR,CAAY,CACvB/H,SAAS,CAAC4H,UAAD,EAAa,OAAb,CADc,EAEvB5H,SAAS,CAACwH,WAAD,EAAc,OAAd,CAFc,CAAZ,CAAb;EAID;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["nodeFs","path","promisify","default","defaultFxRunner","FirefoxProfile","fs","fromEvent","isDirectory","isErrorWithCode","UsageError","WebExtError","getPrefs","defaultPrefGetter","getManifestId","findFreeTcpPort","defaultRemotePortFinder","createLogger","log","import","meta","url","defaultAsyncFsStat","stat","bind","defaultUserProfileCopier","copyFromUserProfile","defaultFirefoxEnv","XPCOM_DEBUG_BREAK","NS_TRACE_MALLOC_DISABLE_STACKS","run","profile","fxRunner","findRemotePort","firefoxBinary","binaryArgs","extensions","debug","remotePort","startsWith","flatpakAppId","substring","map","sourceDir","concat","results","process","env","firefox","binary","args","join","on","error","info","stderr","data","toString","trim","stdout","debuggerPort","DEFAULT_PROFILES_NAMES","isDefaultProfile","profilePathOrName","ProfileFinder","Finder","fsStat","includes","baseProfileDir","locateUserDirectory","profilesIniPath","finder","readProfiles","normalizedProfileDirPath","normalize","resolve","sep","profiles","Name","Default","profileFullPath","IsRelative","Path","configureProfile","app","customPrefs","prefs","Object","keys","forEach","pref","setPreference","length","customPrefsStr","JSON","stringify","custom","updatePreferences","Promise","defaultCreateProfileFinder","userDirectoryPath","FxProfile","getPath","profileName","hasProfileName","filter","profileDef","warn","useProfile","profilePath","configureThisProfile","isFirefoxDefaultProfile","createProfileFinder","isForbiddenProfile","destinationDirectory","getProfilePath","profileIsDirPath","createProfile","copyProfile","profileDirectory","copy","copyByName","dirExists","name","installExtension","asProxy","manifestData","extensionPath","asyncFsStat","extensionsDir","mkdir","id","isDir","destPath","writeStream","createWriteStream","write","end","readStream","createReadStream","pipe","all"],"sources":["../../src/firefox/index.js"],"sourcesContent":["/* @flow */\nimport nodeFs from 'fs';\nimport path from 'path';\nimport {promisify} from 'util';\n\nimport {default as defaultFxRunner} from 'fx-runner';\nimport FirefoxProfile from 'firefox-profile';\nimport {fs} from 'mz';\nimport fromEvent from 'promise-toolbox/fromEvent';\n\nimport isDirectory from '../util/is-directory.js';\nimport {isErrorWithCode, UsageError, WebExtError} from '../errors.js';\nimport {getPrefs as defaultPrefGetter} from './preferences.js';\nimport {getManifestId} from '../util/manifest.js';\nimport {findFreeTcpPort as defaultRemotePortFinder} from './remote.js';\nimport {createLogger} from '../util/logger.js';\n// Import flow types\nimport type {\n PreferencesAppName,\n PreferencesGetterFn,\n FirefoxPreferences,\n} from './preferences';\nimport type {ExtensionManifest} from '../util/manifest.js';\nimport type {Extension} from '../extension-runners/base.js';\n\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsStat: typeof fs.stat = fs.stat.bind(fs);\n\nconst defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;\n\nexport const defaultFirefoxEnv = {\n XPCOM_DEBUG_BREAK: 'stack',\n NS_TRACE_MALLOC_DISABLE_STACKS: '1',\n};\n\n// defaultRemotePortFinder types and implementation.\n\n\nexport type RemotePortFinderFn =\n () => Promise<number>;\n\n// Declare the needed 'fx-runner' module flow types.\n\nexport type FirefoxRunnerParams = {|\n binary: ?string,\n profile?: string,\n 'new-instance'?: boolean,\n 'no-remote'?: boolean,\n 'foreground'?: boolean,\n 'listen': number,\n 'binary-args'?: Array<string> | string,\n 'binary-args-first'?: boolean,\n 'env'?: {\n // This match the flowtype signature for process.env (and prevent flow\n // from complaining about differences between their type signature)\n [key: string]: string | void\n },\n 'verbose'?: boolean,\n|};\n\nexport interface FirefoxProcess extends events$EventEmitter {\n stderr: events$EventEmitter;\n stdout: events$EventEmitter;\n kill: Function;\n}\n\nexport type FirefoxRunnerResults = {|\n process: FirefoxProcess,\n binary: string,\n args: Array<string>,\n|}\n\nexport type FirefoxRunnerFn =\n (params: FirefoxRunnerParams) => Promise<FirefoxRunnerResults>;\n\n\nexport type FirefoxInfo = {|\n firefox: FirefoxProcess,\n debuggerPort: number,\n|}\n\n// Run command types and implementaion.\n\nexport type FirefoxRunOptions = {\n fxRunner?: FirefoxRunnerFn,\n findRemotePort?: RemotePortFinderFn,\n firefoxBinary?: string,\n binaryArgs?: Array<string>,\n args?: Array<any>,\n extensions: Array<Extension>,\n};\n\n/*\n * Runs Firefox with the given profile object and resolves a promise on exit.\n */\nexport async function run(\n profile: FirefoxProfile,\n {\n fxRunner = defaultFxRunner,\n findRemotePort = defaultRemotePortFinder,\n firefoxBinary,\n binaryArgs,\n extensions,\n }: FirefoxRunOptions = {}\n): Promise<FirefoxInfo> {\n\n log.debug(`Running Firefox with profile at ${profile.path()}`);\n\n const remotePort = await findRemotePort();\n\n if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {\n const flatpakAppId = firefoxBinary.substring(8);\n log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);\n\n // This should be resolved by the fx-runner.\n firefoxBinary = 'flatpak';\n binaryArgs = [\n 'run',\n `--filesystem=${profile.path()}`,\n ...extensions.map(({ sourceDir }) => `--filesystem=${sourceDir}:ro`),\n // We need to share the network namespace because we want to connect to\n // Firefox with the remote protocol. There is no way to tell flatpak to\n // only expose a port AFAIK.\n '--share=network',\n // Kill the entire sandbox when the launching process dies, which is what\n // we want since exiting web-ext involves `kill` and the process executed\n // here is `flatpak run`.\n '--die-with-parent',\n flatpakAppId,\n ].concat(...(binaryArgs || []));\n }\n\n const results = await fxRunner({\n // if this is falsey, fxRunner tries to find the default one.\n 'binary': firefoxBinary,\n 'binary-args': binaryArgs,\n // For Flatpak we need to respect the order of the command arguments because\n // we have arguments for Flapack (first) and then Firefox.\n 'binary-args-first': firefoxBinary === 'flatpak',\n // This ensures a new instance of Firefox is created. It has nothing\n // to do with the devtools remote debugger.\n 'no-remote': true,\n 'listen': remotePort,\n 'foreground': true,\n 'profile': profile.path(),\n 'env': {\n ...process.env,\n ...defaultFirefoxEnv,\n },\n 'verbose': true,\n });\n\n const firefox = results.process;\n\n log.debug(`Executing Firefox binary: ${results.binary}`);\n log.debug(`Firefox args: ${results.args.join(' ')}`);\n\n firefox.on('error', (error) => {\n // TODO: show a nice error when it can't find Firefox.\n // if (/No such file/.test(err) || err.code === 'ENOENT') {\n log.error(`Firefox error: ${error}`);\n throw error;\n });\n\n log.info(\n 'Use --verbose or open Tools > Web Developer > Browser Console ' +\n 'to see logging');\n\n firefox.stderr.on('data', (data) => {\n log.debug(`Firefox stderr: ${data.toString().trim()}`);\n });\n\n firefox.stdout.on('data', (data) => {\n log.debug(`Firefox stdout: ${data.toString().trim()}`);\n });\n\n firefox.on('close', () => {\n log.debug('Firefox closed');\n });\n\n return { firefox, debuggerPort: remotePort };\n}\n\n\n// isDefaultProfile types and implementation.\n\nconst DEFAULT_PROFILES_NAMES = [\n 'default',\n 'dev-edition-default',\n];\n\nexport type IsDefaultProfileFn = (\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder,\n fsStat?: typeof fs.stat,\n) => Promise<boolean>;\n\n/*\n * Tests if a profile is a default Firefox profile (both as a profile name or\n * profile path).\n *\n * Returns a promise that resolves to true if the profile is one of default Firefox profile.\n */\nexport async function isDefaultProfile(\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder = FirefoxProfile.Finder,\n fsStat?: typeof fs.stat = fs.stat,\n): Promise<boolean> {\n if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {\n return true;\n }\n\n const baseProfileDir = ProfileFinder.locateUserDirectory();\n const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');\n try {\n await fsStat(profilesIniPath);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`profiles.ini not found: ${error}`);\n\n // No profiles exist yet, default to false (the default profile name contains a\n // random generated component).\n return false;\n }\n\n // Re-throw any unexpected exception.\n throw error;\n }\n\n // Check for profile dir path.\n const finder = new ProfileFinder(baseProfileDir);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n\n await readProfiles();\n\n const normalizedProfileDirPath = path.normalize(\n path.join(path.resolve(profilePathOrName), path.sep)\n );\n\n for (const profile of finder.profiles) {\n // Check if the profile dir path or name is one of the default profiles\n // defined in the profiles.ini file.\n if (DEFAULT_PROFILES_NAMES.includes(profile.Name) ||\n profile.Default === '1') {\n let profileFullPath;\n\n // Check for profile name.\n if (profile.Name === profilePathOrName) {\n return true;\n }\n\n // Check for profile path.\n if (profile.IsRelative === '1') {\n profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);\n } else {\n profileFullPath = path.join(profile.Path, path.sep);\n }\n\n if (path.normalize(profileFullPath) === normalizedProfileDirPath) {\n return true;\n }\n }\n }\n\n // Profile directory not found.\n return false;\n}\n\n// configureProfile types and implementation.\n\nexport type ConfigureProfileOptions = {\n app?: PreferencesAppName,\n getPrefs?: PreferencesGetterFn,\n customPrefs?: FirefoxPreferences,\n};\n\nexport type ConfigureProfileFn = (\n profile: FirefoxProfile,\n options?: ConfigureProfileOptions\n) => Promise<FirefoxProfile>;\n\n/*\n * Configures a profile with common preferences that are required to\n * activate extension development.\n *\n * Returns a promise that resolves with the original profile object.\n */\nexport function configureProfile(\n profile: FirefoxProfile,\n {\n app = 'firefox',\n getPrefs = defaultPrefGetter,\n customPrefs = {},\n }: ConfigureProfileOptions = {},\n): Promise<FirefoxProfile> {\n // Set default preferences. Some of these are required for the add-on to\n // operate, such as disabling signatures.\n const prefs = getPrefs(app);\n Object.keys(prefs).forEach((pref) => {\n profile.setPreference(pref, prefs[pref]);\n });\n if (Object.keys(customPrefs).length > 0) {\n const customPrefsStr = JSON.stringify(customPrefs, null, 2);\n log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);\n Object.keys(customPrefs).forEach((custom) => {\n profile.setPreference(custom, customPrefs[custom]);\n });\n }\n profile.updatePreferences();\n return Promise.resolve(profile);\n}\n\nexport type getProfileFn = (profileName: string) => Promise<string | void>;\n\nexport type CreateProfileFinderParams = {\n userDirectoryPath?: string,\n FxProfile?: typeof FirefoxProfile\n}\n\nexport function defaultCreateProfileFinder(\n {\n userDirectoryPath,\n FxProfile = FirefoxProfile,\n }: CreateProfileFinderParams = {}\n): getProfileFn {\n const finder = new FxProfile.Finder(userDirectoryPath);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n const getPath = promisify((...args) => finder.getPath(...args));\n return async (profileName: string): Promise<string | void> => {\n try {\n await readProfiles();\n const hasProfileName = finder.profiles.filter(\n (profileDef) => profileDef.Name === profileName).length !== 0;\n if (hasProfileName) {\n return await getPath(profileName);\n }\n } catch (error) {\n if (!isErrorWithCode('ENOENT', error)) {\n throw error;\n }\n log.warn('Unable to find Firefox profiles.ini');\n }\n };\n}\n\n// useProfile types and implementation.\n\nexport type UseProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n isFirefoxDefaultProfile?: IsDefaultProfileFn,\n customPrefs?: FirefoxPreferences,\n createProfileFinder?: typeof defaultCreateProfileFinder,\n};\n\n// Use the target path as a Firefox profile without cloning it\n\nexport async function useProfile(\n profilePath: string,\n {\n app,\n configureThisProfile = configureProfile,\n isFirefoxDefaultProfile = isDefaultProfile,\n customPrefs = {},\n createProfileFinder = defaultCreateProfileFinder,\n }: UseProfileParams = {},\n): Promise<FirefoxProfile> {\n const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);\n if (isForbiddenProfile) {\n throw new UsageError(\n 'Cannot use --keep-profile-changes on a default profile' +\n ` (\"${profilePath}\")` +\n ' because web-ext will make it insecure and unsuitable for daily use.' +\n '\\nSee https://github.com/mozilla/web-ext/issues/1005'\n );\n }\n\n let destinationDirectory;\n const getProfilePath = createProfileFinder();\n\n const profileIsDirPath = await isDirectory(profilePath);\n if (profileIsDirPath) {\n log.debug(`Using profile directory \"${profilePath}\"`);\n destinationDirectory = profilePath;\n } else {\n log.debug(`Assuming ${profilePath} is a named profile`);\n destinationDirectory = await getProfilePath(profilePath);\n if (!destinationDirectory) {\n throw new UsageError(\n `The request \"${profilePath}\" profile name ` +\n 'cannot be resolved to a profile path'\n );\n }\n }\n\n const profile = new FirefoxProfile({destinationDirectory});\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// createProfile types and implementation.\n\nexport type CreateProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Creates a new temporary profile and resolves with the profile object.\n *\n * The profile will be deleted when the system process exits.\n */\nexport async function createProfile(\n {\n app,\n configureThisProfile = configureProfile,\n customPrefs = {},\n }: CreateProfileParams = {},\n): Promise<FirefoxProfile> {\n const profile = new FirefoxProfile();\n return await configureThisProfile(profile, {app, customPrefs});\n}\n\n\n// copyProfile types and implementation.\n\nexport type CopyProfileOptions = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n copyFromUserProfile?: Function,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Copies an existing Firefox profile and creates a new temporary profile.\n * The new profile will be configured with some preferences required to\n * activate extension development.\n *\n * It resolves with the new profile object.\n *\n * The temporary profile will be deleted when the system process exits.\n *\n * The existing profile can be specified as a directory path or a name of\n * one that exists in the current user's Firefox directory.\n */\nexport async function copyProfile(\n profileDirectory: string,\n {\n app,\n configureThisProfile = configureProfile,\n copyFromUserProfile = defaultUserProfileCopier,\n customPrefs = {},\n }: CopyProfileOptions = {},\n): Promise<FirefoxProfile> {\n\n const copy = promisify(FirefoxProfile.copy);\n const copyByName = promisify(copyFromUserProfile);\n\n try {\n const dirExists = await isDirectory(profileDirectory);\n\n let profile;\n\n if (dirExists) {\n log.debug(`Copying profile directory from \"${profileDirectory}\"`);\n profile = await copy({profileDirectory});\n } else {\n log.debug(`Assuming ${profileDirectory} is a named profile`);\n profile = await copyByName({name: profileDirectory});\n }\n\n return configureThisProfile(profile, {app, customPrefs});\n } catch (error) {\n throw new WebExtError(\n `Could not copy Firefox profile from ${profileDirectory}: ${error}`);\n }\n}\n\n\n// installExtension types and implementation.\n\nexport type InstallExtensionParams = {|\n asProxy?: boolean,\n manifestData: ExtensionManifest,\n profile: FirefoxProfile,\n extensionPath: string,\n asyncFsStat?: typeof defaultAsyncFsStat,\n|};\n\n/*\n * Installs an extension into the given Firefox profile object.\n * Resolves when complete.\n *\n * The extension is copied into a special location and you need to turn\n * on some preferences to allow this. See extensions.autoDisableScopes in\n * ./preferences.js.\n *\n * When asProxy is true, a special proxy file will be installed. This is a\n * text file that contains the path to the extension source.\n */\nexport async function installExtension(\n {\n asProxy = false,\n manifestData,\n profile,\n extensionPath,\n asyncFsStat = defaultAsyncFsStat,\n }: InstallExtensionParams): Promise<any> {\n // This more or less follows\n // https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531\n // (which is broken for web extensions).\n // TODO: maybe uplift a patch that supports web extensions instead?\n\n if (!profile.extensionsDir) {\n throw new WebExtError('profile.extensionsDir was unexpectedly empty');\n }\n\n try {\n await asyncFsStat(profile.extensionsDir);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`Creating extensions directory: ${profile.extensionsDir}`);\n await fs.mkdir(profile.extensionsDir);\n } else {\n throw error;\n }\n }\n\n const id = getManifestId(manifestData);\n if (!id) {\n throw new UsageError(\n 'An explicit extension ID is required when installing to ' +\n 'a profile (applications.gecko.id not found in manifest.json)');\n }\n\n if (asProxy) {\n log.debug(`Installing as an extension proxy; source: ${extensionPath}`);\n\n const isDir = await isDirectory(extensionPath);\n if (!isDir) {\n throw new WebExtError(\n 'proxy install: extensionPath must be the extension source ' +\n `directory; got: ${extensionPath}`);\n }\n\n // Write a special extension proxy file containing the source\n // directory. See:\n // https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file\n const destPath = path.join(profile.extensionsDir, `${id}`);\n const writeStream = nodeFs.createWriteStream(destPath);\n writeStream.write(extensionPath);\n writeStream.end();\n return await fromEvent(writeStream, 'close');\n } else {\n // Write the XPI file to the profile.\n const readStream = nodeFs.createReadStream(extensionPath);\n const destPath = path.join(profile.extensionsDir, `${id}.xpi`);\n const writeStream = nodeFs.createWriteStream(destPath);\n\n log.debug(`Installing extension from ${extensionPath} to ${destPath}`);\n readStream.pipe(writeStream);\n\n return await Promise.all([\n fromEvent(readStream, 'close'),\n fromEvent(writeStream, 'close'),\n ]);\n }\n}\n"],"mappings":"AACA,OAAOA,MAAP,MAAmB,IAAnB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAAQC,SAAR,QAAwB,MAAxB;AAEA,SAAQC,OAAO,IAAIC,eAAnB,QAAyC,WAAzC;AACA,OAAOC,cAAP,MAA2B,iBAA3B;AACA,SAAQC,EAAR,QAAiB,IAAjB;AACA,OAAOC,SAAP,MAAsB,2BAAtB;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,SAAQC,eAAR,EAAyBC,UAAzB,EAAqCC,WAArC,QAAuD,cAAvD;AACA,SAAQC,QAAQ,IAAIC,iBAApB,QAA4C,kBAA5C;AACA,SAAQC,aAAR,QAA4B,qBAA5B;AACA,SAAQC,eAAe,IAAIC,uBAA3B,QAAyD,aAAzD;AACA,SAAQC,YAAR,QAA2B,mBAA3B,C,CACA;;AAUA,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAP,CAAYC,GAAb,CAAxB;AAEA,MAAMC,kBAAkC,GAAGhB,EAAE,CAACiB,IAAH,CAAQC,IAAR,CAAalB,EAAb,CAA3C;AAEA,MAAMmB,wBAAwB,GAAGpB,cAAc,CAACqB,mBAAhD;AAEA,OAAO,MAAMC,iBAAiB,GAAG;EAC/BC,iBAAiB,EAAE,OADY;EAE/BC,8BAA8B,EAAE;AAFD,CAA1B,C,CAKP;;AAyDA;AACA;AACA;AACA,OAAO,eAAeC,GAAf,CACLC,OADK,EAEL;EACEC,QAAQ,GAAG5B,eADb;EAEE6B,cAAc,GAAGjB,uBAFnB;EAGEkB,aAHF;EAIEC,UAJF;EAKEC;AALF,IAMuB,EARlB,EASiB;EAEtBlB,GAAG,CAACmB,KAAJ,CAAW,mCAAkCN,OAAO,CAAC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,SAAS,CAAC+H,WAAD,EAAc,OAAd,CAFc,CAAZ,CAAb;EAID;AACF"}
|
package/lib/program.js
CHANGED
|
@@ -168,6 +168,10 @@ export class Program {
|
|
|
168
168
|
throw new UsageError('Not enough arguments following: start-url');
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
if (Array.isArray(argv.firefoxPreview) && !argv.firefoxPreview.length) {
|
|
172
|
+
argv.firefoxPreview = ['mv3'];
|
|
173
|
+
}
|
|
174
|
+
|
|
171
175
|
return argv;
|
|
172
176
|
} // getArguments() disables validation of required parameters, to allow us to
|
|
173
177
|
// read parameters from config files first. Before the program continues, it
|
|
@@ -483,7 +487,7 @@ Example: $0 --help run.
|
|
|
483
487
|
},
|
|
484
488
|
'firefox': {
|
|
485
489
|
alias: ['f', 'firefox-binary'],
|
|
486
|
-
describe: 'Path or alias to a Firefox executable such as firefox-bin ' + 'or firefox.exe. ' + 'If not specified, the default Firefox will be used. ' + 'You can specify the following aliases in lieu of a path: ' + 'firefox, beta, nightly, firefoxdeveloperedition.',
|
|
490
|
+
describe: 'Path or alias to a Firefox executable such as firefox-bin ' + 'or firefox.exe. ' + 'If not specified, the default Firefox will be used. ' + 'You can specify the following aliases in lieu of a path: ' + 'firefox, beta, nightly, firefoxdeveloperedition. ' + 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' + '`org.mozilla.firefox` is the application ID.',
|
|
487
491
|
demandOption: false,
|
|
488
492
|
type: 'string'
|
|
489
493
|
},
|
|
@@ -560,6 +564,11 @@ Example: $0 --help run.
|
|
|
560
564
|
demandOption: false,
|
|
561
565
|
type: 'array'
|
|
562
566
|
},
|
|
567
|
+
'firefox-preview': {
|
|
568
|
+
describe: 'Turn on developer preview features in Firefox' + ' (defaults to "mv3")',
|
|
569
|
+
demandOption: false,
|
|
570
|
+
type: 'array'
|
|
571
|
+
},
|
|
563
572
|
// Firefox for Android CLI options.
|
|
564
573
|
'adb-bin': {
|
|
565
574
|
describe: 'Specify a custom path to the adb binary',
|
package/lib/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","names":["os","path","readFileSync","camelCase","decamelize","yargs","Parser","yargsParser","defaultCommands","UsageError","createLogger","consoleStream","defaultLogStream","coerceCLICustomPreference","checkForUpdates","defaultUpdateChecker","discoverConfigFiles","defaultConfigDiscovery","loadJSConfigFile","defaultLoadJSConfigFile","applyConfigToArgv","defaultApplyConfigToArgv","log","import","meta","url","envPrefix","defaultGlobalEnv","Program","constructor","argv","absolutePackageDir","process","cwd","slice","programArgv","yargsInstance","verboseEnabled","shouldExitProgram","parserConfiguration","strict","wrap","terminalWidth","commands","options","command","name","description","executor","commandOptions","yargsForCmd","demandCommand","undefined","exitProcess","env","setGlobalOptions","Object","keys","forEach","key","global","demandOption","enableVerboseMode","logStream","version","makeVerbose","info","getArguments","validationInstance","getInternalMethods","getValidationInstance","requiredArguments","demandedOptions","getDemandedOptions","args","err","message","startsWith","configDiscovery","noConfigDiscovery","reload","noReload","input","noInput","ignoreFiles","length","startUrl","checkRequiredArguments","adjustedArgv","cleanupProcessEnvConfigs","systemProcess","cmd","_","toOptionKey","k","replace","separator","filter","optKey","globalOpt","cmdOpt","debug","execute","getVersion","defaultVersionGetter","globalEnv","runCommand","verbose","configFiles","discoveredConfigs","push","config","resolve","niceFileList","map","f","homedir","join","configFileName","configObject","argvFromCLI","error","stack","String","code","exit","packageData","JSON","parse","git","branch","long","throwUsageErrorIfArray","errorMessage","value","Array","isArray","main","runOptions","program","usage","help","alias","recommendCommands","describe","default","requiresArg","type","coerce","arg","normalize","hidden","build","sign","run","choices","lint","docs"],"sources":["../src/program.js"],"sourcesContent":["/* @flow */\nimport os from 'os';\nimport path from 'path';\nimport {readFileSync} from 'fs';\n\nimport camelCase from 'camelcase';\nimport decamelize from 'decamelize';\nimport yargs from 'yargs';\nimport { Parser as yargsParser } from 'yargs/helpers';\n\nimport defaultCommands from './cmd/index.js';\nimport {UsageError} from './errors.js';\nimport {\n createLogger,\n consoleStream as defaultLogStream,\n} from './util/logger.js';\nimport {coerceCLICustomPreference} from './firefox/preferences.js';\nimport {checkForUpdates as defaultUpdateChecker} from './util/updates.js';\nimport {\n discoverConfigFiles as defaultConfigDiscovery,\n loadJSConfigFile as defaultLoadJSConfigFile,\n applyConfigToArgv as defaultApplyConfigToArgv,\n} from './config.js';\n\nconst log = createLogger(import.meta.url);\nconst envPrefix = 'WEB_EXT';\n// Default to \"development\" (the value actually assigned will be interpolated\n// by babel-plugin-transform-inline-environment-variables).\nconst defaultGlobalEnv = process.env.WEBEXT_BUILD_ENV || 'development';\n\n\ntype ProgramOptions = {\n absolutePackageDir?: string,\n}\n\nexport type VersionGetterFn = (absolutePackageDir: string) => Promise<string>;\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype ExecuteOptions = {\n checkForUpdates?: Function,\n systemProcess?: typeof process,\n logStream?: typeof defaultLogStream,\n getVersion?: VersionGetterFn,\n applyConfigToArgv?: typeof defaultApplyConfigToArgv,\n discoverConfigFiles?: typeof defaultConfigDiscovery,\n loadJSConfigFile?: typeof defaultLoadJSConfigFile,\n shouldExitProgram?: boolean,\n globalEnv?: string | void,\n}\n\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir: string;\n yargs: any;\n commands: { [key: string]: Function };\n shouldExitProgram: boolean;\n verboseEnabled: boolean;\n options: Object;\n programArgv: Array<string>;\n demandedOptions: Object;\n\n constructor(\n argv: ?Array<string>,\n {\n absolutePackageDir = process.cwd(),\n }: ProgramOptions = {}\n ) {\n // This allows us to override the process argv which is useful for\n // testing.\n // NOTE: process.argv.slice(2) removes the path to node and web-ext\n // executables from the process.argv array.\n argv = argv || process.argv.slice(2);\n this.programArgv = argv;\n\n // NOTE: always initialize yargs explicitly with the package dir\n // to avoid side-effects due to yargs looking for its configuration\n // section from a package.json file stored in an arbitrary directory\n // (e.g. in tests yargs would end up loading yargs config from the\n // mocha package.json). web-ext package.json doesn't contain any yargs\n // section as it is deprecated and we configure yargs using\n // yargs.parserConfiguration. See web-ext#469 for rationale.\n const yargsInstance = yargs(argv, absolutePackageDir);\n\n this.absolutePackageDir = absolutePackageDir;\n this.verboseEnabled = false;\n this.shouldExitProgram = true;\n\n this.yargs = yargsInstance;\n this.yargs.parserConfiguration({\n 'boolean-negation': true,\n });\n this.yargs.strict();\n this.yargs.wrap(this.yargs.terminalWidth());\n\n this.commands = {};\n this.options = {};\n }\n\n command(\n name: string, description: string, executor: Function,\n commandOptions: Object = {}\n ): Program {\n this.options[camelCase(name)] = commandOptions;\n\n this.yargs.command(name, description, (yargsForCmd) => {\n if (!commandOptions) {\n return;\n }\n return yargsForCmd\n // Make sure the user does not add any extra commands. For example,\n // this would be a mistake because lint does not accept arguments:\n // web-ext lint ./src/path/to/file.js\n .demandCommand(0, 0, undefined,\n 'This command does not take any arguments')\n .strict()\n .exitProcess(this.shouldExitProgram)\n // Calling env() will be unnecessary after\n // https://github.com/yargs/yargs/issues/486 is fixed\n .env(envPrefix)\n .options(commandOptions);\n });\n this.commands[name] = executor;\n return this;\n }\n\n setGlobalOptions(options: Object): Program {\n // This is a convenience for setting global options.\n // An option is only global (i.e. available to all sub commands)\n // with the `global` flag so this makes sure every option has it.\n this.options = {...this.options, ...options};\n Object.keys(options).forEach((key) => {\n options[key].global = true;\n if (options[key].demandOption === undefined) {\n // By default, all options should be \"demanded\" otherwise\n // yargs.strict() will think they are missing when declared.\n options[key].demandOption = true;\n }\n });\n this.yargs.options(options);\n return this;\n }\n\n enableVerboseMode(\n logStream: typeof defaultLogStream,\n version: string\n ): void {\n if (this.verboseEnabled) {\n return;\n }\n\n logStream.makeVerbose();\n log.info('Version:', version);\n this.verboseEnabled = true;\n }\n\n // Retrieve the yargs argv object and apply any further fix needed\n // on the output of the yargs options parsing.\n getArguments(): Object {\n // To support looking up required parameters via config files, we need to\n // temporarily disable the requiredArguments validation. Otherwise yargs\n // would exit early. Validation is enforced by the checkRequiredArguments()\n // method, after reading configuration files.\n //\n // This is an undocumented internal API of yargs! Unit tests to avoid\n // regressions are located at: tests/functional/test.cli.sign.js\n //\n // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930\n const validationInstance =\n this.yargs.getInternalMethods().getValidationInstance();\n const { requiredArguments } = validationInstance;\n // Initialize demandedOptions (which is going to be set to an object with one\n // property for each mandatory global options, then the arrow function below\n // will receive as its demandedOptions parameter a new one that also includes\n // all mandatory options for the sub command selected).\n this.demandedOptions = this.yargs.getDemandedOptions();\n validationInstance.requiredArguments = (args, demandedOptions) => {\n this.demandedOptions = demandedOptions;\n };\n let argv;\n try {\n argv = this.yargs.argv;\n } catch (err) {\n if (err.name === 'YError' &&\n err.message.startsWith('Unknown argument: ')) {\n throw new UsageError(err.message);\n }\n throw err;\n }\n validationInstance.requiredArguments = requiredArguments;\n\n // Yargs boolean options doesn't define the no* counterpart\n // with negate-boolean on Yargs 15. Define as expected by the\n // web-ext execute method.\n if (argv.configDiscovery != null) {\n argv.noConfigDiscovery = !argv.configDiscovery;\n }\n if (argv.reload != null) {\n argv.noReload = !argv.reload;\n }\n\n // Yargs doesn't accept --no-input as a valid option if there isn't a\n // --input option defined to be negated, to fix that the --input is\n // defined and hidden from the yargs help output and we define here\n // the negated argument name that we expect to be set in the parsed\n // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).\n if (argv.input != null) {\n argv.noInput = !argv.input;\n }\n\n // Replacement for the \"requiresArg: true\" parameter until the following bug\n // is fixed: https://github.com/yargs/yargs/issues/1098\n if (argv.ignoreFiles && !argv.ignoreFiles.length) {\n throw new UsageError('Not enough arguments following: ignore-files');\n }\n\n if (argv.startUrl && !argv.startUrl.length) {\n throw new UsageError('Not enough arguments following: start-url');\n }\n\n return argv;\n }\n\n // getArguments() disables validation of required parameters, to allow us to\n // read parameters from config files first. Before the program continues, it\n // must call checkRequiredArguments() to ensure that required parameters are\n // defined (in the CLI or in a config file).\n checkRequiredArguments(adjustedArgv: Object): void {\n const validationInstance =\n this.yargs.getInternalMethods().getValidationInstance();\n validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);\n }\n\n // Remove WEB_EXT_* environment vars that are not a global cli options\n // or an option supported by the current command (See #793).\n cleanupProcessEnvConfigs(systemProcess: typeof process) {\n const cmd = yargsParser(this.programArgv)._[0];\n const env = systemProcess.env || {};\n const toOptionKey = (k) => decamelize(\n camelCase(k.replace(envPrefix, '')), {separator: '-'}\n );\n\n if (cmd) {\n Object.keys(env)\n .filter((k) => k.startsWith(envPrefix))\n .forEach((k) => {\n const optKey = toOptionKey(k);\n const globalOpt = this.options[optKey];\n const cmdOpt = this.options[cmd] && this.options[cmd][optKey];\n\n if (!globalOpt && !cmdOpt) {\n log.debug(`Environment ${k} not supported by web-ext ${cmd}`);\n delete env[k];\n }\n });\n }\n }\n\n async execute(\n {\n checkForUpdates = defaultUpdateChecker,\n systemProcess = process,\n logStream = defaultLogStream,\n getVersion = defaultVersionGetter,\n applyConfigToArgv = defaultApplyConfigToArgv,\n discoverConfigFiles = defaultConfigDiscovery,\n loadJSConfigFile = defaultLoadJSConfigFile,\n shouldExitProgram = true,\n globalEnv = defaultGlobalEnv,\n }: ExecuteOptions = {}\n ): Promise<void> {\n this.shouldExitProgram = shouldExitProgram;\n this.yargs.exitProcess(this.shouldExitProgram);\n\n this.cleanupProcessEnvConfigs(systemProcess);\n const argv = this.getArguments();\n\n const cmd = argv._[0];\n\n const version = await getVersion(this.absolutePackageDir);\n const runCommand = this.commands[cmd];\n\n if (argv.verbose) {\n this.enableVerboseMode(logStream, version);\n }\n\n let adjustedArgv = {...argv};\n\n try {\n if (cmd === undefined) {\n throw new UsageError('No sub-command was specified in the args');\n }\n if (!runCommand) {\n throw new UsageError(`Unknown command: ${cmd}`);\n }\n if (globalEnv === 'production') {\n checkForUpdates({version});\n }\n\n const configFiles = [];\n\n if (argv.configDiscovery) {\n log.debug(\n 'Discovering config files. ' +\n 'Set --no-config-discovery to disable');\n const discoveredConfigs = await discoverConfigFiles();\n configFiles.push(...discoveredConfigs);\n } else {\n log.debug('Not discovering config files');\n }\n\n if (argv.config) {\n configFiles.push(path.resolve(argv.config));\n }\n\n if (configFiles.length) {\n const niceFileList = configFiles\n .map((f) => f.replace(process.cwd(), '.'))\n .map((f) => f.replace(os.homedir(), '~'))\n .join(', ');\n log.info(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`);\n }\n\n configFiles.forEach((configFileName) => {\n const configObject = loadJSConfigFile(configFileName);\n adjustedArgv = applyConfigToArgv({\n argv: adjustedArgv,\n argvFromCLI: argv,\n configFileName,\n configObject,\n options: this.options,\n });\n });\n\n if (adjustedArgv.verbose) {\n // Ensure that the verbose is enabled when specified in a config file.\n this.enableVerboseMode(logStream, version);\n }\n\n this.checkRequiredArguments(adjustedArgv);\n\n await runCommand(adjustedArgv, {shouldExitProgram});\n\n } catch (error) {\n if (!(error instanceof UsageError) || adjustedArgv.verbose) {\n log.error(`\\n${error.stack}\\n`);\n } else {\n log.error(`\\n${String(error)}\\n`);\n }\n if (error.code) {\n log.error(`Error code: ${error.code}\\n`);\n }\n\n log.debug(`Command executed: ${cmd}`);\n\n if (this.shouldExitProgram) {\n systemProcess.exit(1);\n } else {\n throw error;\n }\n }\n }\n}\n\n//A defintion of type of argument for defaultVersionGetter\ntype VersionGetterOptions = {\n globalEnv?: string,\n};\n\nexport async function defaultVersionGetter(\n absolutePackageDir: string,\n {globalEnv = defaultGlobalEnv}: VersionGetterOptions = {}\n): Promise<string> {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData: any = readFileSync(\n path.join(absolutePackageDir, 'package.json'));\n return JSON.parse(packageData).version;\n } else {\n log.debug('Getting version from the git revision');\n // This branch is only reached during development.\n // git-rev-sync is in devDependencies, and lazily imported using require.\n // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916\n // eslint-disable-next-line import/no-extraneous-dependencies\n const git = await import('git-rev-sync');\n return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;\n }\n}\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype MainParams = {\n getVersion?: VersionGetterFn,\n commands?: Object,\n argv: Array<any>,\n runOptions?: Object,\n}\n\nexport function throwUsageErrorIfArray(errorMessage: string): any {\n return (value: any): any => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir: string,\n {\n getVersion = defaultVersionGetter, commands = defaultCommands, argv,\n runOptions = {},\n }: MainParams = {}\n): Promise<any> {\n const program = new Program(argv, {absolutePackageDir});\n const version = await getVersion(absolutePackageDir);\n\n // yargs uses magic camel case expansion to expose options on the\n // final argv object. For example, the 'artifacts-dir' option is alternatively\n // available as argv.artifactsDir.\n program.yargs\n .usage(`Usage: $0 [options] command\n\nOption values can also be set by declaring an environment variable prefixed\nwith $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as\n--source-dir=/path.\n\nTo view specific help for any given command, add the command name.\nExample: $0 --help run.\n`)\n .help('help')\n .alias('h', 'help')\n .env(envPrefix)\n .version(version)\n .demandCommand(1, 'You must specify a command')\n .strict()\n .recommendCommands();\n\n program.setGlobalOptions({\n 'source-dir': {\n alias: 's',\n describe: 'Web extension source directory.',\n default: process.cwd(),\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg != null ? path.resolve(arg) : undefined,\n },\n 'artifacts-dir': {\n alias: 'a',\n describe: 'Directory where artifacts will be saved.',\n default: path.join(process.cwd(), 'web-ext-artifacts'),\n normalize: true,\n requiresArg: true,\n type: 'string',\n },\n 'verbose': {\n alias: 'v',\n describe: 'Show verbose output',\n type: 'boolean',\n demandOption: false,\n },\n 'ignore-files': {\n alias: 'i',\n describe: 'A list of glob patterns to define which files should be ' +\n 'ignored. (Example: --ignore-files=path/to/first.js ' +\n 'path/to/second.js \"**/*.log\")',\n demandOption: false,\n // The following option prevents yargs>=11 from parsing multiple values,\n // so the minimum value requirement is enforced in execute instead.\n // Upstream bug: https://github.com/yargs/yargs/issues/1098\n // requiresArg: true,\n type: 'array',\n },\n 'no-input': {\n describe: 'Disable all features that require standard input',\n type: 'boolean',\n demandOption: false,\n },\n 'input': {\n // This option is defined to make yargs to accept the --no-input\n // defined above, but we hide it from the yargs help output.\n hidden: true,\n type: 'boolean',\n demandOption: false,\n },\n 'config': {\n alias: 'c',\n describe: 'Path to a CommonJS config file to set ' +\n 'option defaults',\n default: undefined,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n },\n 'config-discovery': {\n describe: 'Discover config files in home directory and ' +\n 'working directory. Disable with --no-config-discovery.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n });\n\n program\n .command(\n 'build',\n 'Create an extension package from source',\n commands.build, {\n 'as-needed': {\n describe: 'Watch for file changes and re-build as needed',\n type: 'boolean',\n },\n 'filename': {\n alias: 'n',\n describe: 'Name of the created extension package file.',\n default: undefined,\n normalize: false,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg == null ?\n undefined : throwUsageErrorIfArray(\n 'Multiple --filename/-n option are not allowed'\n )(arg),\n },\n 'overwrite-dest': {\n alias: 'o',\n describe: 'Overwrite destination package if it exists.',\n type: 'boolean',\n },\n })\n .command(\n 'sign',\n 'Sign the extension so it can be installed in Firefox',\n commands.sign, {\n '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 'id': {\n describe:\n 'A custom ID for the extension. This has no effect if the ' +\n 'extension already declares an explicit ID in its manifest.',\n demandOption: false,\n type: 'string',\n },\n 'timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n 'channel': {\n describe: 'The channel for which to sign the addon. Either ' +\n '\\'listed\\' or \\'unlisted\\'',\n type: 'string',\n },\n })\n .command('run', 'Run the extension', commands.run, {\n 'target': {\n alias: 't',\n describe: 'The extensions runners to enable. Specify this option ' +\n 'multiple times to run against multiple targets.',\n default: 'firefox-desktop',\n demandOption: false,\n type: 'array',\n choices: ['firefox-desktop', 'firefox-android', 'chromium'],\n },\n 'firefox': {\n alias: ['f', 'firefox-binary'],\n describe: 'Path or alias to a Firefox executable such as firefox-bin ' +\n 'or firefox.exe. ' +\n 'If not specified, the default Firefox will be used. ' +\n 'You can specify the following aliases in lieu of a path: ' +\n 'firefox, beta, nightly, firefoxdeveloperedition.',\n demandOption: false,\n type: 'string',\n },\n 'firefox-profile': {\n alias: 'p',\n describe: 'Run Firefox using a copy of this profile. The profile ' +\n 'can be specified as a directory or a name, such as one ' +\n 'you would see in the Profile Manager. If not specified, ' +\n 'a new temporary profile will be created.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-binary': {\n describe: 'Path or alias to a Chromium executable such as ' +\n 'google-chrome, google-chrome.exe or opera.exe etc. ' +\n 'If not specified, the default Google Chrome will be used.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-profile': {\n describe: 'Path to a custom Chromium profile',\n demandOption: false,\n type: 'string',\n },\n 'profile-create-if-missing': {\n describe: 'Create the profile directory if it does not already exist',\n demandOption: false,\n type: 'boolean',\n },\n 'keep-profile-changes': {\n describe: 'Run Firefox directly in custom profile. Any changes to ' +\n 'the profile will be saved.',\n demandOption: false,\n type: 'boolean',\n },\n 'reload': {\n describe: 'Reload the extension when source files change.' +\n 'Disable with --no-reload.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n 'watch-file': {\n alias: ['watch-files'],\n describe: 'Reload the extension only when the contents of this' +\n ' file changes. This is useful if you use a custom' +\n ' build process for your extension',\n demandOption: false,\n type: 'array',\n },\n 'watch-ignored': {\n describe: 'Paths and globs patterns that should not be ' +\n 'watched for changes. This is useful if you want ' +\n 'to explicitly prevent web-ext from watching part ' +\n 'of the extension directory tree, ' +\n 'e.g. the node_modules folder.',\n demandOption: false,\n type: 'array',\n },\n 'pre-install': {\n describe: 'Pre-install the extension into the profile before ' +\n 'startup. This is only needed to support older versions ' +\n 'of Firefox.',\n demandOption: false,\n type: 'boolean',\n },\n 'pref': {\n describe: 'Launch firefox with a custom preference ' +\n '(example: --pref=general.useragent.locale=fr-FR). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) => arg != null ?\n coerceCLICustomPreference(arg) : undefined,\n },\n 'start-url': {\n alias: ['u', 'url'],\n describe: 'Launch firefox at specified page',\n demandOption: false,\n type: 'array',\n },\n '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 ),\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('docs', 'Open the web-ext documentation in a browser',\n commands.docs, {});\n\n return program.execute({getVersion, ...runOptions});\n}\n"],"mappings":"AACA,OAAOA,EAAP,MAAe,IAAf;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAAQC,YAAR,QAA2B,IAA3B;AAEA,OAAOC,SAAP,MAAsB,WAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,MAAM,IAAIC,WAAnB,QAAsC,eAAtC;AAEA,OAAOC,eAAP,MAA4B,gBAA5B;AACA,SAAQC,UAAR,QAAyB,aAAzB;AACA,SACEC,YADF,EAEEC,aAAa,IAAIC,gBAFnB,QAGO,kBAHP;AAIA,SAAQC,yBAAR,QAAwC,0BAAxC;AACA,SAAQC,eAAe,IAAIC,oBAA3B,QAAsD,mBAAtD;AACA,SACEC,mBAAmB,IAAIC,sBADzB,EAEEC,gBAAgB,IAAIC,uBAFtB,E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MAJD;MAKRU,OAAO,EAAE,CAAC,MAAD,EAAS,MAAT;IALD,CADqD;IAQ/D,YAAY;MACVX,QAAQ,EAAE,8BADA;MAEVG,IAAI,EAAE,SAFI;MAGVF,OAAO,EAAE;IAHC,CARmD;IAa/D,sBAAsB;MACpBD,QAAQ,EAAE,2DADU;MAEpBF,KAAK,EAAE,GAFa;MAGpBK,IAAI,EAAE,SAHc;MAIpBF,OAAO,EAAE;IAJW,CAbyC;IAmB/D,UAAU;MACRD,QAAQ,EAAE,sBADF;MAERG,IAAI,EAAE,SAFE;MAGRF,OAAO,EAAE;IAHD,CAnBqD;IAwB/D,cAAc;MACZD,QAAQ,EAAE,gDADE;MAEZG,IAAI,EAAE,SAFM;MAGZF,OAAO,EAAE;IAHG,CAxBiD;IA6B/D,eAAe;MACbD,QAAQ,EACN,gEACA,2CAHW;MAIbG,IAAI,EAAE,SAJO;MAKbF,OAAO,EAAE;IALI,CA7BgD;IAoC/D,UAAU;MACRD,QAAQ,EAAE,gCADF;MAERG,IAAI,EAAE,SAFE;MAGRF,OAAO,EAAE;IAHD;EApCqD,CA9OnE,EAwRGpG,OAxRH,CAwRW,MAxRX,EAwRmB,6CAxRnB,EAyRWF,QAAQ,CAACkH,IAzRpB,EAyR0B,EAzR1B;EA2RA,OAAOlB,OAAO,CAACrC,OAAR,CAAgB;IAACC,UAAD;IAAa,GAAGmC;EAAhB,CAAhB,CAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"program.js","names":["os","path","readFileSync","camelCase","decamelize","yargs","Parser","yargsParser","defaultCommands","UsageError","createLogger","consoleStream","defaultLogStream","coerceCLICustomPreference","checkForUpdates","defaultUpdateChecker","discoverConfigFiles","defaultConfigDiscovery","loadJSConfigFile","defaultLoadJSConfigFile","applyConfigToArgv","defaultApplyConfigToArgv","log","import","meta","url","envPrefix","defaultGlobalEnv","Program","constructor","argv","absolutePackageDir","process","cwd","slice","programArgv","yargsInstance","verboseEnabled","shouldExitProgram","parserConfiguration","strict","wrap","terminalWidth","commands","options","command","name","description","executor","commandOptions","yargsForCmd","demandCommand","undefined","exitProcess","env","setGlobalOptions","Object","keys","forEach","key","global","demandOption","enableVerboseMode","logStream","version","makeVerbose","info","getArguments","validationInstance","getInternalMethods","getValidationInstance","requiredArguments","demandedOptions","getDemandedOptions","args","err","message","startsWith","configDiscovery","noConfigDiscovery","reload","noReload","input","noInput","ignoreFiles","length","startUrl","Array","isArray","firefoxPreview","checkRequiredArguments","adjustedArgv","cleanupProcessEnvConfigs","systemProcess","cmd","_","toOptionKey","k","replace","separator","filter","optKey","globalOpt","cmdOpt","debug","execute","getVersion","defaultVersionGetter","globalEnv","runCommand","verbose","configFiles","discoveredConfigs","push","config","resolve","niceFileList","map","f","homedir","join","configFileName","configObject","argvFromCLI","error","stack","String","code","exit","packageData","JSON","parse","git","branch","long","throwUsageErrorIfArray","errorMessage","value","main","runOptions","program","usage","help","alias","recommendCommands","describe","default","requiresArg","type","coerce","arg","normalize","hidden","build","sign","run","choices","lint","docs"],"sources":["../src/program.js"],"sourcesContent":["/* @flow */\nimport os from 'os';\nimport path from 'path';\nimport {readFileSync} from 'fs';\n\nimport camelCase from 'camelcase';\nimport decamelize from 'decamelize';\nimport yargs from 'yargs';\nimport { Parser as yargsParser } from 'yargs/helpers';\n\nimport defaultCommands from './cmd/index.js';\nimport {UsageError} from './errors.js';\nimport {\n createLogger,\n consoleStream as defaultLogStream,\n} from './util/logger.js';\nimport {coerceCLICustomPreference} from './firefox/preferences.js';\nimport {checkForUpdates as defaultUpdateChecker} from './util/updates.js';\nimport {\n discoverConfigFiles as defaultConfigDiscovery,\n loadJSConfigFile as defaultLoadJSConfigFile,\n applyConfigToArgv as defaultApplyConfigToArgv,\n} from './config.js';\n\nconst log = createLogger(import.meta.url);\nconst envPrefix = 'WEB_EXT';\n// Default to \"development\" (the value actually assigned will be interpolated\n// by babel-plugin-transform-inline-environment-variables).\nconst defaultGlobalEnv = process.env.WEBEXT_BUILD_ENV || 'development';\n\n\ntype ProgramOptions = {\n absolutePackageDir?: string,\n}\n\nexport type VersionGetterFn = (absolutePackageDir: string) => Promise<string>;\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype ExecuteOptions = {\n checkForUpdates?: Function,\n systemProcess?: typeof process,\n logStream?: typeof defaultLogStream,\n getVersion?: VersionGetterFn,\n applyConfigToArgv?: typeof defaultApplyConfigToArgv,\n discoverConfigFiles?: typeof defaultConfigDiscovery,\n loadJSConfigFile?: typeof defaultLoadJSConfigFile,\n shouldExitProgram?: boolean,\n globalEnv?: string | void,\n}\n\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir: string;\n yargs: any;\n commands: { [key: string]: Function };\n shouldExitProgram: boolean;\n verboseEnabled: boolean;\n options: Object;\n programArgv: Array<string>;\n demandedOptions: Object;\n\n constructor(\n argv: ?Array<string>,\n {\n absolutePackageDir = process.cwd(),\n }: ProgramOptions = {}\n ) {\n // This allows us to override the process argv which is useful for\n // testing.\n // NOTE: process.argv.slice(2) removes the path to node and web-ext\n // executables from the process.argv array.\n argv = argv || process.argv.slice(2);\n this.programArgv = argv;\n\n // NOTE: always initialize yargs explicitly with the package dir\n // to avoid side-effects due to yargs looking for its configuration\n // section from a package.json file stored in an arbitrary directory\n // (e.g. in tests yargs would end up loading yargs config from the\n // mocha package.json). web-ext package.json doesn't contain any yargs\n // section as it is deprecated and we configure yargs using\n // yargs.parserConfiguration. See web-ext#469 for rationale.\n const yargsInstance = yargs(argv, absolutePackageDir);\n\n this.absolutePackageDir = absolutePackageDir;\n this.verboseEnabled = false;\n this.shouldExitProgram = true;\n\n this.yargs = yargsInstance;\n this.yargs.parserConfiguration({\n 'boolean-negation': true,\n });\n this.yargs.strict();\n this.yargs.wrap(this.yargs.terminalWidth());\n\n this.commands = {};\n this.options = {};\n }\n\n command(\n name: string, description: string, executor: Function,\n commandOptions: Object = {}\n ): Program {\n this.options[camelCase(name)] = commandOptions;\n\n this.yargs.command(name, description, (yargsForCmd) => {\n if (!commandOptions) {\n return;\n }\n return yargsForCmd\n // Make sure the user does not add any extra commands. For example,\n // this would be a mistake because lint does not accept arguments:\n // web-ext lint ./src/path/to/file.js\n .demandCommand(0, 0, undefined,\n 'This command does not take any arguments')\n .strict()\n .exitProcess(this.shouldExitProgram)\n // Calling env() will be unnecessary after\n // https://github.com/yargs/yargs/issues/486 is fixed\n .env(envPrefix)\n .options(commandOptions);\n });\n this.commands[name] = executor;\n return this;\n }\n\n setGlobalOptions(options: Object): Program {\n // This is a convenience for setting global options.\n // An option is only global (i.e. available to all sub commands)\n // with the `global` flag so this makes sure every option has it.\n this.options = {...this.options, ...options};\n Object.keys(options).forEach((key) => {\n options[key].global = true;\n if (options[key].demandOption === undefined) {\n // By default, all options should be \"demanded\" otherwise\n // yargs.strict() will think they are missing when declared.\n options[key].demandOption = true;\n }\n });\n this.yargs.options(options);\n return this;\n }\n\n enableVerboseMode(\n logStream: typeof defaultLogStream,\n version: string\n ): void {\n if (this.verboseEnabled) {\n return;\n }\n\n logStream.makeVerbose();\n log.info('Version:', version);\n this.verboseEnabled = true;\n }\n\n // Retrieve the yargs argv object and apply any further fix needed\n // on the output of the yargs options parsing.\n getArguments(): Object {\n // To support looking up required parameters via config files, we need to\n // temporarily disable the requiredArguments validation. Otherwise yargs\n // would exit early. Validation is enforced by the checkRequiredArguments()\n // method, after reading configuration files.\n //\n // This is an undocumented internal API of yargs! Unit tests to avoid\n // regressions are located at: tests/functional/test.cli.sign.js\n //\n // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930\n const validationInstance =\n this.yargs.getInternalMethods().getValidationInstance();\n const { requiredArguments } = validationInstance;\n // Initialize demandedOptions (which is going to be set to an object with one\n // property for each mandatory global options, then the arrow function below\n // will receive as its demandedOptions parameter a new one that also includes\n // all mandatory options for the sub command selected).\n this.demandedOptions = this.yargs.getDemandedOptions();\n validationInstance.requiredArguments = (args, demandedOptions) => {\n this.demandedOptions = demandedOptions;\n };\n let argv;\n try {\n argv = this.yargs.argv;\n } catch (err) {\n if (err.name === 'YError' &&\n err.message.startsWith('Unknown argument: ')) {\n throw new UsageError(err.message);\n }\n throw err;\n }\n validationInstance.requiredArguments = requiredArguments;\n\n // Yargs boolean options doesn't define the no* counterpart\n // with negate-boolean on Yargs 15. Define as expected by the\n // web-ext execute method.\n if (argv.configDiscovery != null) {\n argv.noConfigDiscovery = !argv.configDiscovery;\n }\n if (argv.reload != null) {\n argv.noReload = !argv.reload;\n }\n\n // Yargs doesn't accept --no-input as a valid option if there isn't a\n // --input option defined to be negated, to fix that the --input is\n // defined and hidden from the yargs help output and we define here\n // the negated argument name that we expect to be set in the parsed\n // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).\n if (argv.input != null) {\n argv.noInput = !argv.input;\n }\n\n // Replacement for the \"requiresArg: true\" parameter until the following bug\n // is fixed: https://github.com/yargs/yargs/issues/1098\n if (argv.ignoreFiles && !argv.ignoreFiles.length) {\n throw new UsageError('Not enough arguments following: ignore-files');\n }\n\n if (argv.startUrl && !argv.startUrl.length) {\n throw new UsageError('Not enough arguments following: start-url');\n }\n\n if (Array.isArray(argv.firefoxPreview) && !argv.firefoxPreview.length) {\n argv.firefoxPreview = ['mv3'];\n }\n\n return argv;\n }\n\n // getArguments() disables validation of required parameters, to allow us to\n // read parameters from config files first. Before the program continues, it\n // must call checkRequiredArguments() to ensure that required parameters are\n // defined (in the CLI or in a config file).\n checkRequiredArguments(adjustedArgv: Object): void {\n const validationInstance =\n this.yargs.getInternalMethods().getValidationInstance();\n validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);\n }\n\n // Remove WEB_EXT_* environment vars that are not a global cli options\n // or an option supported by the current command (See #793).\n cleanupProcessEnvConfigs(systemProcess: typeof process) {\n const cmd = yargsParser(this.programArgv)._[0];\n const env = systemProcess.env || {};\n const toOptionKey = (k) => decamelize(\n camelCase(k.replace(envPrefix, '')), {separator: '-'}\n );\n\n if (cmd) {\n Object.keys(env)\n .filter((k) => k.startsWith(envPrefix))\n .forEach((k) => {\n const optKey = toOptionKey(k);\n const globalOpt = this.options[optKey];\n const cmdOpt = this.options[cmd] && this.options[cmd][optKey];\n\n if (!globalOpt && !cmdOpt) {\n log.debug(`Environment ${k} not supported by web-ext ${cmd}`);\n delete env[k];\n }\n });\n }\n }\n\n async execute(\n {\n checkForUpdates = defaultUpdateChecker,\n systemProcess = process,\n logStream = defaultLogStream,\n getVersion = defaultVersionGetter,\n applyConfigToArgv = defaultApplyConfigToArgv,\n discoverConfigFiles = defaultConfigDiscovery,\n loadJSConfigFile = defaultLoadJSConfigFile,\n shouldExitProgram = true,\n globalEnv = defaultGlobalEnv,\n }: ExecuteOptions = {}\n ): Promise<void> {\n this.shouldExitProgram = shouldExitProgram;\n this.yargs.exitProcess(this.shouldExitProgram);\n\n this.cleanupProcessEnvConfigs(systemProcess);\n const argv = this.getArguments();\n\n const cmd = argv._[0];\n\n const version = await getVersion(this.absolutePackageDir);\n const runCommand = this.commands[cmd];\n\n if (argv.verbose) {\n this.enableVerboseMode(logStream, version);\n }\n\n let adjustedArgv = {...argv};\n\n try {\n if (cmd === undefined) {\n throw new UsageError('No sub-command was specified in the args');\n }\n if (!runCommand) {\n throw new UsageError(`Unknown command: ${cmd}`);\n }\n if (globalEnv === 'production') {\n checkForUpdates({version});\n }\n\n const configFiles = [];\n\n if (argv.configDiscovery) {\n log.debug(\n 'Discovering config files. ' +\n 'Set --no-config-discovery to disable');\n const discoveredConfigs = await discoverConfigFiles();\n configFiles.push(...discoveredConfigs);\n } else {\n log.debug('Not discovering config files');\n }\n\n if (argv.config) {\n configFiles.push(path.resolve(argv.config));\n }\n\n if (configFiles.length) {\n const niceFileList = configFiles\n .map((f) => f.replace(process.cwd(), '.'))\n .map((f) => f.replace(os.homedir(), '~'))\n .join(', ');\n log.info(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`);\n }\n\n configFiles.forEach((configFileName) => {\n const configObject = loadJSConfigFile(configFileName);\n adjustedArgv = applyConfigToArgv({\n argv: adjustedArgv,\n argvFromCLI: argv,\n configFileName,\n configObject,\n options: this.options,\n });\n });\n\n if (adjustedArgv.verbose) {\n // Ensure that the verbose is enabled when specified in a config file.\n this.enableVerboseMode(logStream, version);\n }\n\n this.checkRequiredArguments(adjustedArgv);\n\n await runCommand(adjustedArgv, {shouldExitProgram});\n\n } catch (error) {\n if (!(error instanceof UsageError) || adjustedArgv.verbose) {\n log.error(`\\n${error.stack}\\n`);\n } else {\n log.error(`\\n${String(error)}\\n`);\n }\n if (error.code) {\n log.error(`Error code: ${error.code}\\n`);\n }\n\n log.debug(`Command executed: ${cmd}`);\n\n if (this.shouldExitProgram) {\n systemProcess.exit(1);\n } else {\n throw error;\n }\n }\n }\n}\n\n//A defintion of type of argument for defaultVersionGetter\ntype VersionGetterOptions = {\n globalEnv?: string,\n};\n\nexport async function defaultVersionGetter(\n absolutePackageDir: string,\n {globalEnv = defaultGlobalEnv}: VersionGetterOptions = {}\n): Promise<string> {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData: any = readFileSync(\n path.join(absolutePackageDir, 'package.json'));\n return JSON.parse(packageData).version;\n } else {\n log.debug('Getting version from the git revision');\n // This branch is only reached during development.\n // git-rev-sync is in devDependencies, and lazily imported using require.\n // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916\n // eslint-disable-next-line import/no-extraneous-dependencies\n const git = await import('git-rev-sync');\n return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;\n }\n}\n\n// TODO: add pipes to Flow type after https://github.com/facebook/flow/issues/2405 is fixed\n\ntype MainParams = {\n getVersion?: VersionGetterFn,\n commands?: Object,\n argv: Array<any>,\n runOptions?: Object,\n}\n\nexport function throwUsageErrorIfArray(errorMessage: string): any {\n return (value: any): any => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir: string,\n {\n getVersion = defaultVersionGetter, commands = defaultCommands, argv,\n runOptions = {},\n }: MainParams = {}\n): Promise<any> {\n const program = new Program(argv, {absolutePackageDir});\n const version = await getVersion(absolutePackageDir);\n\n // yargs uses magic camel case expansion to expose options on the\n // final argv object. For example, the 'artifacts-dir' option is alternatively\n // available as argv.artifactsDir.\n program.yargs\n .usage(`Usage: $0 [options] command\n\nOption values can also be set by declaring an environment variable prefixed\nwith $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as\n--source-dir=/path.\n\nTo view specific help for any given command, add the command name.\nExample: $0 --help run.\n`)\n .help('help')\n .alias('h', 'help')\n .env(envPrefix)\n .version(version)\n .demandCommand(1, 'You must specify a command')\n .strict()\n .recommendCommands();\n\n program.setGlobalOptions({\n 'source-dir': {\n alias: 's',\n describe: 'Web extension source directory.',\n default: process.cwd(),\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg != null ? path.resolve(arg) : undefined,\n },\n 'artifacts-dir': {\n alias: 'a',\n describe: 'Directory where artifacts will be saved.',\n default: path.join(process.cwd(), 'web-ext-artifacts'),\n normalize: true,\n requiresArg: true,\n type: 'string',\n },\n 'verbose': {\n alias: 'v',\n describe: 'Show verbose output',\n type: 'boolean',\n demandOption: false,\n },\n 'ignore-files': {\n alias: 'i',\n describe: 'A list of glob patterns to define which files should be ' +\n 'ignored. (Example: --ignore-files=path/to/first.js ' +\n 'path/to/second.js \"**/*.log\")',\n demandOption: false,\n // The following option prevents yargs>=11 from parsing multiple values,\n // so the minimum value requirement is enforced in execute instead.\n // Upstream bug: https://github.com/yargs/yargs/issues/1098\n // requiresArg: true,\n type: 'array',\n },\n 'no-input': {\n describe: 'Disable all features that require standard input',\n type: 'boolean',\n demandOption: false,\n },\n 'input': {\n // This option is defined to make yargs to accept the --no-input\n // defined above, but we hide it from the yargs help output.\n hidden: true,\n type: 'boolean',\n demandOption: false,\n },\n 'config': {\n alias: 'c',\n describe: 'Path to a CommonJS config file to set ' +\n 'option defaults',\n default: undefined,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n },\n 'config-discovery': {\n describe: 'Discover config files in home directory and ' +\n 'working directory. Disable with --no-config-discovery.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n });\n\n program\n .command(\n 'build',\n 'Create an extension package from source',\n commands.build, {\n 'as-needed': {\n describe: 'Watch for file changes and re-build as needed',\n type: 'boolean',\n },\n 'filename': {\n alias: 'n',\n describe: 'Name of the created extension package file.',\n default: undefined,\n normalize: false,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg == null ?\n undefined : throwUsageErrorIfArray(\n 'Multiple --filename/-n option are not allowed'\n )(arg),\n },\n 'overwrite-dest': {\n alias: 'o',\n describe: 'Overwrite destination package if it exists.',\n type: 'boolean',\n },\n })\n .command(\n 'sign',\n 'Sign the extension so it can be installed in Firefox',\n commands.sign, {\n '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 'id': {\n describe:\n 'A custom ID for the extension. This has no effect if the ' +\n 'extension already declares an explicit ID in its manifest.',\n demandOption: false,\n type: 'string',\n },\n 'timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n 'channel': {\n describe: 'The channel for which to sign the addon. Either ' +\n '\\'listed\\' or \\'unlisted\\'',\n type: 'string',\n },\n })\n .command('run', 'Run the extension', commands.run, {\n 'target': {\n alias: 't',\n describe: 'The extensions runners to enable. Specify this option ' +\n 'multiple times to run against multiple targets.',\n default: 'firefox-desktop',\n demandOption: false,\n type: 'array',\n choices: ['firefox-desktop', 'firefox-android', 'chromium'],\n },\n 'firefox': {\n alias: ['f', 'firefox-binary'],\n describe: 'Path or alias to a Firefox executable such as firefox-bin ' +\n 'or firefox.exe. ' +\n 'If not specified, the default Firefox will be used. ' +\n 'You can specify the following aliases in lieu of a path: ' +\n 'firefox, beta, nightly, firefoxdeveloperedition. ' +\n 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' +\n '`org.mozilla.firefox` is the application ID.',\n demandOption: false,\n type: 'string',\n },\n 'firefox-profile': {\n alias: 'p',\n describe: 'Run Firefox using a copy of this profile. The profile ' +\n 'can be specified as a directory or a name, such as one ' +\n 'you would see in the Profile Manager. If not specified, ' +\n 'a new temporary profile will be created.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-binary': {\n describe: 'Path or alias to a Chromium executable such as ' +\n 'google-chrome, google-chrome.exe or opera.exe etc. ' +\n 'If not specified, the default Google Chrome will be used.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-profile': {\n describe: 'Path to a custom Chromium profile',\n demandOption: false,\n type: 'string',\n },\n 'profile-create-if-missing': {\n describe: 'Create the profile directory if it does not already exist',\n demandOption: false,\n type: 'boolean',\n },\n 'keep-profile-changes': {\n describe: 'Run Firefox directly in custom profile. Any changes to ' +\n 'the profile will be saved.',\n demandOption: false,\n type: 'boolean',\n },\n 'reload': {\n describe: 'Reload the extension when source files change.' +\n 'Disable with --no-reload.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n 'watch-file': {\n alias: ['watch-files'],\n describe: 'Reload the extension only when the contents of this' +\n ' file changes. This is useful if you use a custom' +\n ' build process for your extension',\n demandOption: false,\n type: 'array',\n },\n 'watch-ignored': {\n describe: 'Paths and globs patterns that should not be ' +\n 'watched for changes. This is useful if you want ' +\n 'to explicitly prevent web-ext from watching part ' +\n 'of the extension directory tree, ' +\n 'e.g. the node_modules folder.',\n demandOption: false,\n type: 'array',\n },\n 'pre-install': {\n describe: 'Pre-install the extension into the profile before ' +\n 'startup. This is only needed to support older versions ' +\n 'of Firefox.',\n demandOption: false,\n type: 'boolean',\n },\n 'pref': {\n describe: 'Launch firefox with a custom preference ' +\n '(example: --pref=general.useragent.locale=fr-FR). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) => arg != null ?\n coerceCLICustomPreference(arg) : undefined,\n },\n 'start-url': {\n alias: ['u', 'url'],\n describe: 'Launch firefox at specified page',\n demandOption: false,\n type: 'array',\n },\n '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': {\n describe: 'Turn on developer preview features in Firefox' +\n ' (defaults to \"mv3\")',\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 ),\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('docs', 'Open the web-ext documentation in a browser',\n commands.docs, {});\n\n return program.execute({getVersion, ...runOptions});\n}\n"],"mappings":"AACA,OAAOA,EAAP,MAAe,IAAf;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAAQC,YAAR,QAA2B,IAA3B;AAEA,OAAOC,SAAP,MAAsB,WAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,MAAM,IAAIC,WAAnB,QAAsC,eAAtC;AAEA,OAAOC,eAAP,MAA4B,gBAA5B;AACA,SAAQC,UAAR,QAAyB,aAAzB;AACA,SACEC,YADF,EAEEC,aAAa,IAAIC,gBAFnB,QAGO,kBAHP;AAIA,SAAQC,yBAAR,QAAwC,0BAAxC;AACA,SAAQC,eAAe,IAAIC,oBAA3B,QAAsD,mBAAtD;AACA,SACEC,mBAAmB,IAAIC,sBADzB,EAEEC,gBAAgB,IAAIC,uBAFtB,EAGEC,iBAAiB,IAAIC,wBAHvB,QAIO,aAJP;AAMA,MAAMC,GAAG,GAAGZ,YAAY,CAACa,MAAM,CAACC,IAAP,CAAYC,GAAb,CAAxB;AACA,MAAMC,SAAS,GAAG,SAAl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mB,+BAtPnB,EAsPoDF,QAAQ,CAACkH,IAtP7D,EAsPmE;IAC/D,UAAU;MACRd,KAAK,EAAE,GADC;MAERE,QAAQ,EAAE,gCAFF;MAGRG,IAAI,EAAE,QAHE;MAIRF,OAAO,EAAE,MAJD;MAKRU,OAAO,EAAE,CAAC,MAAD,EAAS,MAAT;IALD,CADqD;IAQ/D,YAAY;MACVX,QAAQ,EAAE,8BADA;MAEVG,IAAI,EAAE,SAFI;MAGVF,OAAO,EAAE;IAHC,CARmD;IAa/D,sBAAsB;MACpBD,QAAQ,EAAE,2DADU;MAEpBF,KAAK,EAAE,GAFa;MAGpBK,IAAI,EAAE,SAHc;MAIpBF,OAAO,EAAE;IAJW,CAbyC;IAmB/D,UAAU;MACRD,QAAQ,EAAE,sBADF;MAERG,IAAI,EAAE,SAFE;MAGRF,OAAO,EAAE;IAHD,CAnBqD;IAwB/D,cAAc;MACZD,QAAQ,EAAE,gDADE;MAEZG,IAAI,EAAE,SAFM;MAGZF,OAAO,EAAE;IAHG,CAxBiD;IA6B/D,eAAe;MACbD,QAAQ,EACN,gEACA,2CAHW;MAIbG,IAAI,EAAE,SAJO;MAKbF,OAAO,EAAE;IALI,CA7BgD;IAoC/D,UAAU;MACRD,QAAQ,EAAE,gCADF;MAERG,IAAI,EAAE,SAFE;MAGRF,OAAO,EAAE;IAHD;EApCqD,CAtPnE,EAgSGrG,OAhSH,CAgSW,MAhSX,EAgSmB,6CAhSnB,EAiSWF,QAAQ,CAACmH,IAjSpB,EAiS0B,EAjS1B;EAmSA,OAAOlB,OAAO,CAACnC,OAAR,CAAgB;IAACC,UAAD;IAAa,GAAGiC;EAAhB,CAAhB,CAAP;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-ext",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "A command line tool to help build, run, and test web extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"opera"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@babel/runtime": "7.18.
|
|
58
|
+
"@babel/runtime": "7.18.9",
|
|
59
59
|
"@devicefarmer/adbkit": "3.2.3",
|
|
60
|
-
"addons-linter": "5.
|
|
60
|
+
"addons-linter": "5.14.0",
|
|
61
61
|
"bunyan": "1.8.15",
|
|
62
62
|
"camelcase": "7.0.0",
|
|
63
63
|
"chrome-launcher": "0.15.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"es6-error": "4.1.1",
|
|
67
67
|
"firefox-profile": "4.2.2",
|
|
68
68
|
"fs-extra": "10.1.0",
|
|
69
|
-
"fx-runner": "1.
|
|
69
|
+
"fx-runner": "1.3.0",
|
|
70
70
|
"import-fresh": "3.3.0",
|
|
71
71
|
"mkdirp": "1.0.4",
|
|
72
72
|
"multimatch": "6.0.0",
|
|
@@ -78,24 +78,23 @@
|
|
|
78
78
|
"sign-addon": "5.0.0",
|
|
79
79
|
"source-map-support": "0.5.21",
|
|
80
80
|
"strip-bom": "5.0.0",
|
|
81
|
-
"strip-json-comments": "
|
|
81
|
+
"strip-json-comments": "5.0.0",
|
|
82
82
|
"tmp": "0.2.1",
|
|
83
|
-
"update-notifier": "
|
|
83
|
+
"update-notifier": "6.0.2",
|
|
84
84
|
"watchpack": "2.4.0",
|
|
85
|
-
"ws": "8.
|
|
85
|
+
"ws": "8.8.1",
|
|
86
86
|
"yargs": "17.5.1",
|
|
87
87
|
"zip-dir": "2.0.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@babel/cli": "7.
|
|
91
|
-
"@babel/core": "7.18.
|
|
92
|
-
"@babel/eslint-parser": "7.18.
|
|
93
|
-
"@babel/preset-env": "7.18.
|
|
94
|
-
"@babel/preset-flow": "7.
|
|
95
|
-
"@babel/register": "7.
|
|
96
|
-
"@commitlint/cli": "17.0.
|
|
97
|
-
"@commitlint/config-conventional": "17.0.
|
|
98
|
-
"babel-loader": "8.2.5",
|
|
90
|
+
"@babel/cli": "7.18.10",
|
|
91
|
+
"@babel/core": "7.18.10",
|
|
92
|
+
"@babel/eslint-parser": "7.18.9",
|
|
93
|
+
"@babel/preset-env": "7.18.10",
|
|
94
|
+
"@babel/preset-flow": "7.18.6",
|
|
95
|
+
"@babel/register": "7.18.9",
|
|
96
|
+
"@commitlint/cli": "17.0.3",
|
|
97
|
+
"@commitlint/config-conventional": "17.0.3",
|
|
99
98
|
"babel-plugin-istanbul": "6.1.1",
|
|
100
99
|
"babel-plugin-transform-inline-environment-variables": "0.4.4",
|
|
101
100
|
"chai": "4.3.6",
|
|
@@ -103,11 +102,11 @@
|
|
|
103
102
|
"copy-dir": "1.3.0",
|
|
104
103
|
"cross-env": "7.0.3",
|
|
105
104
|
"deepcopy": "2.1.0",
|
|
106
|
-
"eslint": "8.
|
|
105
|
+
"eslint": "8.21.0",
|
|
107
106
|
"eslint-plugin-async-await": "0.0.0",
|
|
108
107
|
"eslint-plugin-ft-flow": "2.0.1",
|
|
109
108
|
"eslint-plugin-import": "2.26.0",
|
|
110
|
-
"flow-bin": "0.
|
|
109
|
+
"flow-bin": "0.182.0",
|
|
111
110
|
"git-rev-sync": "3.0.2",
|
|
112
111
|
"html-entities": "2.3.3",
|
|
113
112
|
"mocha": "10.0.0",
|
|
@@ -115,7 +114,7 @@
|
|
|
115
114
|
"prettyjson": "1.2.5",
|
|
116
115
|
"shelljs": "0.8.5",
|
|
117
116
|
"sinon": "14.0.0",
|
|
118
|
-
"testdouble": "3.16.
|
|
117
|
+
"testdouble": "3.16.6",
|
|
119
118
|
"yauzl": "2.10.0"
|
|
120
119
|
},
|
|
121
120
|
"author": "Kumar McMillan",
|