npm package: @ifoxxie_dev/cli
Description: A powerful CLI tool built with NestJS and nest-commander for scaffolding NestJS projects and generating commands with AI assistance.
Latest version: 0.0.4

# ifoxxie_dev

A powerful CLI tool built with NestJS and nest-commander for scaffolding NestJS projects and generating commands with AI assistance.

[![npm version](https://img.shields.io/npm/v/@ifoxxie_dev/cli.svg)](https://www.npmjs.com/package/@ifoxxie_dev/cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Features

- **Project Scaffolding**: Create new NestJS projects from pre-built templates (standalone or CLI)
- **AI-Powered Code Generation**: Generate new CLI commands using OpenAI
- **Multiple Package Managers**: Support for npm, yarn, and pnpm
- **Interactive Prompts**: User-friendly CLI experience with spinners and formatted output
- **Auto Module Registration**: Automatically updates `app.module.ts` when generating commands

## Installation

```bash
# Global installation (recommended)
npm install -g @ifoxxie_dev/cli

# Or with yarn
yarn global add @ifoxxie_dev/cli

# Or with pnpm
pnpm add -g @ifoxxie_dev/cli
```

## Quick Start

### 1. Configure OpenAI Token

Before using AI-powered features, configure your OpenAI API token:

```bash
ifoxxie_dev configure --token YOUR_OPENAI_TOKEN
```

Or use interactive mode:

```bash
ifoxxie_dev configure
```

### 2. Create a New Project

```bash
# Create a standalone NestJS project
ifoxxie_dev new project my-app

# Create a CLI project
ifoxxie_dev new project my-cli --template cli

# With automatic dependency installation
ifoxxie_dev new project my-app --install
```

### 3. Generate Commands with AI

Inside a CLI project:

```bash
ifoxxie_dev new command greet "Create a command that greets users by name with optional formal greeting"
```

## Commands

### `configure` (alias: `config`)

Configure CLI settings.

```bash
# Set OpenAI token
ifoxxie_dev configure --token <token>

# Show current configuration
ifoxxie_dev configure --show
```

| Option            | Alias | Description                   |
| ----------------- | ----- | ----------------------------- |
| `--token <token>` | `-t`  | OpenAI API token              |
| `--show`          | `-s`  | Display current configuration |

### `new project` (alias: `new p`)

Create a new NestJS project from templates.

```bash
ifoxxie_dev new project <name> [options]
```

| Option                  | Alias | Description                              | Default      |
| ----------------------- | ----- | ---------------------------------------- | ------------ |
| `--template <template>` | `-t`  | Project template (`standalone` or `cli`) | `standalone` |
| `--overwrite`           | `-o`  | Overwrite existing directory             | `false`      |
| `--install`             | `-i`  | Install dependencies after creation      | `false`      |
| `--yarn`                | -     | Use yarn for installation                | `false`      |
| `--pnpm`                | -     | Use pnpm for installation                | `false`      |

### `new command` (alias: `new c`, `new cmd`)

Generate a new CLI command using AI.

```bash
ifoxxie_dev new command <name> <description>
```

| Argument      | Description                               |
| ------------- | ----------------------------------------- |
| `name`        | Command name (e.g., `deploy`, `generate`) |
| `description` | Description of what the command should do |

## Configuration

Configuration is stored in `~/.hcoder/config.json` and includes:

- OpenAI API token
- Assistant ID
- CLI version

## Templates

Available project templates:

| Template     | Description                                |
| ------------ | ------------------------------------------ |
| `standalone` | Standard NestJS application                |
| `cli`        | NestJS CLI application with nest-commander |

Templates are sourced from [nestjs-cli-templates](https://github.com/ifoxxie_dev/nestjs-cli-templates).

## Requirements

- Node.js >= 18
- Git (for cloning templates)
- OpenAI API key (for AI-powered command generation)

## Examples

### Creating a CLI Project with Dependencies

```bash
ifoxxie_dev new project my-awesome-cli --template cli --install --pnpm
```

### Generating Multiple Commands

```bash
cd my-awesome-cli

# Generate a deploy command
ifoxxie_dev new command deploy "Create a command that deploys the application to a specified environment"

# Generate a backup command
ifoxxie_dev new command backup "Create a command that backs up the database with optional compression"
```

### Viewing Configuration

```bash
ifoxxie_dev config --show
```

Output:

```
┌──────────────────────────────────────┐
│  Configuration                       │
├──────────────┬───────────────────────┤
│ Token        │ sk-...                │
├──────────────┼───────────────────────┤
│ Assistant ID │ asst_...              │
└──────────────┴───────────────────────┘
```

## Tech Stack

- [NestJS](https://nestjs.com/) - Progressive Node.js framework
- [nest-commander](https://docs.nestjs.com/recipes/nest-commander) - CLI framework for NestJS
- [OpenAI](https://openai.com/) - AI-powered code generation
- [chalk](https://github.com/chalk/chalk) - Terminal styling
- [ora](https://github.com/sindresorhus/ora) - Elegant terminal spinners
- [cli-table3](https://github.com/cli-table/cli-table3) - Pretty unicode tables

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Author

**ifoxxie_dev**

---

Made with :heart: using NestJS and nest-commander