1.1.0 • Published 1 month ago

setup-cli-app v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

The easiest way to start a modern cli app. It supercharges your development workflow, allowing you to quickly scaffold resources for your cli application with best practices in mind.

Features

  • Efficient CLI Setup: Start building your CLI app within minutes with a well-structured template and easy-to-use commands.
  • Scoped Debug Logs: Debug logs are scoped to their names: bin, config:mgr and commands:start.
  • Modular Architecture: Built with a modular architecture, allowing for easy customization and extension as your project grows.
  • Configuration Management: Manage your application configurations effortlessly. Customize your app's behavior by modifying the configuration settings.
  • Error Handling: Robust error handling mechanisms ensure smooth execution and graceful recovery from unexpected errors.
  • Build scripts: Integrated build scripts for easy development workflow management.
    • clean: Removes the 'dist' directory.
    • prebuild: Executes 'clean' script before the build.
    • build: Builds the application using 'tsup'.
    • preversion: Executes 'build' script before versioning.
    • postversion: Pushes tags to the repository after versioning.

🏎️ Usage

  1. Run npx setup-cli-app init. Follow the instructions. This scaffolds your project.
  2. Set your config and schema at src/config. (check schema.json) Upon building this TypeScript project, priority is given to configurations specified within the package.json file. Consequently, removing configurations from package.json will prompt the tool to adopt the new settings from the tool.config.js file.

It looks for a config file in the dir of the user who installs/uses it.

{
  // Default configuration
  "properties": {
    "port": {
      "type": "number"
    }
  }
}

Therefore, the user, who installs or utilizes the CLI tool, must include the following property within their package.json:

// package.json
"tool": {
  "port": 9999
}

In the event that it is not specified in package.json, the user must provide a separate file named tool.config.js.

  1. To see debug logs. Set a DEBUG environment variable.
  2. On bumping the package version. The project is build automatically and tags are pushed to remote repo.Or build manually with pnpm build
  3. Run with args setup-cli-app --start.

Commands

All commands are run from the root of the project, from a terminal:

CommandAction
pnpm installInstalls dependencies

Under the Hood:

  • arg: Handles command-line arguments intuitively.
  • cosmiconfig: Simplifies configuration management from various sources, including the current directory, user's home directory, and project-specific locations.
  • Ajv: Ensures robust data validation with JSON schema support.
  • better-ajv-errors: Provides clear and actionable error messages when encountering configuration issues.
  • chalk: Enhances the user experience with colorful command-line output.
  • tsup: Efficient and fast TypeScript module bundler for building your CLI app.
  • rimraf: Cross-platform utility to remove files and directories, commonly used for cleaning build artifacts before rebuilding.
1.1.0

1 month ago

1.0.2

1 month ago

1.0.1

1 month ago

1.0.0

1 month ago