extension-install 4.1.26 → 4.1.27

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.
@@ -26,6 +26,7 @@ export interface CardInput {
26
26
  }
27
27
  export declare const MAX_CARD_ROWS = 3;
28
28
  export declare function card(input?: CardInput): string;
29
+ export declare function browserDisplayName(browser: string): string;
29
30
  export declare function browserRowValue(browser: string, versionLine?: string): string;
30
31
  export declare function isCardKeyClaimed(key: string): boolean;
31
32
  export declare function claimCardKey(key: string): boolean;
@@ -1,5 +1,6 @@
1
1
  import type { InstallBrowserTarget } from './browser-target.js';
2
2
  export declare function browserInstallCommand(_target: InstallBrowserTarget): string;
3
+ export declare function browserInstallCwd(): string;
3
4
  export declare function browserInstallArgs(target: InstallBrowserTarget, destination: string): string[];
4
5
  export declare function browserInstallEnv(target: InstallBrowserTarget, destination: string): NodeJS.ProcessEnv;
5
6
  export declare function runCommand(command: string, args: string[], opts: {
package/dist/module.cjs CHANGED
@@ -228,29 +228,63 @@ function buildExecEnv(base) {
228
228
  Path: updated
229
229
  };
230
230
  }
231
+ function readMajorVersion(userAgent, name) {
232
+ const match = userAgent.match(new RegExp(`${name}/(\\d+)`));
233
+ return match ? Number(match[1]) : null;
234
+ }
231
235
  function detectCurrentPackageManager() {
232
236
  const userAgent = String(process.env.npm_config_user_agent || '').toLowerCase();
233
- if (userAgent.includes('pnpm')) return 'pnpm';
234
- if (userAgent.includes('yarn')) return 'yarn';
235
- if (userAgent.includes('bun')) return 'bun';
236
- if (userAgent.includes('npm')) return 'npm';
237
+ for (const name of [
238
+ 'pnpm',
239
+ 'yarn',
240
+ 'bun',
241
+ 'npm'
242
+ ])if (userAgent.includes(name)) return {
243
+ name,
244
+ major: readMajorVersion(userAgent, name)
245
+ };
237
246
  const execPath = String(process.env.npm_execpath || process.env.NPM_EXEC_PATH || '').toLowerCase();
238
- if (execPath.includes('pnpm')) return 'pnpm';
239
- if (execPath.includes('yarn')) return 'yarn';
240
- if (execPath.includes('bun')) return 'bun';
241
- return 'npm';
247
+ if (execPath.includes('pnpm')) return {
248
+ name: 'pnpm',
249
+ major: null
250
+ };
251
+ if (execPath.includes('yarn')) return {
252
+ name: 'yarn',
253
+ major: null
254
+ };
255
+ if (execPath.includes('bun')) return {
256
+ name: 'bun',
257
+ major: null
258
+ };
259
+ return {
260
+ name: 'npm',
261
+ major: null
262
+ };
263
+ }
264
+ function currentPackageRunner() {
265
+ const { name, major } = detectCurrentPackageManager();
266
+ if ('pnpm' === name) return 'pnpm';
267
+ if ('bun' === name) return 'bunx';
268
+ if ('yarn' === name && null !== major && major >= 2) return 'yarn';
269
+ return 'npx';
242
270
  }
243
271
  function browserInstallCommand(_target) {
244
- const packageManager = detectCurrentPackageManager();
245
- if ('pnpm' === packageManager) return 'win32' === process.platform ? 'pnpm.cmd' : 'pnpm';
246
- if ('bun' === packageManager) return 'win32' === process.platform ? 'bunx.cmd' : 'bunx';
247
- return 'win32' === process.platform ? 'npx.cmd' : 'npx';
272
+ const runner = currentPackageRunner();
273
+ return 'win32' === process.platform ? `${runner}.cmd` : runner;
274
+ }
275
+ function browserInstallCwd() {
276
+ if ('npx' !== currentPackageRunner()) return process.cwd();
277
+ const cacheRoot = resolveBrowsersCacheRoot();
278
+ external_node_fs_default().mkdirSync(cacheRoot, {
279
+ recursive: true
280
+ });
281
+ return cacheRoot;
248
282
  }
249
283
  function browserInstallArgs(target, destination) {
250
- const packageManager = detectCurrentPackageManager();
251
- const packageRunnerPrefix = 'pnpm' === packageManager ? [
284
+ const runner = currentPackageRunner();
285
+ const packageRunnerPrefix = 'pnpm' === runner || 'yarn' === runner ? [
252
286
  'dlx'
253
- ] : 'bun' === packageManager ? [] : [
287
+ ] : 'bunx' === runner ? [] : [
254
288
  '-y'
255
289
  ];
256
290
  if ('edge' === target) return [
@@ -363,7 +397,7 @@ async function extensionInstall({ browser }) {
363
397
  const args = browserInstallArgs(target, destination);
364
398
  const env = browserInstallEnv(target, destination);
365
399
  const result = await runCommand(cmd, args, {
366
- cwd: process.cwd(),
400
+ cwd: browserInstallCwd(),
367
401
  env
368
402
  });
369
403
  if (0 !== result.code) {
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "name": "extension-install",
26
- "version": "4.1.26",
26
+ "version": "4.1.27",
27
27
  "description": "Managed browser installer/uninstaller for Extension.js",
28
28
  "author": {
29
29
  "name": "Cezar Augusto",