extension 3.0.0-next.6 → 3.0.0-next.60
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/dist/cli-lib/messages.d.ts +9 -0
- package/dist/cli.js +609 -653
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -6
- package/types/extension-develop-shim.d.ts +79 -0
- package/types/index.d.ts +2 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var
|
|
3
|
+
var __webpack_modules__ = {
|
|
4
|
+
"extension-develop": function(module) {
|
|
5
|
+
module.exports = import("extension-develop").then(function(module) {
|
|
6
|
+
return module;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var __webpack_module_cache__ = {};
|
|
11
|
+
function __webpack_require__(moduleId) {
|
|
12
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
15
|
+
exports: {}
|
|
16
|
+
};
|
|
17
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
|
+
return module.exports;
|
|
19
|
+
}
|
|
4
20
|
(()=>{
|
|
5
21
|
__webpack_require__.n = (module)=>{
|
|
6
22
|
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
@@ -22,28 +38,30 @@ var __webpack_require__ = {};
|
|
|
22
38
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
23
39
|
})();
|
|
24
40
|
var __webpack_exports__ = {};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
(()=>{
|
|
42
|
+
const external_commander_namespaceObject = require("commander");
|
|
43
|
+
var package_namespaceObject = JSON.parse('{"license":"MIT","repository":{"type":"git","url":"git+https://github.com/extension-js/extension.js.git","directory":"programs/cli"},"engines":{"node":">=18"},"exports":{".":{"types":"./dist/cli.d.ts","import":"./dist/cli.js","require":"./dist/cli.js"}},"main":"./dist/cli.js","types":"./dist/cli.d.ts","typesVersions":{"*":{"types":["./types/index.d.ts"],"types/*":["./types/*"]}},"files":["dist","types"],"bin":{"extension":"./dist/cli.js"},"name":"extension","version":"3.0.0-next.60","description":"Create cross-browser extensions with no build configuration.","homepage":"https://extension.js.org/","author":{"name":"Cezar Augusto","email":"boss@cezaraugusto.net","url":"https://cezaraugusto.com"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"scripts":{"prepublishOnly":"pnpm run compile","compile":"rslib build","watch":"rslib build --watch","test":"vitest run"},"keywords":["zero-config","build","develop","browser","extension","chrome extension","edge extension","firefox extension","safari extension","web","react","typescript","webextension","browser-extension","chrome-extension","firefox-addon","edge-extension","safari-web-extension","manifest-v3","mv3","cross-browser","content-script","background-script","devtools","create-extension","scaffold","starter-template","boilerplate","cli"],"dependencies":{"extension-develop":"^3.0.0-next.60","commander":"^12.1.0","extension-create":"^2.2.0","pintor":"0.3.0","semver":"^7.6.3","update-check":"^1.5.4"},"devDependencies":{"@rslib/core":"^0.6.9","@types/chrome":"^0.0.287","@types/node":"^22.10.1","@types/react":"^19.0.1","@types/react-dom":"^19.0.1","@types/webextension-polyfill":"0.12.3","@types/mock-fs":"^4.13.4","@types/semver":"^7.5.8","mock-fs":"^5.4.1","webextension-polyfill":"^0.12.0","tsconfig":"*","typescript":"5.7.2","vitest":"^3.2.4"}}');
|
|
44
|
+
const external_update_check_namespaceObject = require("update-check");
|
|
45
|
+
var external_update_check_default = /*#__PURE__*/ __webpack_require__.n(external_update_check_namespaceObject);
|
|
46
|
+
const external_pintor_namespaceObject = require("pintor");
|
|
47
|
+
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_namespaceObject);
|
|
48
|
+
function getLoggingPrefix(type) {
|
|
49
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) return external_pintor_default().brightMagenta('error' === type ? 'ERROR' : "\u25BA\u25BA\u25BA");
|
|
50
|
+
if ('error' === type) return external_pintor_default().red('ERROR');
|
|
51
|
+
if ('warn' === type) return external_pintor_default().brightYellow("\u25BA\u25BA\u25BA");
|
|
52
|
+
if ('info' === type) return external_pintor_default().gray("\u25BA\u25BA\u25BA");
|
|
53
|
+
return external_pintor_default().green("\u25BA\u25BA\u25BA");
|
|
54
|
+
}
|
|
55
|
+
const code = (text)=>external_pintor_default().blue(text);
|
|
56
|
+
const arg = (text)=>external_pintor_default().gray(text);
|
|
57
|
+
function updateFailed(err) {
|
|
58
|
+
return `${getLoggingPrefix('error')} Failed to check for updates.\n${external_pintor_default().red(String((null == err ? void 0 : err.message) || err))}`;
|
|
59
|
+
}
|
|
60
|
+
function checkUpdates(packageJson, update) {
|
|
61
|
+
return `${getLoggingPrefix('info')} \u{1F9E9} ${external_pintor_default().blue('Extension.js')} update available.\n\nYou are currently using version ${external_pintor_default().red(String(packageJson.version))}. Latest stable is ${external_pintor_default().green(String(update.latest))}.\nPlease update to enjoy new features and improvements.`;
|
|
62
|
+
}
|
|
63
|
+
function programUserHelp() {
|
|
64
|
+
return `\n${getLoggingPrefix('info')} ${external_pintor_default().underline('Help center for the Extension.js program')}
|
|
47
65
|
|
|
48
66
|
Usage: extension [command] [options]
|
|
49
67
|
|
|
@@ -121,12 +139,12 @@ AI Assistants
|
|
|
121
139
|
|
|
122
140
|
Report issues
|
|
123
141
|
- ${external_pintor_default().underline('https://github.com/cezaraugusto/extension/issues/new')}`;
|
|
124
|
-
}
|
|
125
|
-
function unsupportedBrowserFlag(value, supported) {
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
function programAIHelp() {
|
|
129
|
-
|
|
142
|
+
}
|
|
143
|
+
function unsupportedBrowserFlag(value, supported) {
|
|
144
|
+
return `${getLoggingPrefix('error')} Unsupported --browser value: ${value}. Supported: ${supported.join(', ')}.`;
|
|
145
|
+
}
|
|
146
|
+
function programAIHelp() {
|
|
147
|
+
return `\n${getLoggingPrefix('info')} ${external_pintor_default().gray('Development tips for extension developers and AI assistants')}
|
|
130
148
|
|
|
131
149
|
Browser-Specific Configuration
|
|
132
150
|
- Use browser prefixes in manifest.json for browser-specific fields:
|
|
@@ -143,7 +161,7 @@ Centralized Logger (for AI & CI)
|
|
|
143
161
|
- ${code('--no-log-color')} ${arg(' ')} Disable ANSI colors (pretty)
|
|
144
162
|
- ${code('--log-url')} ${arg('<substring|/regex/>')} Filter by URL
|
|
145
163
|
- ${code('--log-tab')} ${arg('<id>')} Filter by tabId
|
|
146
|
-
- Good CI pattern: ${code('
|
|
164
|
+
- Good CI pattern: ${code('EXTENSION_AUTHOR_MODE=development EXTENSION_AUTO_EXIT_MS=6000 extension dev ./ext --logs=info --log-format=json')}
|
|
147
165
|
|
|
148
166
|
Special Folders for Entrypoints
|
|
149
167
|
- Use special folders to handle entrypoints and assets not declared in manifest.json:
|
|
@@ -236,7 +254,7 @@ Source Inspection & Real-Time Monitoring
|
|
|
236
254
|
- Example: ${code('extension dev --source=' + arg('https://example.com'))}
|
|
237
255
|
|
|
238
256
|
Non-Destructive Testing in CI
|
|
239
|
-
- Prefer ${code('
|
|
257
|
+
- Prefer ${code('EXTENSION_AUTHOR_MODE=development')} to copy local templates and avoid network.
|
|
240
258
|
- Reuse Playwright's Chromium via ${code('--chromium-binary')} path when available.
|
|
241
259
|
- Set ${code(arg('EXTENSION_AUTO_EXIT_MS'))} and ${code(arg('EXTENSION_FORCE_KILL_MS'))} for non-interactive dev sessions.
|
|
242
260
|
|
|
@@ -259,441 +277,425 @@ Cross-Browser Compatibility
|
|
|
259
277
|
- Use ${code('--polyfill')} flag to enable webextension-polyfill
|
|
260
278
|
- Automatically handles browser API differences
|
|
261
279
|
- Supports Chrome, Edge, Firefox with single codebase`;
|
|
262
|
-
}
|
|
263
|
-
const external_semver_namespaceObject = require("semver");
|
|
264
|
-
function isStableVersion(version) {
|
|
265
|
-
const v = external_semver_namespaceObject.parse(version);
|
|
266
|
-
return Boolean(v && 0 === v.prerelease.length);
|
|
267
|
-
}
|
|
268
|
-
async function check_updates_checkUpdates(packageJson) {
|
|
269
|
-
let update = null;
|
|
270
|
-
try {
|
|
271
|
-
update = await external_update_check_default()(packageJson);
|
|
272
|
-
} catch (err) {
|
|
273
|
-
if ('development' === process.env.EXTENSION_ENV) console.error(updateFailed(err));
|
|
274
280
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
const external_path_namespaceObject = require("path");
|
|
280
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
281
|
-
const external_node_os_namespaceObject = require("node:os");
|
|
282
|
-
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
283
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
284
|
-
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
285
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
286
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
287
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
288
|
-
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
289
|
-
function _define_property(obj, key, value) {
|
|
290
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
291
|
-
value: value,
|
|
292
|
-
enumerable: true,
|
|
293
|
-
configurable: true,
|
|
294
|
-
writable: true
|
|
295
|
-
});
|
|
296
|
-
else obj[key] = value;
|
|
297
|
-
return obj;
|
|
298
|
-
}
|
|
299
|
-
function isCI() {
|
|
300
|
-
const v = process.env;
|
|
301
|
-
return Boolean(v.CI || v.GITHUB_ACTIONS || v.GITLAB_CI || v.BUILDKITE || v.CIRCLECI || v.TRAVIS);
|
|
302
|
-
}
|
|
303
|
-
function configDir() {
|
|
304
|
-
const xdg = process.env.XDG_CONFIG_HOME;
|
|
305
|
-
if (xdg) return external_node_path_default().join(xdg, 'extensionjs');
|
|
306
|
-
if ('win32' === process.platform && process.env.APPDATA) return external_node_path_default().join(process.env.APPDATA, 'extensionjs');
|
|
307
|
-
return external_node_path_default().join(external_node_os_default().homedir(), '.config', 'extensionjs');
|
|
308
|
-
}
|
|
309
|
-
function ensureDir(p) {
|
|
310
|
-
if (external_node_fs_default().existsSync(p)) return;
|
|
311
|
-
external_node_fs_default().mkdirSync(p, {
|
|
312
|
-
recursive: true
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
function loadOrCreateId(file) {
|
|
316
|
-
if (external_node_fs_default().existsSync(file)) return external_node_fs_default().readFileSync(file, 'utf8').trim();
|
|
317
|
-
const id = external_node_crypto_default().randomUUID();
|
|
318
|
-
ensureDir(external_node_path_default().dirname(file));
|
|
319
|
-
external_node_fs_default().writeFileSync(file, id, 'utf8');
|
|
320
|
-
return id;
|
|
321
|
-
}
|
|
322
|
-
function auditFilePath() {
|
|
323
|
-
const dir = external_node_path_default().join(configDir(), 'telemetry');
|
|
324
|
-
ensureDir(dir);
|
|
325
|
-
return external_node_path_default().join(dir, 'events.jsonl');
|
|
326
|
-
}
|
|
327
|
-
const DEFAULT_FLUSH_AT = Number(process.env.EXTENSION_TELEMETRY_FLUSH_AT || 10);
|
|
328
|
-
const DEFAULT_FLUSH_INTERVAL = Number(process.env.EXTENSION_TELEMETRY_FLUSH_INTERVAL || 2000);
|
|
329
|
-
const DEFAULT_TIMEOUT_MS = Number(process.env.EXTENSION_TELEMETRY_TIMEOUT_MS || 200);
|
|
330
|
-
class Telemetry {
|
|
331
|
-
track(event, props = {}) {
|
|
332
|
-
if (this.disabled) return;
|
|
333
|
-
const payload = {
|
|
334
|
-
event,
|
|
335
|
-
properties: {
|
|
336
|
-
...this.common,
|
|
337
|
-
...props,
|
|
338
|
-
$ip: null
|
|
339
|
-
},
|
|
340
|
-
distinct_id: this.anonId
|
|
341
|
-
};
|
|
342
|
-
external_node_fs_default().appendFileSync(auditFilePath(), JSON.stringify(payload) + '\n');
|
|
343
|
-
if (this.debug) console.error('[telemetry]', JSON.stringify(payload));
|
|
344
|
-
if (!this.apiKey || !this.host) return;
|
|
345
|
-
this.buffer.push(payload);
|
|
346
|
-
if (this.buffer.length >= DEFAULT_FLUSH_AT) return void this.flush();
|
|
347
|
-
if (!this.timer) this.timer = setTimeout(()=>{
|
|
348
|
-
this.timer = null;
|
|
349
|
-
this.flush();
|
|
350
|
-
}, DEFAULT_FLUSH_INTERVAL);
|
|
281
|
+
const external_semver_namespaceObject = require("semver");
|
|
282
|
+
function isStableVersion(version) {
|
|
283
|
+
const v = external_semver_namespaceObject.parse(version);
|
|
284
|
+
return Boolean(v && 0 === v.prerelease.length);
|
|
351
285
|
}
|
|
352
|
-
async
|
|
353
|
-
|
|
354
|
-
if (0 === this.buffer.length) return;
|
|
355
|
-
const batch = this.buffer.splice(0, this.buffer.length);
|
|
286
|
+
async function check_updates_checkUpdates(packageJson) {
|
|
287
|
+
let update = null;
|
|
356
288
|
try {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
289
|
+
update = await external_update_check_default()(packageJson);
|
|
290
|
+
} catch (err) {
|
|
291
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.error(updateFailed(err));
|
|
292
|
+
}
|
|
293
|
+
if (update && isStableVersion(update.latest)) console.log(checkUpdates(packageJson, update));
|
|
294
|
+
}
|
|
295
|
+
const external_fs_namespaceObject = require("fs");
|
|
296
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
297
|
+
const external_path_namespaceObject = require("path");
|
|
298
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
299
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
300
|
+
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
301
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
302
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
303
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
304
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
305
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
306
|
+
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
307
|
+
function _define_property(obj, key, value) {
|
|
308
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
309
|
+
value: value,
|
|
310
|
+
enumerable: true,
|
|
311
|
+
configurable: true,
|
|
312
|
+
writable: true
|
|
313
|
+
});
|
|
314
|
+
else obj[key] = value;
|
|
315
|
+
return obj;
|
|
378
316
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
317
|
+
function isCI() {
|
|
318
|
+
const v = process.env;
|
|
319
|
+
return Boolean(v.CI || v.GITHUB_ACTIONS || v.GITLAB_CI || v.BUILDKITE || v.CIRCLECI || v.TRAVIS);
|
|
320
|
+
}
|
|
321
|
+
function configDir() {
|
|
322
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
323
|
+
if (xdg) return external_node_path_default().join(xdg, 'extensionjs');
|
|
324
|
+
if ('win32' === process.platform && process.env.APPDATA) return external_node_path_default().join(process.env.APPDATA, 'extensionjs');
|
|
325
|
+
return external_node_path_default().join(external_node_os_default().homedir(), '.config', 'extensionjs');
|
|
326
|
+
}
|
|
327
|
+
function ensureDir(p) {
|
|
328
|
+
if (external_node_fs_default().existsSync(p)) return;
|
|
329
|
+
external_node_fs_default().mkdirSync(p, {
|
|
330
|
+
recursive: true
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function loadOrCreateId(file) {
|
|
334
|
+
if (external_node_fs_default().existsSync(file)) return external_node_fs_default().readFileSync(file, 'utf8').trim();
|
|
335
|
+
const id = external_node_crypto_default().randomUUID();
|
|
336
|
+
ensureDir(external_node_path_default().dirname(file));
|
|
337
|
+
external_node_fs_default().writeFileSync(file, id, 'utf8');
|
|
338
|
+
return id;
|
|
339
|
+
}
|
|
340
|
+
function auditFilePath() {
|
|
341
|
+
const dir = external_node_path_default().join(configDir(), 'telemetry');
|
|
342
|
+
ensureDir(dir);
|
|
343
|
+
return external_node_path_default().join(dir, 'events.jsonl');
|
|
344
|
+
}
|
|
345
|
+
const DEFAULT_FLUSH_AT = Number(process.env.EXTENSION_TELEMETRY_FLUSH_AT || 10);
|
|
346
|
+
const DEFAULT_FLUSH_INTERVAL = Number(process.env.EXTENSION_TELEMETRY_FLUSH_INTERVAL || 2000);
|
|
347
|
+
const DEFAULT_TIMEOUT_MS = Number(process.env.EXTENSION_TELEMETRY_TIMEOUT_MS || 200);
|
|
348
|
+
class Telemetry {
|
|
349
|
+
track(event, props = {}) {
|
|
350
|
+
if (this.disabled) return;
|
|
351
|
+
const payload = {
|
|
352
|
+
event,
|
|
353
|
+
properties: {
|
|
354
|
+
...this.common,
|
|
355
|
+
...props,
|
|
356
|
+
$ip: null
|
|
357
|
+
},
|
|
358
|
+
distinct_id: this.anonId
|
|
359
|
+
};
|
|
360
|
+
external_node_fs_default().appendFileSync(auditFilePath(), JSON.stringify(payload) + '\n');
|
|
361
|
+
if (this.debug) console.error('[telemetry]', JSON.stringify(payload));
|
|
362
|
+
if (!this.apiKey || !this.host) return;
|
|
363
|
+
this.buffer.push(payload);
|
|
364
|
+
if (this.buffer.length >= DEFAULT_FLUSH_AT) return void this.flush();
|
|
365
|
+
if (!this.timer) this.timer = setTimeout(()=>{
|
|
366
|
+
this.timer = null;
|
|
367
|
+
this.flush();
|
|
368
|
+
}, DEFAULT_FLUSH_INTERVAL);
|
|
395
369
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
370
|
+
async flush() {
|
|
371
|
+
if (this.disabled || !this.apiKey || !this.host) return;
|
|
372
|
+
if (0 === this.buffer.length) return;
|
|
373
|
+
const batch = this.buffer.splice(0, this.buffer.length);
|
|
374
|
+
try {
|
|
375
|
+
const ac = new AbortController();
|
|
376
|
+
const t = setTimeout(()=>ac.abort(), DEFAULT_TIMEOUT_MS);
|
|
377
|
+
const url = new URL('/capture/', this.host);
|
|
378
|
+
await fetch(url.toString(), {
|
|
379
|
+
method: 'POST',
|
|
380
|
+
headers: {
|
|
381
|
+
'content-type': 'application/json'
|
|
382
|
+
},
|
|
383
|
+
body: JSON.stringify({
|
|
384
|
+
api_key: this.apiKey,
|
|
385
|
+
batch: batch.map((e)=>({
|
|
386
|
+
event: e.event,
|
|
387
|
+
properties: e.properties,
|
|
388
|
+
distinct_id: e.distinct_id
|
|
389
|
+
}))
|
|
390
|
+
}),
|
|
391
|
+
signal: ac.signal,
|
|
392
|
+
keepalive: true
|
|
393
|
+
}).catch(()=>{});
|
|
394
|
+
clearTimeout(t);
|
|
395
|
+
} catch {}
|
|
396
|
+
}
|
|
397
|
+
shutdown() {}
|
|
398
|
+
constructor(init){
|
|
399
|
+
_define_property(this, "anonId", void 0);
|
|
400
|
+
_define_property(this, "common", void 0);
|
|
401
|
+
_define_property(this, "debug", void 0);
|
|
402
|
+
_define_property(this, "disabled", void 0);
|
|
403
|
+
_define_property(this, "apiKey", void 0);
|
|
404
|
+
_define_property(this, "host", void 0);
|
|
405
|
+
_define_property(this, "buffer", []);
|
|
406
|
+
_define_property(this, "timer", null);
|
|
407
|
+
this.debug = '1' === process.env.EXTENSION_TELEMETRY_DEBUG;
|
|
408
|
+
this.disabled = Boolean(init.disabled);
|
|
409
|
+
this.anonId = 'disabled';
|
|
410
|
+
if (!this.disabled) {
|
|
411
|
+
const idFile = external_node_path_default().join(configDir(), 'telemetry', 'anonymous-id');
|
|
412
|
+
this.anonId = loadOrCreateId(idFile);
|
|
413
|
+
}
|
|
414
|
+
this.common = {
|
|
415
|
+
app: init.app,
|
|
416
|
+
version: init.version,
|
|
417
|
+
os: process.platform,
|
|
418
|
+
arch: process.arch,
|
|
419
|
+
node: process.versions.node,
|
|
420
|
+
is_ci: isCI(),
|
|
421
|
+
schema_version: 1
|
|
422
|
+
};
|
|
423
|
+
this.apiKey = init.apiKey || process.env.EXTENSION_PUBLIC_POSTHOG_KEY;
|
|
424
|
+
this.host = init.host || process.env.EXTENSION_PUBLIC_POSTHOG_HOST;
|
|
425
|
+
if (!this.disabled) {
|
|
426
|
+
const consentPath = external_node_path_default().join(configDir(), 'telemetry', 'consent');
|
|
427
|
+
if (!external_node_fs_default().existsSync(consentPath)) {
|
|
428
|
+
external_node_fs_default().writeFileSync(consentPath, 'ok', 'utf8');
|
|
429
|
+
this.track('cli_telemetry_consent', {
|
|
430
|
+
value: 'implicit_opt_in'
|
|
431
|
+
});
|
|
432
|
+
console.log('[extension] anonymous telemetry helps us improve. Pass --no-telemetry to opt out. Read more in TELEMETRY.md.');
|
|
433
|
+
}
|
|
415
434
|
}
|
|
416
435
|
}
|
|
417
436
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
function isTelemetryDisabledFromArgs(argv) {
|
|
451
|
-
return argv.includes('--no-telemetry');
|
|
452
|
-
}
|
|
453
|
-
const telemetryDisabled = isTelemetryDisabledFromArgs(process.argv);
|
|
454
|
-
const telemetry_cli_telemetry = new Telemetry({
|
|
455
|
-
app: 'extension',
|
|
456
|
-
version: package_namespaceObject.version,
|
|
457
|
-
disabled: telemetryDisabled
|
|
458
|
-
});
|
|
459
|
-
if (!telemetryDisabled) {
|
|
460
|
-
const startedAt = Date.now();
|
|
461
|
-
const known = new Set([
|
|
462
|
-
'create',
|
|
463
|
-
'dev',
|
|
464
|
-
'start',
|
|
465
|
-
'preview',
|
|
466
|
-
'build',
|
|
467
|
-
'cleanup'
|
|
468
|
-
]);
|
|
469
|
-
const invoked = process.argv.slice(2).find((a)=>known.has(a)) || 'unknown';
|
|
470
|
-
telemetry_cli_telemetry.track('cli_boot', {
|
|
471
|
-
command_guess: invoked
|
|
472
|
-
});
|
|
473
|
-
const cwd = process.cwd();
|
|
474
|
-
const manifestPath = external_path_default().join(cwd, 'manifest.json');
|
|
475
|
-
if (external_fs_default().existsSync(manifestPath)) {
|
|
476
|
-
const raw = external_fs_default().readFileSync(manifestPath, 'utf8');
|
|
477
|
-
const json = JSON.parse(raw);
|
|
478
|
-
const summary = summarizeManifest(json);
|
|
479
|
-
telemetry_cli_telemetry.track('manifest_summary', summary);
|
|
437
|
+
function summarizeManifest(manifest) {
|
|
438
|
+
var _manifest_action;
|
|
439
|
+
const mv = (null == manifest ? void 0 : manifest.manifest_version) === 2 ? 2 : 3;
|
|
440
|
+
const permissions = Array.isArray(null == manifest ? void 0 : manifest.permissions) ? manifest.permissions : [];
|
|
441
|
+
const optionalPermissions = Array.isArray(null == manifest ? void 0 : manifest.optional_permissions) ? manifest.optional_permissions : [];
|
|
442
|
+
const hostPermissions = Array.isArray(null == manifest ? void 0 : manifest.host_permissions) ? manifest.host_permissions : [];
|
|
443
|
+
const usesAllUrls = [
|
|
444
|
+
...permissions,
|
|
445
|
+
...hostPermissions
|
|
446
|
+
].includes('<all_urls>');
|
|
447
|
+
const usesDeclarativeNetRequest = permissions.includes('declarativeNetRequest') || permissions.includes('declarativeNetRequestWithHostAccess');
|
|
448
|
+
const background = null == manifest ? void 0 : manifest.background;
|
|
449
|
+
let backgroundType = 'none';
|
|
450
|
+
if (3 === mv && (null == background ? void 0 : background.service_worker)) backgroundType = 'service_worker';
|
|
451
|
+
else if (2 === mv && (Array.isArray(null == background ? void 0 : background.scripts) && background.scripts.length > 0 || (null == background ? void 0 : background.page))) backgroundType = 'event_page';
|
|
452
|
+
const contentScriptsCount = Array.isArray(null == manifest ? void 0 : manifest.content_scripts) ? manifest.content_scripts.length : 0;
|
|
453
|
+
const hasDevtoolsPage = Boolean(null == manifest ? void 0 : manifest.devtools_page);
|
|
454
|
+
const hasActionPopup = Boolean(null == manifest ? void 0 : null == (_manifest_action = manifest.action) ? void 0 : _manifest_action.default_popup);
|
|
455
|
+
return {
|
|
456
|
+
mv,
|
|
457
|
+
permissions_count: permissions.length,
|
|
458
|
+
optional_permissions_count: optionalPermissions.length,
|
|
459
|
+
host_permissions_count: hostPermissions.length,
|
|
460
|
+
uses_all_urls: usesAllUrls,
|
|
461
|
+
uses_declarative_net_request: usesDeclarativeNetRequest,
|
|
462
|
+
background_type: backgroundType,
|
|
463
|
+
content_scripts_count: contentScriptsCount,
|
|
464
|
+
has_devtools_page: hasDevtoolsPage,
|
|
465
|
+
has_action_popup: hasActionPopup
|
|
466
|
+
};
|
|
480
467
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
468
|
+
function isTelemetryDisabledFromArgs(argv) {
|
|
469
|
+
return argv.includes('--no-telemetry');
|
|
470
|
+
}
|
|
471
|
+
const telemetryDisabled = isTelemetryDisabledFromArgs(process.argv);
|
|
472
|
+
const telemetry_cli_telemetry = new Telemetry({
|
|
473
|
+
app: 'extension',
|
|
474
|
+
version: package_namespaceObject.version,
|
|
475
|
+
disabled: telemetryDisabled
|
|
488
476
|
});
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
477
|
+
if (!telemetryDisabled) {
|
|
478
|
+
const startedAt = Date.now();
|
|
479
|
+
const known = new Set([
|
|
480
|
+
'create',
|
|
481
|
+
'dev',
|
|
482
|
+
'start',
|
|
483
|
+
'preview',
|
|
484
|
+
'build',
|
|
485
|
+
'cleanup'
|
|
486
|
+
]);
|
|
487
|
+
const invoked = process.argv.slice(2).find((a)=>known.has(a)) || 'unknown';
|
|
488
|
+
telemetry_cli_telemetry.track('cli_boot', {
|
|
489
|
+
command_guess: invoked
|
|
493
490
|
});
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
491
|
+
const cwd = process.cwd();
|
|
492
|
+
const manifestPath = external_path_default().join(cwd, 'manifest.json');
|
|
493
|
+
if (external_fs_default().existsSync(manifestPath)) {
|
|
494
|
+
const raw = external_fs_default().readFileSync(manifestPath, 'utf8');
|
|
495
|
+
const json = JSON.parse(raw);
|
|
496
|
+
const summary = summarizeManifest(json);
|
|
497
|
+
telemetry_cli_telemetry.track('manifest_summary', summary);
|
|
498
|
+
}
|
|
499
|
+
process.on('beforeExit', async function() {
|
|
500
|
+
telemetry_cli_telemetry.track('cli_shutdown', {
|
|
501
|
+
command_guess: invoked,
|
|
502
|
+
duration_ms: Date.now() - startedAt,
|
|
503
|
+
exit_code: process.exitCode ?? 0
|
|
504
|
+
});
|
|
505
|
+
await telemetry_cli_telemetry.flush();
|
|
499
506
|
});
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
'no',
|
|
512
|
-
'off'
|
|
513
|
-
].includes(normalized);
|
|
514
|
-
}
|
|
515
|
-
async function requireOrDlx(moduleName, versionHint) {
|
|
516
|
-
try {
|
|
517
|
-
return await import(moduleName);
|
|
518
|
-
} catch {}
|
|
519
|
-
const spec = versionHint ? `${moduleName}@${versionHint}` : moduleName;
|
|
520
|
-
const cacheDir = external_node_path_default().join(external_node_os_default().tmpdir(), 'extensionjs-cache', spec);
|
|
521
|
-
const modulePath = external_node_path_default().join(cacheDir, 'node_modules', moduleName);
|
|
522
|
-
const prefer = String(process.env.EXTJS_DLX || '').trim().toLowerCase();
|
|
523
|
-
const isWin = 'win32' === process.platform;
|
|
524
|
-
const npmCmd = isWin ? 'npm.cmd' : 'npm';
|
|
525
|
-
const pnpmCmd = isWin ? 'pnpm.cmd' : 'pnpm';
|
|
526
|
-
const bunCmd = isWin ? 'bun.exe' : 'bun';
|
|
527
|
-
try {
|
|
528
|
-
external_node_fs_default().mkdirSync(cacheDir, {
|
|
529
|
-
recursive: true
|
|
507
|
+
process.on('uncaughtException', function(err) {
|
|
508
|
+
telemetry_cli_telemetry.track('cli_error', {
|
|
509
|
+
command_guess: invoked,
|
|
510
|
+
error_name: String((null == err ? void 0 : err.name) || 'Error').slice(0, 64)
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
process.on('unhandledRejection', function(reason) {
|
|
514
|
+
telemetry_cli_telemetry.track('cli_error', {
|
|
515
|
+
command_guess: invoked,
|
|
516
|
+
error_name: String((null == reason ? void 0 : reason.name) || 'PromiseRejection').slice(0, 64)
|
|
517
|
+
});
|
|
530
518
|
});
|
|
531
|
-
} catch {}
|
|
532
|
-
try {
|
|
533
|
-
var _pkgJson_exports_, _pkgJson_exports, _pkgJson_exports_1, _pkgJson_exports1;
|
|
534
|
-
const pkgJson = JSON.parse(external_node_fs_default().readFileSync(external_node_path_default().join(modulePath, 'package.json'), 'utf8'));
|
|
535
|
-
const main = pkgJson.main || (null == (_pkgJson_exports = pkgJson.exports) ? void 0 : null == (_pkgJson_exports_ = _pkgJson_exports['.']) ? void 0 : _pkgJson_exports_.import) || (null == (_pkgJson_exports1 = pkgJson.exports) ? void 0 : null == (_pkgJson_exports_1 = _pkgJson_exports1['.']) ? void 0 : _pkgJson_exports_1.require);
|
|
536
|
-
if (main) {
|
|
537
|
-
const resolved = (0, external_node_url_namespaceObject.pathToFileURL)(external_node_path_default().join(modulePath, main)).href;
|
|
538
|
-
return await import(resolved);
|
|
539
|
-
}
|
|
540
|
-
} catch {}
|
|
541
|
-
if ('pnpm' === prefer) try {
|
|
542
|
-
external_node_fs_default().writeFileSync(external_node_path_default().join(cacheDir, 'package.json'), JSON.stringify({
|
|
543
|
-
name: 'extensionjs-cache',
|
|
544
|
-
private: true
|
|
545
|
-
}, null, 2));
|
|
546
|
-
} catch {}
|
|
547
|
-
let status = 0;
|
|
548
|
-
if ('pnpm' === prefer) {
|
|
549
|
-
const args = [
|
|
550
|
-
'add',
|
|
551
|
-
spec,
|
|
552
|
-
'--reporter',
|
|
553
|
-
'silent',
|
|
554
|
-
'--no-frozen-lockfile'
|
|
555
|
-
];
|
|
556
|
-
status = (0, external_node_child_process_namespaceObject.spawnSync)(pnpmCmd, args, {
|
|
557
|
-
cwd: cacheDir,
|
|
558
|
-
stdio: 'ignore'
|
|
559
|
-
}).status || 0;
|
|
560
|
-
} else if ('bun' === prefer) {
|
|
561
|
-
const args = [
|
|
562
|
-
'add',
|
|
563
|
-
spec
|
|
564
|
-
];
|
|
565
|
-
status = (0, external_node_child_process_namespaceObject.spawnSync)(bunCmd, args, {
|
|
566
|
-
cwd: cacheDir,
|
|
567
|
-
stdio: 'ignore'
|
|
568
|
-
}).status || 0;
|
|
569
|
-
} else {
|
|
570
|
-
const args = [
|
|
571
|
-
'i',
|
|
572
|
-
spec,
|
|
573
|
-
'--no-fund',
|
|
574
|
-
'--no-audit',
|
|
575
|
-
'--prefer-online',
|
|
576
|
-
'--omit=dev',
|
|
577
|
-
'--no-package-lock'
|
|
578
|
-
];
|
|
579
|
-
status = (0, external_node_child_process_namespaceObject.spawnSync)(npmCmd, args, {
|
|
580
|
-
cwd: cacheDir,
|
|
581
|
-
stdio: 'ignore'
|
|
582
|
-
}).status || 0;
|
|
583
519
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
520
|
+
const external_extension_create_namespaceObject = require("extension-create");
|
|
521
|
+
require("node:url");
|
|
522
|
+
function parseOptionalBoolean(value) {
|
|
523
|
+
if (void 0 === value) return true;
|
|
524
|
+
const normalized = String(value).trim().toLowerCase();
|
|
525
|
+
return ![
|
|
526
|
+
'false',
|
|
527
|
+
'0',
|
|
528
|
+
'no',
|
|
529
|
+
'off'
|
|
530
|
+
].includes(normalized);
|
|
531
|
+
}
|
|
532
|
+
const vendors = (browser)=>{
|
|
533
|
+
const value = browser ?? 'chromium';
|
|
534
|
+
return 'all' === value ? [
|
|
535
|
+
'chrome',
|
|
536
|
+
'edge',
|
|
537
|
+
'firefox'
|
|
538
|
+
] : String(value).split(',');
|
|
539
|
+
};
|
|
540
|
+
function validateVendorsOrExit(vendorsList, onInvalid) {
|
|
541
|
+
const supported = [
|
|
542
|
+
'chrome',
|
|
543
|
+
'edge',
|
|
544
|
+
'firefox',
|
|
545
|
+
'chromium',
|
|
546
|
+
'chromium-based',
|
|
547
|
+
'gecko-based',
|
|
548
|
+
'firefox-based'
|
|
549
|
+
];
|
|
550
|
+
for (const v of vendorsList)if (!supported.includes(v)) {
|
|
551
|
+
onInvalid(v, supported);
|
|
552
|
+
process.exit(1);
|
|
592
553
|
}
|
|
593
|
-
} catch {}
|
|
594
|
-
return await import((0, external_node_url_namespaceObject.pathToFileURL)(external_node_path_default().join(modulePath, 'dist', 'module.js')).href);
|
|
595
|
-
}
|
|
596
|
-
const vendors = (browser)=>{
|
|
597
|
-
const value = browser ?? 'chromium';
|
|
598
|
-
return 'all' === value ? [
|
|
599
|
-
'chrome',
|
|
600
|
-
'edge',
|
|
601
|
-
'firefox'
|
|
602
|
-
] : String(value).split(',');
|
|
603
|
-
};
|
|
604
|
-
function validateVendorsOrExit(vendorsList, onInvalid) {
|
|
605
|
-
const supported = [
|
|
606
|
-
'chrome',
|
|
607
|
-
'edge',
|
|
608
|
-
'firefox',
|
|
609
|
-
'chromium',
|
|
610
|
-
'chromium-based',
|
|
611
|
-
'gecko-based',
|
|
612
|
-
'firefox-based'
|
|
613
|
-
];
|
|
614
|
-
for (const v of vendorsList)if (!supported.includes(v)) {
|
|
615
|
-
onInvalid(v, supported);
|
|
616
|
-
process.exit(1);
|
|
617
554
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
555
|
+
function registerCreateCommand(program, telemetry) {
|
|
556
|
+
program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description('Creates a new extension.').option('-t, --template <template-name>', 'specify a template for the created project').option('--install [boolean]', 'whether or not to install the dependencies after creating the project (disabled by default)', parseOptionalBoolean, false).action(async function(pathOrRemoteUrl, { template, install }) {
|
|
557
|
+
const startedAt = Date.now();
|
|
558
|
+
telemetry.track('cli_command_start', {
|
|
559
|
+
command: 'create',
|
|
560
|
+
template: template || 'default',
|
|
561
|
+
install: Boolean(install)
|
|
562
|
+
});
|
|
563
|
+
try {
|
|
564
|
+
await (0, external_extension_create_namespaceObject.extensionCreate)(pathOrRemoteUrl, {
|
|
565
|
+
template,
|
|
566
|
+
install,
|
|
567
|
+
cliVersion: package_namespaceObject.version
|
|
568
|
+
});
|
|
569
|
+
telemetry.track('cli_command_finish', {
|
|
570
|
+
command: 'create',
|
|
571
|
+
duration_ms: Date.now() - startedAt,
|
|
572
|
+
success: true,
|
|
573
|
+
exit_code: 0
|
|
574
|
+
});
|
|
575
|
+
} catch (err) {
|
|
576
|
+
telemetry.track('cli_command_finish', {
|
|
577
|
+
command: 'create',
|
|
578
|
+
duration_ms: Date.now() - startedAt,
|
|
579
|
+
success: false,
|
|
580
|
+
exit_code: 1
|
|
581
|
+
});
|
|
582
|
+
throw err;
|
|
583
|
+
}
|
|
626
584
|
});
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
585
|
+
}
|
|
586
|
+
function registerDevCommand(program, telemetry) {
|
|
587
|
+
program.command('dev').arguments('[project-path|remote-url]').usage('dev [project-path|remote-url] [options]').description('Starts the development server (development mode)').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `false`').option('--no-open', 'do not open the browser automatically (default: open)').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--source [url]', "[experimental] opens the provided URL in Chrome and prints the full, live HTML of the page after content scripts are injected").option('--author, --author-mode', '[internal] enable maintainer diagnostics (does not affect user runtime logs)').action(async function(pathOrRemoteUrl, { browser = 'chromium', ...devOptions }) {
|
|
588
|
+
var _devOptions_polyfill;
|
|
589
|
+
if (devOptions.author || devOptions['authorMode']) {
|
|
590
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
591
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
592
|
+
}
|
|
593
|
+
const cmdStart = Date.now();
|
|
594
|
+
telemetry.track('cli_command_start', {
|
|
595
|
+
command: 'dev',
|
|
596
|
+
vendors: vendors(browser),
|
|
597
|
+
polyfill_used: (null == (_devOptions_polyfill = devOptions.polyfill) ? void 0 : _devOptions_polyfill.toString()) !== 'false',
|
|
598
|
+
log_level: devOptions.logLevel || 'off',
|
|
599
|
+
log_format: devOptions.logFormat || 'pretty',
|
|
600
|
+
custom_binary_used: Boolean(devOptions.chromiumBinary || devOptions.geckoBinary)
|
|
632
601
|
});
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
success: true,
|
|
637
|
-
exit_code: 0
|
|
602
|
+
const list = vendors(browser);
|
|
603
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
604
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
638
605
|
});
|
|
639
|
-
|
|
606
|
+
if (devOptions.source) {
|
|
607
|
+
const hasExplicitSourceString = 'string' == typeof devOptions.source && 'true' !== String(devOptions.source).trim().toLowerCase();
|
|
608
|
+
const hasStartingUrl = 'string' == typeof devOptions.startingUrl && String(devOptions.startingUrl).trim().length > 0;
|
|
609
|
+
if (!hasExplicitSourceString) devOptions.source = hasStartingUrl ? String(devOptions.startingUrl) : 'https://example.com';
|
|
610
|
+
devOptions.watchSource = true;
|
|
611
|
+
}
|
|
612
|
+
const { extensionDev } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "extension-develop"));
|
|
613
|
+
for (const vendor of list){
|
|
614
|
+
var _devOptions_polyfill1;
|
|
615
|
+
const vendorStart = Date.now();
|
|
616
|
+
telemetry.track('cli_vendor_start', {
|
|
617
|
+
command: 'dev',
|
|
618
|
+
vendor
|
|
619
|
+
});
|
|
620
|
+
const logsOption = devOptions.logs;
|
|
621
|
+
const logContextOption = devOptions.logContext;
|
|
622
|
+
const devArgs = {
|
|
623
|
+
...devOptions,
|
|
624
|
+
profile: devOptions.profile,
|
|
625
|
+
browser: vendor,
|
|
626
|
+
chromiumBinary: devOptions.chromiumBinary,
|
|
627
|
+
geckoBinary: devOptions.geckoBinary,
|
|
628
|
+
polyfill: (null == (_devOptions_polyfill1 = devOptions.polyfill) ? void 0 : _devOptions_polyfill1.toString()) !== 'false',
|
|
629
|
+
open: devOptions.open,
|
|
630
|
+
startingUrl: devOptions.startingUrl,
|
|
631
|
+
source: devOptions.source,
|
|
632
|
+
watchSource: devOptions.watchSource,
|
|
633
|
+
logLevel: logsOption || devOptions.logLevel || 'off',
|
|
634
|
+
logContexts: (()=>{
|
|
635
|
+
const raw = logContextOption || devOptions.logContexts;
|
|
636
|
+
if (!raw || 0 === String(raw).trim().length) return;
|
|
637
|
+
if ('all' === String(raw).trim().toLowerCase()) return;
|
|
638
|
+
const allowed = [
|
|
639
|
+
'background',
|
|
640
|
+
'content',
|
|
641
|
+
'page',
|
|
642
|
+
'sidebar',
|
|
643
|
+
'popup',
|
|
644
|
+
'options',
|
|
645
|
+
'devtools'
|
|
646
|
+
];
|
|
647
|
+
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
648
|
+
return values.length ? values : void 0;
|
|
649
|
+
})(),
|
|
650
|
+
logFormat: devOptions.logFormat || 'pretty',
|
|
651
|
+
logTimestamps: false !== devOptions.logTimestamps,
|
|
652
|
+
logColor: false !== devOptions.logColor,
|
|
653
|
+
logUrl: devOptions.logUrl,
|
|
654
|
+
logTab: devOptions.logTab
|
|
655
|
+
};
|
|
656
|
+
await extensionDev(pathOrRemoteUrl, devArgs);
|
|
657
|
+
telemetry.track('cli_vendor_finish', {
|
|
658
|
+
command: 'dev',
|
|
659
|
+
vendor,
|
|
660
|
+
duration_ms: Date.now() - vendorStart
|
|
661
|
+
});
|
|
662
|
+
}
|
|
640
663
|
telemetry.track('cli_command_finish', {
|
|
641
|
-
command: '
|
|
642
|
-
duration_ms: Date.now() -
|
|
643
|
-
success:
|
|
644
|
-
exit_code:
|
|
664
|
+
command: 'dev',
|
|
665
|
+
duration_ms: Date.now() - cmdStart,
|
|
666
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
667
|
+
exit_code: process.exitCode ?? 0
|
|
645
668
|
});
|
|
646
|
-
throw err;
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
function registerDevCommand(program, telemetry) {
|
|
651
|
-
program.command('dev').arguments('[project-path|remote-url]').usage('dev [project-path|remote-url] [options]').description('Starts the development server (development mode)').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `false`').option('--no-open', 'do not open the browser automatically (default: open)').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--source [url]', "[experimental] opens the provided URL in Chrome and prints the full, live HTML of the page after content scripts are injected").action(async function(pathOrRemoteUrl, { browser = 'chromium', ...devOptions }) {
|
|
652
|
-
var _devOptions_polyfill;
|
|
653
|
-
const cmdStart = Date.now();
|
|
654
|
-
telemetry.track('cli_command_start', {
|
|
655
|
-
command: 'dev',
|
|
656
|
-
vendors: vendors(browser),
|
|
657
|
-
polyfill_used: (null == (_devOptions_polyfill = devOptions.polyfill) ? void 0 : _devOptions_polyfill.toString()) !== 'false',
|
|
658
|
-
log_level: devOptions.logLevel || 'off',
|
|
659
|
-
log_format: devOptions.logFormat || 'pretty',
|
|
660
|
-
custom_binary_used: Boolean(devOptions.chromiumBinary || devOptions.geckoBinary)
|
|
661
|
-
});
|
|
662
|
-
const list = vendors(browser);
|
|
663
|
-
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
664
|
-
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
665
669
|
});
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
670
|
+
}
|
|
671
|
+
function registerStartCommand(program, telemetry) {
|
|
672
|
+
program.command('start').arguments('[project-path|remote-url]').usage('start [project-path|remote-url] [options]').description('Starts the development server (production mode)').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `true`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--source [url]', "[experimental] opens the provided URL in Chrome and prints the full, live HTML of the page after content scripts are injected").option('--author, --author-mode', '[internal] enable maintainer diagnostics (does not affect user runtime logs)').action(async function(pathOrRemoteUrl, { browser = 'chromium', ...startOptions }) {
|
|
673
|
+
var _startOptions_polyfill;
|
|
674
|
+
if (startOptions.author || startOptions['authorMode']) {
|
|
675
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
676
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
677
|
+
}
|
|
678
|
+
const cmdStart = Date.now();
|
|
679
|
+
telemetry.track('cli_command_start', {
|
|
680
|
+
command: 'start',
|
|
681
|
+
vendors: vendors(browser),
|
|
682
|
+
polyfill_used: (null == (_startOptions_polyfill = startOptions.polyfill) ? void 0 : _startOptions_polyfill.toString()) !== 'false'
|
|
683
|
+
});
|
|
684
|
+
const list = vendors(browser);
|
|
685
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
686
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
680
687
|
});
|
|
681
|
-
const
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
source: devOptions.source,
|
|
693
|
-
watchSource: devOptions.watchSource,
|
|
694
|
-
logLevel: logsOption || devOptions.logLevel || 'off',
|
|
695
|
-
logContexts: (()=>{
|
|
696
|
-
const raw = logContextOption || devOptions.logContexts;
|
|
688
|
+
const { extensionStart } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "extension-develop"));
|
|
689
|
+
for (const vendor of list){
|
|
690
|
+
const vendorStart = Date.now();
|
|
691
|
+
telemetry.track('cli_vendor_start', {
|
|
692
|
+
command: 'start',
|
|
693
|
+
vendor
|
|
694
|
+
});
|
|
695
|
+
const logsOption = startOptions.logs;
|
|
696
|
+
const logContextOption = startOptions.logContext;
|
|
697
|
+
const logContexts = (()=>{
|
|
698
|
+
const raw = logContextOption || startOptions.logContexts;
|
|
697
699
|
if (!raw || 0 === String(raw).trim().length) return;
|
|
698
700
|
if ('all' === String(raw).trim().toLowerCase()) return;
|
|
699
701
|
const allowed = [
|
|
@@ -707,232 +709,186 @@ function registerDevCommand(program, telemetry) {
|
|
|
707
709
|
];
|
|
708
710
|
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
709
711
|
return values.length ? values : void 0;
|
|
710
|
-
})()
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
telemetry.track('cli_command_start', {
|
|
737
|
-
command: 'start',
|
|
738
|
-
vendors: vendors(browser),
|
|
739
|
-
polyfill_used: (null == (_startOptions_polyfill = startOptions.polyfill) ? void 0 : _startOptions_polyfill.toString()) !== 'false'
|
|
740
|
-
});
|
|
741
|
-
const list = vendors(browser);
|
|
742
|
-
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
743
|
-
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
744
|
-
});
|
|
745
|
-
const major = String(package_namespaceObject.version).split('.')[0] || '2';
|
|
746
|
-
const { extensionStart } = await requireOrDlx('extension-develop', major);
|
|
747
|
-
for (const vendor of list){
|
|
748
|
-
const vendorStart = Date.now();
|
|
749
|
-
telemetry.track('cli_vendor_start', {
|
|
750
|
-
command: 'start',
|
|
751
|
-
vendor
|
|
752
|
-
});
|
|
753
|
-
const logsOption = startOptions.logs;
|
|
754
|
-
const logContextOption = startOptions.logContext;
|
|
755
|
-
const logContexts = (()=>{
|
|
756
|
-
const raw = logContextOption || startOptions.logContexts;
|
|
757
|
-
if (!raw || 0 === String(raw).trim().length) return;
|
|
758
|
-
if ('all' === String(raw).trim().toLowerCase()) return;
|
|
759
|
-
const allowed = [
|
|
760
|
-
'background',
|
|
761
|
-
'content',
|
|
762
|
-
'page',
|
|
763
|
-
'sidebar',
|
|
764
|
-
'popup',
|
|
765
|
-
'options',
|
|
766
|
-
'devtools'
|
|
767
|
-
];
|
|
768
|
-
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
769
|
-
return values.length ? values : void 0;
|
|
770
|
-
})();
|
|
771
|
-
await extensionStart(pathOrRemoteUrl, {
|
|
772
|
-
mode: 'production',
|
|
773
|
-
profile: startOptions.profile,
|
|
774
|
-
browser: vendor,
|
|
775
|
-
chromiumBinary: startOptions.chromiumBinary,
|
|
776
|
-
geckoBinary: startOptions.geckoBinary,
|
|
777
|
-
startingUrl: startOptions.startingUrl,
|
|
778
|
-
port: startOptions.port,
|
|
779
|
-
source: 'string' == typeof startOptions.source ? startOptions.source : startOptions.source,
|
|
780
|
-
watchSource: startOptions.watchSource,
|
|
781
|
-
logLevel: logsOption || startOptions.logLevel || 'off',
|
|
782
|
-
logContexts,
|
|
783
|
-
logFormat: startOptions.logFormat || 'pretty',
|
|
784
|
-
logTimestamps: false !== startOptions.logTimestamps,
|
|
785
|
-
logColor: false !== startOptions.logColor,
|
|
786
|
-
logUrl: startOptions.logUrl,
|
|
787
|
-
logTab: startOptions.logTab
|
|
788
|
-
});
|
|
789
|
-
telemetry.track('cli_vendor_finish', {
|
|
712
|
+
})();
|
|
713
|
+
await extensionStart(pathOrRemoteUrl, {
|
|
714
|
+
mode: 'production',
|
|
715
|
+
profile: startOptions.profile,
|
|
716
|
+
browser: vendor,
|
|
717
|
+
chromiumBinary: startOptions.chromiumBinary,
|
|
718
|
+
geckoBinary: startOptions.geckoBinary,
|
|
719
|
+
startingUrl: startOptions.startingUrl,
|
|
720
|
+
port: startOptions.port,
|
|
721
|
+
source: 'string' == typeof startOptions.source ? startOptions.source : startOptions.source,
|
|
722
|
+
watchSource: startOptions.watchSource,
|
|
723
|
+
logLevel: logsOption || startOptions.logLevel || 'off',
|
|
724
|
+
logContexts,
|
|
725
|
+
logFormat: startOptions.logFormat || 'pretty',
|
|
726
|
+
logTimestamps: false !== startOptions.logTimestamps,
|
|
727
|
+
logColor: false !== startOptions.logColor,
|
|
728
|
+
logUrl: startOptions.logUrl,
|
|
729
|
+
logTab: startOptions.logTab
|
|
730
|
+
});
|
|
731
|
+
telemetry.track('cli_vendor_finish', {
|
|
732
|
+
command: 'start',
|
|
733
|
+
vendor,
|
|
734
|
+
duration_ms: Date.now() - vendorStart
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
telemetry.track('cli_command_finish', {
|
|
790
738
|
command: 'start',
|
|
791
|
-
|
|
792
|
-
|
|
739
|
+
duration_ms: Date.now() - cmdStart,
|
|
740
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
741
|
+
exit_code: process.exitCode ?? 0
|
|
793
742
|
});
|
|
794
|
-
}
|
|
795
|
-
telemetry.track('cli_command_finish', {
|
|
796
|
-
command: 'start',
|
|
797
|
-
duration_ms: Date.now() - cmdStart,
|
|
798
|
-
success: 0 === process.exitCode || null == process.exitCode,
|
|
799
|
-
exit_code: process.exitCode ?? 0
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
function registerPreviewCommand(program, telemetry) {
|
|
804
|
-
program.command('preview').arguments('[project-name]').usage('preview [path-to-remote-extension] [options]').description('Preview the extension in production mode').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--source [url]', "[experimental] opens the provided URL in Chrome and prints the full, live HTML of the page after content scripts are injected").action(async function(pathOrRemoteUrl, { browser = 'chromium', ...previewOptions }) {
|
|
805
|
-
const cmdStart = Date.now();
|
|
806
|
-
telemetry.track('cli_command_start', {
|
|
807
|
-
command: 'preview',
|
|
808
|
-
vendors: vendors(browser)
|
|
809
|
-
});
|
|
810
|
-
const list = vendors(browser);
|
|
811
|
-
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
812
|
-
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
813
743
|
});
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
const
|
|
822
|
-
telemetry.track('
|
|
744
|
+
}
|
|
745
|
+
function registerPreviewCommand(program, telemetry) {
|
|
746
|
+
program.command('preview').arguments('[project-name]').usage('preview [path-to-remote-extension] [options]').description('Preview the extension in production mode').option('--profile <path-to-file | boolean>', 'what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--chromium-binary <path-to-binary>', 'specify a path to the Chromium binary. This option overrides the --browser setting. Defaults to the system default').option('--gecko-binary, --firefox-binary <path-to-binary>', 'specify a path to the Gecko binary. This option overrides the --browser setting. Defaults to the system default').option('--starting-url <url>', 'specify the starting URL for the browser. Defaults to `undefined`').option('--port <port>', 'specify the port to use for the development server. Defaults to `8080`').option('--log-context <list>', '[experimental] comma-separated contexts to include (background,content,page,sidebar,popup,options,devtools). Use `all` to include all contexts (default)').option('--logs <off|error|warn|info|debug|trace|all>', '[experimental] minimum centralized logger level to display in terminal (default: off)').option('--log-format <pretty|json>', '[experimental] output format for logger events. Defaults to `pretty`').option('--no-log-timestamps', 'disable ISO timestamps in pretty output').option('--no-log-color', 'disable color in pretty output').option('--log-url <pattern>', '[experimental] only show logs where event.url matches this substring or regex (/re/i)').option('--log-tab <id>', 'only show logs for a specific tabId (number)').option('--source [url]', "[experimental] opens the provided URL in Chrome and prints the full, live HTML of the page after content scripts are injected").option('--author, --author-mode', '[internal] enable maintainer diagnostics (does not affect user runtime logs)').action(async function(pathOrRemoteUrl, { browser = 'chromium', ...previewOptions }) {
|
|
747
|
+
if (previewOptions.author || previewOptions['authorMode']) {
|
|
748
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
749
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
750
|
+
}
|
|
751
|
+
const cmdStart = Date.now();
|
|
752
|
+
telemetry.track('cli_command_start', {
|
|
823
753
|
command: 'preview',
|
|
824
|
-
|
|
754
|
+
vendors: vendors(browser)
|
|
825
755
|
});
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const raw = logContextOption || previewOptions.logContexts;
|
|
830
|
-
if (!raw || 0 === String(raw).trim().length) return;
|
|
831
|
-
if ('all' === String(raw).trim().toLowerCase()) return;
|
|
832
|
-
const allowed = [
|
|
833
|
-
'background',
|
|
834
|
-
'content',
|
|
835
|
-
'page',
|
|
836
|
-
'sidebar',
|
|
837
|
-
'popup',
|
|
838
|
-
'options',
|
|
839
|
-
'devtools'
|
|
840
|
-
];
|
|
841
|
-
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
842
|
-
return values.length ? values : void 0;
|
|
843
|
-
})();
|
|
844
|
-
await extensionPreview(pathOrRemoteUrl, {
|
|
845
|
-
mode: 'production',
|
|
846
|
-
profile: previewOptions.profile,
|
|
847
|
-
browser: vendor,
|
|
848
|
-
chromiumBinary: previewOptions.chromiumBinary,
|
|
849
|
-
geckoBinary: previewOptions.geckoBinary,
|
|
850
|
-
startingUrl: previewOptions.startingUrl,
|
|
851
|
-
port: previewOptions.port,
|
|
852
|
-
source: 'string' == typeof previewOptions.source ? previewOptions.source : previewOptions.source,
|
|
853
|
-
watchSource: previewOptions.watchSource,
|
|
854
|
-
logLevel: logsOption || previewOptions.logLevel || 'off',
|
|
855
|
-
logContexts,
|
|
856
|
-
logFormat: previewOptions.logFormat || 'pretty',
|
|
857
|
-
logTimestamps: false !== previewOptions.logTimestamps,
|
|
858
|
-
logColor: false !== previewOptions.logColor,
|
|
859
|
-
logUrl: previewOptions.logUrl,
|
|
860
|
-
logTab: previewOptions.logTab
|
|
756
|
+
const list = vendors(browser);
|
|
757
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
758
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
861
759
|
});
|
|
862
|
-
|
|
760
|
+
if (!process.env.EXTJS_LIGHT) {
|
|
761
|
+
const isRemote = 'string' == typeof pathOrRemoteUrl && /^https?:/i.test(pathOrRemoteUrl);
|
|
762
|
+
if (isRemote) process.env.EXTJS_LIGHT = '1';
|
|
763
|
+
}
|
|
764
|
+
const { extensionPreview } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "extension-develop"));
|
|
765
|
+
for (const vendor of list){
|
|
766
|
+
const vendorStart = Date.now();
|
|
767
|
+
telemetry.track('cli_vendor_start', {
|
|
768
|
+
command: 'preview',
|
|
769
|
+
vendor
|
|
770
|
+
});
|
|
771
|
+
const logsOption = previewOptions.logs;
|
|
772
|
+
const logContextOption = previewOptions.logContext;
|
|
773
|
+
const logContexts = (()=>{
|
|
774
|
+
const raw = logContextOption || previewOptions.logContexts;
|
|
775
|
+
if (!raw || 0 === String(raw).trim().length) return;
|
|
776
|
+
if ('all' === String(raw).trim().toLowerCase()) return;
|
|
777
|
+
const allowed = [
|
|
778
|
+
'background',
|
|
779
|
+
'content',
|
|
780
|
+
'page',
|
|
781
|
+
'sidebar',
|
|
782
|
+
'popup',
|
|
783
|
+
'options',
|
|
784
|
+
'devtools'
|
|
785
|
+
];
|
|
786
|
+
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
787
|
+
return values.length ? values : void 0;
|
|
788
|
+
})();
|
|
789
|
+
await extensionPreview(pathOrRemoteUrl, {
|
|
790
|
+
mode: 'production',
|
|
791
|
+
profile: previewOptions.profile,
|
|
792
|
+
browser: vendor,
|
|
793
|
+
chromiumBinary: previewOptions.chromiumBinary,
|
|
794
|
+
geckoBinary: previewOptions.geckoBinary,
|
|
795
|
+
startingUrl: previewOptions.startingUrl,
|
|
796
|
+
port: previewOptions.port,
|
|
797
|
+
source: 'string' == typeof previewOptions.source ? previewOptions.source : previewOptions.source,
|
|
798
|
+
watchSource: previewOptions.watchSource,
|
|
799
|
+
logLevel: logsOption || previewOptions.logLevel || 'off',
|
|
800
|
+
logContexts,
|
|
801
|
+
logFormat: previewOptions.logFormat || 'pretty',
|
|
802
|
+
logTimestamps: false !== previewOptions.logTimestamps,
|
|
803
|
+
logColor: false !== previewOptions.logColor,
|
|
804
|
+
logUrl: previewOptions.logUrl,
|
|
805
|
+
logTab: previewOptions.logTab
|
|
806
|
+
});
|
|
807
|
+
telemetry.track('cli_vendor_finish', {
|
|
808
|
+
command: 'preview',
|
|
809
|
+
vendor,
|
|
810
|
+
duration_ms: Date.now() - vendorStart
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
telemetry.track('cli_command_finish', {
|
|
863
814
|
command: 'preview',
|
|
864
|
-
|
|
865
|
-
|
|
815
|
+
duration_ms: Date.now() - cmdStart,
|
|
816
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
817
|
+
exit_code: process.exitCode ?? 0
|
|
866
818
|
});
|
|
867
|
-
}
|
|
868
|
-
telemetry.track('cli_command_finish', {
|
|
869
|
-
command: 'preview',
|
|
870
|
-
duration_ms: Date.now() - cmdStart,
|
|
871
|
-
success: 0 === process.exitCode || null == process.exitCode,
|
|
872
|
-
exit_code: process.exitCode ?? 0
|
|
873
|
-
});
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
function registerBuildCommand(program, telemetry) {
|
|
877
|
-
program.command('build').arguments('[project-name]').usage('build [path-to-remote-extension] [options]').description('Builds the extension for production').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `false`').option('--zip [boolean]', 'whether or not to compress the extension into a ZIP file. Defaults to `false`').option('--zip-source [boolean]', 'whether or not to include the source files in the ZIP file. Defaults to `false`').option('--zip-filename <string>', 'specify the name of the ZIP file. Defaults to the extension name and version').option('--silent [boolean]', 'whether or not to open the browser automatically. Defaults to `false`').action(async function(pathOrRemoteUrl, { browser = 'chromium', ...buildOptions }) {
|
|
878
|
-
const cmdStart = Date.now();
|
|
879
|
-
telemetry.track('cli_command_start', {
|
|
880
|
-
command: 'build',
|
|
881
|
-
vendors: vendors(browser),
|
|
882
|
-
polyfill_used: buildOptions.polyfill || false,
|
|
883
|
-
zip: buildOptions.zip || false,
|
|
884
|
-
zip_source: buildOptions.zipSource || false
|
|
885
|
-
});
|
|
886
|
-
const list = vendors(browser);
|
|
887
|
-
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
888
|
-
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
889
819
|
});
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
for (
|
|
893
|
-
|
|
894
|
-
|
|
820
|
+
}
|
|
821
|
+
function registerBuildCommand(program, telemetry) {
|
|
822
|
+
program.command('build').arguments('[project-name]').usage('build [path-to-remote-extension] [options]').description('Builds the extension for production').option('--browser <chrome | chromium | edge | firefox | chromium-based | gecko-based | firefox-based>', 'specify a browser/engine to run. Defaults to `chromium`').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `false`').option('--zip [boolean]', 'whether or not to compress the extension into a ZIP file. Defaults to `false`').option('--zip-source [boolean]', 'whether or not to include the source files in the ZIP file. Defaults to `false`').option('--zip-filename <string>', 'specify the name of the ZIP file. Defaults to the extension name and version').option('--silent [boolean]', 'whether or not to open the browser automatically. Defaults to `false`').option('--author, --author-mode', '[internal] enable maintainer diagnostics (does not affect user runtime logs)').action(async function(pathOrRemoteUrl, { browser = 'chromium', ...buildOptions }) {
|
|
823
|
+
if (buildOptions.author || buildOptions['authorMode']) {
|
|
824
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
825
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
826
|
+
}
|
|
827
|
+
const cmdStart = Date.now();
|
|
828
|
+
telemetry.track('cli_command_start', {
|
|
895
829
|
command: 'build',
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
polyfill: buildOptions.polyfill,
|
|
901
|
-
zip: buildOptions.zip,
|
|
902
|
-
zipSource: buildOptions.zipSource,
|
|
903
|
-
zipFilename: buildOptions.zipFilename,
|
|
904
|
-
silent: buildOptions.silent
|
|
830
|
+
vendors: vendors(browser),
|
|
831
|
+
polyfill_used: buildOptions.polyfill || false,
|
|
832
|
+
zip: buildOptions.zip || false,
|
|
833
|
+
zip_source: buildOptions.zipSource || false
|
|
905
834
|
});
|
|
906
|
-
|
|
907
|
-
|
|
835
|
+
const list = vendors(browser);
|
|
836
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
837
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
908
838
|
});
|
|
909
|
-
|
|
839
|
+
const { extensionBuild } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "extension-develop"));
|
|
840
|
+
for (const vendor of list){
|
|
841
|
+
const vendorStart = Date.now();
|
|
842
|
+
telemetry.track('cli_vendor_start', {
|
|
843
|
+
command: 'build',
|
|
844
|
+
vendor
|
|
845
|
+
});
|
|
846
|
+
const buildSummary = await extensionBuild(pathOrRemoteUrl, {
|
|
847
|
+
browser: vendor,
|
|
848
|
+
polyfill: buildOptions.polyfill,
|
|
849
|
+
zip: buildOptions.zip,
|
|
850
|
+
zipSource: buildOptions.zipSource,
|
|
851
|
+
zipFilename: buildOptions.zipFilename,
|
|
852
|
+
silent: buildOptions.silent
|
|
853
|
+
});
|
|
854
|
+
telemetry.track('cli_build_summary', {
|
|
855
|
+
...buildSummary
|
|
856
|
+
});
|
|
857
|
+
telemetry.track('cli_vendor_finish', {
|
|
858
|
+
command: 'build',
|
|
859
|
+
vendor,
|
|
860
|
+
duration_ms: Date.now() - vendorStart
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
telemetry.track('cli_command_finish', {
|
|
910
864
|
command: 'build',
|
|
911
|
-
|
|
912
|
-
|
|
865
|
+
duration_ms: Date.now() - cmdStart,
|
|
866
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
867
|
+
exit_code: process.exitCode ?? 0
|
|
913
868
|
});
|
|
914
|
-
}
|
|
915
|
-
telemetry.track('cli_command_finish', {
|
|
916
|
-
command: 'build',
|
|
917
|
-
duration_ms: Date.now() - cmdStart,
|
|
918
|
-
success: 0 === process.exitCode || null == process.exitCode,
|
|
919
|
-
exit_code: process.exitCode ?? 0
|
|
920
869
|
});
|
|
870
|
+
}
|
|
871
|
+
check_updates_checkUpdates(package_namespaceObject);
|
|
872
|
+
const extensionJs = external_commander_namespaceObject.program;
|
|
873
|
+
extensionJs.name(package_namespaceObject.name).description(package_namespaceObject.description).version(package_namespaceObject.version).option('--no-telemetry', 'disable anonymous telemetry for this run').option('--ai-help', 'show AI-assistant oriented help and tips').addHelpText('after', programUserHelp()).showHelpAfterError(true).showSuggestionAfterError(true);
|
|
874
|
+
registerCreateCommand(extensionJs, telemetry_cli_telemetry);
|
|
875
|
+
registerDevCommand(extensionJs, telemetry_cli_telemetry);
|
|
876
|
+
registerStartCommand(extensionJs, telemetry_cli_telemetry);
|
|
877
|
+
registerPreviewCommand(extensionJs, telemetry_cli_telemetry);
|
|
878
|
+
registerBuildCommand(extensionJs, telemetry_cli_telemetry);
|
|
879
|
+
extensionJs.on('option:ai-help', function() {
|
|
880
|
+
console.log(programAIHelp());
|
|
881
|
+
process.exit(0);
|
|
921
882
|
});
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
extensionJs.on('option:ai-help', function() {
|
|
932
|
-
console.log(programAIHelp());
|
|
933
|
-
process.exit(0);
|
|
934
|
-
});
|
|
935
|
-
extensionJs.parse();
|
|
883
|
+
if (process.argv.length <= 2) {
|
|
884
|
+
extensionJs.outputHelp();
|
|
885
|
+
process.exit(0);
|
|
886
|
+
}
|
|
887
|
+
extensionJs.parseAsync().catch((err)=>{
|
|
888
|
+
console.error(err);
|
|
889
|
+
process.exit(1);
|
|
890
|
+
});
|
|
891
|
+
})();
|
|
936
892
|
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
937
893
|
Object.defineProperty(exports, '__esModule', {
|
|
938
894
|
value: true
|