extension-install 4.1.26 → 4.1.28
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/lib/messaging.d.ts +1 -0
- package/dist/lib/runner.d.ts +1 -0
- package/dist/module.cjs +50 -16
- package/package.json +1 -1
package/dist/lib/messaging.d.ts
CHANGED
|
@@ -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;
|
package/dist/lib/runner.d.ts
CHANGED
|
@@ -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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
251
|
-
const packageRunnerPrefix = 'pnpm' ===
|
|
284
|
+
const runner = currentPackageRunner();
|
|
285
|
+
const packageRunnerPrefix = 'pnpm' === runner || 'yarn' === runner ? [
|
|
252
286
|
'dlx'
|
|
253
|
-
] : '
|
|
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:
|
|
400
|
+
cwd: browserInstallCwd(),
|
|
367
401
|
env
|
|
368
402
|
});
|
|
369
403
|
if (0 !== result.code) {
|