1.8.0 • Published 11 months ago

@guoyunhe/create-cli v1.8.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
11 months ago

@guoyunhe/create-cli

Initialize a Node.js command line tool project

Get Started

Create a new project

npm create @guoyunhe/cli my-cli

Initialize an existing project

cd my-cli
npm init @guoyunhe/cli

Project structure

├── dist # Build output
│   ├── index.js # CJS API entry
│   ├── index.mjs # ESM API entry
│   ├── index.d.ts # TypeScript declaration
│   ├── my-cli.js # CJS CLI script
│   └── my-cli.mjs # ESM CLI script
├── src # Source code
│   ├── bin # CLI scripts
│   │   └── my-cli.ts
│   ├── index.test.ts # API unit test
│   └── index.ts # API entry (add all exports here)
├── .editorconfig
├── .gitignore
├── CHANGELOG.md
├── package.json
├── README.md
└── tsconfig.json

Package scripts

# Build output
npm run build
# Build output in watch mode
npm run watch
# Format source code
npm run format
# Check lint issues
npm run lint
# Run unit tests (support all jest command options)
npm test
# Run unit tests in watch mode
npm test -- --watch
# Update unit test snapshots
npm test -- -u

Advanced Options

Initial package version

1.0.0 by default.

npm create @guoyunhe/cli my-cli --package-version 0.1.0

Add multiple bin

Let's say, you want to add a new bin called health-check.

First, create src/bin/health-check.ts, with shebang #!/usr/bin/env node:

#!/usr/bin/env node

console.log('Doing health check...');

// Add your code...

Then, add bin entry to your package.json:

{
  "bin": {
    "health-check": "dist/health-check.js"
  }
}
1.8.0

11 months ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago