Template that you can use to create an executable CLI, ready to be published in NPM. It does not use any bundler, dependencies or unnecessary abstractions.
This is what it looks like when you are developing it:
And this is what it would look like to the hypothetical end consumer of this CLI:
If you are wondering whether or not you need a bundler for your purposes, you can read this answer on stackoverflow and maybe this blog article.
The procedure is fairly simple.
- Use this project as a template.
- Refill every occurrence of 'cli-executable-publishable' inside package.json with your own project name. Replace 'description', 'keys' and 'author' with your own values and clear the readme:
cat /dev/null > README.md
. Update the license. - Copy the example npmrc file as '.npmrc':
cp .npmrc.example .npmrc
and replace the placeholder with a Personal Access Token created with 'write:packages' as scope. - Do
pnpm install
. If you don't have pnpm yet, follow this guide. - To test if your CLI works as intended before publishing, use npm as explained here to avoid headaches.
- When you're ready to publish, do
pnpm publish
.