# @cimplify/cli

The Cimplify command-line tool. Deploy from your terminal, manage env vars, attach domains, scaffold storefronts.

## Install

```bash
curl -fsSL https://cimplify.io/install | sh
```

Detects your OS + arch, downloads the matching binary from the latest GitHub release, verifies its sha256, and drops it in `~/.local/bin/cimplify`. ~20 ms cold start. The binary bundles every storefront template and the full component registry — `init`, `add`, and `list` work without a separate `@cimplify/sdk` install.

Override the destination with `--prefix`, pin a version with `--version cli-v0.1.0`, or skip the install entirely with `bunx @cimplify/cli <command>`.

## What you can do

```bash
cimplify init my-store --template restaurant   # scaffold a working storefront
cimplify login                                  # browser PKCE flow (or --api-key for CI)
cimplify projects create my-store               # create a Cimplify project + Freestyle repo
cimplify link <project-id>                      # bind the current directory to a project
cimplify deploy [--prod]                        # push HEAD + build + deploy
cimplify logs --follow                          # stream build logs
cimplify rollback <deploy-id>                   # re-deploy a previous SHA
cimplify env push                               # upload .env.local to the linked project
cimplify domains add shop.example.com           # add a custom domain (prints DNS records)
cimplify status                                 # latest deployment summary
```

`cimplify --help` lists every subcommand and flag.

## Conventions

- **Project link:** `cimplify link <project-id>` writes `.cimplify/project.json` in the working directory. Subsequent commands read it to know which project to act on — no `--project` flag needed for the common case.
- **Auth:** credentials persist at `~/.config/cimplify/auth.json`. CI uses `--api-key dk_live_…` to skip the browser.
- **JSON mode:** pass `--json` (or set `CIMPLIFY_JSON=1`) for `{ ok, data | error }` machine-readable output on stdout.
- **Yes/no prompts:** pass `--yes` (or `-y`) to auto-confirm.

## How it talks to Cimplify

Every cloud command is a thin HTTP client over `https://api.cimplify.io` (override with `CIMPLIFY_API_URL`). The deploy flow specifically:

1. `git push` to the project's git remote (uses a short-TTL token minted by Cimplify when the remote is Freestyle-hosted; falls back to your existing git auth otherwise).
2. `POST /v1/businesses/<bid>/projects/<pid>/deploy` with the local SHA.
3. Poll `/deployments/<id>/progress` every 1 second, printing log chunks as they arrive.
4. Exit 0 on `active`, 2 on `superseded`, 1 on `failed` / `cancelled`.

## Storefront templates

`cimplify init` ships with six designs out of the box:

| Template | Use case |
|---|---|
| `bakery` (default) | Warm food-style storefront |
| `restaurant` | Menu + ordering UI |
| `retail` | Product-grid retail |
| `services` | Booking-style storefront |
| `grocery` | Catalogue-heavy grocery layout |
| `fashion` | Editorial fashion layout |

Each is a full Next.js project wired to `@cimplify/sdk` with the design system pre-applied.

## Related

- [`@cimplify/sdk`](../sdk/README.md) — the runtime SDK + storefront components scaffolded by `cimplify init`.

## License

MIT.
