# Bootstrap — crear proyectos (`boogiepop new`)

Guía corta de setup. La referencia completa (pasos del MS, Terraform, costos, troubleshooting) está en **[CLI-BOOTSTRAP-INFRA.md](./CLI-BOOTSTRAP-INFRA.md)**.

## Destinos GitHub

| Tipo | Variable env | Ejemplo repo |
|------|--------------|--------------|
| `next` | `GITHUB_ORG_BOOGIEPOP` | `github.com/blanck1945/boogiepop-my-app` |
| `streamlit`, `vite` | `GITHUB_ORG_REMOTES` | `github.com/Boogiepop-remotes/boogiepop-my-app` |

Consultá orgs reales con el MS levantado: `GET /bootstrap/meta/targets`.

## Setup (una vez)

### 1. Tokens y secrets

| Dónde | Variable | Para qué |
|-------|----------|----------|
| **Bootstrap MS** `.env` | `GITHUB_TOKEN` | Crear repos, push, colaboradores |
| **Bootstrap MS** `.env` | `BOOTSTRAP_API_KEY` | Auth CLI → MS |
| **Bootstrap MS** `.env` | `INFRA_TERRAFORM_DIR` | Ruta a `boogiepop-infra/terraform` |
| **Bootstrap MS** `.env` | `BOOGIEPOP_API_URL` + `BOOGIEPOP_ADMIN_*` | Registrar app en DB (pública, oculta en hub) |
| **CLI** `~/.boogiepop/bootstrap.json` | `apiKey` | Mismo valor que `BOOTSTRAP_API_KEY` |

PAT recomendado: scopes `repo`, acceso a las orgs `GITHUB_ORG_BOOGIEPOP` y `GITHUB_ORG_REMOTES`.

### 2. Levantar el Bootstrap MS

```bash
cd boogiepop-bootstrap-core && npm install && npm run build
cd ../boogiepop-bootstrap
cp .env.example .env   # completar GITHUB_TOKEN, BOOTSTRAP_API_KEY, INFRA_TERRAFORM_DIR
npm install && npm run start:dev
```

Requiere **git**, **terraform** y **credenciales AWS** en la máquina del MS.

### 3. Configurar la CLI

```bash
cd boogiepop-cli && npm run build
boogiepop bootstrap config --url http://localhost:3100 --key <BOOTSTRAP_API_KEY>
```

## Uso

```bash
boogiepop new              # wizard interactivo
boogiepop new --dry-run    # solo muestra qué enviaría
boogiepop new --no-clone   # no clona en ./<nombre>
```

## Infra AWS (opción del wizard)

Si elegís **Sí**:

1. Genera archivos `*_&lt;app&gt;.tf` en `boogiepop-infra`
2. Setea `enable_&lt;app&gt;_ecs = true` en `terraform.tfvars`
3. Corre `terraform apply -target=…` (solo recursos de esa app)
4. Luego crea el repo, transforma el seed y pushea `main`

Si la infra **ya existe** (reintento tras fallo parcial), elegí **No** en infra y cloná/completá manualmente.

## Estado del roadmap

| Fase | Estado |
|------|--------|
| CLI `new` + Bootstrap MS + core | ✅ |
| Scaffold Terraform + apply acotado + S3/Secrets | ✅ |
| Deploy GitHub Actions OIDC en repo nuevo | ✅ |
| Deploy del propio Bootstrap MS a ECS | Pendiente |
| GitLab groups en bootstrap | Pendiente |
| UI repository-manager | Pendiente |

## Troubleshooting rápido

| Síntoma | Acción |
|---------|--------|
| `Bootstrap MS no configurado` | `boogiepop bootstrap config` |
| `401 API key inválida` | Igualar CLI y `.env` del MS |
| `403` al crear repo | PAT sin acceso a la org destino |
| `terraform apply falló (código 1)` | Ver [CLI-BOOTSTRAP-INFRA.md § Recuperación](./CLI-BOOTSTRAP-INFRA.md#recuperación-ante-fallos) |
| `git not found` | Instalar Git donde corre el MS |
