-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use
package-manager-detector
(#227)
- Loading branch information
Showing
12 changed files
with
42 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,6 @@ | ||
function npmRun(agent: string) { | ||
return (args: string[]) => { | ||
if (args.length > 1) | ||
return `${agent} run ${args[0]} -- ${args.slice(1).join(' ')}` | ||
else return `${agent} run ${args[0]}` | ||
} | ||
} | ||
import type { Agent, Command } from 'package-manager-detector/agents' | ||
import { AGENTS, COMMANDS, INSTALL_PAGE, LOCKS } from 'package-manager-detector/agents' | ||
|
||
const yarn = { | ||
'agent': 'yarn {0}', | ||
'run': 'yarn run {0}', | ||
'install': 'yarn install {0}', | ||
'frozen': 'yarn install --frozen-lockfile', | ||
'global': 'yarn global add {0}', | ||
'add': 'yarn add {0}', | ||
'upgrade': 'yarn upgrade {0}', | ||
'upgrade-interactive': 'yarn upgrade-interactive {0}', | ||
'execute': 'npx {0}', | ||
'uninstall': 'yarn remove {0}', | ||
'global_uninstall': 'yarn global remove {0}', | ||
} | ||
const pnpm = { | ||
'agent': 'pnpm {0}', | ||
'run': 'pnpm run {0}', | ||
'install': 'pnpm i {0}', | ||
'frozen': 'pnpm i --frozen-lockfile', | ||
'global': 'pnpm add -g {0}', | ||
'add': 'pnpm add {0}', | ||
'upgrade': 'pnpm update {0}', | ||
'upgrade-interactive': 'pnpm update -i {0}', | ||
'execute': 'pnpm dlx {0}', | ||
'uninstall': 'pnpm remove {0}', | ||
'global_uninstall': 'pnpm remove --global {0}', | ||
} | ||
const bun = { | ||
'agent': 'bun {0}', | ||
'run': 'bun run {0}', | ||
'install': 'bun install {0}', | ||
'frozen': 'bun install --frozen-lockfile', | ||
'global': 'bun add -g {0}', | ||
'add': 'bun add {0}', | ||
'upgrade': 'bun update {0}', | ||
'upgrade-interactive': 'bun update {0}', | ||
'execute': 'bun x {0}', | ||
'uninstall': 'bun remove {0}', | ||
'global_uninstall': 'bun remove -g {0}', | ||
} | ||
export { AGENTS, COMMANDS, INSTALL_PAGE, LOCKS } | ||
|
||
export const AGENTS = { | ||
'npm': { | ||
'agent': 'npm {0}', | ||
'run': npmRun('npm'), | ||
'install': 'npm i {0}', | ||
'frozen': 'npm ci', | ||
'global': 'npm i -g {0}', | ||
'add': 'npm i {0}', | ||
'upgrade': 'npm update {0}', | ||
'upgrade-interactive': null, | ||
'execute': 'npx {0}', | ||
'uninstall': 'npm uninstall {0}', | ||
'global_uninstall': 'npm uninstall -g {0}', | ||
}, | ||
'yarn': yarn, | ||
'yarn@berry': { | ||
...yarn, | ||
'frozen': 'yarn install --immutable', | ||
'upgrade': 'yarn up {0}', | ||
'upgrade-interactive': 'yarn up -i {0}', | ||
'execute': 'yarn dlx {0}', | ||
// Yarn 2+ removed 'global', see https://github.com/yarnpkg/berry/issues/821 | ||
'global': 'npm i -g {0}', | ||
'global_uninstall': 'npm uninstall -g {0}', | ||
}, | ||
'pnpm': pnpm, | ||
// pnpm v6.x or below | ||
'pnpm@6': { | ||
...pnpm, | ||
run: npmRun('pnpm'), | ||
}, | ||
'bun': bun, | ||
} | ||
|
||
export type Agent = keyof typeof AGENTS | ||
export type Command = keyof typeof AGENTS.npm | ||
|
||
export const agents = Object.keys(AGENTS) as Agent[] | ||
|
||
// the order here matters, more specific one comes first | ||
export const LOCKS: Record<string, Agent> = { | ||
'bun.lockb': 'bun', | ||
'pnpm-lock.yaml': 'pnpm', | ||
'yarn.lock': 'yarn', | ||
'package-lock.json': 'npm', | ||
'npm-shrinkwrap.json': 'npm', | ||
} | ||
|
||
export const INSTALL_PAGE: Record<Agent, string> = { | ||
'bun': 'https://bun.sh', | ||
'pnpm': 'https://pnpm.io/installation', | ||
'pnpm@6': 'https://pnpm.io/6.x/installation', | ||
'yarn': 'https://classic.yarnpkg.com/en/docs/install', | ||
'yarn@berry': 'https://yarnpkg.com/getting-started/install', | ||
'npm': 'https://docs.npmjs.com/cli/v8/configuring-npm/install', | ||
} | ||
export type { Agent, Command } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.