web-ext 10.4.0 → 10.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cmd/build.js.map +1 -1
- package/lib/cmd/docs.js.map +1 -1
- package/lib/cmd/dump-config.js.map +1 -1
- package/lib/cmd/index.js.map +1 -1
- package/lib/cmd/lint.js +2 -0
- package/lib/cmd/lint.js.map +1 -1
- package/lib/cmd/run.js.map +1 -1
- package/lib/cmd/sign.js.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/extension-runners/chromium.js +1 -2
- package/lib/extension-runners/chromium.js.map +1 -1
- package/lib/extension-runners/firefox-android.js.map +1 -1
- package/lib/extension-runners/firefox-desktop.js.map +1 -1
- package/lib/extension-runners/index.js.map +1 -1
- package/lib/firefox/index.js.map +1 -1
- package/lib/firefox/package-identifiers.js.map +1 -1
- package/lib/firefox/preferences.js.map +1 -1
- package/lib/firefox/rdp-client.js +2 -2
- package/lib/firefox/rdp-client.js.map +1 -1
- package/lib/firefox/remote.js.map +1 -1
- package/lib/main.js.map +1 -1
- package/lib/program.js +6 -1
- package/lib/program.js.map +1 -1
- package/lib/util/adb.js.map +1 -1
- package/lib/util/artifacts.js.map +1 -1
- package/lib/util/expand-prefs.js.map +1 -1
- package/lib/util/file-exists.js.map +1 -1
- package/lib/util/file-filter.js.map +1 -1
- package/lib/util/is-directory.js.map +1 -1
- package/lib/util/logger.js.map +1 -1
- package/lib/util/manifest.js +1 -1
- package/lib/util/manifest.js.map +1 -1
- package/lib/util/promisify.js.map +1 -1
- package/lib/util/stdin.js.map +1 -1
- package/lib/util/submit-addon.js +6 -3
- package/lib/util/submit-addon.js.map +1 -1
- package/lib/util/temp-dir.js.map +1 -1
- package/lib/util/updates.js.map +1 -1
- package/lib/watcher.js.map +1 -1
- package/package.json +12 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.js","names":["net","connectToFirefox","defaultFirefoxConnector","createLogger","isErrorWithCode","RemoteTempInstallNotSupported","UsageError","WebExtError","log","import","meta","url","requestErrorToMessage","err","Error","String","error","message","RemoteFirefox","client","checkedForAddonReloading","constructor","on","debug","info","JSON","stringify","rdpError","disconnect","addonRequest","addon","request","response","to","actor","type","getAddonsActor","addonsActor","Promise","reject","installTemporaryAddon","addonPath","openDevTools","getInstalledAddon","addonId","addons","id","map","a","checkForAddonReloading","requestTypes","indexOf","supportedRequestTypes","reloadAddon","process","stdout","write","Date","toTimeString","connect","port","connectWithMaxRetries","maxRetries","retryInterval","establishConnection","lastError","retries","resolve","setTimeout","stack","findFreeTcpPort","srv","createServer","listen","freeTcpPort","address","close"],"sources":["../../src/firefox/remote.js"],"sourcesContent":["import net from 'net';\n\nimport { connectToFirefox as defaultFirefoxConnector } from './rdp-client.js';\nimport { createLogger } from '../util/logger.js';\nimport {\n isErrorWithCode,\n RemoteTempInstallNotSupported,\n UsageError,\n WebExtError,\n} from '../errors.js';\n\nconst log = createLogger(import.meta.url);\n\n// NOTE: this type aliases Object to catch any other possible response.\n\n// Convert a request rejection to a message string.\nfunction requestErrorToMessage(err) {\n if (err instanceof Error) {\n return String(err);\n }\n return `${err.error}: ${err.message}`;\n}\n\nexport class RemoteFirefox {\n client;\n checkedForAddonReloading;\n\n constructor(client) {\n this.client = client;\n this.checkedForAddonReloading = false;\n\n client.on('disconnect', () => {\n log.debug('Received \"disconnect\" from Firefox client');\n });\n client.on('end', () => {\n log.debug('Received \"end\" from Firefox client');\n });\n client.on('unsolicited-event', (info) => {\n log.debug(`Received message from client: ${JSON.stringify(info)}`);\n });\n client.on('rdp-error', (rdpError) => {\n log.debug(`Received error from client: ${JSON.stringify(rdpError)}`);\n });\n client.on('error', (error) => {\n log.debug(`Received error from client: ${String(error)}`);\n });\n }\n\n disconnect() {\n this.client.disconnect();\n }\n\n async addonRequest(addon, request) {\n try {\n const response = await this.client.request({\n to: addon.actor,\n type: request,\n });\n return response;\n } catch (err) {\n log.debug(`Client responded to '${request}' request with error:`, err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: addonRequest() error: ${message}`);\n }\n }\n\n async getAddonsActor() {\n try {\n // getRoot should work since Firefox 55 (bug 1352157).\n const response = await this.client.request('getRoot');\n if (response.addonsActor == null) {\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This version of Firefox does not provide an add-ons actor for ' +\n 'remote installation.',\n ),\n );\n }\n return response.addonsActor;\n } catch (err) {\n // Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).\n log.debug('Falling back to listTabs because getRoot failed', err);\n }\n\n try {\n const response = await this.client.request('listTabs');\n // addonsActor was added to listTabs in Firefox 49 (bug 1273183).\n if (response.addonsActor == null) {\n log.debug(\n 'listTabs returned a falsey addonsActor: ' +\n `${JSON.stringify(response)}`,\n );\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This is an older version of Firefox that does not provide an ' +\n 'add-ons actor for remote installation. Try Firefox 49 or ' +\n 'higher.',\n ),\n );\n }\n return response.addonsActor;\n } catch (err) {\n log.debug('listTabs error', err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listTabs() error: ${message}`);\n }\n }\n\n async installTemporaryAddon(addonPath, openDevTools) {\n const addonsActor = await this.getAddonsActor();\n\n try {\n const response = await this.client.request({\n to: addonsActor,\n type: 'installTemporaryAddon',\n addonPath,\n openDevTools,\n });\n log.debug(`installTemporaryAddon: ${JSON.stringify(response)}`);\n log.info(`Installed ${addonPath} as a temporary add-on`);\n return response;\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`installTemporaryAddon: Error: ${message}`);\n }\n }\n\n async getInstalledAddon(addonId) {\n try {\n const response = await this.client.request('listAddons');\n for (const addon of response.addons) {\n if (addon.id === addonId) {\n return addon;\n }\n }\n log.debug(\n `Remote Firefox has these addons: ${response.addons.map((a) => a.id)}`,\n );\n return Promise.reject(\n new WebExtError(\n 'The remote Firefox does not have your extension installed',\n ),\n );\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listAddons() error: ${message}`);\n }\n }\n\n async checkForAddonReloading(addon) {\n if (this.checkedForAddonReloading) {\n // We only need to check once if reload() is supported.\n return addon;\n } else {\n const response = await this.addonRequest(addon, 'requestTypes');\n\n if (response.requestTypes.indexOf('reload') === -1) {\n const supportedRequestTypes = JSON.stringify(response.requestTypes);\n log.debug(`Remote Firefox only supports: ${supportedRequestTypes}`);\n throw new UsageError(\n 'This Firefox version does not support add-on reloading. ' +\n 'Re-run with --no-reload',\n );\n } else {\n this.checkedForAddonReloading = true;\n return addon;\n }\n }\n }\n\n async reloadAddon(addonId) {\n const addon = await this.getInstalledAddon(addonId);\n await this.checkForAddonReloading(addon);\n await this.addonRequest(addon, 'reload');\n process.stdout.write(\n `\\rLast extension reload: ${new Date().toTimeString()}`,\n );\n log.debug('\\n');\n }\n}\n\n// Connect types and implementation\n\nexport async function connect(\n port,\n { connectToFirefox = defaultFirefoxConnector } = {},\n) {\n log.debug(`Connecting to Firefox on port ${port}`);\n const client = await connectToFirefox(port);\n log.debug(`Connected to the remote Firefox debugger on port ${port}`);\n return new RemoteFirefox(client);\n}\n\n// ConnectWithMaxRetries types and implementation\n\nexport async function connectWithMaxRetries(\n // A max of 250 will try connecting for 30 seconds.\n { maxRetries = 250, retryInterval = 120, port },\n { connectToFirefox = connect } = {},\n) {\n async function establishConnection() {\n var lastError;\n\n for (let retries = 0; retries <= maxRetries; retries++) {\n try {\n return await connectToFirefox(port);\n } catch (error) {\n if (isErrorWithCode('ECONNREFUSED', error)) {\n // Wait for `retryInterval` ms.\n await new Promise((resolve) => {\n setTimeout(resolve, retryInterval);\n });\n\n lastError = error;\n log.debug(\n `Retrying Firefox (${retries}); connection error: ${error}`,\n );\n } else {\n log.error(error.stack);\n throw error;\n }\n }\n }\n\n log.debug('Connect to Firefox debugger: too many retries');\n throw lastError;\n }\n\n log.debug('Connecting to the remote Firefox debugger');\n return establishConnection();\n}\n\nexport function findFreeTcpPort() {\n return new Promise((resolve) => {\n const srv = net.createServer();\n srv.listen(0, '127.0.0.1', () => {\n const freeTcpPort = srv.address().port;\n srv.close(() => resolve(freeTcpPort));\n });\n });\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,gBAAgB,IAAIC,uBAAuB,QAAQ,iBAAiB;AAC7E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACEC,eAAe,EACfC,6BAA6B,EAC7BC,UAAU,EACVC,WAAW,QACN,cAAc;AAErB,MAAMC,GAAG,GAAGL,YAAY,CAACM,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;;AAEzC;;AAEA;AACA,SAASC,qBAAqBA,CAACC,GAAG,EAAE;EAClC,IAAIA,GAAG,YAAYC,KAAK,EAAE;IACxB,OAAOC,MAAM,CAACF,GAAG,CAAC;EACpB;EACA,OAAO,GAAGA,GAAG,CAACG,KAAK,KAAKH,GAAG,CAACI,OAAO,EAAE;AACvC;AAEA,OAAO,MAAMC,aAAa,CAAC;EACzBC,MAAM;EACNC,wBAAwB;EAExBC,WAAWA,CAACF,MAAM,EAAE;IAClB,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,wBAAwB,GAAG,KAAK;IAErCD,MAAM,CAACG,EAAE,CAAC,YAAY,EAAE,MAAM;MAC5Bd,GAAG,CAACe,KAAK,CAAC,2CAA2C,CAAC;IACxD,CAAC,CAAC;IACFJ,MAAM,CAACG,EAAE,CAAC,KAAK,EAAE,MAAM;MACrBd,GAAG,CAACe,KAAK,CAAC,oCAAoC,CAAC;IACjD,CAAC,CAAC;IACFJ,MAAM,CAACG,EAAE,CAAC,mBAAmB,EAAGE,IAAI,IAAK;MACvChB,GAAG,CAACe,KAAK,CAAC,iCAAiCE,IAAI,CAACC,SAAS,CAACF,IAAI,CAAC,EAAE,CAAC;IACpE,CAAC,CAAC;IACFL,MAAM,CAACG,EAAE,CAAC,WAAW,EAAGK,QAAQ,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,EAAE;UAC1C;UACA,MAAM,IAAIsB,OAAO,CAAE6B,OAAO,IAAK;YAC7BC,UAAU,CAACD,OAAO,EAAEJ,aAAa,CAAC;UACpC,CAAC,CAAC;UAEFE,SAAS,GAAGjD,KAAK;UACjBR,GAAG,CAACe,KAAK,CACP,qBAAqB2C,OAAO,wBAAwBlD,KAAK,EAC3D,CAAC;QACH,CAAC,MAAM;UACLR,GAAG,CAACQ,KAAK,CAACA,KAAK,CAACqD,KAAK,CAAC;UACtB,MAAMrD,KAAK;QACb;MACF;IACF;IAEAR,GAAG,CAACe,KAAK,CAAC,+CAA+C,CAAC;IAC1D,MAAM0C,SAAS;EACjB;EAEAzD,GAAG,CAACe,KAAK,CAAC,2CAA2C,CAAC;EACtD,OAAOyC,mBAAmB,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASM,eAAeA,CAAA,EAAG;EAChC,OAAO,IAAIhC,OAAO,CAAE6B,OAAO,IAAK;IAC9B,MAAMI,GAAG,GAAGvE,GAAG,CAACwE,YAAY,CAAC,CAAC;IAC9BD,GAAG,CAACE,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM;MAC/B,MAAMC,WAAW,GAAGH,GAAG,CAACI,OAAO,CAAC,CAAC,CAACf,IAAI;MACtCW,GAAG,CAACK,KAAK,CAAC,MAAMT,OAAO,CAACO,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"remote.js","names":[],"sources":["../../src/firefox/remote.js"],"sourcesContent":["import net from 'net';\n\nimport { connectToFirefox as defaultFirefoxConnector } from './rdp-client.js';\nimport { createLogger } from '../util/logger.js';\nimport {\n isErrorWithCode,\n RemoteTempInstallNotSupported,\n UsageError,\n WebExtError,\n} from '../errors.js';\n\nconst log = createLogger(import.meta.url);\n\n// NOTE: this type aliases Object to catch any other possible response.\n\n// Convert a request rejection to a message string.\nfunction requestErrorToMessage(err) {\n if (err instanceof Error) {\n return String(err);\n }\n return `${err.error}: ${err.message}`;\n}\n\nexport class RemoteFirefox {\n client;\n checkedForAddonReloading;\n\n constructor(client) {\n this.client = client;\n this.checkedForAddonReloading = false;\n\n client.on('disconnect', () => {\n log.debug('Received \"disconnect\" from Firefox client');\n });\n client.on('end', () => {\n log.debug('Received \"end\" from Firefox client');\n });\n client.on('unsolicited-event', (info) => {\n log.debug(`Received message from client: ${JSON.stringify(info)}`);\n });\n client.on('rdp-error', (rdpError) => {\n log.debug(`Received error from client: ${JSON.stringify(rdpError)}`);\n });\n client.on('error', (error) => {\n log.debug(`Received error from client: ${String(error)}`);\n });\n }\n\n disconnect() {\n this.client.disconnect();\n }\n\n async addonRequest(addon, request) {\n try {\n const response = await this.client.request({\n to: addon.actor,\n type: request,\n });\n return response;\n } catch (err) {\n log.debug(`Client responded to '${request}' request with error:`, err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: addonRequest() error: ${message}`);\n }\n }\n\n async getAddonsActor() {\n try {\n // getRoot should work since Firefox 55 (bug 1352157).\n const response = await this.client.request('getRoot');\n if (response.addonsActor == null) {\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This version of Firefox does not provide an add-ons actor for ' +\n 'remote installation.',\n ),\n );\n }\n return response.addonsActor;\n } catch (err) {\n // Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).\n log.debug('Falling back to listTabs because getRoot failed', err);\n }\n\n try {\n const response = await this.client.request('listTabs');\n // addonsActor was added to listTabs in Firefox 49 (bug 1273183).\n if (response.addonsActor == null) {\n log.debug(\n 'listTabs returned a falsey addonsActor: ' +\n `${JSON.stringify(response)}`,\n );\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This is an older version of Firefox that does not provide an ' +\n 'add-ons actor for remote installation. Try Firefox 49 or ' +\n 'higher.',\n ),\n );\n }\n return response.addonsActor;\n } catch (err) {\n log.debug('listTabs error', err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listTabs() error: ${message}`);\n }\n }\n\n async installTemporaryAddon(addonPath, openDevTools) {\n const addonsActor = await this.getAddonsActor();\n\n try {\n const response = await this.client.request({\n to: addonsActor,\n type: 'installTemporaryAddon',\n addonPath,\n openDevTools,\n });\n log.debug(`installTemporaryAddon: ${JSON.stringify(response)}`);\n log.info(`Installed ${addonPath} as a temporary add-on`);\n return response;\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`installTemporaryAddon: Error: ${message}`);\n }\n }\n\n async getInstalledAddon(addonId) {\n try {\n const response = await this.client.request('listAddons');\n for (const addon of response.addons) {\n if (addon.id === addonId) {\n return addon;\n }\n }\n log.debug(\n `Remote Firefox has these addons: ${response.addons.map((a) => a.id)}`,\n );\n return Promise.reject(\n new WebExtError(\n 'The remote Firefox does not have your extension installed',\n ),\n );\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listAddons() error: ${message}`);\n }\n }\n\n async checkForAddonReloading(addon) {\n if (this.checkedForAddonReloading) {\n // We only need to check once if reload() is supported.\n return addon;\n } else {\n const response = await this.addonRequest(addon, 'requestTypes');\n\n if (response.requestTypes.indexOf('reload') === -1) {\n const supportedRequestTypes = JSON.stringify(response.requestTypes);\n log.debug(`Remote Firefox only supports: ${supportedRequestTypes}`);\n throw new UsageError(\n 'This Firefox version does not support add-on reloading. ' +\n 'Re-run with --no-reload',\n );\n } else {\n this.checkedForAddonReloading = true;\n return addon;\n }\n }\n }\n\n async reloadAddon(addonId) {\n const addon = await this.getInstalledAddon(addonId);\n await this.checkForAddonReloading(addon);\n await this.addonRequest(addon, 'reload');\n process.stdout.write(\n `\\rLast extension reload: ${new Date().toTimeString()}`,\n );\n log.debug('\\n');\n }\n}\n\n// Connect types and implementation\n\nexport async function connect(\n port,\n { connectToFirefox = defaultFirefoxConnector } = {},\n) {\n log.debug(`Connecting to Firefox on port ${port}`);\n const client = await connectToFirefox(port);\n log.debug(`Connected to the remote Firefox debugger on port ${port}`);\n return new RemoteFirefox(client);\n}\n\n// ConnectWithMaxRetries types and implementation\n\nexport async function connectWithMaxRetries(\n // A max of 250 will try connecting for 30 seconds.\n { maxRetries = 250, retryInterval = 120, port },\n { connectToFirefox = connect } = {},\n) {\n async function establishConnection() {\n var lastError;\n\n for (let retries = 0; retries <= maxRetries; retries++) {\n try {\n return await connectToFirefox(port);\n } catch (error) {\n if (isErrorWithCode('ECONNREFUSED', error)) {\n // Wait for `retryInterval` ms.\n await new Promise((resolve) => {\n setTimeout(resolve, retryInterval);\n });\n\n lastError = error;\n log.debug(\n `Retrying Firefox (${retries}); connection error: ${error}`,\n );\n } else {\n log.error(error.stack);\n throw error;\n }\n }\n }\n\n log.debug('Connect to Firefox debugger: too many retries');\n throw lastError;\n }\n\n log.debug('Connecting to the remote Firefox debugger');\n return establishConnection();\n}\n\nexport function findFreeTcpPort() {\n return new Promise((resolve) => {\n const srv = net.createServer();\n srv.listen(0, '127.0.0.1', () => {\n const freeTcpPort = srv.address().port;\n srv.close(() => resolve(freeTcpPort));\n });\n });\n}\n"],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK;AAErB,SAAS,gBAAgB,IAAI,uBAAuB,QAAQ,iBAAiB;AAC7E,SAAS,YAAY,QAAQ,mBAAmB;AAChD,SACE,eAAe,EACf,6BAA6B,EAC7B,UAAU,EACV,WAAW,QACN,cAAc;AAErB,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;;AAEzC;;AAEA;AACA,SAAS,qBAAqB,CAAC,GAAG,EAAE;EAClC,IAAI,GAAG,YAAY,KAAK,EAAE;IACxB,OAAO,MAAM,CAAC,GAAG,CAAC;EACpB;EACA,OAAO,GAAG,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE;AACvC;AAEA,OAAO,MAAM,aAAa,CAAC;EACzB,MAAM;EACN,wBAAwB;EAExB,WAAW,CAAC,MAAM,EAAE;IAClB,IAAI,CAAC,MAAM,GAAG,MAA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AAS;IAEb,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE;MACtD,IAAI;QACF,OAAO,MAAM,gBAAgB,CAAC,IAAI,CAAC;MACrC,CAAC,CAAC,OAAO,KAAK,EAAE;QACd,IAAI,eAAe,CAAC,cAAc,EAAE,KAAK,CAAC,EAAE;UAC1C;UACA,MAAM,IAAI,OAAO,CAAE,OAAO,IAAK;YAC7B,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC;UACpC,CAAC,CAAC;UAEF,SAAS,GAAG,KAAK;UACjB,GAAG,CAAC,KAAK,CACP,qBAAqB,OAAO,wBAAwB,KAAK,EAC3D,CAAC;QACH,CAAC,MAAM;UACL,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;UACtB,MAAM,KAAK;QACb;MACF;IACF;IAEA,GAAG,CAAC,KAAK,CAAC,+CAA+C,CAAC;IAC1D,MAAM,SAAS;EACjB;EAEA,GAAG,CAAC,KAAK,CAAC,2CAA2C,CAAC;EACtD,OAAO,mBAAmB,CAAC,CAAC;AAC9B;AAEA,OAAO,SAAS,eAAe,GAAG;EAChC,OAAO,IAAI,OAAO,CAAE,OAAO,IAAK;IAC9B,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9B,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM;MAC/B,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;MACtC,GAAG,CAAC,KAAK,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":[
|
|
1
|
+
{"version":3,"file":"main.js","names":[],"sources":["../src/main.js"],"sourcesContent":["import { main } from './program.js';\nimport cmd from './cmd/index.js';\n\n// This only exposes main and cmd, while util/logger and util/adb are defined as\n// separate additional exports in the package.json.\nexport default { main, cmd };\n"],"mappings":"AAAA,SAAS,IAAI,QAAQ,cAAc;AACnC,OAAO,GAAG,MAAM,gBAAgB;;AAEhC;AACA;AACA,eAAe;EAAE,IAAI;EAAE;AAAI,CAAC","ignoreList":[]}
|
package/lib/program.js
CHANGED
|
@@ -14,7 +14,7 @@ import { discoverConfigFiles as defaultConfigDiscovery, loadJSConfigFile as defa
|
|
|
14
14
|
const log = createLogger(import.meta.url);
|
|
15
15
|
const envPrefix = 'WEB_EXT';
|
|
16
16
|
// Default to "development" (the value actually assigned will be interpolated
|
|
17
|
-
// by babel-plugin-
|
|
17
|
+
// at build time by scripts/babel-plugin-inline-environment-variables.cjs).
|
|
18
18
|
const defaultGlobalEnv = "production" || 'development';
|
|
19
19
|
export const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';
|
|
20
20
|
|
|
@@ -648,6 +648,11 @@ Example: $0 --help run.
|
|
|
648
648
|
type: 'boolean',
|
|
649
649
|
default: false
|
|
650
650
|
},
|
|
651
|
+
enterprise: {
|
|
652
|
+
describe: 'Treat your extension as an enterprise extension',
|
|
653
|
+
type: 'boolean',
|
|
654
|
+
default: false
|
|
655
|
+
},
|
|
651
656
|
boring: {
|
|
652
657
|
describe: 'Disables colorful shell output',
|
|
653
658
|
type: 'boolean',
|
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","AMO_BASE_URL","Program","absolutePackageDir","commands","shouldExitProgram","verboseEnabled","options","programArgv","demandedOptions","constructor","argv","process","cwd","slice","yargsInstance","parserConfiguration","strict","wrap","terminalWidth","command","name","description","executor","commandOptions","yargsForCmd","demandCommand","undefined","exitProcess","env","setGlobalOptions","Object","keys","forEach","key","global","demandOption","enableVerboseMode","logStream","version","makeVerbose","info","getArguments","validationInstance","getInternalMethods","getValidationInstance","requiredArguments","getDemandedOptions","args","err","message","startsWith","configDiscovery","noConfigDiscovery","reload","noReload","input","noInput","ignoreFiles","length","startUrl","checkRequiredArguments","adjustedArgv","cleanupProcessEnvConfigs","systemProcess","cmd","_","toOptionKey","k","replace","separator","filter","optKey","globalOpt","cmdOpt","debug","execute","getVersion","defaultVersionGetter","globalEnv","runCommand","verbose","webextVersion","configFiles","discoveredConfigs","push","config","resolve","niceFileList","map","f","homedir","join","configFileName","configObject","argvFromCLI","error","stack","String","code","cause","exit","packageData","JSON","parse","git","branch","long","throwUsageErrorIfArray","errorMessage","value","Array","isArray","main","runOptions","program","usage","help","alias","recommendCommands","describe","default","requiresArg","type","coerce","arg","normalize","hidden","build","filename","dumpConfig","sign","timeout","channel","run","target","choices","firefox","pref","devtools","lint","output","metadata","pretty","privileged","boring","docs"],"sources":["../src/program.js"],"sourcesContent":["import os from 'os';\nimport path from 'path';\nimport { readFileSync } from 'fs';\n\nimport camelCase from 'camelcase';\nimport decamelize from 'decamelize';\nimport yargs from 'yargs';\nimport { Parser as yargsParser } from 'yargs/helpers';\n\nimport defaultCommands from './cmd/index.js';\nimport { UsageError } from './errors.js';\nimport {\n createLogger,\n consoleStream as defaultLogStream,\n} from './util/logger.js';\nimport { coerceCLICustomPreference } from './firefox/preferences.js';\nimport { checkForUpdates as defaultUpdateChecker } from './util/updates.js';\nimport {\n discoverConfigFiles as defaultConfigDiscovery,\n loadJSConfigFile as defaultLoadJSConfigFile,\n applyConfigToArgv as defaultApplyConfigToArgv,\n} from './config.js';\n\nconst log = createLogger(import.meta.url);\nconst envPrefix = 'WEB_EXT';\n// Default to \"development\" (the value actually assigned will be interpolated\n// by babel-plugin-transform-inline-environment-variables).\nconst defaultGlobalEnv = process.env.WEBEXT_BUILD_ENV || 'development';\n\nexport const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir;\n yargs;\n commands;\n shouldExitProgram;\n verboseEnabled;\n options;\n programArgv;\n demandedOptions;\n\n constructor(argv, { absolutePackageDir = process.cwd() } = {}) {\n // This allows us to override the process argv which is useful for\n // testing.\n // NOTE: process.argv.slice(2) removes the path to node and web-ext\n // executables from the process.argv array.\n argv = argv || process.argv.slice(2);\n this.programArgv = argv;\n\n // NOTE: always initialize yargs explicitly with the package dir\n // to avoid side-effects due to yargs looking for its configuration\n // section from a package.json file stored in an arbitrary directory\n // (e.g. in tests yargs would end up loading yargs config from the\n // mocha package.json). web-ext package.json doesn't contain any yargs\n // section as it is deprecated and we configure yargs using\n // yargs.parserConfiguration. See web-ext#469 for rationale.\n const yargsInstance = yargs(argv, absolutePackageDir);\n\n this.absolutePackageDir = absolutePackageDir;\n this.verboseEnabled = false;\n this.shouldExitProgram = true;\n\n this.yargs = yargsInstance;\n this.yargs.parserConfiguration({\n 'boolean-negation': true,\n });\n this.yargs.strict();\n this.yargs.wrap(this.yargs.terminalWidth());\n\n this.commands = {};\n this.options = {};\n }\n\n command(name, description, executor, commandOptions = {}) {\n this.options[camelCase(name)] = commandOptions;\n\n this.yargs.command(name, description, (yargsForCmd) => {\n if (!commandOptions) {\n return;\n }\n return (\n yargsForCmd\n // Make sure the user does not add any extra commands. For example,\n // this would be a mistake because lint does not accept arguments:\n // web-ext lint ./src/path/to/file.js\n .demandCommand(\n 0,\n 0,\n undefined,\n 'This command does not take any arguments',\n )\n .strict()\n .exitProcess(this.shouldExitProgram)\n // Calling env() will be unnecessary after\n // https://github.com/yargs/yargs/issues/486 is fixed\n .env(envPrefix)\n .options(commandOptions)\n );\n });\n this.commands[name] = executor;\n return this;\n }\n\n setGlobalOptions(options) {\n // This is a convenience for setting global options.\n // An option is only global (i.e. available to all sub commands)\n // with the `global` flag so this makes sure every option has it.\n this.options = { ...this.options, ...options };\n Object.keys(options).forEach((key) => {\n options[key].global = true;\n if (options[key].demandOption === undefined) {\n // By default, all options should be \"demanded\" otherwise\n // yargs.strict() will think they are missing when declared.\n options[key].demandOption = true;\n }\n });\n this.yargs.options(options);\n return this;\n }\n\n enableVerboseMode(logStream, version) {\n if (this.verboseEnabled) {\n return;\n }\n\n logStream.makeVerbose();\n log.info('Version:', version);\n this.verboseEnabled = true;\n }\n\n // Retrieve the yargs argv object and apply any further fix needed\n // on the output of the yargs options parsing.\n getArguments() {\n // To support looking up required parameters via config files, we need to\n // temporarily disable the requiredArguments validation. Otherwise yargs\n // would exit early. Validation is enforced by the checkRequiredArguments()\n // method, after reading configuration files.\n //\n // This is an undocumented internal API of yargs! Unit tests to avoid\n // regressions are located at: tests/functional/test.cli.sign.js\n //\n // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930\n const validationInstance = this.yargs\n .getInternalMethods()\n .getValidationInstance();\n const { requiredArguments } = validationInstance;\n // Initialize demandedOptions (which is going to be set to an object with one\n // property for each mandatory global options, then the arrow function below\n // will receive as its demandedOptions parameter a new one that also includes\n // all mandatory options for the sub command selected).\n this.demandedOptions = this.yargs.getDemandedOptions();\n validationInstance.requiredArguments = (args, demandedOptions) => {\n this.demandedOptions = demandedOptions;\n };\n let argv;\n try {\n argv = this.yargs.argv;\n } catch (err) {\n if (\n err.name === 'YError' &&\n err.message.startsWith('Unknown argument: ')\n ) {\n throw new UsageError(err.message);\n }\n throw err;\n }\n validationInstance.requiredArguments = requiredArguments;\n\n // Yargs boolean options doesn't define the no* counterpart\n // with negate-boolean on Yargs 15. Define as expected by the\n // web-ext execute method.\n if (argv.configDiscovery != null) {\n argv.noConfigDiscovery = !argv.configDiscovery;\n }\n if (argv.reload != null) {\n argv.noReload = !argv.reload;\n }\n\n // Yargs doesn't accept --no-input as a valid option if there isn't a\n // --input option defined to be negated, to fix that the --input is\n // defined and hidden from the yargs help output and we define here\n // the negated argument name that we expect to be set in the parsed\n // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).\n if (argv.input != null) {\n argv.noInput = !argv.input;\n }\n\n // Replacement for the \"requiresArg: true\" parameter until the following bug\n // is fixed: https://github.com/yargs/yargs/issues/1098\n if (argv.ignoreFiles && !argv.ignoreFiles.length) {\n throw new UsageError('Not enough arguments following: ignore-files');\n }\n\n if (argv.startUrl && !argv.startUrl.length) {\n throw new UsageError('Not enough arguments following: start-url');\n }\n\n return argv;\n }\n\n // getArguments() disables validation of required parameters, to allow us to\n // read parameters from config files first. Before the program continues, it\n // must call checkRequiredArguments() to ensure that required parameters are\n // defined (in the CLI or in a config file).\n checkRequiredArguments(adjustedArgv) {\n const validationInstance = this.yargs\n .getInternalMethods()\n .getValidationInstance();\n validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);\n }\n\n // Remove WEB_EXT_* environment vars that are not a global cli options\n // or an option supported by the current command (See #793).\n cleanupProcessEnvConfigs(systemProcess) {\n const cmd = yargsParser(this.programArgv)._[0];\n const env = systemProcess.env || {};\n const toOptionKey = (k) =>\n decamelize(camelCase(k.replace(envPrefix, '')), { separator: '-' });\n\n if (cmd) {\n Object.keys(env)\n .filter((k) => k.startsWith(envPrefix))\n .forEach((k) => {\n const optKey = toOptionKey(k);\n const globalOpt = this.options[optKey];\n const cmdOpt = this.options[cmd] && this.options[cmd][optKey];\n\n if (!globalOpt && !cmdOpt) {\n log.debug(`Environment ${k} not supported by web-ext ${cmd}`);\n delete env[k];\n }\n });\n }\n }\n\n async execute({\n checkForUpdates = defaultUpdateChecker,\n systemProcess = process,\n logStream = defaultLogStream,\n getVersion = defaultVersionGetter,\n applyConfigToArgv = defaultApplyConfigToArgv,\n discoverConfigFiles = defaultConfigDiscovery,\n loadJSConfigFile = defaultLoadJSConfigFile,\n shouldExitProgram = true,\n globalEnv = defaultGlobalEnv,\n } = {}) {\n this.shouldExitProgram = shouldExitProgram;\n this.yargs.exitProcess(this.shouldExitProgram);\n\n this.cleanupProcessEnvConfigs(systemProcess);\n const argv = this.getArguments();\n\n const cmd = argv._[0];\n\n const version = await getVersion(this.absolutePackageDir);\n const runCommand = this.commands[cmd];\n\n if (argv.verbose) {\n this.enableVerboseMode(logStream, version);\n }\n\n let adjustedArgv = { ...argv, webextVersion: version };\n\n try {\n if (cmd === undefined) {\n throw new UsageError('No sub-command was specified in the args');\n }\n if (!runCommand) {\n throw new UsageError(`Unknown command: ${cmd}`);\n }\n if (globalEnv === 'production') {\n checkForUpdates({ version });\n }\n\n const configFiles = [];\n\n if (argv.configDiscovery) {\n log.debug(\n 'Discovering config files. ' + 'Set --no-config-discovery to disable',\n );\n const discoveredConfigs = await discoverConfigFiles();\n configFiles.push(...discoveredConfigs);\n } else {\n log.debug('Not discovering config files');\n }\n\n if (argv.config) {\n configFiles.push(path.resolve(argv.config));\n }\n\n if (configFiles.length) {\n const niceFileList = configFiles\n .map((f) => f.replace(process.cwd(), '.'))\n .map((f) => f.replace(os.homedir(), '~'))\n .join(', ');\n log.debug(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`,\n );\n }\n\n for (const configFileName of configFiles) {\n const configObject = await loadJSConfigFile(configFileName);\n adjustedArgv = applyConfigToArgv({\n argv: adjustedArgv,\n argvFromCLI: argv,\n configFileName,\n configObject,\n options: this.options,\n });\n }\n\n if (adjustedArgv.verbose) {\n // Ensure that the verbose is enabled when specified in a config file.\n this.enableVerboseMode(logStream, version);\n }\n\n this.checkRequiredArguments(adjustedArgv);\n\n await runCommand(adjustedArgv, { shouldExitProgram });\n } catch (error) {\n if (!(error instanceof UsageError) || adjustedArgv.verbose) {\n log.error(`\\n${error.stack}\\n`);\n } else {\n log.error(`\\n${String(error)}\\n`);\n }\n if (error.code) {\n log.error(`Error code: ${error.code}\\n`);\n }\n if (error.cause && adjustedArgv.verbose) {\n log.error(`Error cause: ${error.cause.stack}\\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 definition of type of argument for defaultVersionGetter\n\nexport async function defaultVersionGetter(\n absolutePackageDir,\n { globalEnv = defaultGlobalEnv } = {},\n) {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData = readFileSync(\n path.join(absolutePackageDir, 'package.json'),\n );\n return JSON.parse(packageData).version;\n } else {\n log.debug('Getting version from the git revision');\n // This branch is only reached during development.\n // git-rev-sync is in devDependencies, and lazily imported using require.\n // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916\n // eslint-disable-next-line import/no-extraneous-dependencies\n const git = await import('git-rev-sync');\n return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;\n }\n}\n\nexport function throwUsageErrorIfArray(errorMessage) {\n return (value) => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir,\n {\n getVersion = defaultVersionGetter,\n commands = defaultCommands,\n argv,\n runOptions = {},\n } = {},\n) {\n const program = new Program(argv, { absolutePackageDir });\n const version = await getVersion(absolutePackageDir);\n\n // yargs uses magic camel case expansion to expose options on the\n // final argv object. For example, the 'artifacts-dir' option is alternatively\n // available as argv.artifactsDir.\n program.yargs\n .usage(\n `Usage: $0 [options] command\n\nOption values can also be set by declaring an environment variable prefixed\nwith $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as\n--source-dir=/path.\n\nTo view specific help for any given command, add the command name.\nExample: $0 --help run.\n`,\n )\n .help('help')\n .alias('h', 'help')\n .env(envPrefix)\n .version(version)\n .demandCommand(1, 'You must specify a command')\n .strict()\n .recommendCommands();\n\n program.setGlobalOptions({\n 'source-dir': {\n alias: 's',\n describe: 'Web extension source directory.',\n default: process.cwd(),\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg ?? undefined,\n },\n 'artifacts-dir': {\n alias: 'a',\n describe: 'Directory where artifacts will be saved.',\n default: path.join(process.cwd(), 'web-ext-artifacts'),\n normalize: true,\n requiresArg: true,\n type: 'string',\n },\n verbose: {\n alias: 'v',\n describe: 'Show verbose output',\n type: 'boolean',\n demandOption: false,\n },\n 'ignore-files': {\n alias: 'i',\n describe:\n 'A list of glob patterns to define which files should be ' +\n 'ignored. (Example: --ignore-files=path/to/first.js ' +\n 'path/to/second.js \"**/*.log\")',\n demandOption: false,\n // The following option prevents yargs>=11 from parsing multiple values,\n // so the minimum value requirement is enforced in execute instead.\n // Upstream bug: https://github.com/yargs/yargs/issues/1098\n // requiresArg: true,\n type: 'array',\n },\n 'no-input': {\n describe: 'Disable all features that require standard input',\n type: 'boolean',\n demandOption: false,\n },\n input: {\n // This option is defined to make yargs to accept the --no-input\n // defined above, but we hide it from the yargs help output.\n hidden: true,\n type: 'boolean',\n demandOption: false,\n },\n config: {\n alias: 'c',\n describe: 'Path to a CommonJS config file to set ' + 'option defaults',\n default: undefined,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n },\n 'config-discovery': {\n describe:\n 'Discover config files in home directory and ' +\n 'working directory. Disable with --no-config-discovery.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n });\n\n program\n .command(\n 'build',\n 'Create an extension package from source',\n commands.build,\n {\n 'as-needed': {\n describe: 'Watch for file changes and re-build as needed',\n type: 'boolean',\n },\n filename: {\n alias: 'n',\n describe: 'Name of the created extension package file.',\n default: undefined,\n normalize: false,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n coerce: (arg) =>\n arg == null\n ? undefined\n : throwUsageErrorIfArray(\n 'Multiple --filename/-n option are not allowed',\n )(arg),\n },\n 'overwrite-dest': {\n alias: 'o',\n describe: 'Overwrite destination package if it exists.',\n type: 'boolean',\n },\n },\n )\n .command(\n 'dump-config',\n 'Run config discovery and dump the resulting config data as JSON',\n commands.dumpConfig,\n {},\n )\n .command(\n 'sign',\n 'Submit the extension to Mozilla Add-ons (AMO) for signing so it can be installed in Firefox',\n commands.sign,\n {\n 'amo-base-url': {\n describe: 'Submission API URL prefix',\n default: AMO_BASE_URL,\n demandOption: true,\n type: 'string',\n },\n 'api-key': {\n describe: 'API key (JWT issuer) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-secret': {\n describe: 'API secret (JWT secret) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-proxy': {\n describe:\n 'Use a proxy to access the signing API. ' +\n 'Example: https://yourproxy:6000 ',\n demandOption: false,\n type: 'string',\n },\n timeout: {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n 'approval-timeout': {\n describe:\n 'Number of milliseconds to wait for approval before giving up. ' +\n 'Set to 0 to disable waiting for approval. Fallback to `timeout` if not set.',\n type: 'number',\n },\n channel: {\n describe:\n \"The channel for which to sign the addon. Either 'listed' or 'unlisted'.\",\n demandOption: true,\n type: 'string',\n },\n 'amo-metadata': {\n describe:\n 'Path to a JSON file containing an object with metadata to be passed to the API. ' +\n 'See https://addons-server.readthedocs.io/en/latest/topics/api/addons.html for details.',\n type: 'string',\n },\n 'upload-source-code': {\n describe:\n 'Path to an archive file containing human readable source code of this submission, ' +\n 'if the code in --source-dir has been processed to make it unreadable. ' +\n 'See https://extensionworkshop.com/documentation/publish/source-code-submission/ for ' +\n 'details.',\n type: 'string',\n },\n },\n )\n .command('run', 'Run the extension', commands.run, {\n target: {\n alias: 't',\n describe:\n 'The extensions runners to enable. Specify this option ' +\n 'multiple times to run against multiple targets.',\n default: 'firefox-desktop',\n demandOption: false,\n type: 'array',\n choices: ['firefox-desktop', 'firefox-android', 'chromium'],\n },\n firefox: {\n alias: ['f', 'firefox-binary'],\n describe:\n 'Path or alias to a Firefox executable such as firefox-bin ' +\n 'or firefox.exe. ' +\n 'If not specified, the default Firefox will be used. ' +\n 'You can specify the following aliases in lieu of a path: ' +\n 'firefox, beta, nightly, firefoxdeveloperedition (or deved). ' +\n 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' +\n '`org.mozilla.firefox` is the application ID.',\n demandOption: false,\n type: 'string',\n },\n 'firefox-profile': {\n alias: 'p',\n describe:\n 'Run Firefox using a copy of this profile. The profile ' +\n 'can be specified as a directory or a name, such as one ' +\n 'you would see in the Profile Manager. If not specified, ' +\n 'a new temporary profile will be created.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-binary': {\n describe:\n 'Path or alias to a Chromium executable such as ' +\n 'google-chrome, google-chrome.exe or opera.exe etc. ' +\n 'If not specified, the default Google Chrome will be used.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-pref': {\n describe:\n 'Launch chromium with a custom preference ' +\n '(example: --chromium-pref=browser.theme.follows_system_colors=false). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) =>\n arg != null ? coerceCLICustomPreference(arg) : undefined,\n },\n 'chromium-profile': {\n describe: 'Path to a custom Chromium profile',\n demandOption: false,\n type: 'string',\n },\n 'profile-create-if-missing': {\n describe: 'Create the profile directory if it does not already exist',\n demandOption: false,\n type: 'boolean',\n },\n 'keep-profile-changes': {\n describe:\n 'Run Firefox directly in custom profile. Any changes to ' +\n 'the profile will be saved.',\n demandOption: false,\n type: 'boolean',\n },\n reload: {\n describe:\n 'Reload the extension when source files change. ' +\n 'Disable with --no-reload.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n 'watch-file': {\n alias: ['watch-files'],\n describe:\n 'Reload the extension only when the contents of this' +\n ' file changes. This is useful if you use a custom' +\n ' build process for your extension',\n demandOption: false,\n type: 'array',\n },\n 'watch-ignored': {\n describe:\n 'Paths and globs patterns that should not be ' +\n 'watched for changes. This is useful if you want ' +\n 'to explicitly prevent web-ext from watching part ' +\n 'of the extension directory tree, ' +\n 'e.g. the node_modules folder.',\n demandOption: false,\n type: 'array',\n },\n 'pre-install': {\n describe:\n 'Pre-install the extension into the profile before ' +\n 'startup. This is only needed to support older versions ' +\n 'of Firefox.',\n demandOption: false,\n type: 'boolean',\n },\n pref: {\n describe:\n 'Launch firefox with a custom preference ' +\n '(example: --pref=general.useragent.locale=fr-FR). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) =>\n arg != null ? coerceCLICustomPreference(arg) : undefined,\n },\n 'start-url': {\n alias: ['u', 'url'],\n describe: 'Launch firefox at specified page',\n demandOption: false,\n type: 'array',\n },\n devtools: {\n describe:\n 'Open the DevTools for the installed add-on ' +\n '(Firefox 106 and later)',\n demandOption: false,\n type: 'boolean',\n },\n 'browser-console': {\n alias: ['bc'],\n describe: 'Open the DevTools Browser Console.',\n demandOption: false,\n type: 'boolean',\n },\n args: {\n alias: ['arg'],\n describe: 'Additional CLI options passed to the Browser binary',\n demandOption: false,\n type: 'array',\n },\n // Firefox for Android CLI options.\n 'adb-bin': {\n describe: 'Specify a custom path to the adb binary',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-host': {\n describe: 'Connect to adb on the specified host',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-port': {\n describe: 'Connect to adb on the specified port',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-device': {\n alias: ['android-device'],\n describe: 'Connect to the specified adb device name',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-discovery-timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n demandOption: false,\n type: 'number',\n requiresArg: true,\n },\n 'adb-remove-old-artifacts': {\n describe: 'Remove old artifacts directories from the adb device',\n demandOption: false,\n type: 'boolean',\n },\n 'firefox-apk': {\n describe:\n 'Run a specific Firefox for Android APK. ' +\n 'Example: org.mozilla.fennec_aurora',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'firefox-apk-component': {\n describe:\n 'Run a specific Android Component (defaults to <firefox-apk>/.App)',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n })\n .command('lint', 'Validate the extension source', commands.lint, {\n output: {\n alias: 'o',\n describe: 'The type of output to generate',\n type: 'string',\n default: 'text',\n choices: ['json', 'text'],\n },\n metadata: {\n describe: 'Output only metadata as JSON',\n type: 'boolean',\n default: false,\n },\n 'warnings-as-errors': {\n describe: 'Treat warnings as errors by exiting non-zero for warnings',\n alias: 'w',\n type: 'boolean',\n default: false,\n },\n pretty: {\n describe: 'Prettify JSON output',\n type: 'boolean',\n default: false,\n },\n privileged: {\n describe: 'Treat your extension as a privileged extension',\n type: 'boolean',\n default: false,\n },\n 'self-hosted': {\n describe:\n 'Your extension will be self-hosted. This disables messages ' +\n 'related to hosting on addons.mozilla.org.',\n type: 'boolean',\n default: false,\n },\n boring: {\n describe: 'Disables colorful shell output',\n type: 'boolean',\n default: false,\n },\n })\n .command(\n 'docs',\n 'Open the web-ext documentation in a browser',\n commands.docs,\n {},\n );\n\n return program.execute({ getVersion, ...runOptions });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,YAAY,QAAQ,IAAI;AAEjC,OAAOC,SAAS,MAAM,WAAW;AACjC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,IAAIC,WAAW,QAAQ,eAAe;AAErD,OAAOC,eAAe,MAAM,gBAAgB;AAC5C,SAASC,UAAU,QAAQ,aAAa;AACxC,SACEC,YAAY,EACZC,aAAa,IAAIC,gBAAgB,QAC5B,kBAAkB;AACzB,SAASC,yBAAyB,QAAQ,0BAA0B;AACpE,SAASC,eAAe,IAAIC,oBAAoB,QAAQ,mBAAmB;AAC3E,SACEC,mBAAmB,IAAIC,sBAAsB,EAC7CC,gBAAgB,IAAIC,uBAAuB,EAC3CC,iBAAiB,IAAIC,wBAAwB,QACxC,aAAa;AAEpB,MAAMC,GAAG,GAAGZ,YAAY,CAACa,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AACzC,MAAMC,SAAS,GAAG,SAAS;AAC3B;A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AAC,CAAC;AACvD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"program.js","names":[],"sources":["../src/program.js"],"sourcesContent":["import os from 'os';\nimport path from 'path';\nimport { readFileSync } from 'fs';\n\nimport camelCase from 'camelcase';\nimport decamelize from 'decamelize';\nimport yargs from 'yargs';\nimport { Parser as yargsParser } from 'yargs/helpers';\n\nimport defaultCommands from './cmd/index.js';\nimport { UsageError } from './errors.js';\nimport {\n createLogger,\n consoleStream as defaultLogStream,\n} from './util/logger.js';\nimport { coerceCLICustomPreference } from './firefox/preferences.js';\nimport { checkForUpdates as defaultUpdateChecker } from './util/updates.js';\nimport {\n discoverConfigFiles as defaultConfigDiscovery,\n loadJSConfigFile as defaultLoadJSConfigFile,\n applyConfigToArgv as defaultApplyConfigToArgv,\n} from './config.js';\n\nconst log = createLogger(import.meta.url);\nconst envPrefix = 'WEB_EXT';\n// Default to \"development\" (the value actually assigned will be interpolated\n// at build time by scripts/babel-plugin-inline-environment-variables.cjs).\nconst defaultGlobalEnv = process.env.WEBEXT_BUILD_ENV || 'development';\n\nexport const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';\n\n/*\n * The command line program.\n */\nexport class Program {\n absolutePackageDir;\n yargs;\n commands;\n shouldExitProgram;\n verboseEnabled;\n options;\n programArgv;\n demandedOptions;\n\n constructor(argv, { absolutePackageDir = process.cwd() } = {}) {\n // This allows us to override the process argv which is useful for\n // testing.\n // NOTE: process.argv.slice(2) removes the path to node and web-ext\n // executables from the process.argv array.\n argv = argv || process.argv.slice(2);\n this.programArgv = argv;\n\n // NOTE: always initialize yargs explicitly with the package dir\n // to avoid side-effects due to yargs looking for its configuration\n // section from a package.json file stored in an arbitrary directory\n // (e.g. in tests yargs would end up loading yargs config from the\n // mocha package.json). web-ext package.json doesn't contain any yargs\n // section as it is deprecated and we configure yargs using\n // yargs.parserConfiguration. See web-ext#469 for rationale.\n const yargsInstance = yargs(argv, absolutePackageDir);\n\n this.absolutePackageDir = absolutePackageDir;\n this.verboseEnabled = false;\n this.shouldExitProgram = true;\n\n this.yargs = yargsInstance;\n this.yargs.parserConfiguration({\n 'boolean-negation': true,\n });\n this.yargs.strict();\n this.yargs.wrap(this.yargs.terminalWidth());\n\n this.commands = {};\n this.options = {};\n }\n\n command(name, description, executor, commandOptions = {}) {\n this.options[camelCase(name)] = commandOptions;\n\n this.yargs.command(name, description, (yargsForCmd) => {\n if (!commandOptions) {\n return;\n }\n return (\n yargsForCmd\n // Make sure the user does not add any extra commands. For example,\n // this would be a mistake because lint does not accept arguments:\n // web-ext lint ./src/path/to/file.js\n .demandCommand(\n 0,\n 0,\n undefined,\n 'This command does not take any arguments',\n )\n .strict()\n .exitProcess(this.shouldExitProgram)\n // Calling env() will be unnecessary after\n // https://github.com/yargs/yargs/issues/486 is fixed\n .env(envPrefix)\n .options(commandOptions)\n );\n });\n this.commands[name] = executor;\n return this;\n }\n\n setGlobalOptions(options) {\n // This is a convenience for setting global options.\n // An option is only global (i.e. available to all sub commands)\n // with the `global` flag so this makes sure every option has it.\n this.options = { ...this.options, ...options };\n Object.keys(options).forEach((key) => {\n options[key].global = true;\n if (options[key].demandOption === undefined) {\n // By default, all options should be \"demanded\" otherwise\n // yargs.strict() will think they are missing when declared.\n options[key].demandOption = true;\n }\n });\n this.yargs.options(options);\n return this;\n }\n\n enableVerboseMode(logStream, version) {\n if (this.verboseEnabled) {\n return;\n }\n\n logStream.makeVerbose();\n log.info('Version:', version);\n this.verboseEnabled = true;\n }\n\n // Retrieve the yargs argv object and apply any further fix needed\n // on the output of the yargs options parsing.\n getArguments() {\n // To support looking up required parameters via config files, we need to\n // temporarily disable the requiredArguments validation. Otherwise yargs\n // would exit early. Validation is enforced by the checkRequiredArguments()\n // method, after reading configuration files.\n //\n // This is an undocumented internal API of yargs! Unit tests to avoid\n // regressions are located at: tests/functional/test.cli.sign.js\n //\n // Replace hack if possible: https://github.com/mozilla/web-ext/issues/1930\n const validationInstance = this.yargs\n .getInternalMethods()\n .getValidationInstance();\n const { requiredArguments } = validationInstance;\n // Initialize demandedOptions (which is going to be set to an object with one\n // property for each mandatory global options, then the arrow function below\n // will receive as its demandedOptions parameter a new one that also includes\n // all mandatory options for the sub command selected).\n this.demandedOptions = this.yargs.getDemandedOptions();\n validationInstance.requiredArguments = (args, demandedOptions) => {\n this.demandedOptions = demandedOptions;\n };\n let argv;\n try {\n argv = this.yargs.argv;\n } catch (err) {\n if (\n err.name === 'YError' &&\n err.message.startsWith('Unknown argument: ')\n ) {\n throw new UsageError(err.message);\n }\n throw err;\n }\n validationInstance.requiredArguments = requiredArguments;\n\n // Yargs boolean options doesn't define the no* counterpart\n // with negate-boolean on Yargs 15. Define as expected by the\n // web-ext execute method.\n if (argv.configDiscovery != null) {\n argv.noConfigDiscovery = !argv.configDiscovery;\n }\n if (argv.reload != null) {\n argv.noReload = !argv.reload;\n }\n\n // Yargs doesn't accept --no-input as a valid option if there isn't a\n // --input option defined to be negated, to fix that the --input is\n // defined and hidden from the yargs help output and we define here\n // the negated argument name that we expect to be set in the parsed\n // arguments (and fix https://github.com/mozilla/web-ext/issues/1860).\n if (argv.input != null) {\n argv.noInput = !argv.input;\n }\n\n // Replacement for the \"requiresArg: true\" parameter until the following bug\n // is fixed: https://github.com/yargs/yargs/issues/1098\n if (argv.ignoreFiles && !argv.ignoreFiles.length) {\n throw new UsageError('Not enough arguments following: ignore-files');\n }\n\n if (argv.startUrl && !argv.startUrl.length) {\n throw new UsageError('Not enough arguments following: start-url');\n }\n\n return argv;\n }\n\n // getArguments() disables validation of required parameters, to allow us to\n // read parameters from config files first. Before the program continues, it\n // must call checkRequiredArguments() to ensure that required parameters are\n // defined (in the CLI or in a config file).\n checkRequiredArguments(adjustedArgv) {\n const validationInstance = this.yargs\n .getInternalMethods()\n .getValidationInstance();\n validationInstance.requiredArguments(adjustedArgv, this.demandedOptions);\n }\n\n // Remove WEB_EXT_* environment vars that are not a global cli options\n // or an option supported by the current command (See #793).\n cleanupProcessEnvConfigs(systemProcess) {\n const cmd = yargsParser(this.programArgv)._[0];\n const env = systemProcess.env || {};\n const toOptionKey = (k) =>\n decamelize(camelCase(k.replace(envPrefix, '')), { separator: '-' });\n\n if (cmd) {\n Object.keys(env)\n .filter((k) => k.startsWith(envPrefix))\n .forEach((k) => {\n const optKey = toOptionKey(k);\n const globalOpt = this.options[optKey];\n const cmdOpt = this.options[cmd] && this.options[cmd][optKey];\n\n if (!globalOpt && !cmdOpt) {\n log.debug(`Environment ${k} not supported by web-ext ${cmd}`);\n delete env[k];\n }\n });\n }\n }\n\n async execute({\n checkForUpdates = defaultUpdateChecker,\n systemProcess = process,\n logStream = defaultLogStream,\n getVersion = defaultVersionGetter,\n applyConfigToArgv = defaultApplyConfigToArgv,\n discoverConfigFiles = defaultConfigDiscovery,\n loadJSConfigFile = defaultLoadJSConfigFile,\n shouldExitProgram = true,\n globalEnv = defaultGlobalEnv,\n } = {}) {\n this.shouldExitProgram = shouldExitProgram;\n this.yargs.exitProcess(this.shouldExitProgram);\n\n this.cleanupProcessEnvConfigs(systemProcess);\n const argv = this.getArguments();\n\n const cmd = argv._[0];\n\n const version = await getVersion(this.absolutePackageDir);\n const runCommand = this.commands[cmd];\n\n if (argv.verbose) {\n this.enableVerboseMode(logStream, version);\n }\n\n let adjustedArgv = { ...argv, webextVersion: version };\n\n try {\n if (cmd === undefined) {\n throw new UsageError('No sub-command was specified in the args');\n }\n if (!runCommand) {\n throw new UsageError(`Unknown command: ${cmd}`);\n }\n if (globalEnv === 'production') {\n checkForUpdates({ version });\n }\n\n const configFiles = [];\n\n if (argv.configDiscovery) {\n log.debug(\n 'Discovering config files. ' + 'Set --no-config-discovery to disable',\n );\n const discoveredConfigs = await discoverConfigFiles();\n configFiles.push(...discoveredConfigs);\n } else {\n log.debug('Not discovering config files');\n }\n\n if (argv.config) {\n configFiles.push(path.resolve(argv.config));\n }\n\n if (configFiles.length) {\n const niceFileList = configFiles\n .map((f) => f.replace(process.cwd(), '.'))\n .map((f) => f.replace(os.homedir(), '~'))\n .join(', ');\n log.debug(\n 'Applying config file' +\n `${configFiles.length !== 1 ? 's' : ''}: ` +\n `${niceFileList}`,\n );\n }\n\n for (const configFileName of configFiles) {\n const configObject = await loadJSConfigFile(configFileName);\n adjustedArgv = applyConfigToArgv({\n argv: adjustedArgv,\n argvFromCLI: argv,\n configFileName,\n configObject,\n options: this.options,\n });\n }\n\n if (adjustedArgv.verbose) {\n // Ensure that the verbose is enabled when specified in a config file.\n this.enableVerboseMode(logStream, version);\n }\n\n this.checkRequiredArguments(adjustedArgv);\n\n await runCommand(adjustedArgv, { shouldExitProgram });\n } catch (error) {\n if (!(error instanceof UsageError) || adjustedArgv.verbose) {\n log.error(`\\n${error.stack}\\n`);\n } else {\n log.error(`\\n${String(error)}\\n`);\n }\n if (error.code) {\n log.error(`Error code: ${error.code}\\n`);\n }\n if (error.cause && adjustedArgv.verbose) {\n log.error(`Error cause: ${error.cause.stack}\\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 definition of type of argument for defaultVersionGetter\n\nexport async function defaultVersionGetter(\n absolutePackageDir,\n { globalEnv = defaultGlobalEnv } = {},\n) {\n if (globalEnv === 'production') {\n log.debug('Getting the version from package.json');\n const packageData = readFileSync(\n path.join(absolutePackageDir, 'package.json'),\n );\n return JSON.parse(packageData).version;\n } else {\n log.debug('Getting version from the git revision');\n // This branch is only reached during development.\n // git-rev-sync is in devDependencies, and lazily imported using require.\n // This also avoids logspam from https://github.com/mozilla/web-ext/issues/1916\n // eslint-disable-next-line import/no-extraneous-dependencies\n const git = await import('git-rev-sync');\n return `${git.branch(absolutePackageDir)}-${git.long(absolutePackageDir)}`;\n }\n}\n\nexport function throwUsageErrorIfArray(errorMessage) {\n return (value) => {\n if (Array.isArray(value)) {\n throw new UsageError(errorMessage);\n }\n return value;\n };\n}\n\nexport async function main(\n absolutePackageDir,\n {\n getVersion = defaultVersionGetter,\n commands = defaultCommands,\n argv,\n runOptions = {},\n } = {},\n) {\n const program = new Program(argv, { absolutePackageDir });\n const version = await getVersion(absolutePackageDir);\n\n // yargs uses magic camel case expansion to expose options on the\n // final argv object. For example, the 'artifacts-dir' option is alternatively\n // available as argv.artifactsDir.\n program.yargs\n .usage(\n `Usage: $0 [options] command\n\nOption values can also be set by declaring an environment variable prefixed\nwith $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as\n--source-dir=/path.\n\nTo view specific help for any given command, add the command name.\nExample: $0 --help run.\n`,\n )\n .help('help')\n .alias('h', 'help')\n .env(envPrefix)\n .version(version)\n .demandCommand(1, 'You must specify a command')\n .strict()\n .recommendCommands();\n\n program.setGlobalOptions({\n 'source-dir': {\n alias: 's',\n describe: 'Web extension source directory.',\n default: process.cwd(),\n requiresArg: true,\n type: 'string',\n coerce: (arg) => arg ?? undefined,\n },\n 'artifacts-dir': {\n alias: 'a',\n describe: 'Directory where artifacts will be saved.',\n default: path.join(process.cwd(), 'web-ext-artifacts'),\n normalize: true,\n requiresArg: true,\n type: 'string',\n },\n verbose: {\n alias: 'v',\n describe: 'Show verbose output',\n type: 'boolean',\n demandOption: false,\n },\n 'ignore-files': {\n alias: 'i',\n describe:\n 'A list of glob patterns to define which files should be ' +\n 'ignored. (Example: --ignore-files=path/to/first.js ' +\n 'path/to/second.js \"**/*.log\")',\n demandOption: false,\n // The following option prevents yargs>=11 from parsing multiple values,\n // so the minimum value requirement is enforced in execute instead.\n // Upstream bug: https://github.com/yargs/yargs/issues/1098\n // requiresArg: true,\n type: 'array',\n },\n 'no-input': {\n describe: 'Disable all features that require standard input',\n type: 'boolean',\n demandOption: false,\n },\n input: {\n // This option is defined to make yargs to accept the --no-input\n // defined above, but we hide it from the yargs help output.\n hidden: true,\n type: 'boolean',\n demandOption: false,\n },\n config: {\n alias: 'c',\n describe: 'Path to a CommonJS config file to set ' + 'option defaults',\n default: undefined,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n },\n 'config-discovery': {\n describe:\n 'Discover config files in home directory and ' +\n 'working directory. Disable with --no-config-discovery.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n });\n\n program\n .command(\n 'build',\n 'Create an extension package from source',\n commands.build,\n {\n 'as-needed': {\n describe: 'Watch for file changes and re-build as needed',\n type: 'boolean',\n },\n filename: {\n alias: 'n',\n describe: 'Name of the created extension package file.',\n default: undefined,\n normalize: false,\n demandOption: false,\n requiresArg: true,\n type: 'string',\n coerce: (arg) =>\n arg == null\n ? undefined\n : throwUsageErrorIfArray(\n 'Multiple --filename/-n option are not allowed',\n )(arg),\n },\n 'overwrite-dest': {\n alias: 'o',\n describe: 'Overwrite destination package if it exists.',\n type: 'boolean',\n },\n },\n )\n .command(\n 'dump-config',\n 'Run config discovery and dump the resulting config data as JSON',\n commands.dumpConfig,\n {},\n )\n .command(\n 'sign',\n 'Submit the extension to Mozilla Add-ons (AMO) for signing so it can be installed in Firefox',\n commands.sign,\n {\n 'amo-base-url': {\n describe: 'Submission API URL prefix',\n default: AMO_BASE_URL,\n demandOption: true,\n type: 'string',\n },\n 'api-key': {\n describe: 'API key (JWT issuer) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-secret': {\n describe: 'API secret (JWT secret) from addons.mozilla.org',\n demandOption: true,\n type: 'string',\n },\n 'api-proxy': {\n describe:\n 'Use a proxy to access the signing API. ' +\n 'Example: https://yourproxy:6000 ',\n demandOption: false,\n type: 'string',\n },\n timeout: {\n describe: 'Number of milliseconds to wait before giving up',\n type: 'number',\n },\n 'approval-timeout': {\n describe:\n 'Number of milliseconds to wait for approval before giving up. ' +\n 'Set to 0 to disable waiting for approval. Fallback to `timeout` if not set.',\n type: 'number',\n },\n channel: {\n describe:\n \"The channel for which to sign the addon. Either 'listed' or 'unlisted'.\",\n demandOption: true,\n type: 'string',\n },\n 'amo-metadata': {\n describe:\n 'Path to a JSON file containing an object with metadata to be passed to the API. ' +\n 'See https://addons-server.readthedocs.io/en/latest/topics/api/addons.html for details.',\n type: 'string',\n },\n 'upload-source-code': {\n describe:\n 'Path to an archive file containing human readable source code of this submission, ' +\n 'if the code in --source-dir has been processed to make it unreadable. ' +\n 'See https://extensionworkshop.com/documentation/publish/source-code-submission/ for ' +\n 'details.',\n type: 'string',\n },\n },\n )\n .command('run', 'Run the extension', commands.run, {\n target: {\n alias: 't',\n describe:\n 'The extensions runners to enable. Specify this option ' +\n 'multiple times to run against multiple targets.',\n default: 'firefox-desktop',\n demandOption: false,\n type: 'array',\n choices: ['firefox-desktop', 'firefox-android', 'chromium'],\n },\n firefox: {\n alias: ['f', 'firefox-binary'],\n describe:\n 'Path or alias to a Firefox executable such as firefox-bin ' +\n 'or firefox.exe. ' +\n 'If not specified, the default Firefox will be used. ' +\n 'You can specify the following aliases in lieu of a path: ' +\n 'firefox, beta, nightly, firefoxdeveloperedition (or deved). ' +\n 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' +\n '`org.mozilla.firefox` is the application ID.',\n demandOption: false,\n type: 'string',\n },\n 'firefox-profile': {\n alias: 'p',\n describe:\n 'Run Firefox using a copy of this profile. The profile ' +\n 'can be specified as a directory or a name, such as one ' +\n 'you would see in the Profile Manager. If not specified, ' +\n 'a new temporary profile will be created.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-binary': {\n describe:\n 'Path or alias to a Chromium executable such as ' +\n 'google-chrome, google-chrome.exe or opera.exe etc. ' +\n 'If not specified, the default Google Chrome will be used.',\n demandOption: false,\n type: 'string',\n },\n 'chromium-pref': {\n describe:\n 'Launch chromium with a custom preference ' +\n '(example: --chromium-pref=browser.theme.follows_system_colors=false). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) =>\n arg != null ? coerceCLICustomPreference(arg) : undefined,\n },\n 'chromium-profile': {\n describe: 'Path to a custom Chromium profile',\n demandOption: false,\n type: 'string',\n },\n 'profile-create-if-missing': {\n describe: 'Create the profile directory if it does not already exist',\n demandOption: false,\n type: 'boolean',\n },\n 'keep-profile-changes': {\n describe:\n 'Run Firefox directly in custom profile. Any changes to ' +\n 'the profile will be saved.',\n demandOption: false,\n type: 'boolean',\n },\n reload: {\n describe:\n 'Reload the extension when source files change. ' +\n 'Disable with --no-reload.',\n demandOption: false,\n default: true,\n type: 'boolean',\n },\n 'watch-file': {\n alias: ['watch-files'],\n describe:\n 'Reload the extension only when the contents of this' +\n ' file changes. This is useful if you use a custom' +\n ' build process for your extension',\n demandOption: false,\n type: 'array',\n },\n 'watch-ignored': {\n describe:\n 'Paths and globs patterns that should not be ' +\n 'watched for changes. This is useful if you want ' +\n 'to explicitly prevent web-ext from watching part ' +\n 'of the extension directory tree, ' +\n 'e.g. the node_modules folder.',\n demandOption: false,\n type: 'array',\n },\n 'pre-install': {\n describe:\n 'Pre-install the extension into the profile before ' +\n 'startup. This is only needed to support older versions ' +\n 'of Firefox.',\n demandOption: false,\n type: 'boolean',\n },\n pref: {\n describe:\n 'Launch firefox with a custom preference ' +\n '(example: --pref=general.useragent.locale=fr-FR). ' +\n 'You can repeat this option to set more than one ' +\n 'preference.',\n demandOption: false,\n requiresArg: true,\n type: 'array',\n coerce: (arg) =>\n arg != null ? coerceCLICustomPreference(arg) : undefined,\n },\n 'start-url': {\n alias: ['u', 'url'],\n describe: 'Launch firefox at specified page',\n demandOption: false,\n type: 'array',\n },\n devtools: {\n describe:\n 'Open the DevTools for the installed add-on ' +\n '(Firefox 106 and later)',\n demandOption: false,\n type: 'boolean',\n },\n 'browser-console': {\n alias: ['bc'],\n describe: 'Open the DevTools Browser Console.',\n demandOption: false,\n type: 'boolean',\n },\n args: {\n alias: ['arg'],\n describe: 'Additional CLI options passed to the Browser binary',\n demandOption: false,\n type: 'array',\n },\n // Firefox for Android CLI options.\n 'adb-bin': {\n describe: 'Specify a custom path to the adb binary',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-host': {\n describe: 'Connect to adb on the specified host',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-port': {\n describe: 'Connect to adb on the specified port',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-device': {\n alias: ['android-device'],\n describe: 'Connect to the specified adb device name',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'adb-discovery-timeout': {\n describe: 'Number of milliseconds to wait before giving up',\n demandOption: false,\n type: 'number',\n requiresArg: true,\n },\n 'adb-remove-old-artifacts': {\n describe: 'Remove old artifacts directories from the adb device',\n demandOption: false,\n type: 'boolean',\n },\n 'firefox-apk': {\n describe:\n 'Run a specific Firefox for Android APK. ' +\n 'Example: org.mozilla.fennec_aurora',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n 'firefox-apk-component': {\n describe:\n 'Run a specific Android Component (defaults to <firefox-apk>/.App)',\n demandOption: false,\n type: 'string',\n requiresArg: true,\n },\n })\n .command('lint', 'Validate the extension source', commands.lint, {\n output: {\n alias: 'o',\n describe: 'The type of output to generate',\n type: 'string',\n default: 'text',\n choices: ['json', 'text'],\n },\n metadata: {\n describe: 'Output only metadata as JSON',\n type: 'boolean',\n default: false,\n },\n 'warnings-as-errors': {\n describe: 'Treat warnings as errors by exiting non-zero for warnings',\n alias: 'w',\n type: 'boolean',\n default: false,\n },\n pretty: {\n describe: 'Prettify JSON output',\n type: 'boolean',\n default: false,\n },\n privileged: {\n describe: 'Treat your extension as a privileged extension',\n type: 'boolean',\n default: false,\n },\n 'self-hosted': {\n describe:\n 'Your extension will be self-hosted. This disables messages ' +\n 'related to hosting on addons.mozilla.org.',\n type: 'boolean',\n default: false,\n },\n enterprise: {\n describe: 'Treat your extension as an enterprise extension',\n type: 'boolean',\n default: false,\n },\n boring: {\n describe: 'Disables colorful shell output',\n type: 'boolean',\n default: false,\n },\n })\n .command(\n 'docs',\n 'Open the web-ext documentation in a browser',\n commands.docs,\n {},\n );\n\n return program.execute({ getVersion, ...runOptions });\n}\n"],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI;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EAAE;IACX,CAAC;IACD,oBAAoB,EAAE;MACpB,QAAQ,EAAE,2DAA2D;MACrE,KAAK,EAAE,GAAG;MACV,IAAI,EAAE,SAAS;MACf,OAAO,EAAE;IACX,CAAC;IACD,MAAM,EAAE;MACN,QAAQ,EAAE,sBAAsB;MAChC,IAAI,EAAE,SAAS;MACf,OAAO,EAAE;IACX,CAAC;IACD,UAAU,EAAE;MACV,QAAQ,EAAE,gDAAgD;MAC1D,IAAI,EAAE,SAAS;MACf,OAAO,EAAE;IACX,CAAC;IACD,aAAa,EAAE;MACb,QAAQ,EACN,6DAA6D,GAC7D,2CAA2C;MAC7C,IAAI,EAAE,SAAS;MACf,OAAO,EAAE;IACX,CAAC;IACD,UAAU,EAAE;MACV,QAAQ,EAAE,iDAAiD;MAC3D,IAAI,EAAE,SAAS;MACf,OAAO,EAAE;IACX,CAAC;IACD,MAAM,EAAE;MACN,QAAQ,EAAE,gCAAgC;MAC1C,IAAI,EAAE,SAAS;MACf,OAAO,EAAE;IACX;EACF,CAAC,CAAC,CACD,OAAO,CACN,MAAM,EACN,6CAA6C,EAC7C,QAAQ,CAAC,IAAI,EACb,CAAC,CACH,CAAC;EAEH,OAAO,OAAO,CAAC,OAAO,CAAC;IAAE,UAAU;IAAE,GAAG;EAAW,CAAC,CAAC;AACvD","ignoreList":[]}
|
package/lib/util/adb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.js","names":["ADBKit","isErrorWithCode","UsageError","WebExtError","createLogger","packageIdentifiers","defaultApkComponents","DEVICE_DIR_BASE","ARTIFACTS_DIR_PREFIX","defaultADB","default","log","import","meta","url","wrapADBCall","asyncFn","error","message","includes","ADBUtils","params","adb","adbClient","artifactsDirMap","userAbortDiscovery","constructor","adbBin","adbHost","adbPort","createClient","bin","host","port","Map","runShellCommand","deviceId","cmd","debug","JSON","stringify","getDevice","shell","then","util","readAll","res","toString","discoverDevices","devices","listDevices","map","dev","id","getCurrentUser","currentUser","userId","parseInt","trim","isNaN","discoverInstalledFirefoxAPKs","firefoxApk","pmList","split","line","replace","filter","browser","startsWith","amForceStopAPK","apk","getOrCreateArtifactsDir","artifactsDir","get","Date","now","testDirOut","set","detectOrRemoveOldArtifacts","removeArtifactDirs","files","readdir","found","file","isDirectory","name","clearArtifactsDir","delete","pushFile","localPath","devicePath","push","transfer","Promise","resolve","on","startFirefoxAPK","apkComponent","deviceProfileDir","extras","key","value","component","startActivity","wait","action","category","setUserAbortDiscovery","discoverRDPUnixSocket","maxDiscoveryTime","retryInterval","rdpUnixSockets","discoveryStartedAt","msg","length","info","endsWith","setTimeout","pop","setupForward","remote","local","forward","listADBDevices","adbUtils","listADBFirefoxAPKs"],"sources":["../../src/util/adb.js"],"sourcesContent":["import ADBKit from '@devicefarmer/adbkit';\n\nimport { isErrorWithCode, UsageError, WebExtError } from '../errors.js';\nimport { createLogger } from '../util/logger.js';\nimport packageIdentifiers, {\n defaultApkComponents,\n} from '../firefox/package-identifiers.js';\n\nexport const DEVICE_DIR_BASE = '/data/local/tmp/';\nexport const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-';\n\nconst defaultADB = ADBKit.default;\n\nconst log = createLogger(import.meta.url);\n\n// Helper function used to raise an UsageError when the adb binary has not been found.\nasync function wrapADBCall(asyncFn) {\n try {\n return await asyncFn();\n } catch (error) {\n if (\n isErrorWithCode('ENOENT', error) &&\n error.message.includes('spawn adb')\n ) {\n throw new UsageError(\n 'No adb executable has been found. ' +\n 'You can Use --adb-bin, --adb-host/--adb-port ' +\n 'to configure it manually if needed.',\n );\n }\n\n throw error;\n }\n}\n\nexport default class ADBUtils {\n params;\n adb;\n adbClient;\n\n // Map<deviceId -> artifactsDir>\n artifactsDirMap;\n // Toggled when the user wants to abort the RDP Unix Socket discovery loop\n // while it is still executing.\n userAbortDiscovery;\n\n constructor(params) {\n this.params = params;\n\n const { adb, adbBin, adbHost, adbPort } = params;\n\n this.adb = adb || defaultADB;\n\n this.adbClient = this.adb.createClient({\n bin: adbBin,\n host: adbHost,\n port: adbPort,\n });\n\n this.artifactsDirMap = new Map();\n\n this.userAbortDiscovery = false;\n }\n\n async runShellCommand(deviceId, cmd) {\n const { adb, adbClient } = this;\n\n log.debug(`Run adb shell command on ${deviceId}: ${JSON.stringify(cmd)}`);\n\n return wrapADBCall(async () => {\n return await adbClient\n .getDevice(deviceId)\n .shell(cmd)\n .then(adb.util.readAll);\n }).then((res) => res.toString());\n }\n\n async discoverDevices() {\n const { adbClient } = this;\n\n let devices = [];\n\n log.debug('Listing android devices');\n devices = await wrapADBCall(async () => adbClient.listDevices());\n\n return devices.map((dev) => dev.id);\n }\n\n async getCurrentUser(deviceId) {\n log.debug(`Retrieving current user on ${deviceId}`);\n\n const currentUser = await this.runShellCommand(deviceId, [\n 'am',\n 'get-current-user',\n ]);\n\n const userId = parseInt(currentUser.trim());\n if (isNaN(userId)) {\n throw new WebExtError(`Unable to retrieve current user on ${deviceId}`);\n }\n return userId;\n }\n\n async discoverInstalledFirefoxAPKs(deviceId, firefoxApk) {\n const userId = await this.getCurrentUser(deviceId);\n\n log.debug(`Listing installed Firefox APKs on ${deviceId}`);\n const pmList = await this.runShellCommand(deviceId, [\n 'pm',\n 'list',\n 'packages',\n '--user',\n `${userId}`,\n ]);\n\n return pmList\n .split('\\n')\n .map((line) => line.replace('package:', '').trim())\n .filter((line) => {\n // Look for an exact match if firefoxApk is defined.\n if (firefoxApk) {\n return line === firefoxApk;\n }\n // Match any package name that starts with the package name of a Firefox for Android browser.\n for (const browser of packageIdentifiers) {\n if (line.startsWith(browser)) {\n return true;\n }\n }\n\n return false;\n });\n }\n\n async amForceStopAPK(deviceId, apk) {\n await this.runShellCommand(deviceId, ['am', 'force-stop', apk]);\n }\n\n async getOrCreateArtifactsDir(deviceId) {\n let artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (artifactsDir) {\n return artifactsDir;\n }\n\n artifactsDir = `${DEVICE_DIR_BASE}${ARTIFACTS_DIR_PREFIX}${Date.now()}`;\n\n const testDirOut = (\n await this.runShellCommand(deviceId, `test -d ${artifactsDir} ; echo $?`)\n ).trim();\n\n if (testDirOut !== '1') {\n throw new WebExtError(\n `Cannot create artifacts directory ${artifactsDir} ` +\n `because it exists on ${deviceId}.`,\n );\n }\n\n await this.runShellCommand(deviceId, ['mkdir', '-p', artifactsDir]);\n\n this.artifactsDirMap.set(deviceId, artifactsDir);\n\n return artifactsDir;\n }\n\n async detectOrRemoveOldArtifacts(deviceId, removeArtifactDirs = false) {\n const { adbClient } = this;\n\n log.debug('Checking adb device for existing web-ext artifacts dirs');\n\n return wrapADBCall(async () => {\n const files = await adbClient\n .getDevice(deviceId)\n .readdir(DEVICE_DIR_BASE);\n let found = false;\n\n for (const file of files) {\n if (\n !file.isDirectory() ||\n !file.name.startsWith(ARTIFACTS_DIR_PREFIX)\n ) {\n continue;\n }\n\n // Return earlier if we only need to warn the user that some\n // existing artifacts dirs have been found on the adb device.\n if (!removeArtifactDirs) {\n return true;\n }\n\n found = true;\n\n const artifactsDir = `${DEVICE_DIR_BASE}${file.name}`;\n\n log.debug(\n `Removing artifacts directory ${artifactsDir} from device ${deviceId}`,\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n return found;\n });\n }\n\n async clearArtifactsDir(deviceId) {\n const artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (!artifactsDir) {\n // nothing to do here.\n return;\n }\n\n this.artifactsDirMap.delete(deviceId);\n\n log.debug(\n `Removing ${artifactsDir} artifacts directory on ${deviceId} device`,\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n async pushFile(deviceId, localPath, devicePath) {\n const { adbClient } = this;\n\n log.debug(`Pushing ${localPath} to ${devicePath} on ${deviceId}`);\n\n await wrapADBCall(async () => {\n await adbClient\n .getDevice(deviceId)\n .push(localPath, devicePath)\n .then(function (transfer) {\n return new Promise((resolve) => {\n transfer.on('end', resolve);\n });\n });\n });\n }\n\n async startFirefoxAPK(deviceId, apk, apkComponent, deviceProfileDir) {\n const { adbClient } = this;\n\n log.debug(`Starting ${apk} on ${deviceId}`);\n\n // Fenix does ignore the -profile parameter, on the contrary Fennec\n // would run using the given path as the profile to be used during\n // this execution.\n const extras = [\n {\n key: 'args',\n value: `-profile ${deviceProfileDir}`,\n },\n ];\n\n if (!apkComponent) {\n apkComponent = '.App';\n if (defaultApkComponents[apk]) {\n apkComponent = defaultApkComponents[apk];\n }\n } else if (!apkComponent.includes('.')) {\n apkComponent = `.${apkComponent}`;\n }\n\n // If `apk` is a browser package or the `apk` has a browser package prefix:\n // prepend the package identifier before `apkComponent`.\n if (apkComponent.startsWith('.')) {\n for (const browser of packageIdentifiers) {\n if (apk === browser || apk.startsWith(`${browser}.`)) {\n apkComponent = browser + apkComponent;\n break;\n }\n }\n }\n\n // If `apkComponent` starts with a '.', then adb will expand the following\n // to: `${apk}/${apk}.${apkComponent}`\n let component = `${apk}`;\n if (apkComponent) {\n component += `/${apkComponent}`;\n }\n\n await wrapADBCall(async () => {\n try {\n // TODO: once Fenix (release) uses Android 13, we can get rid of this\n // call and only use the second call in the `catch` block.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.activity.MAIN',\n component,\n extras,\n });\n } catch {\n // Android 13+ requires a different action/category but we still need\n // to support older Fenix builds.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.intent.action.MAIN',\n category: 'android.intent.category.LAUNCHER',\n component,\n extras,\n });\n }\n });\n }\n\n setUserAbortDiscovery(value) {\n this.userAbortDiscovery = value;\n }\n\n async discoverRDPUnixSocket(\n deviceId,\n apk,\n { maxDiscoveryTime, retryInterval } = {},\n ) {\n let rdpUnixSockets = [];\n\n const discoveryStartedAt = Date.now();\n const msg =\n `Waiting for ${apk} Remote Debugging Server...` +\n '\\nMake sure to enable \"Remote Debugging via USB\" ' +\n 'from Settings -> Developer Tools if it is not yet enabled.';\n\n while (rdpUnixSockets.length === 0) {\n log.info(msg);\n if (this.userAbortDiscovery) {\n throw new UsageError(\n 'Exiting Firefox Remote Debugging socket discovery on user request',\n );\n }\n\n if (Date.now() - discoveryStartedAt > maxDiscoveryTime) {\n throw new WebExtError(\n 'Timeout while waiting for the Android Firefox Debugger Socket',\n );\n }\n\n rdpUnixSockets = (\n await this.runShellCommand(deviceId, ['cat', '/proc/net/unix'])\n )\n .split('\\n')\n .filter((line) => {\n // The RDP unix socket is expected to be a path in the form:\n // /data/data/org.mozilla.fennec_rpl/firefox-debugger-socket\n return line.trim().endsWith(`${apk}/firefox-debugger-socket`);\n });\n\n if (rdpUnixSockets.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, retryInterval));\n }\n }\n\n // Convert into an array of unix socket filenames.\n rdpUnixSockets = rdpUnixSockets.map((line) => {\n return line.trim().split(/\\s/).pop();\n });\n\n if (rdpUnixSockets.length > 1) {\n throw new WebExtError(\n 'Unexpected multiple RDP sockets: ' +\n `${JSON.stringify(rdpUnixSockets)}`,\n );\n }\n\n return rdpUnixSockets[0];\n }\n\n async setupForward(deviceId, remote, local) {\n const { adbClient } = this;\n\n // TODO(rpl): we should use adb.listForwards and reuse the existing one if any (especially\n // because adbkit doesn't seem to support `adb forward --remote` yet).\n log.debug(`Configuring ADB forward for ${deviceId}: ${remote} -> ${local}`);\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).forward(local, remote);\n });\n }\n}\n\nexport async function listADBDevices(adbBin) {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverDevices();\n}\n\nexport async function listADBFirefoxAPKs(deviceId, adbBin) {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverInstalledFirefoxAPKs(deviceId);\n}\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,sBAAsB;AAEzC,SAASC,eAAe,EAAEC,UAAU,EAAEC,WAAW,QAAQ,cAAc;AACvE,SAASC,YAAY,QAAQ,mBAAmB;AAChD,OAAOC,kBAAkB,IACvBC,oBAAoB,QACf,mCAA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,CAAC5D,GAAG,CAAEa,IAAI,IAAK;MAC5C,OAAOA,IAAI,CAACN,IAAI,CAAC,CAAC,CAACK,KAAK,CAAC,IAAI,CAAC,CAACuD,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,IAAIP,cAAc,CAACG,MAAM,GAAG,CAAC,EAAE;MAC7B,MAAM,IAAI/G,WAAW,CACnB,mCAAmC,GACjC,GAAGoC,IAAI,CAACC,SAAS,CAACuE,cAAc,CAAC,EACrC,CAAC;IACH;IAEA,OAAOA,cAAc,CAAC,CAAC,CAAC;EAC1B;EAEA,MAAMQ,YAAYA,CAACnF,QAAQ,EAAEoF,MAAM,EAAEC,KAAK,EAAE;IAC1C,MAAM;MAAElG;IAAU,CAAC,GAAG,IAAI;;IAE1B;IACA;IACAZ,GAAG,CAAC2B,KAAK,CAAC,+BAA+BF,QAAQ,KAAKoF,MAAM,OAAOC,KAAK,EAAE,CAAC;IAE3E,MAAM1G,WAAW,CAAC,YAAY;MAC5B,MAAMQ,SAAS,CAACkB,SAAS,CAACL,QAAQ,CAAC,CAACsF,OAAO,CAACD,KAAK,EAAED,MAAM,CAAC;IAC5D,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,eAAeG,cAAcA,CAAChG,MAAM,EAAE;EAC3C,MAAMiG,QAAQ,GAAG,IAAIxG,QAAQ,CAAC;IAAEO;EAAO,CAAC,CAAC;EACzC,OAAOiG,QAAQ,CAAC5E,eAAe,CAAC,CAAC;AACnC;AAEA,OAAO,eAAe6E,kBAAkBA,CAACzF,QAAQ,EAAET,MAAM,EAAE;EACzD,MAAMiG,QAAQ,GAAG,IAAIxG,QAAQ,CAAC;IAAEO;EAAO,CAAC,CAAC;EACzC,OAAOiG,QAAQ,CAAChE,4BAA4B,CAACxB,QAAQ,CAAC;AACxD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"adb.js","names":[],"sources":["../../src/util/adb.js"],"sourcesContent":["import ADBKit from '@devicefarmer/adbkit';\n\nimport { isErrorWithCode, UsageError, WebExtError } from '../errors.js';\nimport { createLogger } from '../util/logger.js';\nimport packageIdentifiers, {\n defaultApkComponents,\n} from '../firefox/package-identifiers.js';\n\nexport const DEVICE_DIR_BASE = '/data/local/tmp/';\nexport const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-';\n\nconst defaultADB = ADBKit.default;\n\nconst log = createLogger(import.meta.url);\n\n// Helper function used to raise an UsageError when the adb binary has not been found.\nasync function wrapADBCall(asyncFn) {\n try {\n return await asyncFn();\n } catch (error) {\n if (\n isErrorWithCode('ENOENT', error) &&\n error.message.includes('spawn adb')\n ) {\n throw new UsageError(\n 'No adb executable has been found. ' +\n 'You can Use --adb-bin, --adb-host/--adb-port ' +\n 'to configure it manually if needed.',\n );\n }\n\n throw error;\n }\n}\n\nexport default class ADBUtils {\n params;\n adb;\n adbClient;\n\n // Map<deviceId -> artifactsDir>\n artifactsDirMap;\n // Toggled when the user wants to abort the RDP Unix Socket discovery loop\n // while it is still executing.\n userAbortDiscovery;\n\n constructor(params) {\n this.params = params;\n\n const { adb, adbBin, adbHost, adbPort } = params;\n\n this.adb = adb || defaultADB;\n\n this.adbClient = this.adb.createClient({\n bin: adbBin,\n host: adbHost,\n port: adbPort,\n });\n\n this.artifactsDirMap = new Map();\n\n this.userAbortDiscovery = false;\n }\n\n async runShellCommand(deviceId, cmd) {\n const { adb, adbClient } = this;\n\n log.debug(`Run adb shell command on ${deviceId}: ${JSON.stringify(cmd)}`);\n\n return wrapADBCall(async () => {\n return await adbClient\n .getDevice(deviceId)\n .shell(cmd)\n .then(adb.util.readAll);\n }).then((res) => res.toString());\n }\n\n async discoverDevices() {\n const { adbClient } = this;\n\n let devices = [];\n\n log.debug('Listing android devices');\n devices = await wrapADBCall(async () => adbClient.listDevices());\n\n return devices.map((dev) => dev.id);\n }\n\n async getCurrentUser(deviceId) {\n log.debug(`Retrieving current user on ${deviceId}`);\n\n const currentUser = await this.runShellCommand(deviceId, [\n 'am',\n 'get-current-user',\n ]);\n\n const userId = parseInt(currentUser.trim());\n if (isNaN(userId)) {\n throw new WebExtError(`Unable to retrieve current user on ${deviceId}`);\n }\n return userId;\n }\n\n async discoverInstalledFirefoxAPKs(deviceId, firefoxApk) {\n const userId = await this.getCurrentUser(deviceId);\n\n log.debug(`Listing installed Firefox APKs on ${deviceId}`);\n const pmList = await this.runShellCommand(deviceId, [\n 'pm',\n 'list',\n 'packages',\n '--user',\n `${userId}`,\n ]);\n\n return pmList\n .split('\\n')\n .map((line) => line.replace('package:', '').trim())\n .filter((line) => {\n // Look for an exact match if firefoxApk is defined.\n if (firefoxApk) {\n return line === firefoxApk;\n }\n // Match any package name that starts with the package name of a Firefox for Android browser.\n for (const browser of packageIdentifiers) {\n if (line.startsWith(browser)) {\n return true;\n }\n }\n\n return false;\n });\n }\n\n async amForceStopAPK(deviceId, apk) {\n await this.runShellCommand(deviceId, ['am', 'force-stop', apk]);\n }\n\n async getOrCreateArtifactsDir(deviceId) {\n let artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (artifactsDir) {\n return artifactsDir;\n }\n\n artifactsDir = `${DEVICE_DIR_BASE}${ARTIFACTS_DIR_PREFIX}${Date.now()}`;\n\n const testDirOut = (\n await this.runShellCommand(deviceId, `test -d ${artifactsDir} ; echo $?`)\n ).trim();\n\n if (testDirOut !== '1') {\n throw new WebExtError(\n `Cannot create artifacts directory ${artifactsDir} ` +\n `because it exists on ${deviceId}.`,\n );\n }\n\n await this.runShellCommand(deviceId, ['mkdir', '-p', artifactsDir]);\n\n this.artifactsDirMap.set(deviceId, artifactsDir);\n\n return artifactsDir;\n }\n\n async detectOrRemoveOldArtifacts(deviceId, removeArtifactDirs = false) {\n const { adbClient } = this;\n\n log.debug('Checking adb device for existing web-ext artifacts dirs');\n\n return wrapADBCall(async () => {\n const files = await adbClient\n .getDevice(deviceId)\n .readdir(DEVICE_DIR_BASE);\n let found = false;\n\n for (const file of files) {\n if (\n !file.isDirectory() ||\n !file.name.startsWith(ARTIFACTS_DIR_PREFIX)\n ) {\n continue;\n }\n\n // Return earlier if we only need to warn the user that some\n // existing artifacts dirs have been found on the adb device.\n if (!removeArtifactDirs) {\n return true;\n }\n\n found = true;\n\n const artifactsDir = `${DEVICE_DIR_BASE}${file.name}`;\n\n log.debug(\n `Removing artifacts directory ${artifactsDir} from device ${deviceId}`,\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n return found;\n });\n }\n\n async clearArtifactsDir(deviceId) {\n const artifactsDir = this.artifactsDirMap.get(deviceId);\n\n if (!artifactsDir) {\n // nothing to do here.\n return;\n }\n\n this.artifactsDirMap.delete(deviceId);\n\n log.debug(\n `Removing ${artifactsDir} artifacts directory on ${deviceId} device`,\n );\n\n await this.runShellCommand(deviceId, ['rm', '-rf', artifactsDir]);\n }\n\n async pushFile(deviceId, localPath, devicePath) {\n const { adbClient } = this;\n\n log.debug(`Pushing ${localPath} to ${devicePath} on ${deviceId}`);\n\n await wrapADBCall(async () => {\n await adbClient\n .getDevice(deviceId)\n .push(localPath, devicePath)\n .then(function (transfer) {\n return new Promise((resolve) => {\n transfer.on('end', resolve);\n });\n });\n });\n }\n\n async startFirefoxAPK(deviceId, apk, apkComponent, deviceProfileDir) {\n const { adbClient } = this;\n\n log.debug(`Starting ${apk} on ${deviceId}`);\n\n // Fenix does ignore the -profile parameter, on the contrary Fennec\n // would run using the given path as the profile to be used during\n // this execution.\n const extras = [\n {\n key: 'args',\n value: `-profile ${deviceProfileDir}`,\n },\n ];\n\n if (!apkComponent) {\n apkComponent = '.App';\n if (defaultApkComponents[apk]) {\n apkComponent = defaultApkComponents[apk];\n }\n } else if (!apkComponent.includes('.')) {\n apkComponent = `.${apkComponent}`;\n }\n\n // If `apk` is a browser package or the `apk` has a browser package prefix:\n // prepend the package identifier before `apkComponent`.\n if (apkComponent.startsWith('.')) {\n for (const browser of packageIdentifiers) {\n if (apk === browser || apk.startsWith(`${browser}.`)) {\n apkComponent = browser + apkComponent;\n break;\n }\n }\n }\n\n // If `apkComponent` starts with a '.', then adb will expand the following\n // to: `${apk}/${apk}.${apkComponent}`\n let component = `${apk}`;\n if (apkComponent) {\n component += `/${apkComponent}`;\n }\n\n await wrapADBCall(async () => {\n try {\n // TODO: once Fenix (release) uses Android 13, we can get rid of this\n // call and only use the second call in the `catch` block.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.activity.MAIN',\n component,\n extras,\n });\n } catch {\n // Android 13+ requires a different action/category but we still need\n // to support older Fenix builds.\n await adbClient.getDevice(deviceId).startActivity({\n wait: true,\n action: 'android.intent.action.MAIN',\n category: 'android.intent.category.LAUNCHER',\n component,\n extras,\n });\n }\n });\n }\n\n setUserAbortDiscovery(value) {\n this.userAbortDiscovery = value;\n }\n\n async discoverRDPUnixSocket(\n deviceId,\n apk,\n { maxDiscoveryTime, retryInterval } = {},\n ) {\n let rdpUnixSockets = [];\n\n const discoveryStartedAt = Date.now();\n const msg =\n `Waiting for ${apk} Remote Debugging Server...` +\n '\\nMake sure to enable \"Remote Debugging via USB\" ' +\n 'from Settings -> Developer Tools if it is not yet enabled.';\n\n while (rdpUnixSockets.length === 0) {\n log.info(msg);\n if (this.userAbortDiscovery) {\n throw new UsageError(\n 'Exiting Firefox Remote Debugging socket discovery on user request',\n );\n }\n\n if (Date.now() - discoveryStartedAt > maxDiscoveryTime) {\n throw new WebExtError(\n 'Timeout while waiting for the Android Firefox Debugger Socket',\n );\n }\n\n rdpUnixSockets = (\n await this.runShellCommand(deviceId, ['cat', '/proc/net/unix'])\n )\n .split('\\n')\n .filter((line) => {\n // The RDP unix socket is expected to be a path in the form:\n // /data/data/org.mozilla.fennec_rpl/firefox-debugger-socket\n return line.trim().endsWith(`${apk}/firefox-debugger-socket`);\n });\n\n if (rdpUnixSockets.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, retryInterval));\n }\n }\n\n // Convert into an array of unix socket filenames.\n rdpUnixSockets = rdpUnixSockets.map((line) => {\n return line.trim().split(/\\s/).pop();\n });\n\n if (rdpUnixSockets.length > 1) {\n throw new WebExtError(\n 'Unexpected multiple RDP sockets: ' +\n `${JSON.stringify(rdpUnixSockets)}`,\n );\n }\n\n return rdpUnixSockets[0];\n }\n\n async setupForward(deviceId, remote, local) {\n const { adbClient } = this;\n\n // TODO(rpl): we should use adb.listForwards and reuse the existing one if any (especially\n // because adbkit doesn't seem to support `adb forward --remote` yet).\n log.debug(`Configuring ADB forward for ${deviceId}: ${remote} -> ${local}`);\n\n await wrapADBCall(async () => {\n await adbClient.getDevice(deviceId).forward(local, remote);\n });\n }\n}\n\nexport async function listADBDevices(adbBin) {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverDevices();\n}\n\nexport async function listADBFirefoxAPKs(deviceId, adbBin) {\n const adbUtils = new ADBUtils({ adbBin });\n return adbUtils.discoverInstalledFirefoxAPKs(deviceId);\n}\n"],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB;AAEzC,SAAS,eAAe,EAAE,UAAU,EAAE,WAAW,QAAQ,cAAc;AACvE,SAAS,YAAY,QAAQ,mBAAmB;AAChD,OAAO,kBAAkB,IACvB,oBAAoB,QACf,mCAAmC;AAE1C,OAAO,MAAM,eAAe,GAAG,kBAAkB;AACjD,OAAO,MAAM,oBAAoB,GAAG,oBAAoB;AAExD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO;AAEjC,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;;AAEzC;AACA,eAAe,WAAW,CAAC,OAAO,EAAE;EAClC,IAAI;IACF,OAAO,MAAM,OAAO,CAAC,CAAC;EACxB,CAAC,CAAC,OAAO,KAAK,EAAE;IACd,IACE,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,IAChC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EACnC;MACA,MAAM,IAAI,UAAU,CAClB,oCAAoC,GAClC,+CAA+C,GAC/C,qCACJ,CAAC;IACH;IAEA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]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","names":[
|
|
1
|
+
{"version":3,"file":"artifacts.js","names":[],"sources":["../../src/util/artifacts.js"],"sourcesContent":["import fs from 'fs/promises';\n\nimport { UsageError, isErrorWithCode } from '../errors.js';\nimport { createLogger } from './logger.js';\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsAccess = fs.access.bind(fs);\n\nexport async function prepareArtifactsDir(\n artifactsDir,\n {\n asyncMkdirp = (dirPath) => fs.mkdir(dirPath, { recursive: true }),\n asyncFsAccess = defaultAsyncFsAccess,\n } = {},\n) {\n try {\n const stats = await fs.stat(artifactsDir);\n if (!stats.isDirectory()) {\n throw new UsageError(\n `--artifacts-dir=\"${artifactsDir}\" exists but it is not a directory.`,\n );\n }\n // If the artifactsDir already exists, check that we have the write permissions on it.\n try {\n await asyncFsAccess(artifactsDir, fs.constants.W_OK);\n } catch (accessErr) {\n if (isErrorWithCode('EACCES', accessErr)) {\n throw new UsageError(\n `--artifacts-dir=\"${artifactsDir}\" exists but the user lacks ` +\n 'permissions on it.',\n );\n } else {\n throw accessErr;\n }\n }\n } catch (error) {\n if (isErrorWithCode('EACCES', error)) {\n // Handle errors when the artifactsDir cannot be accessed.\n throw new UsageError(\n `Cannot access --artifacts-dir=\"${artifactsDir}\" because the user ` +\n `lacks permissions: ${error}`,\n );\n } else if (isErrorWithCode('ENOENT', error)) {\n // Create the artifact dir if it doesn't exist yet.\n try {\n log.debug(`Creating artifacts directory: ${artifactsDir}`);\n await asyncMkdirp(artifactsDir);\n } catch (mkdirErr) {\n if (isErrorWithCode('EACCES', mkdirErr)) {\n // Handle errors when the artifactsDir cannot be created for lack of permissions.\n throw new UsageError(\n `Cannot create --artifacts-dir=\"${artifactsDir}\" because the ` +\n `user lacks permissions: ${mkdirErr}`,\n );\n } else {\n throw mkdirErr;\n }\n }\n } else {\n throw error;\n }\n }\n\n return artifactsDir;\n}\n"],"mappings":"AAAA,OAAO,E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,YAAY,EAAE,CAAC;QAC1D,MAAM,WAAW,CAAC,YAAY,CAAC;MACjC,CAAC,CAAC,OAAO,QAAQ,EAAE;QACjB,IAAI,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE;UACvC;UACA,MAAM,IAAI,UAAU,CAClB,kCAAkC,YAAY,gBAAgB,GAC5D,2BAA2B,QAAQ,EACvC,CAAC;QACH,CAAC,MAAM;UACL,MAAM,QAAQ;QAChB;MACF;IACF,CAAC,MAAM;MACL,MAAM,KAAK;IACb;EACF;EAEA,OAAO,YAAY;AACrB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand-prefs.js","names":[
|
|
1
|
+
{"version":3,"file":"expand-prefs.js","names":[],"sources":["../../src/util/expand-prefs.js"],"sourcesContent":["/**\n * Given an object where the keys are the flattened path to a\n * preference, and the value is the value to set at that path, return\n * an object where the paths are fully expanded.\n */\nexport default function expandPrefs(prefs) {\n const prefsMap = new Map();\n\n for (const [key, value] of Object.entries(prefs)) {\n let submap = prefsMap;\n const props = key.split('.');\n const lastProp = props.pop();\n\n for (const prop of props) {\n if (!submap.has(prop)) {\n submap.set(prop, new Map());\n }\n\n submap = submap.get(prop);\n\n if (!(submap instanceof Map)) {\n throw new Error(\n `Cannot set ${key} because a value already exists at ${prop}`,\n );\n }\n }\n submap.set(lastProp, value);\n }\n return mapToObject(prefsMap);\n}\n\nfunction mapToObject(map) {\n return Object.fromEntries(\n Array.from(map, ([k, v]) => [k, v instanceof Map ? mapToObject(v) : v]),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS,WAAW,CAAC,KAAK,EAAE;EACzC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC;EAE1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;IAChD,IAAI,MAAM,GAAG,QAAQ;IACrB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;MACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;MAC7B;MAEA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;MAEzB,IAAI,EAAE,MAAM,YAAY,GAAG,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CACb,cAAc,GAAG,sCAAsC,IAAI,EAC7D,CAAC;MACH;IACF;IACA,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;EAC7B;EACA,OAAO,WAAW,CAAC,QAAQ,CAAC;AAC9B;AAEA,SAAS,WAAW,CAAC,GAAG,EAAE;EACxB,OAAO,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CACxE,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-exists.js","names":[
|
|
1
|
+
{"version":3,"file":"file-exists.js","names":[],"sources":["../../src/util/file-exists.js"],"sourcesContent":["import fs from 'fs/promises';\n\nimport { isErrorWithCode } from '../errors.js';\n\n/*\n * Resolves true if the path is a readable file.\n *\n * Usage:\n *\n * const exists = await fileExists(filePath);\n * if (exists) {\n * // ...\n * }\n *\n * */\nexport default async function fileExists(\n path,\n { fileIsReadable = (f) => fs.access(f, fs.constants.R_OK) } = {},\n) {\n try {\n await fileIsReadable(path);\n const stat = await fs.stat(path);\n return stat.isFile();\n } catch (error) {\n if (isErrorWithCode(['EACCES', 'ENOENT'], error)) {\n return false;\n }\n throw error;\n }\n}\n"],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa;AAE5B,SAAS,eAAe,QAAQ,cAAc;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAe,UAAU,CACtC,IAAI,EACJ;EAAE,cAAc,GAAI,CAAC,IAAK,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI;AAAE,CAAC,GAAG,CAAC,CAAC,EAChE;EACA,IAAI;IACF,MAAM,cAAc,CAAC,IAAI,CAAC;IAC1B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;EACtB,CAAC,CAAC,OAAO,KAAK,EAAE;IACd,IAAI,eAAe,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE;MAChD,OAAO,KAAK;IACd;IACA,MAAM,KAAK;EACb;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-filter.js","names":[
|
|
1
|
+
{"version":3,"file":"file-filter.js","names":[],"sources":["../../src/util/file-filter.js"],"sourcesContent":["import path from 'path';\n\nimport multimatch from 'multimatch';\n\nimport { createLogger } from './logger.js';\n\nconst log = createLogger(import.meta.url);\n\n// check if target is a sub directory of src\nexport const isSubPath = (src, target) => {\n const relate = path.relative(src, target);\n // same dir\n if (!relate) {\n return false;\n }\n if (relate === '..') {\n return false;\n }\n return !relate.startsWith(`..${path.sep}`);\n};\n\n// FileFilter types and implementation.\n\n/*\n * Allows or ignores files.\n */\nexport class FileFilter {\n filesToIgnore;\n sourceDir;\n\n constructor({\n baseIgnoredPatterns = [\n '**/*.xpi',\n '**/*.zip',\n '**/.*', // any hidden file and folder\n '**/.*/**/*', // and the content inside hidden folder\n '**/node_modules',\n '**/node_modules/**/*',\n ],\n ignoreFiles = [],\n sourceDir,\n artifactsDir,\n } = {}) {\n sourceDir = path.resolve(sourceDir);\n\n this.filesToIgnore = [];\n this.sourceDir = sourceDir;\n\n this.addToIgnoreList(baseIgnoredPatterns);\n if (ignoreFiles) {\n this.addToIgnoreList(ignoreFiles);\n }\n if (artifactsDir && isSubPath(sourceDir, artifactsDir)) {\n artifactsDir = path.resolve(artifactsDir);\n log.debug(\n `Ignoring artifacts directory \"${artifactsDir}\" ` +\n 'and all its subdirectories',\n );\n this.addToIgnoreList([artifactsDir, path.join(artifactsDir, '**', '*')]);\n }\n }\n\n /**\n * Resolve relative path to absolute path with sourceDir.\n */\n resolveWithSourceDir(file) {\n const resolvedPath = path.resolve(this.sourceDir, file);\n log.debug(\n `Resolved path ${file} with sourceDir ${this.sourceDir} ` +\n `to ${resolvedPath}`,\n );\n return resolvedPath;\n }\n\n /**\n * Insert more files into filesToIgnore array.\n */\n addToIgnoreList(files) {\n for (const file of files) {\n if (file.charAt(0) === '!') {\n const resolvedFile = this.resolveWithSourceDir(file.substr(1));\n this.filesToIgnore.push(`!${resolvedFile}`);\n } else {\n this.filesToIgnore.push(this.resolveWithSourceDir(file));\n }\n }\n }\n\n /*\n * Returns true if the file is wanted.\n *\n * If filePath does not start with a slash, it will be treated as a path\n * relative to sourceDir when matching it against all configured\n * ignore-patterns.\n *\n * Example: this is called by zipdir as wantFile(filePath) for each\n * file in the folder that is being archived.\n */\n wantFile(filePath) {\n const resolvedPath = this.resolveWithSourceDir(filePath);\n const matches = multimatch(resolvedPath, this.filesToIgnore);\n if (matches.length > 0) {\n log.debug(`FileFilter: ignoring file ${resolvedPath}`);\n return false;\n }\n return true;\n }\n}\n\n// a helper function to make mocking easier\n\nexport const createFileFilter = (params) => new FileFilter(params);\n"],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM;AAEvB,OAAO,UAAU,MAAM,YAAY;AAEnC,SAAS,YAAY,QAAQ,aAAa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,"file":"is-directory.js","names":[
|
|
1
|
+
{"version":3,"file":"is-directory.js","names":[],"sources":["../../src/util/is-directory.js"],"sourcesContent":["import fs from 'fs/promises';\n\nimport { onlyErrorsWithCode } from '../errors.js';\n\n/*\n * Resolves true if the path is a readable directory.\n *\n * Usage:\n *\n * isDirectory('/some/path')\n * .then((dirExists) => {\n * // dirExists will be true or false.\n * });\n *\n * */\nexport default function isDirectory(path) {\n return fs\n .stat(path)\n .then((stats) => stats.isDirectory())\n .catch(\n onlyErrorsWithCode(['ENOENT', 'ENOTDIR'], () => {\n return false;\n }),\n );\n}\n"],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa;AAE5B,SAAS,kBAAkB,QAAQ,cAAc;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS,WAAW,CAAC,IAAI,EAAE;EACxC,OAAO,EAAE,CACN,IAAI,CAAC,IAAI,CAAC,CACV,IAAI,CAAE,KAAK,IAAK,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CACpC,KAAK,CACJ,kBAAkB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM;IAC9C,OAAO,KAAK;EACd,CAAC,CACH,CAAC;AACL","ignoreList":[]}
|
package/lib/util/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":[
|
|
1
|
+
{"version":3,"file":"logger.js","names":[],"sources":["../../src/util/logger.js"],"sourcesContent":["import { fileURLToPath } from 'url';\n\nimport pino, { levels as logLevels } from 'pino';\n\nexport class ConsoleStream {\n verbose;\n isCapturing;\n capturedMessages;\n\n constructor({ verbose = false } = {}) {\n this.verbose = verbose;\n this.isCapturing = false;\n this.capturedMessages = [];\n }\n\n format({ name, msg, level }) {\n const prefix = this.verbose ? `[${name}][${logLevels.labels[level]}] ` : '';\n return `${prefix}${msg}\\n`;\n }\n\n makeVerbose() {\n this.verbose = true;\n }\n\n write(jsonString, { localProcess = process } = {}) {\n const packet = JSON.parse(jsonString);\n const thisLevel = this.verbose\n ? logLevels.values.trace\n : logLevels.values.info;\n if (packet.level >= thisLevel) {\n const msg = this.format(packet);\n if (this.isCapturing) {\n this.capturedMessages.push(msg);\n } else if (packet.level > logLevels.values.info) {\n localProcess.stderr.write(msg);\n } else {\n localProcess.stdout.write(msg);\n }\n }\n }\n\n startCapturing() {\n this.isCapturing = true;\n }\n\n stopCapturing() {\n this.isCapturing = false;\n this.capturedMessages = [];\n }\n\n flushCapturedLogs({ localProcess = process } = {}) {\n for (const msg of this.capturedMessages) {\n localProcess.stdout.write(msg);\n }\n this.capturedMessages = [];\n }\n}\n\nexport const consoleStream = new ConsoleStream();\n\n// createLogger types and implementation.\n\nexport function createLogger(moduleURL, { createPinoLog = pino } = {}) {\n return createPinoLog(\n {\n // Strip the leading src/ from file names (which is in all file names) to\n // make the name less redundant.\n name: moduleURL\n ? fileURLToPath(moduleURL).replace(/^src\\//, '')\n : 'unknown-module',\n // Capture all log levels and let the stream filter them.\n level: logLevels.values.trace,\n },\n consoleStream,\n );\n}\n"],"mappings":"AAAA,SAAS,aAAa,QAAQ,KAAK;AAEnC,OAAO,IAAI,IAAI,MAAM,IAAI,SAAS,QAAQ,MAAM;AAEhD,OAAO,MAAM,aAAa,CAAC;EACzB,OAAO;EACP,WAAW;EACX,gBAAgB;EAEhB,WAAW,CAAC;IAAE,OAAO,GAAG;EAAM,CAAC,GAAG,CAAC,CAAC,EAAE;IACpC,IAAI,CAAC,OAAO,GAAG,OAAO;IACtB,IAAI,CAAC,WAAW,GAAG,KAAK;IACxB,IAAI,CAAC,gBAAgB,GAAG,EAAE;EAC5B;EAEA,MAAM,CAAC;IAAE,IAAI;IAAE,GAAG;IAAE;EAAM,CAAC,EAAE;IAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,KAAK,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE;IAC3E,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Aa,CAAC,CAAC;;AAEhD;;AAEA,OAAO,SAAS,YAAY,CAAC,SAAS,EAAE;EAAE,aAAa,GAAG;AAAK,CAAC,GAAG,CAAC,CAAC,EAAE;EACrE,OAAO,aAAa,CAClB;IACE;IACA;IACA,IAAI,EAAE,SAAS,GACX,aAAa,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GAC9C,gBAAgB;IACpB;IACA,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC;EAC1B,CAAC,EACD,aACF,CAAC;AACH","ignoreList":[]}
|
package/lib/util/manifest.js
CHANGED
|
@@ -55,7 +55,7 @@ export function getManifestId(manifestData) {
|
|
|
55
55
|
// we prefer bss even if the id property isn't available.
|
|
56
56
|
// This match what Firefox does in this particular scenario, see
|
|
57
57
|
// https://searchfox.org/mozilla-central/rev/828f2319c0195d7f561ed35533aef6fe183e68e3/toolkit/mozapps/extensions/internal/XPIInstall.jsm#470-474,488
|
|
58
|
-
if (apps
|
|
58
|
+
if (apps?.gecko) {
|
|
59
59
|
return apps.gecko.id;
|
|
60
60
|
}
|
|
61
61
|
}
|