A starter project for creating node cli commands with Typescript. It comes with pre-configured / pre-installed:
yarn
package managereslint
with Typescript supportairbnb-typescript/base
eslint profileprettier
for code formattinghusky
with pre-configured for pre-commit and pre-push hookscommander
for 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
-
package.json
>name
-
package.json
>bin
key. 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:
yarn lint
Manually running prettier
on all files, automatically formatting them.
yarn prettier
Modify .eslintignore
, .eslintrc.js
, .prettierignore
, .prettierrc.js
to adjust eslint and prettier behavior
See https://eslint.org/ and https://prettier.io/ for more details.
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.
Copyright 2020 Konstantinos Ioannou
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.