Well, I'm working on projects that use different Package Managers and I'm a little tired of writing wrong commands or mixing the incorrect flags.
I've started creating a command cheatsheet to guide me through, but if speak with truth, it was not enough, because don't solve the problem at all.
npm vs yarn vs pnpm commands cheatsheet
Camilo Martinez ・ May 10 '22 ・ 2 min read
So, inspired by projects like
Volta I've decided to create a CLI translator, to write commands in only one way and this CLI tool will translate them to the current package manager form used in the project.
That's how swpm (Switch Package Manager) was born.
This is an example of how
swpm works. The same command, no matter the package manager used on the project.
So, if you are in the same boat as me, or don't want to relearn commands for each package manager, install
npm install swpm --location=global yarn global add swpm pnpm install swpm --global bun install -g swpm volta install swpm
... and enjoy life.
This is a WIP project, and for now, there are available for translation the most used commands
remove, but we will add other gradually (or by request).
But commands are not restricted only to this list. Using
swpm will try to infer the package manager and reuse the rest of the parameters.
For example, shared commands between all the package managers, like:
swpm init [<name> --yes] swpm run <command> [-- <args>] swpm test swpm publish swpm unpublish <package> swpm deprecate <package> <message>
Flags are important to
swpm because can modify or set his behavior.
For example, you can pin a package manager to be used by default on a project.
swpm --pin <npm|yarn|pnpm|bun> swpm -p <npm|yarn|pnpm|bun>
So, with this pin, you can change over the projects, and in the future, you not going to need to worry or remember about the package manager to use. Just use the
swpm command and it will do all the work for you.
This is a little introduction about what
swpm can do, if calls your attention, you can learn more about it on:
deinsoftware / swpm
Switch Package Manager
Switch Package Manager
npm could cause a
bun project to break.
swpm is a CLI that intends to solve this problem by unifying the most used commands for the most common Node Package Managers into one. It will recognize the Package Manager used on the project and automatically will translate those commands.
This is an example of how #swpm works. The same command, no matter the package manager used on the project.
We will start with most used command, then other commands will be added gradually.
Track the command progress implementation on CHEATSHEET.
Progress: 90% of…
Comments and contributions are welcome. It's my first project using
node.js and I'm sure not following the best practices, but if you have recommendations, I'm open to listening and learning.
That’s All Folks!
Happy Coding 🖖
Top comments (0)