extension 4.1.22 → 4.1.23

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.cjs CHANGED
@@ -6735,6 +6735,10 @@ var __webpack_modules__ = {
6735
6735
  if ('debug' === type) return pintor__rspack_import_0_default().dim(pintor__rspack_import_0_default().gray(DEBUG_GLYPH));
6736
6736
  return pintor__rspack_import_0_default().gray(GLYPH);
6737
6737
  }
6738
+ const ANSI_PATTERN = /\[[0-9;]*m/g;
6739
+ function hasChannelPrefix(text) {
6740
+ return String(text || '').replace(ANSI_PATTERN, '').trimStart().startsWith(GLYPH);
6741
+ }
6738
6742
  const MACHINE_OUTPUT_VALUES = new Set([
6739
6743
  'json',
6740
6744
  'ndjson'
@@ -6767,7 +6771,8 @@ var __webpack_modules__ = {
6767
6771
  truncate (input, max = 800) {
6768
6772
  const s = (()=>{
6769
6773
  try {
6770
- return 'string' == typeof input ? input : JSON.stringify(input);
6774
+ if ('string' == typeof input) return input;
6775
+ return JSON.stringify(input) ?? String(input);
6771
6776
  } catch {
6772
6777
  return String(input);
6773
6778
  }
@@ -6993,6 +6998,7 @@ var __webpack_modules__ = {
6993
6998
  Gg: ()=>humanError,
6994
6999
  Nr: ()=>card,
6995
7000
  Pl: ()=>prefix,
7001
+ Qi: ()=>hasChannelPrefix,
6996
7002
  T_: ()=>artifactNoun,
6997
7003
  VR: ()=>isCardKeyClaimed,
6998
7004
  _o: ()=>isDebug,
@@ -8338,8 +8344,13 @@ var __webpack_modules__ = {
8338
8344
  function availableCommandsBlock() {
8339
8345
  return COMMANDS.map(commandHelpEntry).join('\n\n');
8340
8346
  }
8347
+ function projectCliVersionMismatch(running, declared, range, installCommand) {
8348
+ return `${getLoggingPrefix('warn')} Running ${messages_code(`extension ${running}`)}, this project declares ${messages_code(`${declared}@${range}`)}.\nRun ${messages_code(installCommand)} so the project's own version runs.`;
8349
+ }
8341
8350
  function unhandledError(err) {
8342
- const message = err instanceof Error ? err.stack || err.message : 'string' == typeof err ? err : messaging.Sc.truncate(err);
8351
+ const rendered = err instanceof Error ? err.message : '';
8352
+ if ((0, messaging.Qi)(rendered)) return rendered;
8353
+ const message = err instanceof Error ? err.stack || err.message : 'string' == typeof err ? err : null == err ? '' : messaging.Sc.truncate(err);
8343
8354
  return `${getLoggingPrefix('error')} ${external_pintor_default().red(String(message || 'Unknown error'))}`;
8344
8355
  }
8345
8356
  function updateFailed(err) {
@@ -9665,6 +9676,102 @@ Cross-browser compatibility
9665
9676
  const values = String(raw).split(',').map((value)=>value.trim()).filter((value)=>value.length > 0);
9666
9677
  return values.length > 0 ? values : void 0;
9667
9678
  }
9679
+ const external_semver_namespaceObject = require("semver");
9680
+ var external_semver_default = /*#__PURE__*/ __webpack_require__.n(external_semver_namespaceObject);
9681
+ const CLI_PACKAGES = [
9682
+ 'extension',
9683
+ 'extension-develop'
9684
+ ];
9685
+ const LOCKFILE_COMMANDS = [
9686
+ [
9687
+ 'pnpm-lock.yaml',
9688
+ 'pnpm install'
9689
+ ],
9690
+ [
9691
+ 'yarn.lock',
9692
+ 'yarn install'
9693
+ ],
9694
+ [
9695
+ 'bun.lock',
9696
+ 'bun install'
9697
+ ],
9698
+ [
9699
+ 'bun.lockb',
9700
+ 'bun install'
9701
+ ],
9702
+ [
9703
+ 'deno.lock',
9704
+ 'deno install'
9705
+ ],
9706
+ [
9707
+ 'package-lock.json',
9708
+ 'npm install'
9709
+ ]
9710
+ ];
9711
+ function installCommandFor(files) {
9712
+ for (const [lockfile, command] of LOCKFILE_COMMANDS)if (files.includes(lockfile)) return command;
9713
+ return 'npm install';
9714
+ }
9715
+ function declaredCliDependency(manifest) {
9716
+ for (const field of [
9717
+ manifest?.dependencies,
9718
+ manifest?.devDependencies
9719
+ ])for (const name of CLI_PACKAGES){
9720
+ const range = field?.[name];
9721
+ if ('string' == typeof range && range.length > 0) return {
9722
+ name,
9723
+ range
9724
+ };
9725
+ }
9726
+ return null;
9727
+ }
9728
+ function isComparableRange(range) {
9729
+ const trimmed = range.trim();
9730
+ if (!trimmed || '*' === trimmed || 'latest' === trimmed) return false;
9731
+ if (/^(workspace|file|link|git|github|npm):/i.test(trimmed)) return false;
9732
+ if (/^[./]/.test(trimmed)) return false;
9733
+ return null !== external_semver_default().validRange(trimmed);
9734
+ }
9735
+ function versionMismatch(input) {
9736
+ const declared = declaredCliDependency(input.manifest);
9737
+ if (!declared) return null;
9738
+ if (!isComparableRange(declared.range)) return null;
9739
+ if (!external_semver_default().valid(input.running)) return null;
9740
+ const comparable = external_semver_default().prerelease(input.running) ? external_semver_default().coerce(input.running)?.version ?? input.running : input.running;
9741
+ if (external_semver_default().satisfies(comparable, declared.range, {
9742
+ includePrerelease: true
9743
+ })) return null;
9744
+ return {
9745
+ declared: declared.name,
9746
+ range: declared.range,
9747
+ running: input.running
9748
+ };
9749
+ }
9750
+ function readProjectManifest(projectPath) {
9751
+ try {
9752
+ return JSON.parse(external_node_fs_.readFileSync(external_node_path_.join(projectPath, 'package.json'), 'utf-8'));
9753
+ } catch {
9754
+ return null;
9755
+ }
9756
+ }
9757
+ function checkProjectCliVersion(projectPath, running) {
9758
+ let files = [];
9759
+ try {
9760
+ files = external_node_fs_.readdirSync(projectPath);
9761
+ } catch {
9762
+ return null;
9763
+ }
9764
+ if (!files.includes('package.json')) return null;
9765
+ const mismatch = versionMismatch({
9766
+ manifest: readProjectManifest(projectPath),
9767
+ running
9768
+ });
9769
+ if (!mismatch) return null;
9770
+ return {
9771
+ ...mismatch,
9772
+ command: installCommandFor(files)
9773
+ };
9774
+ }
9668
9775
  function registerBuildCommand(program) {
9669
9776
  program.command('build').arguments('[project-name]').usage('[path-to-remote-extension] [options]').description(commandDescriptions.build).option(`--browser <${BROWSER_TARGETS_HELP}>`, 'specify a browser/engine to run. Defaults to `chromium`. `safari` builds a Safari app via Xcode (macOS only)').option('--polyfill [boolean]', 'whether or not to apply the cross-browser polyfill. Defaults to `false`', parseOptionalBoolean).option('--no-polyfill', 'disable the cross-browser polyfill').option('--zip [boolean]', 'whether or not to compress the extension into a ZIP file. Defaults to `false`', parseOptionalBoolean).option('--zip-source [boolean]', 'whether or not to include the source files in the ZIP file. Defaults to `false`', parseOptionalBoolean).option('--zip-filename <string>', 'specify the name of the ZIP file. Defaults to the extension name and version').option('--silent [boolean]', 'suppress the build summary output. Defaults to `false`', parseOptionalBoolean).option('--addon-lint [boolean]', 'check Firefox builds against addons.mozilla.org rules with addons-linter when it is installed. Findings print as warnings. Defaults to `true`', parseOptionalBoolean).option('--no-addon-lint', 'skip the addons.mozilla.org lint of Firefox builds').option('--install [boolean]', '[internal] install project dependencies when missing', parseOptionalBoolean).option('--extensions <list>', 'comma-separated list of companion extensions or store URLs to load').option('--mode <development|production|none>', 'bundler mode override (also sets NODE_ENV). Defaults to `production`').option('--open [boolean]', 'open the built Safari app after packaging (safari targets only). Defaults to `false`', parseOptionalBoolean).option('--app-name <name>', 'override the Safari app name (safari targets only). Defaults to the manifest `name`').option('--bundle-id <reverse.dns>', 'set a user-owned Safari bundle identifier (safari targets only). Defaults to a generated dev.extensionjs.* id shared by every build of the same source, so set your own before the first submission').option('--development-team <id>', 'sign the Safari app with an Apple Developer team id (safari targets only). Without it the build is ad-hoc signed, which Safari loads locally with no per-launch toggle. Use a team id for a stable identity you can distribute').option('--macos-only [boolean]', 'generate a macOS-only Safari Xcode project (safari targets only). Pass `false` for a universal macOS + iOS project. Defaults to `true`', parseOptionalBoolean).option('--force-regenerate', 'regenerate the Safari Xcode project even when up to date (safari targets only)').option('--output <pretty|json>', 'result format. Use json for a schema-1 envelope on stdout').addOption(new external_commander_namespaceObject.Option('--debug', 'print maintainer diagnostics alongside normal output')).addOption(new external_commander_namespaceObject.Option('--author, --author-mode', 'deprecated alias for --debug').hideHelp()).action(async (pathOrRemoteUrl, { browser: cliBrowser, ...buildOptions })=>{
9670
9777
  const browser = cliBrowser ?? await resolveConfigBrowser(pathOrRemoteUrl || process.cwd(), 'build') ?? 'chromium';
@@ -9732,6 +9839,8 @@ Cross-browser compatibility
9732
9839
  }
9733
9840
  const { extensionBuild } = await loadExtensionDevelopModule();
9734
9841
  const asJson = isJsonOutput(buildOptions);
9842
+ const cliVersion = checkProjectCliVersion(external_node_path_.resolve(pathOrRemoteUrl || process.cwd()), getCliPackageJson().version);
9843
+ if (cliVersion) console.warn(projectCliVersionMismatch(cliVersion.running, cliVersion.declared, cliVersion.range, cliVersion.command));
9735
9844
  if (asJson) process.env.EXTENSION_OUTPUT = 'json';
9736
9845
  const built = [];
9737
9846
  const summaries = [];
@@ -10319,6 +10428,8 @@ Cross-browser compatibility
10319
10428
  if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
10320
10429
  }
10321
10430
  const asJson = 'json' === resolveOutputFormat(devOptions);
10431
+ const cliVersion = checkProjectCliVersion(external_node_path_.resolve(pathOrRemoteUrl || process.cwd()), getCliPackageJson().version);
10432
+ if (cliVersion) console.warn(projectCliVersionMismatch(cliVersion.running, cliVersion.declared, cliVersion.range, cliVersion.command));
10322
10433
  if (void 0 !== devOptions.parentPid) {
10323
10434
  const parentPid = parseParentPid(devOptions.parentPid);
10324
10435
  if (void 0 === parentPid) {
@@ -11259,6 +11370,8 @@ Cross-browser compatibility
11259
11370
  if (!process.env.EXTENSION_VERBOSE) process.env.EXTENSION_VERBOSE = '1';
11260
11371
  }
11261
11372
  const asJson = 'json' === resolveOutputFormat(startOptions);
11373
+ const cliVersion = checkProjectCliVersion(external_node_path_.resolve(pathOrRemoteUrl || process.cwd()), getCliPackageJson().version);
11374
+ if (cliVersion) console.warn(projectCliVersionMismatch(cliVersion.running, cliVersion.declared, cliVersion.range, cliVersion.command));
11262
11375
  if (asJson) process.env.EXTENSION_OUTPUT = 'json';
11263
11376
  const list = vendors(browser);
11264
11377
  let unsupportedBrowser = '';
@@ -11432,7 +11545,6 @@ Cross-browser compatibility
11432
11545
  await exitAfterDrain(1);
11433
11546
  });
11434
11547
  }
11435
- const external_semver_namespaceObject = require("semver");
11436
11548
  const external_update_check_namespaceObject = require("update-check");
11437
11549
  var external_update_check_default = /*#__PURE__*/ __webpack_require__.n(external_update_check_namespaceObject);
11438
11550
  function isStableVersion(version) {
@@ -195,6 +195,7 @@ export declare const COMMANDS: readonly CommandSpec[];
195
195
  export declare function commandSpec(name: CommandName): CommandSpec;
196
196
  export declare const commandDescriptions: Record<CommandName, string>;
197
197
  export declare function availableCommandsBlock(): string;
198
+ export declare function projectCliVersionMismatch(running: string, declared: string, range: string, installCommand: string): string;
198
199
  export declare function unhandledError(err: unknown): string;
199
200
  export declare function updateFailed(err: unknown): string;
200
201
  export declare function checkUpdates(packageJson: Record<string, unknown>, update: {
@@ -0,0 +1,26 @@
1
+ export declare const CLI_PACKAGES: readonly ['extension', 'extension-develop'];
2
+ export declare function installCommandFor(files: string[]): string;
3
+ export interface ProjectManifest {
4
+ dependencies?: Record<string, string>;
5
+ devDependencies?: Record<string, string>;
6
+ }
7
+ export interface DeclaredCli {
8
+ name: string;
9
+ range: string;
10
+ }
11
+ export interface VersionMismatch {
12
+ declared: string;
13
+ range: string;
14
+ running: string;
15
+ }
16
+ export declare function declaredCliDependency(manifest: ProjectManifest | null): DeclaredCli | null;
17
+ export declare function isComparableRange(range: string): boolean;
18
+ export declare function versionMismatch(input: {
19
+ manifest: ProjectManifest | null;
20
+ running: string;
21
+ }): VersionMismatch | null;
22
+ export declare function readProjectManifest(projectPath: string): ProjectManifest | null;
23
+ export interface ProjectCliVersionCheck extends VersionMismatch {
24
+ command: string;
25
+ }
26
+ export declare function checkProjectCliVersion(projectPath: string, running: string): ProjectCliVersionCheck | null;
package/package.json CHANGED
@@ -38,7 +38,7 @@
38
38
  "extension": "./bin/extension.cjs"
39
39
  },
40
40
  "name": "extension",
41
- "version": "4.1.22",
41
+ "version": "4.1.23",
42
42
  "description": "The cross-browser extension framework. Build Chrome, Edge, Firefox, and Safari extensions with no build configuration.",
43
43
  "homepage": "https://extension.js.org/",
44
44
  "bugs": {
@@ -105,9 +105,9 @@
105
105
  "vivaldi-location2": "2.1.1",
106
106
  "waterfox-location": "2.1.1",
107
107
  "yandex-location": "2.1.1",
108
- "extension-create": "4.1.22",
109
- "extension-develop": "4.1.22",
110
- "extension-install": "4.1.22",
108
+ "extension-create": "4.1.23",
109
+ "extension-develop": "4.1.23",
110
+ "extension-install": "4.1.23",
111
111
  "commander": "^15.0.0",
112
112
  "pintor": "0.3.0",
113
113
  "semver": "^7.7.3",