sheinsight / ni

πŸ’‘ Use the right package manager by rust

Home Page:https://github.com/sheinsight/ni

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

n

πŸ’‘ Inspired by ni

Choose the correct command prefix (npm, yarn, pnpm) based on the packageManager configuration in your package.json.

Why

Why do we need to do this when we already have ni πŸ€”οΈ ?

Because ni runs on the Node environment, which means that when we switch between different versions of Node using tools like fnm and nvm, we always need to globally install ni, which is not elegant.

We hope to have a tool similar to ni, but it does not depend on the Node environment, so that we can better collaborate with fnm and nvm.

Differences from ni

Our philosophy is somewhat different from ni. We are strict and require you to declare packageManager in package.json.

Installation

Using a script (macOS/Linux)

curl -fsSL https://raw.githubusercontent.com/sheinsight/ni/main/install.sh | bash

Use case

install

# Ready βœ…
n i
# npm install
# yarn install
# pnpm install
# Ready βœ…
n ci
# npm ci
# yarn install --frozen-lockfile (Yarn 1)
# pnpm install --frozen-lockfile

add

# Ready βœ…
n add react
# npm add react
# yarn add react
# pnpm add react
# Ready βœ…
n add react -D
# npm add --save-dev react
# yarn add --save-dev react
# pnpm add --save-dev react
# Ready βœ…
n add react -S
# npm add --save react
# yarn add --save react
# pnpm add --save react
# Ready βœ…
n add react -O
# npm add --save-optional react
# yarn add --save-optional react
# pnpm add --save-optional react
# Ready βœ…
n add -g eslint

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

run

# Ready βœ…
n r dev
# npm run dev
# yarn run dev
# pnpm run dev
# Ready βœ…
n r dev --port=3000
# npm run dev -- --port=3000
# yarn run dev --port=3000
# pnpm run dev --port=3000
# Ready ❌
n r
# interactively select the script to run
# supports https://www.npmjs.com/package/npm-scripts-info convention

npx

# Ready βœ…
n dlx tsx
# npx vitest
# yarn dlx vitest
# pnpm dlx vitest

upgrade

# Ready βœ…
n u
# npm upgrade
# yarn upgrade (Yarn 1)
# pnpm update

uninstall

# Ready βœ…
n un
# npm uninstall webpack
# yarn remove webpack
# pnpm remove webpack
# Ready βœ…
n un -g silent

# npm uninstall -g silent
# yarn global remove silent
# pnpm remove -g silent
# Ready βœ…
n set-cache /root
# npm config set cache /root
# yarn config set cache-folder /root
# pnpm config set store-dir /root

About

πŸ’‘ Use the right package manager by rust

https://github.com/sheinsight/ni

License:MIT License


Languages

Language:HTML 90.6%Language:Rust 7.5%Language:Shell 2.0%Language:TypeScript 0.0%