npm package: @gobuildlabs/saas-init
Description: CLI tool to scaffold new SaaS projects with the starter kit
Latest version: 3.0.4

# SaaS Init CLI

CLI tool to quickly scaffold new SaaS projects using the SaaS Starter Kit.

## Installation

```bash
# Global installation
npm install -g @gobuildlabs/saas-init

# Or use directly with npx (recommended)
npx @gobuildlabs/saas-init my-saas
```

## Usage

### Interactive Mode

```bash
npx @gobuildlabs/saas-init
```

The CLI will prompt you for:
- Project name
- Description
- Author details
- Support email
- Authentication providers (Email, Google, GitHub, Twitter)
- Features to enable (Billing, Analytics, etc.)
- Package manager (pnpm, npm, yarn)

### With Project Name

```bash
npx @gobuildlabs/saas-init my-saas-app
```

### Command Options

```bash
npx @gobuildlabs/saas-init [project-name] [options]

Options:
  -t, --template <template>  Template to use (default: saas-template)
  --skip-git                 Skip git initialization
  --skip-install             Skip dependency installation
  --use-npm                  Use npm instead of pnpm
  --use-yarn                 Use yarn instead of pnpm
  -h, --help                 Display help
  -V, --version              Display version
```

## Examples

### Create with npm and skip git

```bash
npx @gobuildlabs/saas-init my-app --use-npm --skip-git
```

### Create without installing dependencies

```bash
npx @gobuildlabs/saas-init my-app --skip-install
```

## What It Does

1. ✅ Creates new project directory
2. ✅ Clones the template repository
3. ✅ Prompts for configuration (name, email, features)
4. ✅ Updates `package.json` with your details
5. ✅ Updates `config/saas.config.ts` with your settings
6. ✅ Creates `.env.local` from `.env.example`
7. ✅ Installs dependencies (unless skipped)
8. ✅ Initializes git repository (unless skipped)
9. ✅ Shows next steps

## After Running

The CLI creates a project with this structure:

```
my-saas-app/
├── app/                    # Next.js pages (empty, ready for your code)
├── components/             # React components
├── config/
│   ├── saas.config.ts     # ✅ Configured with your details
│   └── stripe.config.ts   # ⚠️ Add Stripe Price IDs
├── lib/
│   ├── stripe-config.ts   # Uses @gobuildlabs/saas-starter-kit
│   ├── supabase.ts        # Supabase server client
│   ├── seo.ts             # SEO helpers
│   └── utils.ts           # Utilities
├── .env.local             # ✅ Created (add your API keys)
├── .env.example           # Template for environment variables
└── package.json           # ✅ Configured with your name
```

## Next Steps

After the CLI completes, follow these steps:

1. **Navigate to your project**
   ```bash
   cd my-saas-app
   ```

2. **Set up Supabase**
   - Create project at [supabase.com](https://supabase.com)
   - Copy URL and keys to `.env.local`

3. **Set up Stripe**
   - Create products in [Stripe Dashboard](https://dashboard.stripe.com)
   - Copy Price IDs to `config/stripe.config.ts`
   - Add API keys to `.env.local`

4. **Run development server**
   ```bash
   pnpm dev  # or npm/yarn dev
   ```

5. **Start building!** 🚀

## Environment Variables

The CLI creates a `.env.local` file. You need to fill in:

```env
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# Stripe
STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Database
DATABASE_URL=postgresql://...
```

## Troubleshooting

### "Command not found: npx"

Make sure you have Node.js 18+ installed:
```bash
node --version  # Should be v18.0.0 or higher
```

### "Template not found"

The CLI looks for templates in:
1. Local: `packages/saas-template` (for development)
2. GitHub: `gobuildlabs/saas-template` (for production)

Make sure the template repository exists.

### Permission errors on installation

Try with sudo (macOS/Linux):
```bash
sudo npm install -g @gobuildlabs/saas-init
```

Or use npx instead (recommended):
```bash
npx @gobuildlabs/saas-init my-app
```

## Development

To work on the CLI locally:

```bash
cd packages/cli

# Install dependencies
pnpm install

# Build
pnpm build

# Test locally
node bin/cli.js my-test-app
```

## Contributing

Issues and pull requests are welcome!

## License

MIT