extension 3.0.0 → 3.1.0-next.10
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/README.md +7 -5
- package/dist/cli.js +647 -660
- package/package.json +15 -15
- package/types/extension-create-shim.d.ts +24 -0
- package/types/extension-develop-shim.d.ts +18 -0
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var
|
|
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
|
-
}
|
|
3
|
+
var __webpack_require__ = {};
|
|
20
4
|
(()=>{
|
|
21
5
|
__webpack_require__.n = (module)=>{
|
|
22
6
|
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
@@ -38,68 +22,67 @@ function __webpack_require__(moduleId) {
|
|
|
38
22
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
39
23
|
})();
|
|
40
24
|
var __webpack_exports__ = {};
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return external_pintor_default().brightMagenta(base);
|
|
53
|
-
}
|
|
54
|
-
if ('error' === type) return external_pintor_default().red('ERROR');
|
|
55
|
-
if ('warn' === type) return external_pintor_default().brightYellow("\u25BA\u25BA\u25BA");
|
|
56
|
-
if ('info' === type) return external_pintor_default().gray("\u25BA\u25BA\u25BA");
|
|
57
|
-
return external_pintor_default().green("\u25BA\u25BA\u25BA");
|
|
58
|
-
}
|
|
59
|
-
const code = (text)=>external_pintor_default().blue(text);
|
|
60
|
-
const arg = (text)=>external_pintor_default().gray(text);
|
|
61
|
-
const fmt = {
|
|
62
|
-
heading: (title)=>external_pintor_default().underline(external_pintor_default().blue(title)),
|
|
63
|
-
label: (k)=>external_pintor_default().gray(k.toUpperCase()),
|
|
64
|
-
val: (v)=>external_pintor_default().underline(v),
|
|
65
|
-
code: (v)=>external_pintor_default().blue(v),
|
|
66
|
-
bullet: (s)=>`- ${s}`,
|
|
67
|
-
block (title, rows) {
|
|
68
|
-
const head = fmt.heading(title);
|
|
69
|
-
const body = rows.map(([k, v])=>`${fmt.label(k)} ${v}`).join('\n');
|
|
70
|
-
return `${head}\n${body}`;
|
|
71
|
-
},
|
|
72
|
-
truncate (input, max = 800) {
|
|
73
|
-
const s = (()=>{
|
|
74
|
-
try {
|
|
75
|
-
return 'string' == typeof input ? input : JSON.stringify(input);
|
|
76
|
-
} catch {
|
|
77
|
-
return String(input);
|
|
78
|
-
}
|
|
79
|
-
})();
|
|
80
|
-
return s.length > max ? s.slice(0, max) + "\u2026" : s;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const commandDescriptions = {
|
|
84
|
-
create: 'Creates a new extension from a template (React, TypeScript, Vue, Svelte, etc.)',
|
|
85
|
-
dev: 'Starts the development server with hot reloading',
|
|
86
|
-
start: 'Builds and starts the extension in production mode',
|
|
87
|
-
preview: 'Previews the extension in production mode without building',
|
|
88
|
-
build: 'Builds the extension for packaging/distribution',
|
|
89
|
-
cleanup: 'Cleans up orphaned instances and frees unused ports'
|
|
90
|
-
};
|
|
91
|
-
function unhandledError(err) {
|
|
92
|
-
const message = err instanceof Error ? err.stack || err.message : 'string' == typeof err ? err : fmt.truncate(err);
|
|
93
|
-
return `${getLoggingPrefix('error')} ${external_pintor_default().red(String(message || 'Unknown error'))}`;
|
|
94
|
-
}
|
|
95
|
-
function updateFailed(err) {
|
|
96
|
-
return `${getLoggingPrefix('error')} Failed to check for updates.\n${external_pintor_default().red(String((null == err ? void 0 : err.message) || err))}`;
|
|
25
|
+
const external_commander_namespaceObject = require("commander");
|
|
26
|
+
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.1.0-next.10","description":"Create cross-browser extensions with no build configuration.","homepage":"https://extension.js.org/","bugs":{"url":"https://github.com/extension-js/extension.js/issues"},"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-create":"^3.1.0-next.10","extension-develop":"^3.1.0-next.10","commander":"^14.0.2","pintor":"0.3.0","semver":"^7.7.3","update-check":"^1.5.4"},"devDependencies":{"@rslib/core":"^0.19.2","@types/chrome":"^0.1.33","@types/node":"^25.0.9","@types/react":"^19.2.8","@types/react-dom":"^19.2.3","@types/webextension-polyfill":"0.12.4","@types/mock-fs":"^4.13.4","@types/semver":"^7.7.1","mock-fs":"^5.5.0","webextension-polyfill":"^0.12.0","tsconfig":"*","typescript":"5.9.3","vitest":"^4.0.17"}}');
|
|
27
|
+
const external_update_check_namespaceObject = require("update-check");
|
|
28
|
+
var external_update_check_default = /*#__PURE__*/ __webpack_require__.n(external_update_check_namespaceObject);
|
|
29
|
+
const external_pintor_namespaceObject = require("pintor");
|
|
30
|
+
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_namespaceObject);
|
|
31
|
+
function getLoggingPrefix(type) {
|
|
32
|
+
const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
|
|
33
|
+
if (isAuthor) {
|
|
34
|
+
const base = 'error' === type ? 'ERROR Author says' : '►►► Author says';
|
|
35
|
+
return external_pintor_default().brightMagenta(base);
|
|
97
36
|
}
|
|
98
|
-
|
|
99
|
-
|
|
37
|
+
if ('error' === type) return external_pintor_default().red('ERROR');
|
|
38
|
+
if ('warn' === type) return external_pintor_default().brightYellow('►►►');
|
|
39
|
+
if ('info' === type) return external_pintor_default().gray('►►►');
|
|
40
|
+
return external_pintor_default().green('►►►');
|
|
41
|
+
}
|
|
42
|
+
const code = (text)=>external_pintor_default().blue(text);
|
|
43
|
+
const arg = (text)=>external_pintor_default().gray(text);
|
|
44
|
+
const fmt = {
|
|
45
|
+
heading: (title)=>external_pintor_default().underline(external_pintor_default().blue(title)),
|
|
46
|
+
label: (k)=>external_pintor_default().gray(k.toUpperCase()),
|
|
47
|
+
val: (v)=>external_pintor_default().underline(v),
|
|
48
|
+
code: (v)=>external_pintor_default().blue(v),
|
|
49
|
+
bullet: (s)=>`- ${s}`,
|
|
50
|
+
block (title, rows) {
|
|
51
|
+
const head = fmt.heading(title);
|
|
52
|
+
const body = rows.map(([k, v])=>`${fmt.label(k)} ${v}`).join('\n');
|
|
53
|
+
return `${head}\n${body}`;
|
|
54
|
+
},
|
|
55
|
+
truncate (input, max = 800) {
|
|
56
|
+
const s = (()=>{
|
|
57
|
+
try {
|
|
58
|
+
return 'string' == typeof input ? input : JSON.stringify(input);
|
|
59
|
+
} catch {
|
|
60
|
+
return String(input);
|
|
61
|
+
}
|
|
62
|
+
})();
|
|
63
|
+
return s.length > max ? s.slice(0, max) + '…' : s;
|
|
100
64
|
}
|
|
101
|
-
|
|
102
|
-
|
|
65
|
+
};
|
|
66
|
+
const commandDescriptions = {
|
|
67
|
+
create: 'Creates a new extension from a template (React, TypeScript, Vue, Svelte, etc.)',
|
|
68
|
+
dev: 'Starts the development server with hot reloading',
|
|
69
|
+
start: 'Builds and starts the extension in production mode',
|
|
70
|
+
preview: 'Previews the extension in production mode without building',
|
|
71
|
+
build: 'Builds the extension for packaging/distribution',
|
|
72
|
+
cleanup: 'Cleans up orphaned instances and frees unused ports'
|
|
73
|
+
};
|
|
74
|
+
function unhandledError(err) {
|
|
75
|
+
const message = err instanceof Error ? err.stack || err.message : 'string' == typeof err ? err : fmt.truncate(err);
|
|
76
|
+
return `${getLoggingPrefix('error')} ${external_pintor_default().red(String(message || 'Unknown error'))}`;
|
|
77
|
+
}
|
|
78
|
+
function updateFailed(err) {
|
|
79
|
+
return `${getLoggingPrefix('error')} Failed to check for updates.\n${external_pintor_default().red(String(err?.message || err))}`;
|
|
80
|
+
}
|
|
81
|
+
function checkUpdates(packageJson, update) {
|
|
82
|
+
return `${getLoggingPrefix('info')} 🧩 ${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))}.\nUpdate to the latest stable to get fixes and new features.`;
|
|
83
|
+
}
|
|
84
|
+
function programUserHelp() {
|
|
85
|
+
return `\n${getLoggingPrefix('info')} ${external_pintor_default().underline('Help center for the Extension.js program')}
|
|
103
86
|
|
|
104
87
|
Usage: extension [command] [options]
|
|
105
88
|
|
|
@@ -177,12 +160,12 @@ AI Assistants
|
|
|
177
160
|
|
|
178
161
|
Report issues
|
|
179
162
|
- ${external_pintor_default().underline('https://github.com/cezaraugusto/extension/issues/new')}`;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
163
|
+
}
|
|
164
|
+
function unsupportedBrowserFlag(value, supported) {
|
|
165
|
+
return `${getLoggingPrefix('error')} Unsupported --browser value: ${value}. Supported: ${supported.join(', ')}.`;
|
|
166
|
+
}
|
|
167
|
+
function programAIHelp() {
|
|
168
|
+
return `\n${getLoggingPrefix('info')} ${external_pintor_default().gray('Development tips for extension developers and AI assistants')}
|
|
186
169
|
|
|
187
170
|
Browser-Specific Configuration
|
|
188
171
|
- Use browser prefixes in manifest.json for browser-specific fields:
|
|
@@ -209,17 +192,17 @@ Special Folders for Entrypoints
|
|
|
209
192
|
|
|
210
193
|
Predictable Output Paths
|
|
211
194
|
- Core HTML destinations are standardized across browsers so you can reference them safely in code/tests:
|
|
212
|
-
- ${code('devtools_page')}
|
|
213
|
-
- ${code('sidebar_action.default_panel')} (MV2) and ${code('side_panel.default_path')} (MV3)
|
|
214
|
-
- ${code('options_ui.page')} and ${code('options_page')}
|
|
215
|
-
- ${code('background.page')}
|
|
216
|
-
- ${code('action.default_popup')}, ${code('browser_action.default_popup')}, ${code('page_action.default_popup')}
|
|
195
|
+
- ${code('devtools_page')} → ${code('devtools/index.html')}
|
|
196
|
+
- ${code('sidebar_action.default_panel')} (MV2) and ${code('side_panel.default_path')} (MV3) → ${code('sidebar/index.html')}
|
|
197
|
+
- ${code('options_ui.page')} and ${code('options_page')} → ${code('options/index.html')}
|
|
198
|
+
- ${code('background.page')} → ${code('background/index.html')}
|
|
199
|
+
- ${code('action.default_popup')}, ${code('browser_action.default_popup')}, ${code('page_action.default_popup')} → ${code('action/index.html')}
|
|
217
200
|
- Other predictable outputs:
|
|
218
|
-
- ${code('chrome_url_overrides.*')}
|
|
219
|
-
- ${code("content_scripts[n].js/css")}
|
|
220
|
-
- ${code('sandbox.pages[]')}
|
|
221
|
-
- ${code("user_scripts.api_script")}
|
|
222
|
-
- ${code('icons/*')}
|
|
201
|
+
- ${code('chrome_url_overrides.*')} → ${code('chrome_url_overrides/<key>.html')}
|
|
202
|
+
- ${code("content_scripts[n].js/css")} → ${code("content_scripts/content-<n>.{js,css}")}
|
|
203
|
+
- ${code('sandbox.pages[]')} → ${code('sandbox/page-<n>.html')}
|
|
204
|
+
- ${code("user_scripts.api_script")} → ${code("user_scripts/api_script.js")}
|
|
205
|
+
- ${code('icons/*')} → ${code('icons/')} (feature-specific icon folders preserved where applicable)
|
|
223
206
|
|
|
224
207
|
Public & Special Folders (Output Behavior)
|
|
225
208
|
- ${external_pintor_default().underline(code('public/'))} is the web root in output. Authors can use ${code('/foo')}, ${code('/public/foo')}, ${code('public/foo')}, or ${code('./public/foo')} and they all emit as ${code('dist/<browser>/foo')}.
|
|
@@ -315,616 +298,620 @@ Cross-Browser Compatibility
|
|
|
315
298
|
- Use ${code('--polyfill')} flag to enable webextension-polyfill
|
|
316
299
|
- Automatically handles browser API differences
|
|
317
300
|
- Supports Chrome, Edge, Firefox with single codebase`;
|
|
301
|
+
}
|
|
302
|
+
const external_semver_namespaceObject = require("semver");
|
|
303
|
+
function isStableVersion(version) {
|
|
304
|
+
const v = external_semver_namespaceObject.parse(version);
|
|
305
|
+
return Boolean(v && 0 === v.prerelease.length);
|
|
306
|
+
}
|
|
307
|
+
async function check_updates_checkUpdates(packageJson) {
|
|
308
|
+
let update = null;
|
|
309
|
+
try {
|
|
310
|
+
update = await external_update_check_default()(packageJson);
|
|
311
|
+
} catch (err) {
|
|
312
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.error(updateFailed(err));
|
|
318
313
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
if (update && isStableVersion(update.latest)) console.log(checkUpdates(packageJson, update));
|
|
315
|
+
}
|
|
316
|
+
const external_fs_namespaceObject = require("fs");
|
|
317
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
318
|
+
const external_path_namespaceObject = require("path");
|
|
319
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
320
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
321
|
+
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
322
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
323
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
324
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
325
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
326
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
327
|
+
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
328
|
+
function _define_property(obj, key, value) {
|
|
329
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
330
|
+
value: value,
|
|
331
|
+
enumerable: true,
|
|
332
|
+
configurable: true,
|
|
333
|
+
writable: true
|
|
334
|
+
});
|
|
335
|
+
else obj[key] = value;
|
|
336
|
+
return obj;
|
|
337
|
+
}
|
|
338
|
+
function isCI() {
|
|
339
|
+
const v = process.env;
|
|
340
|
+
return Boolean(v.CI || v.GITHUB_ACTIONS || v.GITLAB_CI || v.BUILDKITE || v.CIRCLECI || v.TRAVIS);
|
|
341
|
+
}
|
|
342
|
+
function configDir() {
|
|
343
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
344
|
+
if (xdg) return external_node_path_default().join(xdg, 'extensionjs');
|
|
345
|
+
if ('win32' === process.platform && process.env.APPDATA) return external_node_path_default().join(process.env.APPDATA, 'extensionjs');
|
|
346
|
+
return external_node_path_default().join(external_node_os_default().homedir(), '.config', 'extensionjs');
|
|
347
|
+
}
|
|
348
|
+
function ensureDir(p) {
|
|
349
|
+
if (external_node_fs_default().existsSync(p)) return;
|
|
350
|
+
external_node_fs_default().mkdirSync(p, {
|
|
351
|
+
recursive: true
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function loadOrCreateId(file) {
|
|
355
|
+
if (external_node_fs_default().existsSync(file)) return external_node_fs_default().readFileSync(file, 'utf8').trim();
|
|
356
|
+
const id = external_node_crypto_default().randomUUID();
|
|
357
|
+
ensureDir(external_node_path_default().dirname(file));
|
|
358
|
+
external_node_fs_default().writeFileSync(file, id, 'utf8');
|
|
359
|
+
return id;
|
|
360
|
+
}
|
|
361
|
+
function auditFilePath() {
|
|
362
|
+
const dir = external_node_path_default().join(configDir(), 'telemetry');
|
|
363
|
+
ensureDir(dir);
|
|
364
|
+
return external_node_path_default().join(dir, 'events.jsonl');
|
|
365
|
+
}
|
|
366
|
+
const DEFAULT_FLUSH_AT = Number(process.env.EXTENSION_TELEMETRY_FLUSH_AT || 10);
|
|
367
|
+
const DEFAULT_FLUSH_INTERVAL = Number(process.env.EXTENSION_TELEMETRY_FLUSH_INTERVAL || 2000);
|
|
368
|
+
const DEFAULT_TIMEOUT_MS = Number(process.env.EXTENSION_TELEMETRY_TIMEOUT_MS || 200);
|
|
369
|
+
class Telemetry {
|
|
370
|
+
track(event, props = {}) {
|
|
371
|
+
if (this.disabled) return;
|
|
372
|
+
const payload = {
|
|
373
|
+
event,
|
|
374
|
+
properties: {
|
|
375
|
+
...this.common,
|
|
376
|
+
...props,
|
|
377
|
+
$ip: null
|
|
378
|
+
},
|
|
379
|
+
distinct_id: this.anonId
|
|
380
|
+
};
|
|
381
|
+
external_node_fs_default().appendFileSync(auditFilePath(), JSON.stringify(payload) + '\n');
|
|
382
|
+
if (this.debug) console.error('[telemetry]', JSON.stringify(payload));
|
|
383
|
+
if (!this.apiKey || !this.host) return;
|
|
384
|
+
this.buffer.push(payload);
|
|
385
|
+
if (this.buffer.length >= DEFAULT_FLUSH_AT) return void this.flush();
|
|
386
|
+
if (!this.timer) this.timer = setTimeout(()=>{
|
|
387
|
+
this.timer = null;
|
|
388
|
+
this.flush();
|
|
389
|
+
}, DEFAULT_FLUSH_INTERVAL);
|
|
323
390
|
}
|
|
324
|
-
async
|
|
325
|
-
|
|
391
|
+
async flush() {
|
|
392
|
+
if (this.disabled || !this.apiKey || !this.host) return;
|
|
393
|
+
if (0 === this.buffer.length) return;
|
|
394
|
+
const batch = this.buffer.splice(0, this.buffer.length);
|
|
326
395
|
try {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
335
|
-
const external_path_namespaceObject = require("path");
|
|
336
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
337
|
-
const external_node_os_namespaceObject = require("node:os");
|
|
338
|
-
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
339
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
340
|
-
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
341
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
342
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
343
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
344
|
-
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
345
|
-
function _define_property(obj, key, value) {
|
|
346
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
347
|
-
value: value,
|
|
348
|
-
enumerable: true,
|
|
349
|
-
configurable: true,
|
|
350
|
-
writable: true
|
|
351
|
-
});
|
|
352
|
-
else obj[key] = value;
|
|
353
|
-
return obj;
|
|
354
|
-
}
|
|
355
|
-
function isCI() {
|
|
356
|
-
const v = process.env;
|
|
357
|
-
return Boolean(v.CI || v.GITHUB_ACTIONS || v.GITLAB_CI || v.BUILDKITE || v.CIRCLECI || v.TRAVIS);
|
|
358
|
-
}
|
|
359
|
-
function configDir() {
|
|
360
|
-
const xdg = process.env.XDG_CONFIG_HOME;
|
|
361
|
-
if (xdg) return external_node_path_default().join(xdg, 'extensionjs');
|
|
362
|
-
if ('win32' === process.platform && process.env.APPDATA) return external_node_path_default().join(process.env.APPDATA, 'extensionjs');
|
|
363
|
-
return external_node_path_default().join(external_node_os_default().homedir(), '.config', 'extensionjs');
|
|
364
|
-
}
|
|
365
|
-
function ensureDir(p) {
|
|
366
|
-
if (external_node_fs_default().existsSync(p)) return;
|
|
367
|
-
external_node_fs_default().mkdirSync(p, {
|
|
368
|
-
recursive: true
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
function loadOrCreateId(file) {
|
|
372
|
-
if (external_node_fs_default().existsSync(file)) return external_node_fs_default().readFileSync(file, 'utf8').trim();
|
|
373
|
-
const id = external_node_crypto_default().randomUUID();
|
|
374
|
-
ensureDir(external_node_path_default().dirname(file));
|
|
375
|
-
external_node_fs_default().writeFileSync(file, id, 'utf8');
|
|
376
|
-
return id;
|
|
377
|
-
}
|
|
378
|
-
function auditFilePath() {
|
|
379
|
-
const dir = external_node_path_default().join(configDir(), 'telemetry');
|
|
380
|
-
ensureDir(dir);
|
|
381
|
-
return external_node_path_default().join(dir, 'events.jsonl');
|
|
382
|
-
}
|
|
383
|
-
const DEFAULT_FLUSH_AT = Number(process.env.EXTENSION_TELEMETRY_FLUSH_AT || 10);
|
|
384
|
-
const DEFAULT_FLUSH_INTERVAL = Number(process.env.EXTENSION_TELEMETRY_FLUSH_INTERVAL || 2000);
|
|
385
|
-
const DEFAULT_TIMEOUT_MS = Number(process.env.EXTENSION_TELEMETRY_TIMEOUT_MS || 200);
|
|
386
|
-
class Telemetry {
|
|
387
|
-
track(event, props = {}) {
|
|
388
|
-
if (this.disabled) return;
|
|
389
|
-
const payload = {
|
|
390
|
-
event,
|
|
391
|
-
properties: {
|
|
392
|
-
...this.common,
|
|
393
|
-
...props,
|
|
394
|
-
$ip: null
|
|
396
|
+
const ac = new AbortController();
|
|
397
|
+
const t = setTimeout(()=>ac.abort(), DEFAULT_TIMEOUT_MS);
|
|
398
|
+
const url = new URL('/capture/', this.host);
|
|
399
|
+
await fetch(url.toString(), {
|
|
400
|
+
method: 'POST',
|
|
401
|
+
headers: {
|
|
402
|
+
'content-type': 'application/json'
|
|
395
403
|
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (this.disabled || !this.apiKey || !this.host) return;
|
|
410
|
-
if (0 === this.buffer.length) return;
|
|
411
|
-
const batch = this.buffer.splice(0, this.buffer.length);
|
|
412
|
-
try {
|
|
413
|
-
const ac = new AbortController();
|
|
414
|
-
const t = setTimeout(()=>ac.abort(), DEFAULT_TIMEOUT_MS);
|
|
415
|
-
const url = new URL('/capture/', this.host);
|
|
416
|
-
await fetch(url.toString(), {
|
|
417
|
-
method: 'POST',
|
|
418
|
-
headers: {
|
|
419
|
-
'content-type': 'application/json'
|
|
420
|
-
},
|
|
421
|
-
body: JSON.stringify({
|
|
422
|
-
api_key: this.apiKey,
|
|
423
|
-
batch: batch.map((e)=>({
|
|
424
|
-
event: e.event,
|
|
425
|
-
properties: e.properties,
|
|
426
|
-
distinct_id: e.distinct_id
|
|
427
|
-
}))
|
|
428
|
-
}),
|
|
429
|
-
signal: ac.signal,
|
|
430
|
-
keepalive: true
|
|
431
|
-
}).catch(()=>{});
|
|
432
|
-
clearTimeout(t);
|
|
433
|
-
} catch {}
|
|
434
|
-
}
|
|
435
|
-
shutdown() {}
|
|
436
|
-
constructor(init){
|
|
437
|
-
_define_property(this, "anonId", void 0);
|
|
438
|
-
_define_property(this, "common", void 0);
|
|
439
|
-
_define_property(this, "debug", void 0);
|
|
440
|
-
_define_property(this, "disabled", void 0);
|
|
441
|
-
_define_property(this, "apiKey", void 0);
|
|
442
|
-
_define_property(this, "host", void 0);
|
|
443
|
-
_define_property(this, "buffer", []);
|
|
444
|
-
_define_property(this, "timer", null);
|
|
445
|
-
this.debug = '1' === process.env.EXTENSION_TELEMETRY_DEBUG;
|
|
446
|
-
this.disabled = Boolean(init.disabled);
|
|
447
|
-
this.anonId = 'disabled';
|
|
448
|
-
if (!this.disabled) {
|
|
449
|
-
const idFile = external_node_path_default().join(configDir(), 'telemetry', 'anonymous-id');
|
|
450
|
-
this.anonId = loadOrCreateId(idFile);
|
|
451
|
-
}
|
|
452
|
-
this.common = {
|
|
453
|
-
app: init.app,
|
|
454
|
-
version: init.version,
|
|
455
|
-
os: process.platform,
|
|
456
|
-
arch: process.arch,
|
|
457
|
-
node: process.versions.node,
|
|
458
|
-
is_ci: isCI(),
|
|
459
|
-
schema_version: 1
|
|
460
|
-
};
|
|
461
|
-
this.apiKey = init.apiKey || process.env.EXTENSION_PUBLIC_POSTHOG_KEY;
|
|
462
|
-
this.host = init.host || process.env.EXTENSION_PUBLIC_POSTHOG_HOST;
|
|
463
|
-
if (!this.disabled) {
|
|
464
|
-
const consentPath = external_node_path_default().join(configDir(), 'telemetry', 'consent');
|
|
465
|
-
if (!external_node_fs_default().existsSync(consentPath)) {
|
|
466
|
-
external_node_fs_default().writeFileSync(consentPath, 'ok', 'utf8');
|
|
467
|
-
this.track('cli_telemetry_consent', {
|
|
468
|
-
value: 'implicit_opt_in'
|
|
469
|
-
});
|
|
470
|
-
console.log(`${external_pintor_default().gray("\u25BA\u25BA\u25BA system")} [extension] anonymous telemetry helps us improve. Pass --no-telemetry to opt out. Read more in TELEMETRY.md.`);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
404
|
+
body: JSON.stringify({
|
|
405
|
+
api_key: this.apiKey,
|
|
406
|
+
batch: batch.map((e)=>({
|
|
407
|
+
event: e.event,
|
|
408
|
+
properties: e.properties,
|
|
409
|
+
distinct_id: e.distinct_id
|
|
410
|
+
}))
|
|
411
|
+
}),
|
|
412
|
+
signal: ac.signal,
|
|
413
|
+
keepalive: true
|
|
414
|
+
}).catch(()=>{});
|
|
415
|
+
clearTimeout(t);
|
|
416
|
+
} catch {}
|
|
474
417
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
background_type: backgroundType,
|
|
501
|
-
content_scripts_count: contentScriptsCount,
|
|
502
|
-
has_devtools_page: hasDevtoolsPage,
|
|
503
|
-
has_action_popup: hasActionPopup
|
|
418
|
+
shutdown() {}
|
|
419
|
+
constructor(init){
|
|
420
|
+
_define_property(this, "anonId", void 0);
|
|
421
|
+
_define_property(this, "common", void 0);
|
|
422
|
+
_define_property(this, "debug", void 0);
|
|
423
|
+
_define_property(this, "disabled", void 0);
|
|
424
|
+
_define_property(this, "apiKey", void 0);
|
|
425
|
+
_define_property(this, "host", void 0);
|
|
426
|
+
_define_property(this, "buffer", []);
|
|
427
|
+
_define_property(this, "timer", null);
|
|
428
|
+
this.debug = '1' === process.env.EXTENSION_TELEMETRY_DEBUG;
|
|
429
|
+
this.disabled = Boolean(init.disabled);
|
|
430
|
+
this.anonId = 'disabled';
|
|
431
|
+
if (!this.disabled) {
|
|
432
|
+
const idFile = external_node_path_default().join(configDir(), 'telemetry', 'anonymous-id');
|
|
433
|
+
this.anonId = loadOrCreateId(idFile);
|
|
434
|
+
}
|
|
435
|
+
this.common = {
|
|
436
|
+
app: init.app,
|
|
437
|
+
version: init.version,
|
|
438
|
+
os: process.platform,
|
|
439
|
+
arch: process.arch,
|
|
440
|
+
node: process.versions.node,
|
|
441
|
+
is_ci: isCI(),
|
|
442
|
+
schema_version: 1
|
|
504
443
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
];
|
|
514
|
-
while(stack.length > 0){
|
|
515
|
-
const dir = stack.pop();
|
|
516
|
-
if (!dir) continue;
|
|
517
|
-
let entries;
|
|
518
|
-
try {
|
|
519
|
-
entries = external_fs_default().readdirSync(dir, {
|
|
520
|
-
withFileTypes: true
|
|
444
|
+
this.apiKey = init.apiKey || process.env.EXTENSION_PUBLIC_POSTHOG_KEY;
|
|
445
|
+
this.host = init.host || process.env.EXTENSION_PUBLIC_POSTHOG_HOST;
|
|
446
|
+
if (!this.disabled) {
|
|
447
|
+
const consentPath = external_node_path_default().join(configDir(), 'telemetry', 'consent');
|
|
448
|
+
if (!external_node_fs_default().existsSync(consentPath)) {
|
|
449
|
+
external_node_fs_default().writeFileSync(consentPath, 'ok', 'utf8');
|
|
450
|
+
this.track('cli_telemetry_consent', {
|
|
451
|
+
value: 'implicit_opt_in'
|
|
521
452
|
});
|
|
522
|
-
|
|
523
|
-
continue;
|
|
524
|
-
}
|
|
525
|
-
for (const entry of entries){
|
|
526
|
-
if (entry.isFile() && 'manifest.json' === entry.name) return external_path_default().join(dir, entry.name);
|
|
527
|
-
if (entry.isDirectory() && !entry.name.startsWith('.') && 'node_modules' !== entry.name && 'dist' !== entry.name) stack.push(external_path_default().join(dir, entry.name));
|
|
453
|
+
console.log(`${external_pintor_default().gray('►►► system')} [extension] anonymous telemetry helps us improve. Pass --no-telemetry to opt out. Read more in TELEMETRY.md.`);
|
|
528
454
|
}
|
|
529
455
|
}
|
|
530
|
-
return null;
|
|
531
456
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
457
|
+
}
|
|
458
|
+
function summarizeManifest(manifest) {
|
|
459
|
+
const mv = manifest?.manifest_version === 2 ? 2 : 3;
|
|
460
|
+
const permissions = Array.isArray(manifest?.permissions) ? manifest.permissions : [];
|
|
461
|
+
const optionalPermissions = Array.isArray(manifest?.optional_permissions) ? manifest.optional_permissions : [];
|
|
462
|
+
const hostPermissions = Array.isArray(manifest?.host_permissions) ? manifest.host_permissions : [];
|
|
463
|
+
const usesAllUrls = [
|
|
464
|
+
...permissions,
|
|
465
|
+
...hostPermissions
|
|
466
|
+
].includes('<all_urls>');
|
|
467
|
+
const usesDeclarativeNetRequest = permissions.includes('declarativeNetRequest') || permissions.includes('declarativeNetRequestWithHostAccess');
|
|
468
|
+
const background = manifest?.background;
|
|
469
|
+
let backgroundType = 'none';
|
|
470
|
+
if (3 === mv && background?.service_worker) backgroundType = 'service_worker';
|
|
471
|
+
else if (2 === mv && (Array.isArray(background?.scripts) && background.scripts.length > 0 || background?.page)) backgroundType = 'event_page';
|
|
472
|
+
const contentScriptsCount = Array.isArray(manifest?.content_scripts) ? manifest.content_scripts.length : 0;
|
|
473
|
+
const hasDevtoolsPage = Boolean(manifest?.devtools_page);
|
|
474
|
+
const hasActionPopup = Boolean(manifest?.action?.default_popup);
|
|
475
|
+
return {
|
|
476
|
+
mv,
|
|
477
|
+
permissions_count: permissions.length,
|
|
478
|
+
optional_permissions_count: optionalPermissions.length,
|
|
479
|
+
host_permissions_count: hostPermissions.length,
|
|
480
|
+
uses_all_urls: usesAllUrls,
|
|
481
|
+
uses_declarative_net_request: usesDeclarativeNetRequest,
|
|
482
|
+
background_type: backgroundType,
|
|
483
|
+
content_scripts_count: contentScriptsCount,
|
|
484
|
+
has_devtools_page: hasDevtoolsPage,
|
|
485
|
+
has_action_popup: hasActionPopup
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
function isTelemetryDisabledFromArgs(argv) {
|
|
489
|
+
return argv.includes('--no-telemetry');
|
|
490
|
+
}
|
|
491
|
+
const telemetryDisabled = isTelemetryDisabledFromArgs(process.argv);
|
|
492
|
+
function findManifestJson(projectRoot) {
|
|
493
|
+
const stack = [
|
|
494
|
+
projectRoot
|
|
495
|
+
];
|
|
496
|
+
while(stack.length > 0){
|
|
497
|
+
const dir = stack.pop();
|
|
498
|
+
if (!dir) continue;
|
|
499
|
+
let entries;
|
|
500
|
+
try {
|
|
501
|
+
entries = external_fs_default().readdirSync(dir, {
|
|
502
|
+
withFileTypes: true
|
|
563
503
|
});
|
|
564
|
-
|
|
504
|
+
} catch {
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
for (const entry of entries){
|
|
508
|
+
if (entry.isFile() && 'manifest.json' === entry.name) return external_path_default().join(dir, entry.name);
|
|
509
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && 'node_modules' !== entry.name && 'dist' !== entry.name) stack.push(external_path_default().join(dir, entry.name));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
const telemetry_cli_telemetry = new Telemetry({
|
|
515
|
+
app: 'extension',
|
|
516
|
+
version: package_namespaceObject.version,
|
|
517
|
+
disabled: telemetryDisabled
|
|
518
|
+
});
|
|
519
|
+
if (!telemetryDisabled) {
|
|
520
|
+
const startedAt = Date.now();
|
|
521
|
+
const known = new Set([
|
|
522
|
+
'create',
|
|
523
|
+
'dev',
|
|
524
|
+
'start',
|
|
525
|
+
'preview',
|
|
526
|
+
'build',
|
|
527
|
+
'cleanup'
|
|
528
|
+
]);
|
|
529
|
+
const invoked = process.argv.slice(2).find((a)=>known.has(a)) || 'unknown';
|
|
530
|
+
telemetry_cli_telemetry.track('cli_boot', {
|
|
531
|
+
command_guess: invoked
|
|
532
|
+
});
|
|
533
|
+
const manifestPath = findManifestJson(process.cwd());
|
|
534
|
+
if (manifestPath) {
|
|
535
|
+
const raw = external_fs_default().readFileSync(manifestPath, 'utf8');
|
|
536
|
+
const json = JSON.parse(raw);
|
|
537
|
+
const summary = summarizeManifest(json);
|
|
538
|
+
telemetry_cli_telemetry.track('manifest_summary', summary);
|
|
539
|
+
}
|
|
540
|
+
process.on('beforeExit', async function() {
|
|
541
|
+
telemetry_cli_telemetry.track('cli_shutdown', {
|
|
542
|
+
command_guess: invoked,
|
|
543
|
+
duration_ms: Date.now() - startedAt,
|
|
544
|
+
exit_code: process.exitCode ?? 0
|
|
565
545
|
});
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
546
|
+
await telemetry_cli_telemetry.flush();
|
|
547
|
+
});
|
|
548
|
+
process.on('uncaughtException', function(err) {
|
|
549
|
+
telemetry_cli_telemetry.track('cli_error', {
|
|
550
|
+
command_guess: invoked,
|
|
551
|
+
error_name: String(err?.name || 'Error').slice(0, 64)
|
|
571
552
|
});
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
553
|
+
});
|
|
554
|
+
process.on('unhandledRejection', function(reason) {
|
|
555
|
+
telemetry_cli_telemetry.track('cli_error', {
|
|
556
|
+
command_guess: invoked,
|
|
557
|
+
error_name: String(reason?.name || 'PromiseRejection').slice(0, 64)
|
|
577
558
|
});
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
require("node:url");
|
|
562
|
+
function parseOptionalBoolean(value) {
|
|
563
|
+
if (void 0 === value) return true;
|
|
564
|
+
const normalized = String(value).trim().toLowerCase();
|
|
565
|
+
return ![
|
|
566
|
+
'false',
|
|
567
|
+
'0',
|
|
568
|
+
'no',
|
|
569
|
+
'off'
|
|
570
|
+
].includes(normalized);
|
|
571
|
+
}
|
|
572
|
+
const vendors = (browser)=>{
|
|
573
|
+
const value = browser ?? 'chromium';
|
|
574
|
+
return 'all' === value ? [
|
|
575
|
+
'chrome',
|
|
576
|
+
'edge',
|
|
577
|
+
'firefox'
|
|
578
|
+
] : String(value).split(',');
|
|
579
|
+
};
|
|
580
|
+
function validateVendorsOrExit(vendorsList, onInvalid) {
|
|
581
|
+
const supported = [
|
|
582
|
+
'chrome',
|
|
583
|
+
'edge',
|
|
584
|
+
'firefox',
|
|
585
|
+
'chromium',
|
|
586
|
+
'chromium-based',
|
|
587
|
+
'gecko-based',
|
|
588
|
+
'firefox-based'
|
|
589
|
+
];
|
|
590
|
+
for (const v of vendorsList)if (!supported.includes(v)) {
|
|
591
|
+
onInvalid(v, supported);
|
|
592
|
+
process.exit(1);
|
|
578
593
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
'
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
'firefox'
|
|
597
|
-
] : String(value).split(',');
|
|
598
|
-
};
|
|
599
|
-
function validateVendorsOrExit(vendorsList, onInvalid) {
|
|
600
|
-
const supported = [
|
|
601
|
-
'chrome',
|
|
602
|
-
'edge',
|
|
603
|
-
'firefox',
|
|
604
|
-
'chromium',
|
|
605
|
-
'chromium-based',
|
|
606
|
-
'gecko-based',
|
|
607
|
-
'firefox-based'
|
|
608
|
-
];
|
|
609
|
-
for (const v of vendorsList)if (!supported.includes(v)) {
|
|
610
|
-
onInvalid(v, supported);
|
|
611
|
-
process.exit(1);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
function registerCreateCommand(program, telemetry) {
|
|
615
|
-
program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description(commandDescriptions.create).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 }) {
|
|
616
|
-
const startedAt = Date.now();
|
|
617
|
-
telemetry.track('cli_command_start', {
|
|
618
|
-
command: 'create',
|
|
619
|
-
template: template || 'default',
|
|
620
|
-
install: Boolean(install)
|
|
594
|
+
}
|
|
595
|
+
function registerCreateCommand(program, telemetry) {
|
|
596
|
+
program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description(commandDescriptions.create).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 (enabled by default)', parseOptionalBoolean, true).action(async function(pathOrRemoteUrl, { template, install }) {
|
|
597
|
+
const startedAt = Date.now();
|
|
598
|
+
telemetry.track('cli_command_start', {
|
|
599
|
+
command: 'create',
|
|
600
|
+
template: template || 'default',
|
|
601
|
+
install: Boolean(install)
|
|
602
|
+
});
|
|
603
|
+
try {
|
|
604
|
+
const { extensionCreate } = await import("extension-create");
|
|
605
|
+
const { ensureDependencies, preflightOptionalDependenciesForProject } = await import("extension-develop");
|
|
606
|
+
const projectPath = external_path_namespaceObject.isAbsolute(pathOrRemoteUrl) ? pathOrRemoteUrl : external_path_namespaceObject.join(process.cwd(), pathOrRemoteUrl);
|
|
607
|
+
await extensionCreate(pathOrRemoteUrl, {
|
|
608
|
+
template,
|
|
609
|
+
install,
|
|
610
|
+
cliVersion: package_namespaceObject.version
|
|
621
611
|
});
|
|
622
|
-
|
|
623
|
-
await (
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
cliVersion: package_namespaceObject.version
|
|
627
|
-
});
|
|
628
|
-
telemetry.track('cli_command_finish', {
|
|
629
|
-
command: 'create',
|
|
630
|
-
duration_ms: Date.now() - startedAt,
|
|
631
|
-
success: true,
|
|
632
|
-
exit_code: 0
|
|
612
|
+
if (install) {
|
|
613
|
+
await ensureDependencies(projectPath, {
|
|
614
|
+
skipProjectInstall: true,
|
|
615
|
+
showRunAgainMessage: false
|
|
633
616
|
});
|
|
634
|
-
|
|
635
|
-
telemetry.track('cli_command_finish', {
|
|
636
|
-
command: 'create',
|
|
637
|
-
duration_ms: Date.now() - startedAt,
|
|
638
|
-
success: false,
|
|
639
|
-
exit_code: 1
|
|
640
|
-
});
|
|
641
|
-
throw err;
|
|
617
|
+
await preflightOptionalDependenciesForProject(projectPath, 'development');
|
|
642
618
|
}
|
|
619
|
+
telemetry.track('cli_command_finish', {
|
|
620
|
+
command: 'create',
|
|
621
|
+
duration_ms: Date.now() - startedAt,
|
|
622
|
+
success: true,
|
|
623
|
+
exit_code: 0
|
|
624
|
+
});
|
|
625
|
+
} catch (err) {
|
|
626
|
+
telemetry.track('cli_command_finish', {
|
|
627
|
+
command: 'create',
|
|
628
|
+
duration_ms: Date.now() - startedAt,
|
|
629
|
+
success: false,
|
|
630
|
+
exit_code: 1
|
|
631
|
+
});
|
|
632
|
+
throw err;
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
function normalizeSourceOption(source, startingUrl) {
|
|
637
|
+
if (!source) return;
|
|
638
|
+
const hasExplicitSourceString = 'string' == typeof source && 'true' !== String(source).trim().toLowerCase();
|
|
639
|
+
const hasStartingUrl = 'string' == typeof startingUrl && String(startingUrl).trim().length > 0;
|
|
640
|
+
if (!hasExplicitSourceString) return hasStartingUrl ? String(startingUrl) : 'https://example.com';
|
|
641
|
+
return String(source);
|
|
642
|
+
}
|
|
643
|
+
function parseLogContexts(raw) {
|
|
644
|
+
if (!raw || 0 === String(raw).trim().length) return;
|
|
645
|
+
if ('all' === String(raw).trim().toLowerCase()) return;
|
|
646
|
+
const allowed = [
|
|
647
|
+
'background',
|
|
648
|
+
'content',
|
|
649
|
+
'page',
|
|
650
|
+
'sidebar',
|
|
651
|
+
'popup',
|
|
652
|
+
'options',
|
|
653
|
+
'devtools'
|
|
654
|
+
];
|
|
655
|
+
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
656
|
+
return values.length > 0 ? values : void 0;
|
|
657
|
+
}
|
|
658
|
+
function registerDevCommand(program, telemetry) {
|
|
659
|
+
program.command('dev').arguments('[project-path|remote-url]').usage('dev [project-path|remote-url] [options]').description(commandDescriptions.dev).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 }) {
|
|
660
|
+
if (devOptions.author || devOptions['authorMode']) {
|
|
661
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
662
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
663
|
+
}
|
|
664
|
+
const cmdStart = Date.now();
|
|
665
|
+
telemetry.track('cli_command_start', {
|
|
666
|
+
command: 'dev',
|
|
667
|
+
vendors: vendors(browser),
|
|
668
|
+
polyfill_used: devOptions.polyfill?.toString() !== 'false',
|
|
669
|
+
log_level: devOptions.logLevel || 'off',
|
|
670
|
+
log_format: devOptions.logFormat || 'pretty',
|
|
671
|
+
custom_binary_used: Boolean(devOptions.chromiumBinary || devOptions.geckoBinary)
|
|
643
672
|
});
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
'
|
|
657
|
-
'content',
|
|
658
|
-
'page',
|
|
659
|
-
'sidebar',
|
|
660
|
-
'popup',
|
|
661
|
-
'options',
|
|
662
|
-
'devtools'
|
|
663
|
-
];
|
|
664
|
-
const values = String(raw).split(',').map((s)=>s.trim()).filter((s)=>s.length > 0).filter((c)=>allowed.includes(c));
|
|
665
|
-
return values.length > 0 ? values : void 0;
|
|
666
|
-
}
|
|
667
|
-
function registerDevCommand(program, telemetry) {
|
|
668
|
-
program.command('dev').arguments('[project-path|remote-url]').usage('dev [project-path|remote-url] [options]').description(commandDescriptions.dev).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 }) {
|
|
669
|
-
var _devOptions_polyfill;
|
|
670
|
-
if (devOptions.author || devOptions['authorMode']) {
|
|
671
|
-
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
672
|
-
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
673
|
-
}
|
|
674
|
-
const cmdStart = Date.now();
|
|
675
|
-
telemetry.track('cli_command_start', {
|
|
673
|
+
const list = vendors(browser);
|
|
674
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
675
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
676
|
+
});
|
|
677
|
+
const normalizedSource = normalizeSourceOption(devOptions.source, devOptions.startingUrl);
|
|
678
|
+
if (normalizedSource) {
|
|
679
|
+
devOptions.source = normalizedSource;
|
|
680
|
+
devOptions.watchSource = true;
|
|
681
|
+
}
|
|
682
|
+
const { extensionDev } = await import("extension-develop");
|
|
683
|
+
for (const vendor of list){
|
|
684
|
+
const vendorStart = Date.now();
|
|
685
|
+
telemetry.track('cli_vendor_start', {
|
|
676
686
|
command: 'dev',
|
|
677
|
-
|
|
678
|
-
polyfill_used: (null == (_devOptions_polyfill = devOptions.polyfill) ? void 0 : _devOptions_polyfill.toString()) !== 'false',
|
|
679
|
-
log_level: devOptions.logLevel || 'off',
|
|
680
|
-
log_format: devOptions.logFormat || 'pretty',
|
|
681
|
-
custom_binary_used: Boolean(devOptions.chromiumBinary || devOptions.geckoBinary)
|
|
682
|
-
});
|
|
683
|
-
const list = vendors(browser);
|
|
684
|
-
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
685
|
-
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
687
|
+
vendor
|
|
686
688
|
});
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
devOptions
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
startingUrl: devOptions.startingUrl,
|
|
711
|
-
source: devOptions.source,
|
|
712
|
-
watchSource: devOptions.watchSource,
|
|
713
|
-
logLevel: logsOption || devOptions.logLevel || 'off',
|
|
714
|
-
logContexts: parseLogContexts(logContextOption),
|
|
715
|
-
logFormat: devOptions.logFormat || 'pretty',
|
|
716
|
-
logTimestamps: false !== devOptions.logTimestamps,
|
|
717
|
-
logColor: false !== devOptions.logColor,
|
|
718
|
-
logUrl: devOptions.logUrl,
|
|
719
|
-
logTab: devOptions.logTab
|
|
720
|
-
};
|
|
721
|
-
await extensionDev(pathOrRemoteUrl, devArgs);
|
|
722
|
-
telemetry.track('cli_vendor_finish', {
|
|
723
|
-
command: 'dev',
|
|
724
|
-
vendor,
|
|
725
|
-
duration_ms: Date.now() - vendorStart
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
telemetry.track('cli_command_finish', {
|
|
689
|
+
const logsOption = devOptions.logs;
|
|
690
|
+
const logContextOption = devOptions.logContext;
|
|
691
|
+
const devArgs = {
|
|
692
|
+
...devOptions,
|
|
693
|
+
profile: devOptions.profile,
|
|
694
|
+
browser: vendor,
|
|
695
|
+
chromiumBinary: devOptions.chromiumBinary,
|
|
696
|
+
geckoBinary: devOptions.geckoBinary,
|
|
697
|
+
polyfill: devOptions.polyfill?.toString() !== 'false',
|
|
698
|
+
open: devOptions.open,
|
|
699
|
+
startingUrl: devOptions.startingUrl,
|
|
700
|
+
source: devOptions.source,
|
|
701
|
+
watchSource: devOptions.watchSource,
|
|
702
|
+
logLevel: logsOption || devOptions.logLevel || 'off',
|
|
703
|
+
logContexts: parseLogContexts(logContextOption),
|
|
704
|
+
logFormat: devOptions.logFormat || 'pretty',
|
|
705
|
+
logTimestamps: false !== devOptions.logTimestamps,
|
|
706
|
+
logColor: false !== devOptions.logColor,
|
|
707
|
+
logUrl: devOptions.logUrl,
|
|
708
|
+
logTab: devOptions.logTab
|
|
709
|
+
};
|
|
710
|
+
await extensionDev(pathOrRemoteUrl, devArgs);
|
|
711
|
+
telemetry.track('cli_vendor_finish', {
|
|
729
712
|
command: 'dev',
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
exit_code: process.exitCode ?? 0
|
|
713
|
+
vendor,
|
|
714
|
+
duration_ms: Date.now() - vendorStart
|
|
733
715
|
});
|
|
716
|
+
}
|
|
717
|
+
telemetry.track('cli_command_finish', {
|
|
718
|
+
command: 'dev',
|
|
719
|
+
duration_ms: Date.now() - cmdStart,
|
|
720
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
721
|
+
exit_code: process.exitCode ?? 0
|
|
734
722
|
});
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
function registerStartCommand(program, telemetry) {
|
|
726
|
+
program.command('start').arguments('[project-path|remote-url]').usage('start [project-path|remote-url] [options]').description(commandDescriptions.start).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 }) {
|
|
727
|
+
if (startOptions.author || startOptions.authorMode) {
|
|
728
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
729
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
730
|
+
}
|
|
731
|
+
const cmdStart = Date.now();
|
|
732
|
+
telemetry.track('cli_command_start', {
|
|
733
|
+
command: 'start',
|
|
734
|
+
vendors: vendors(browser),
|
|
735
|
+
polyfill_used: startOptions.polyfill?.toString() !== 'false'
|
|
736
|
+
});
|
|
737
|
+
const list = vendors(browser);
|
|
738
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
739
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
740
|
+
});
|
|
741
|
+
const { extensionStart } = await import("extension-develop");
|
|
742
|
+
for (const vendor of list){
|
|
743
|
+
const vendorStart = Date.now();
|
|
744
|
+
telemetry.track('cli_vendor_start', {
|
|
745
745
|
command: 'start',
|
|
746
|
-
|
|
747
|
-
polyfill_used: (null == (_startOptions_polyfill = startOptions.polyfill) ? void 0 : _startOptions_polyfill.toString()) !== 'false'
|
|
746
|
+
vendor
|
|
748
747
|
});
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
748
|
+
const logsOption = startOptions.logs;
|
|
749
|
+
const logContextOption = startOptions.logContext;
|
|
750
|
+
const logContexts = parseLogContexts(logContextOption);
|
|
751
|
+
await extensionStart(pathOrRemoteUrl, {
|
|
752
|
+
mode: 'production',
|
|
753
|
+
profile: startOptions.profile,
|
|
754
|
+
browser: vendor,
|
|
755
|
+
chromiumBinary: startOptions.chromiumBinary,
|
|
756
|
+
geckoBinary: startOptions.geckoBinary,
|
|
757
|
+
startingUrl: startOptions.startingUrl,
|
|
758
|
+
port: startOptions.port,
|
|
759
|
+
source: 'string' == typeof startOptions.source ? startOptions.source : startOptions.source,
|
|
760
|
+
watchSource: startOptions.watchSource,
|
|
761
|
+
logLevel: logsOption || startOptions.logLevel || 'off',
|
|
762
|
+
logContexts,
|
|
763
|
+
logFormat: startOptions.logFormat || 'pretty',
|
|
764
|
+
logTimestamps: false !== startOptions.logTimestamps,
|
|
765
|
+
logColor: false !== startOptions.logColor,
|
|
766
|
+
logUrl: startOptions.logUrl,
|
|
767
|
+
logTab: startOptions.logTab
|
|
752
768
|
});
|
|
753
|
-
|
|
754
|
-
for (const vendor of list){
|
|
755
|
-
const vendorStart = Date.now();
|
|
756
|
-
telemetry.track('cli_vendor_start', {
|
|
757
|
-
command: 'start',
|
|
758
|
-
vendor
|
|
759
|
-
});
|
|
760
|
-
const logsOption = startOptions.logs;
|
|
761
|
-
const logContextOption = startOptions.logContext;
|
|
762
|
-
const logContexts = parseLogContexts(logContextOption);
|
|
763
|
-
await extensionStart(pathOrRemoteUrl, {
|
|
764
|
-
mode: 'production',
|
|
765
|
-
profile: startOptions.profile,
|
|
766
|
-
browser: vendor,
|
|
767
|
-
chromiumBinary: startOptions.chromiumBinary,
|
|
768
|
-
geckoBinary: startOptions.geckoBinary,
|
|
769
|
-
startingUrl: startOptions.startingUrl,
|
|
770
|
-
port: startOptions.port,
|
|
771
|
-
source: 'string' == typeof startOptions.source ? startOptions.source : startOptions.source,
|
|
772
|
-
watchSource: startOptions.watchSource,
|
|
773
|
-
logLevel: logsOption || startOptions.logLevel || 'off',
|
|
774
|
-
logContexts,
|
|
775
|
-
logFormat: startOptions.logFormat || 'pretty',
|
|
776
|
-
logTimestamps: false !== startOptions.logTimestamps,
|
|
777
|
-
logColor: false !== startOptions.logColor,
|
|
778
|
-
logUrl: startOptions.logUrl,
|
|
779
|
-
logTab: startOptions.logTab
|
|
780
|
-
});
|
|
781
|
-
telemetry.track('cli_vendor_finish', {
|
|
782
|
-
command: 'start',
|
|
783
|
-
vendor,
|
|
784
|
-
duration_ms: Date.now() - vendorStart
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
telemetry.track('cli_command_finish', {
|
|
769
|
+
telemetry.track('cli_vendor_finish', {
|
|
788
770
|
command: 'start',
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
exit_code: process.exitCode ?? 0
|
|
771
|
+
vendor,
|
|
772
|
+
duration_ms: Date.now() - vendorStart
|
|
792
773
|
});
|
|
774
|
+
}
|
|
775
|
+
telemetry.track('cli_command_finish', {
|
|
776
|
+
command: 'start',
|
|
777
|
+
duration_ms: Date.now() - cmdStart,
|
|
778
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
779
|
+
exit_code: process.exitCode ?? 0
|
|
793
780
|
});
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
function registerPreviewCommand(program, telemetry) {
|
|
784
|
+
program.command('preview').arguments('[project-name]').usage('preview [path-to-remote-extension] [options]').description(commandDescriptions.preview).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 }) {
|
|
785
|
+
if (previewOptions.author || previewOptions['authorMode']) {
|
|
786
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
787
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
788
|
+
}
|
|
789
|
+
const cmdStart = Date.now();
|
|
790
|
+
telemetry.track('cli_command_start', {
|
|
791
|
+
command: 'preview',
|
|
792
|
+
vendors: vendors(browser)
|
|
793
|
+
});
|
|
794
|
+
const list = vendors(browser);
|
|
795
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
796
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
797
|
+
});
|
|
798
|
+
if (!process.env.EXTJS_LIGHT) {
|
|
799
|
+
const isRemote = 'string' == typeof pathOrRemoteUrl && /^https?:/i.test(pathOrRemoteUrl);
|
|
800
|
+
if (isRemote) process.env.EXTJS_LIGHT = '1';
|
|
801
|
+
}
|
|
802
|
+
const { extensionPreview } = await import("extension-develop");
|
|
803
|
+
for (const vendor of list){
|
|
804
|
+
const vendorStart = Date.now();
|
|
805
|
+
telemetry.track('cli_vendor_start', {
|
|
803
806
|
command: 'preview',
|
|
804
|
-
|
|
807
|
+
vendor
|
|
805
808
|
});
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
809
|
+
const logsOption = previewOptions.logs;
|
|
810
|
+
const logContextOption = previewOptions.logContext;
|
|
811
|
+
const logContexts = parseLogContexts(logContextOption);
|
|
812
|
+
await extensionPreview(pathOrRemoteUrl, {
|
|
813
|
+
mode: 'production',
|
|
814
|
+
profile: previewOptions.profile,
|
|
815
|
+
browser: vendor,
|
|
816
|
+
chromiumBinary: previewOptions.chromiumBinary,
|
|
817
|
+
geckoBinary: previewOptions.geckoBinary,
|
|
818
|
+
startingUrl: previewOptions.startingUrl,
|
|
819
|
+
port: previewOptions.port,
|
|
820
|
+
source: 'string' == typeof previewOptions.source ? previewOptions.source : previewOptions.source,
|
|
821
|
+
watchSource: previewOptions.watchSource,
|
|
822
|
+
logLevel: logsOption || previewOptions.logLevel || 'off',
|
|
823
|
+
logContexts,
|
|
824
|
+
logFormat: previewOptions.logFormat || 'pretty',
|
|
825
|
+
logTimestamps: false !== previewOptions.logTimestamps,
|
|
826
|
+
logColor: false !== previewOptions.logColor,
|
|
827
|
+
logUrl: previewOptions.logUrl,
|
|
828
|
+
logTab: previewOptions.logTab
|
|
809
829
|
});
|
|
810
|
-
|
|
811
|
-
const isRemote = 'string' == typeof pathOrRemoteUrl && /^https?:/i.test(pathOrRemoteUrl);
|
|
812
|
-
if (isRemote) process.env.EXTJS_LIGHT = '1';
|
|
813
|
-
}
|
|
814
|
-
const { extensionPreview } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "extension-develop"));
|
|
815
|
-
for (const vendor of list){
|
|
816
|
-
const vendorStart = Date.now();
|
|
817
|
-
telemetry.track('cli_vendor_start', {
|
|
818
|
-
command: 'preview',
|
|
819
|
-
vendor
|
|
820
|
-
});
|
|
821
|
-
const logsOption = previewOptions.logs;
|
|
822
|
-
const logContextOption = previewOptions.logContext;
|
|
823
|
-
const logContexts = parseLogContexts(logContextOption);
|
|
824
|
-
await extensionPreview(pathOrRemoteUrl, {
|
|
825
|
-
mode: 'production',
|
|
826
|
-
profile: previewOptions.profile,
|
|
827
|
-
browser: vendor,
|
|
828
|
-
chromiumBinary: previewOptions.chromiumBinary,
|
|
829
|
-
geckoBinary: previewOptions.geckoBinary,
|
|
830
|
-
startingUrl: previewOptions.startingUrl,
|
|
831
|
-
port: previewOptions.port,
|
|
832
|
-
source: 'string' == typeof previewOptions.source ? previewOptions.source : previewOptions.source,
|
|
833
|
-
watchSource: previewOptions.watchSource,
|
|
834
|
-
logLevel: logsOption || previewOptions.logLevel || 'off',
|
|
835
|
-
logContexts,
|
|
836
|
-
logFormat: previewOptions.logFormat || 'pretty',
|
|
837
|
-
logTimestamps: false !== previewOptions.logTimestamps,
|
|
838
|
-
logColor: false !== previewOptions.logColor,
|
|
839
|
-
logUrl: previewOptions.logUrl,
|
|
840
|
-
logTab: previewOptions.logTab
|
|
841
|
-
});
|
|
842
|
-
telemetry.track('cli_vendor_finish', {
|
|
843
|
-
command: 'preview',
|
|
844
|
-
vendor,
|
|
845
|
-
duration_ms: Date.now() - vendorStart
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
telemetry.track('cli_command_finish', {
|
|
830
|
+
telemetry.track('cli_vendor_finish', {
|
|
849
831
|
command: 'preview',
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
exit_code: process.exitCode ?? 0
|
|
832
|
+
vendor,
|
|
833
|
+
duration_ms: Date.now() - vendorStart
|
|
853
834
|
});
|
|
835
|
+
}
|
|
836
|
+
telemetry.track('cli_command_finish', {
|
|
837
|
+
command: 'preview',
|
|
838
|
+
duration_ms: Date.now() - cmdStart,
|
|
839
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
840
|
+
exit_code: process.exitCode ?? 0
|
|
854
841
|
});
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function registerBuildCommand(program, telemetry) {
|
|
845
|
+
program.command('build').arguments('[project-name]').usage('build [path-to-remote-extension] [options]').description(commandDescriptions.build).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 }) {
|
|
846
|
+
if (buildOptions.author || buildOptions['authorMode']) {
|
|
847
|
+
process.env.EXTENSION_AUTHOR_MODE = 'true';
|
|
848
|
+
if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
|
|
849
|
+
}
|
|
850
|
+
const cmdStart = Date.now();
|
|
851
|
+
telemetry.track('cli_command_start', {
|
|
852
|
+
command: 'build',
|
|
853
|
+
vendors: vendors(browser),
|
|
854
|
+
polyfill_used: buildOptions.polyfill || false,
|
|
855
|
+
zip: buildOptions.zip || false,
|
|
856
|
+
zip_source: buildOptions.zipSource || false
|
|
857
|
+
});
|
|
858
|
+
const list = vendors(browser);
|
|
859
|
+
validateVendorsOrExit(list, (invalid, supported)=>{
|
|
860
|
+
console.error(unsupportedBrowserFlag(invalid, supported));
|
|
861
|
+
});
|
|
862
|
+
const { extensionBuild } = await import("extension-develop");
|
|
863
|
+
for (const vendor of list){
|
|
864
|
+
const vendorStart = Date.now();
|
|
865
|
+
telemetry.track('cli_vendor_start', {
|
|
864
866
|
command: 'build',
|
|
865
|
-
|
|
866
|
-
polyfill_used: buildOptions.polyfill || false,
|
|
867
|
-
zip: buildOptions.zip || false,
|
|
868
|
-
zip_source: buildOptions.zipSource || false
|
|
867
|
+
vendor
|
|
869
868
|
});
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
|
|
869
|
+
const buildSummary = await extensionBuild(pathOrRemoteUrl, {
|
|
870
|
+
browser: vendor,
|
|
871
|
+
polyfill: buildOptions.polyfill,
|
|
872
|
+
zip: buildOptions.zip,
|
|
873
|
+
zipSource: buildOptions.zipSource,
|
|
874
|
+
zipFilename: buildOptions.zipFilename,
|
|
875
|
+
silent: buildOptions.silent
|
|
873
876
|
});
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
command: 'build',
|
|
879
|
-
vendor
|
|
880
|
-
});
|
|
881
|
-
const buildSummary = await extensionBuild(pathOrRemoteUrl, {
|
|
882
|
-
browser: vendor,
|
|
883
|
-
polyfill: buildOptions.polyfill,
|
|
884
|
-
zip: buildOptions.zip,
|
|
885
|
-
zipSource: buildOptions.zipSource,
|
|
886
|
-
zipFilename: buildOptions.zipFilename,
|
|
887
|
-
silent: buildOptions.silent
|
|
888
|
-
});
|
|
889
|
-
telemetry.track('cli_build_summary', {
|
|
890
|
-
...buildSummary
|
|
891
|
-
});
|
|
892
|
-
telemetry.track('cli_vendor_finish', {
|
|
893
|
-
command: 'build',
|
|
894
|
-
vendor,
|
|
895
|
-
duration_ms: Date.now() - vendorStart
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
telemetry.track('cli_command_finish', {
|
|
877
|
+
telemetry.track('cli_build_summary', {
|
|
878
|
+
...buildSummary
|
|
879
|
+
});
|
|
880
|
+
telemetry.track('cli_vendor_finish', {
|
|
899
881
|
command: 'build',
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
exit_code: process.exitCode ?? 0
|
|
882
|
+
vendor,
|
|
883
|
+
duration_ms: Date.now() - vendorStart
|
|
903
884
|
});
|
|
885
|
+
}
|
|
886
|
+
telemetry.track('cli_command_finish', {
|
|
887
|
+
command: 'build',
|
|
888
|
+
duration_ms: Date.now() - cmdStart,
|
|
889
|
+
success: 0 === process.exitCode || null == process.exitCode,
|
|
890
|
+
exit_code: process.exitCode ?? 0
|
|
904
891
|
});
|
|
905
|
-
}
|
|
906
|
-
check_updates_checkUpdates(package_namespaceObject);
|
|
907
|
-
const extensionJs = external_commander_namespaceObject.program;
|
|
908
|
-
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);
|
|
909
|
-
registerCreateCommand(extensionJs, telemetry_cli_telemetry);
|
|
910
|
-
registerDevCommand(extensionJs, telemetry_cli_telemetry);
|
|
911
|
-
registerStartCommand(extensionJs, telemetry_cli_telemetry);
|
|
912
|
-
registerPreviewCommand(extensionJs, telemetry_cli_telemetry);
|
|
913
|
-
registerBuildCommand(extensionJs, telemetry_cli_telemetry);
|
|
914
|
-
extensionJs.on('option:ai-help', function() {
|
|
915
|
-
console.log(programAIHelp());
|
|
916
|
-
process.exit(0);
|
|
917
|
-
});
|
|
918
|
-
if (process.argv.length <= 2) {
|
|
919
|
-
extensionJs.outputHelp();
|
|
920
|
-
process.exit(0);
|
|
921
|
-
}
|
|
922
|
-
extensionJs.parseAsync().catch((err)=>{
|
|
923
|
-
console.error(unhandledError(err));
|
|
924
|
-
process.exit(1);
|
|
925
892
|
});
|
|
926
|
-
}
|
|
927
|
-
|
|
893
|
+
}
|
|
894
|
+
check_updates_checkUpdates(package_namespaceObject);
|
|
895
|
+
const extensionJs = external_commander_namespaceObject.program;
|
|
896
|
+
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);
|
|
897
|
+
registerCreateCommand(extensionJs, telemetry_cli_telemetry);
|
|
898
|
+
registerDevCommand(extensionJs, telemetry_cli_telemetry);
|
|
899
|
+
registerStartCommand(extensionJs, telemetry_cli_telemetry);
|
|
900
|
+
registerPreviewCommand(extensionJs, telemetry_cli_telemetry);
|
|
901
|
+
registerBuildCommand(extensionJs, telemetry_cli_telemetry);
|
|
902
|
+
extensionJs.on('option:ai-help', function() {
|
|
903
|
+
console.log(programAIHelp());
|
|
904
|
+
process.exit(0);
|
|
905
|
+
});
|
|
906
|
+
if (process.argv.length <= 2) {
|
|
907
|
+
extensionJs.outputHelp();
|
|
908
|
+
process.exit(0);
|
|
909
|
+
}
|
|
910
|
+
extensionJs.parseAsync().catch((err)=>{
|
|
911
|
+
console.error(unhandledError(err));
|
|
912
|
+
process.exit(1);
|
|
913
|
+
});
|
|
914
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
928
915
|
Object.defineProperty(exports, '__esModule', {
|
|
929
916
|
value: true
|
|
930
917
|
});
|