TypeScript CLI starter kit for Node.js. Optimized for quick setup and development efficiency.
MIT License
An all-inclusive starter kit for crafting command-line interfaces (CLI) using TypeScript, driven by Node.js. This kit is meticulously designed to kick-start your development journey with a solid foundation, encompassing features such as argument parsing, environment setup, logging, testing suites, as well as code formatting and linting capabilities.
This template incorporates several key tools and libraries to enhance your CLI development experience:
.env
file into process.env
,Before you begin, ensure you have installed Node.js and pnpm on your system.
To start using this CLI TypeScript starter, follow these steps:
npx cli-typescript-starter create my-project
or
npx giget@latest gh:kucherenko/cli-typescript-starter my-project
or
pnpm exec degit kucherenko/cli-typescript-starter my-project
Navigate to your project directory and install the necessary dependencies:
cd my-project && pnpm install
Update the package.json
to reflect your project's details:
"name": "my-project",
"bin": {
"my-project": "./bin/run"
}
Create a .env
file in the root directory and configure your environment variables as needed.
This starter comes equipped with several predefined scripts to facilitate development, alongside sample commands to demonstrate the capabilities of the CLI application.
pnpm start [command name]
to run any command. This utilizes ts-node
for a seamlessmy-project [command name]
to run the desiredpackage.json
in bin
).info
: Prints information about the current system and Node.js configuration. This command is useful forgreeting
: Demonstrates interactive prompts within the CLI. It's a great way to see how user inputs can becreate
: Create new project based on cli-typescript-starter
.All commands are located in the src/commands/
folder. This organization makes it easy to find and modify commands or
add new ones as needed.
This starter comes with several predefined scripts to help with development:
pnpm build
- Build the project using tsup
.pnpm build:watch
- Automatically rebuild the project on file changes.pnpm commit
- run commitizen
tool for helping with commit messages.pnpm commitlint
- lint commit messages.pnpm compile
- Compile TypeScript files using tsc
.pnpm clean
- Remove compiled code from the dist/
directory.pnpm format
- Check files for code style issues using Prettier.pnpm format:fix
- Automatically fix code formatting issues with Prettier.pnpm lint
- Check code for style issues with ESLint.pnpm lint:fix
- Automatically fix code style issues with ESLint.pnpm start [command]
- Run the CLI application using ts-node
.pnpm start:node [command]
- Run the CLI application from the dist/
directory.pnpm test
- Run unit tests.pnpm test:watch
- Run tests and watch for file changes.This project utilizes semantic-release
to automate version management and the NPM publishing
process. Semantic-release
automates the workflow of releasing new versions, including the generation of detailed
release notes based on commit messages that follow the conventional commit format.
The publishing process is triggered automatically when changes are merged into the main branch. Here's how it works:
semantic-release
determines the type of version change (semantic-release
publishes the new version to the NPM registry and creates a GitHubTo ensure a smooth semantic-release
process:
semantic-release
accurately determine version changes and generateNPM_TOKEN
for authentication during the publicationBy integrating semantic-release
, this project streamlines its release process, ensuring that versions are managed
efficiently and that users are well-informed of each update through automatically generated release notes.
To contribute to this project or customize it for your needs, consider the following guidelines:
commitizen
and commitlint
to ensure our commit messages are consistent and follow the@commitlint/config-conventional
. To make a commit, you canpnpm commit
, which will guide you through creating a conventional commit message..env
file for local development. For production, ensure you configure thecommitlint
.Contributions are welcome! If you'd like to improve this CLI TypeScript starter, please follow the standard fork-and-pull request workflow. Here are a few guidelines to keep in mind:
commitizen
and commitlint
with@commitlint/config-conventional
configuration, enforced by Husky git hooks.By adhering to these guidelines, you help maintain the quality and consistency of the project, making it easier for others to contribute and for users to understand and utilize the project effectively.
This project is licensed under the MIT License - see the LICENSE file for details.
Andrey Kucherenko
Happy Coding!