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.
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
- Yarn
- pnpm
npm run apinni generate
yarn apinni generate
pnpm 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
- Yarn
- pnpm
npm run apinni watch
yarn apinni watch
pnpm run apinni watch
This monitors file changes and regenerates types automatically.
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:
| Flag | Description | Shortcut |
|---|---|---|
--use-existing-build | Skips compilation step (if run-time decorators defined). Instead uses existing build folder defined in tsconfig.json | -u |
--verbose | Enable detailed logging for debugging. | -v |
Global flags:
| Flag | Description | Shortcut |
|---|---|---|
--help | Display help information. | -h |
Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| Command not found | Ensure apinni is installed as a dev dependency. |
| No files processed | Check include patterns and ensure decorators are used. |
| Permission errors | Run with appropriate permissions or check file paths. |
| High memory usage | Limit include patterns for large projects. |
Debugging
- Use
--verbosefor logs (if enabled in your setup). - Verify
tsconfig.jsonsettings. - Clear cache if issues persist:
rm -rf node_modules/.cache.
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.
Report CLI issues on GitHub.