@brlt/n
v0.1.1
Published
Use the right package manager
Readme
@brlt/n
An extended fork of @antfu/ni - "use the right package manager"
pnpm · yarn · npm
pnpm add -g @brlt/nyarn global add @brlt/nnpm i -g @brlt/nThis package expands upon the original @antfu/ni by Anthony Fu by adding several new commands, but also renaming a couple to eliminate some conflicts I encountered.
For example, I had some trouble with Nx workspaces for monorepo projects, since nx was occupied. So nx was renamed to nex.
This is very much a work in progress. I haven't had time to add any tests for the updated commands yet, and I'm sure some of them are partially (maybe even completely) broken. Please contribute! PRs welcome!
How does it work?
ni assumes that you work with lockfiles (and you should). See the list of commands.
Before it runs, it will detect your yarn.lock / pnpm-lock.yaml / package-lock.json to know current package manager (or packageManager field in your packages.json), and runs the corresponding commands.
Config
; ~/.nirc
; fallback when no lock found
defaultAgent=npm # default "prompt"
; for global installs
globalAgent=npm# ~/.bashrc
# custom configuration file path
export NI_CONFIG_FILE="$HOME/.config/ni/nirc"Commands
ni - install
ni
# npm install
# yarn install
# pnpm installni axiosni @types/node -D
# npm i @types/node -D
# yarn add @types/node -D
# pnpm add -D @types/nodeni --frozen # or nci
# npm ci
# yarn install --frozen-lockfile
# pnpm install --frozen-lockfileni -g iroiro
# npm i -g iroiro
# yarn global add iroiro
# pnpm add -g iroiro
# this uses default agent, regardless your current working directoryChange Directory
ni -C packages/foo vite
nr -C playground devnci - clean install
nci
# npm ci
# yarn install --frozen-lockfile
# pnpm install --frozen-lockfileIf the corresponding node manager is not present, this command will install it globally.
nr - run
nr
# interactively select the script to run
# supports https://www.npmjs.com/package/npm-scripts-info conventionnr -
# rerun the last commandnr dev --port=3000
# npm run dev -- --port=3000
# yarn run dev --port=3000
# pnpm run dev -- --port=3000~~nx~~ nex - execute
Renamed to
nexto eliminate conflict with Nx monorepos
nex jest
# npx jest
# yarn dlx jest
# pnpm dlx jestnu - upgrade
nu
# npm upgrade
# yarn upgrade
# pnpm updatenu -i
# (not available for npm)
# yarn upgrade-interactive
# pnpm update -inun - uninstall
nun axios
# npm uninstall axios
# yarn remove axios
# pnpm remove axiosnun @types/node -D
# npm uninstall @types/node -D
# yarn remove @types/node -D
# pnpm remove -D @types/nodenun -g eslint
# npm uninstall -g eslint
# yarn global remove eslint
# pnpm remove -g eslintnl - link
nl next
# npm link next
# yarn link next
# pnpm link nextnb - bin
nb
# npm bin
# yarn bin
# pnpm binnb -g
# npm bin --global
# yarn global bin
# pnpm -g binnh - help
nh
# npm help # yarn help # pnpm helpnh version
# npm help version
# yarn help version
# pnpm help versionnv - version
nv
# npm version
# yarn version
# pnpm versionnp - publish
np
# npm publish
# yarn publish
# pnpm publishnp --registry=https://npm.pkg.github.comna - agent alias
na
# npm
# pnpm
# yarnno - outdated
no
# npm outdated
# yarn outdated
# pnpm outdatedno --long
# npm outdated --long
# yarn outdated --long
# pnpm outdated --longnt - test
nt
# npm test
# yarn test
# pnpm test