A modern TypeScript starter template for building CLI tools
- 🎯 TypeScript First - Full TypeScript support with strict type checking
- 📦 Zero Config - Pre-configured build system with tsup
- 🔄 Semantic Release - Automated versioning and changelog generation
- ⚡ Fast Build - Optimized bundle with minification
# Clone this repository
git clone https://github.com/amirkabiri/create-npm-cmd.git my-awesome-cli
cd my-awesome-cli
# Install dependencies
npm install
# Build
npm run build
# Test locally
npm link
my-awesome-npm-cmd --helpmy-awesome-npm-cmd example
# Output: Hello World!- Create a command file in
src/commands/:
// src/commands/my-command.ts
import chalk from 'chalk';
export function myCommand() {
console.log(chalk.green('My custom command!'));
}- Register it in
src/cli.ts:
import { myCommand } from './commands/my-command';
program
.command('my-command')
.description('Description of my command')
.action(myCommand);npm run build- Build for productionnpm run build:watch- Build in watch modenpm run clean- Remove dist folder
- Create a GitHub repository
- Set up GitHub Actions secrets:
NPM_TOKEN- Get from npmjs.com
Use Conventional Commits for automatic versioning:
fix: bug fix # Patch release (0.0.x)
feat: new feature # Minor release (0.x.0)
feat!: breaking # Major release (x.0.0)npm run build
npm publishUpdate package.json:
{
"name": "your-cli-name",
"bin": {
"your-command": "./dist/cli.cjs"
}
}Update src/cli.ts:
program
.name('your-command')
.description('Your CLI description')- TypeScript - Type-safe JavaScript
- Commander.js - CLI framework
- Chalk - Terminal styling
- tsup - TypeScript bundler
- semantic-release - Automated versioning
MIT License - see the LICENSE file for details.
Happy CLI building! 🎉