npm package: @hegoatek/cli
Description: HegoaTek CLI - Create and manage HegoaTek projects
Author: HegoaTek
Latest version: 1.2.1

# HegoaTek CLI

Interactive command-line tool for creating and managing HegoaTek projects.

**For development setup:** See [DEVELOPMENT.md](./DEVELOPMENT.md)

## Installation

### Global Installation (Recommended)

Install globally to use `hegoatek` command from anywhere:

```bash
npm install -g @hegoatek/cli
hegoatek --version
```

### Per-Project Installation

Install as a dev dependency in your project:

```bash
npm install --save-dev @hegoatek/cli
npx hegoatek new my-project
```

## Quick Start

### Interactive Mode (Recommended)

```bash
hegoatek new
```

Answer the questions to customize your project:

- Project name
- Project type (SaaS Single-Tenant, Multi-Tenant, Site Vitrine)
- Authentication provider (JWT, Supabase, Auth0)
- Storage provider (Cloudflare R2, AWS S3, Local)
- Email provider (Resend, SendGrid, SMTP)
- Billing (Stripe)

### Non-Interactive Mode

```bash
hegoatek new my-project --template=saas-single-tenant
```

## Commands

### `hegoatek new [name]`

Create a new HegoaTek project.

**Usage:**

```bash
hegoatek new                                    # Fully interactive
hegoatek new my-project                         # Name provided, then interactive
hegoatek new my-project -t saas-single-tenant   # Non-interactive (skip questions)
```

**Options:**

- `-t, --template <template>` - Template name (optional)
- `-d, --directory <dir>` - Output directory (default: current directory)

**Available Templates:**

- `saas-single-tenant` - SaaS for one customer (Angular + NestJS)
- `saas-multitenant` - Multi-tenant SaaS with RLS (Angular + NestJS)
- `site-vitrine-nextjs` - Marketing site with contact form (Next.js)

### `hegoatek info`

Display information about available templates and providers.

**Usage:**

```bash
hegoatek info
```

Shows details about:

- Available project templates
- Authentication providers
- Storage providers
- Email providers

### `hegoatek help [command]`

Show help for a specific command or list all commands.

**Usage:**

```bash
hegoatek help              # Show all commands
hegoatek help new          # Help for 'new' command
```

## Environment Setup

After creating a project, you'll need to configure environment variables.

### SaaS Templates (Angular + NestJS)

Create a `.env` file in the project root (a template is generated automatically):

```bash
# Authentication
AUTH_PROVIDER=custom
JWT_SECRET=your-secret-key-here
JWT_EXPIRATION_SECONDS=86400

# Database (Neon PostgreSQL)
DATABASE_URL=postgresql://user:password@host:5432/dbname

# Storage (if configured)
STORAGE_PROVIDER=cloudflare-r2
R2_ACCOUNT_ID=your-account-id
R2_ACCESS_KEY_ID=your-key-id
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name

# Email (if configured)
RESEND_API_KEY=re_your_api_key

# Frontend (Angular)
API_URL=http://localhost:3000
```

### Next.js Templates

```bash
# Email
RESEND_API_KEY=re_your_api_key
CONTACT_EMAIL=your@email.com
```

## Project Structure

### SaaS Single-Tenant

```
my-project/
├── frontend/           # Angular 21 application
│   ├── src/
│   │   ├── app/
│   │   │   ├── login/
│   │   │   └── home/
│   │   └── main.ts
│   ├── angular.json
│   └── package.json
├── backend/            # NestJS 11 API
│   ├── src/
│   │   ├── app.controller.ts
│   │   ├── app.module.ts
│   │   └── main.ts
│   ├── nest-cli.json
│   └── package.json
├── prisma/             # Database schema
│   ├── schema.prisma
│   └── migrations/
├── .env
├── .env.example
└── package.json
```

### Site Vitrine (Next.js)

```
my-site/
├── src/
│   ├── app/
│   │   ├── layout.tsx
│   │   ├── page.tsx
│   │   ├── about/
│   │   ├── contact/
│   │   └── api/
│   │       └── contact/route.ts
│   └── components/
├── public/
├── next.config.mjs
├── tailwind.config.ts
└── package.json
```

## Development

### Start SaaS Project

```bash
cd my-project
npm install

# Terminal 1: Backend
npm run start:backend

# Terminal 2: Frontend
npm run start:frontend

# Or both in parallel
npm run start:all
```

### Start Next.js Project

```bash
cd my-site
npm install
npm run dev
```

## Common Tasks

### Run Tests

```bash
npm run test
```

### Build for Production

```bash
npm run build
```

### Format Code

```bash
npm run format
```

### Lint Code

```bash
npm run lint
```

### Database Management (SaaS)

```bash
# Generate Prisma Client
npm run prisma:generate

# Create migration
npm run prisma:migrate

# Open Prisma Studio GUI
npm run prisma:studio
```

## Troubleshooting

### "hegoatek: command not found"

Install globally:

```bash
npm install -g @hegoatek/cli
```

### "Templates not found"

Ensure you have a stable internet connection. You can also specify a version:

```bash
npm install -g @hegoatek/cli@latest
```

### "Permission denied" on macOS/Linux

Use sudo:

```bash
sudo npm install -g @hegoatek/cli
```

Or fix npm permissions: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

### Port already in use

Change the port in your development configuration or kill the process:

```bash
# Find process using port 3000
lsof -i :3000

# Kill it
kill -9 <PID>
```

## Examples

### Example 1: Create a SaaS Platform

```bash
$ hegoatek new my-saas-app

? Project name: my-saas-app
? Select project type: SaaS Single-Tenant (Angular + NestJS)
? Configure advanced features? Yes
? Authentication provider: Custom JWT (Recommended)
? File storage: Cloudflare R2 (Recommended)
? Email provider: Resend (Recommended)
? Enable Stripe billing? Yes

✨ Creating project "my-saas-app"...
  ✔ Copied template
  ✔ Updated configuration
  ✔ Generated .env file
  ✔ Initialized Git

🎉 Project created successfully!
```

### Example 2: Create a Marketing Site

```bash
hegoatek new my-website -t site-vitrine-nextjs
```

### Example 3: View Available Options

```bash
hegoatek info
```

## Next Steps

After creating your project:

1. **Install Dependencies**

   ```bash
   npm install
   ```

2. **Configure Environment**

   - Edit `.env` with your API keys and configuration
   - Check `.env.example` for required variables

3. **Start Development**

   ```bash
   npm run dev
   ```

4. **Deploy** (See project README for deployment guides)

## Documentation

For more information:

- [HegoaTek Studio Documentation](../../../README.md)
- [@hegoatek/core](../core/README.md) - NestJS Modules
- [@hegoatek/ui-angular](../ui-angular/README.md) - Angular Components
- [@hegoatek/config-schemas](../config-schemas/README.md) - Configuration Schemas

## License

MIT

## Support

For issues or questions:

- Check the troubleshooting section above
- Review project README after creation
- Visit the main documentation