Skip to content

Diottodev/pkg

Repository files navigation

pkg

npm i in a yarn project, again? F**k!

pkg - use the right package manager


npm i -g @nico-diotto-dev/pkg

npm · yarn · pnpm · bun


pkg - install

pkg

# npm install
# yarn install
# pnpm install
# bun install
pkg vite

# npm i vite
# yarn add vite
# pnpm add vite
# bun add vite
pkg @types/node -D

# npm i @types/node -D
# yarn add @types/node -D
# pnpm add -D @types/node
# bun add -d @types/node
pkg --frozen

# npm ci
# yarn install --frozen-lockfile (Yarn 1)
# yarn install --immutable (Yarn Berry)
# pnpm install --frozen-lockfile
# bun install --no-save
pkg -g eslint

# npm i -g eslint
# yarn global add eslint (Yarn 1)
# pnpm add -g eslint
# bun add -g eslint

# this uses default agent, regardless your current working directory

pkr - run

pkr dev --port=3000

# npm run dev -- --port=3000
# yarn run dev --port=3000
# pnpm run dev --port=3000
# bun run dev --port=3000
pkr

# interactively select the script to run
# supports https://www.npmjs.com/package/npm-scripts-info convention
pkr -

# rerun the last command

pkx - download & execute

pkx vitest

# npx vitest
# yarn dlx vitest
# pnpm dlx vitest
# bunx vitest

pk up - upgrade

pk up

# npm upgrade
# yarn upgrade (Yarn 1)
# yarn up (Yarn Berry)
# pnpm update
# bun update
pk up -i

# (not available for npm & bun)
# yarn upgrade-interactive (Yarn 1)
# yarn up -i (Yarn Berry)
# pnpm update -i

pk un - uninstall

pk un webpack

# npm uninstall webpack
# yarn remove webpack
# pnpm remove webpack
# bun remove webpack
pk un -g silent

# npm uninstall -g silent
# yarn global remove silent
# pnpm remove -g silent
# bun remove -g silent

pk clean - clean install

pk clean

# npm ci
# yarn install --frozen-lockfile
# pnpm install --frozen-lockfile
# bun install --no-save

if the corresponding node manager is not present, this command will install it globally along the way.


pk ag - agent alias

pk ag

# npm
# yarn
# pnpm
# bun
pk ag run foo

# npm run foo
# yarn run foo
# pnpm run foo
# bun run foo

Global Flags

# ?               | Print the command execution depends on the agent
pkg vite ?

# -C              | Change directory before running the command
pkg -C packages/foo vite
pkr -C playground dev

# -v, --version   | Show version number
pkg -v

# -h, --help      | Show help
pkg -h

Config

; ~/.pkgrc

; fallback when no lock found
defaultAgent=npm # default "prompt"

; for global installs
globalAgent=npm
# ~/.bashrc

# custom configuration file path
export PKG_CONFIG_FILE="$HOME/.config/pkg/pkgrc"

How?

ni assumes that you work with lockfiles (and you should)

Before it runs, it will detect your yarn.lock / pnpm-lock.yaml / package-lock.json / bun.lockb to know current package manager (or packageManager field in your packages.json if specified), and runs the corresponding commands.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published