|
1 | 1 | import type { JsrPackageInfo } from '#shared/types/jsr' |
2 | 2 |
|
3 | 3 | export const packageManagers = [ |
4 | | - { id: 'npm', label: 'npm', action: 'install' }, |
5 | | - { id: 'pnpm', label: 'pnpm', action: 'add' }, |
6 | | - { id: 'yarn', label: 'yarn', action: 'add' }, |
7 | | - { id: 'bun', label: 'bun', action: 'add' }, |
8 | | - { id: 'deno', label: 'deno', action: 'add' }, |
9 | | - { id: 'vlt', label: 'vlt', action: 'install' }, |
| 4 | + { id: 'npm', label: 'npm', action: 'install', execute: 'npx' }, |
| 5 | + { id: 'pnpm', label: 'pnpm', action: 'add', execute: 'pnpm dlx' }, |
| 6 | + { id: 'yarn', label: 'yarn', action: 'add', execute: 'yarn dlx' }, |
| 7 | + { id: 'bun', label: 'bun', action: 'add', execute: 'bunx' }, |
| 8 | + { id: 'deno', label: 'deno', action: 'add', execute: 'deno run' }, |
| 9 | + { id: 'vlt', label: 'vlt', action: 'install', execute: 'vlt x' }, |
10 | 10 | ] as const |
11 | 11 |
|
12 | 12 | export type PackageManagerId = (typeof packageManagers)[number]['id'] |
@@ -59,3 +59,13 @@ export function getInstallCommandParts(options: InstallCommandOptions): string[] |
59 | 59 |
|
60 | 60 | return [pm.label, pm.action, `${spec}${version}`] |
61 | 61 | } |
| 62 | + |
| 63 | +export function getExecuteCommand(options: InstallCommandOptions): string { |
| 64 | + return getExecuteCommandParts(options).join(' ') |
| 65 | +} |
| 66 | + |
| 67 | +export function getExecuteCommandParts(options: InstallCommandOptions): string[] { |
| 68 | + const pm = packageManagers.find(p => p.id === options.packageManager) |
| 69 | + if (!pm) return [] |
| 70 | + return [pm.execute, getPackageSpecifier(options)] |
| 71 | +} |
0 commit comments