Skip to main content

Apinni CLI

The Apinni CLI (apinni) is the primary tool for generating type definitions from your decorated TypeScript code. It supports various commands, flags, and configuration options to fit your workflow. This document covers CLI usage, including running in watch mode, custom configurations, and common troubleshooting steps.

CLI Overview

The apinni CLI processes your project's controllers and endpoints, compiling TypeScript and generating type files. It's designed for ease of use in development and build pipelines.

Basic Usage

Run the CLI directly via npx or through scripts in package.json.

Running Generation

npm run apinni generate

This command scans for files, processes decorators, and outputs type definitions.

Running in Watch Mode

For development, use the watch command:

npm run apinni watch

This monitors file changes and regenerates types automatically.

tip

Since it relies on Chokidar - no need for extra dev-server running.

Commands and Flags

The CLI supports the following commands:

  • generate: Generate types with decorators (one-time run).
  • watch: Run in watch mode for automatic regeneration on changes.

Flags

Flags are command-specific. The generate command supports the following flags:

FlagDescriptionShortcut
--use-existing-buildSkips compilation step (if run-time decorators defined). Instead uses existing build folder defined in tsconfig.json-u
--verboseEnable detailed logging for debugging.-v

Global flags:

FlagDescriptionShortcut
--helpDisplay help information.-h

Troubleshooting

Common Issues

IssueSolution
Command not foundEnsure apinni is installed as a dev dependency.
No files processedCheck include patterns and ensure decorators are used.
Permission errorsRun with appropriate permissions or check file paths.
High memory usageLimit include patterns for large projects.

Debugging

  • Use --verbose for logs (if enabled in your setup).
  • Verify tsconfig.json settings.
  • Clear cache if issues persist: rm -rf node_modules/.cache.
warning

Always compile your project before running apinni generate if using --use-existing-build flag.

Advanced Usage

Integrate with build tools like Webpack or Vite by running apinni generate --use-existing-build in after-build scripts.

For more, see Guides.

info

Report CLI issues on GitHub.