Skip to content

Latest commit

 

History

History

node-cli

node-cli

Configuration

  • Node v18.12.1, pnpm
  • Vite for bundling in es format and CLI configuration
  • Prettier and Eslint with custom rules for formatting and linting
  • Husky, lint-staged and commitlint configs for clean linted commits
  • Custom config for automated publishing to NPM with release-it and creating GitHub releases
  • Preinstalled recommended packages for developing cross-platform CLI tools
  • GitHub Actions to validate PR's and pushes to main
  • GitHub PR and Issue templates
  • Renovate Bot for automated dependency management

Setting up

  • Do a quick search for all the TODO: comments across the template and follow the instructions.
  • pnpm install for installing all dependencies.
  • pnpm build for creating the production build in /dist.
  • Run pnpm build:watch in one terminal tab and in another tab run node . to test your CLI locally.
  • Install your CLI tool as a global dependency by npm install -g . for testing
  • You can refer to the scripts field in package.json to see the list of tasks.

Recommended Packages

(* indicates preinstalled)

  • pathe* - Cross-platform support for paths (replaces Node's path)
  • fs-extra* - Async file operations and error handling (replaces Node's fs and fs/promises)
  • inquirer - Simplest way to query user input interactively
  • execa* - Promise based shell command executor
  • minimist* - Parses CLI arguments and define aliases
  • minimatch - Glob expression matcher
  • ansi-colors* - Colorizing terminal output, much lighter than chalk
  • nanospinner - Lightweight spinner for async tasks

Publishing

  • Make sure the working directory is clean and upto date with remote.
  • Run pnpm release this will launch release-it, now select the appropriate options in the terminal (eg. semver - major, minor, patch)
  • The package will be published to NPM and a draft release will be created on GitHub. You can update the changelog and release the new version from GitHub's releases page.