I have created a starter project for creating node cli commands with Typescript.
It comes with pre-configured / pre-installed:
eslintwith Typescript support
prettierfor code formatting
huskywith pre-configured for pre-commit and pre-push hooks
commanderfor handling command line argument and cli help.
You can clone the project from Github: https://github.com/killerchip/ts-cli-template
or use Github’s Generate from template project feature.
Once you cloned the project you might want to change project’s name in
binkey. This will be the cli command that your users will use when launching your program.
src/cli.ts: The name of your cli command in help files.
Start building your code around
src/index.ts that’s the entry point.
When you commit your code, the parts you touched will be automatically go through prettier transformation.
When you push your code, it will go also under eslint investigation. If problems found the code won’t be pushed.
Manually checking eslint rules:
prettier on all files, automatically formatting them.
.prettierrc.js to adjust eslint and prettier behavior
cli.ts has sample code for using commander to automatically build help description and handling command line options.
See https://www.npmjs.com/package/commander for more details.