replica-omnisciente/docs/guides/cli/netlify.md

75 lines
2.3 KiB
Markdown

# netlify (Netlify CLI)
## What it is
Netlify's CLI: deploy static sites and serverless functions, run the local dev
server (`netlify dev`) that emulates Netlify's edge/functions environment, and
manage sites/env from the terminal.
## Install
Via npm (current stable; Node LTS required):
```bash
npm install -g netlify-cli
```
## Authenticate
```bash
netlify login # browser OAuth
netlify status # shows account + site link
```
Token stored under `~/.config/netlify/`. For CI use a personal access token
from the dashboard, kept in Vaultwarden (https://vault.portugalfuturista.org),
exported as `NETLIFY_AUTH_TOKEN` (plus `NETLIFY_SITE_ID`).
## Configure for this environment
```bash
cd <site>
netlify init # or: netlify link
netlify dev # local server w/ functions emulation
netlify deploy # draft deploy, prints a preview URL
netlify deploy --prod # production
netlify env:list
```
## Self-hosted equivalent
None deployed. Closest self-hosted path for static + functions today:
**Caddy** serving a build output directory on a Proxmox CT, exposed through
the `pf-tunnel-v2` Cloudflare tunnel (route added via cloudflared — see
[cloudflared-wrangler.md](cloudflared-wrangler.md)). Netlify-style edge
functions have no drop-in self-hosted runtime; Cloudflare Workers + `wrangler
dev` is the nearest alternative.
## Aurélio integration
The **cli-edge** skill can drive `netlify` for legacy site deploys. No
dedicated connector-registry entry — treated as an external SaaS; closest
listed edge connector is `vercel`.
## Verify
```bash
netlify --version
# netlify-cli/1x.y.z linux-x64 node-v2x.y.z
netlify status
# ──────────────────────┐
# Current Netlify User │
# ... │
netlify sites:list | head
```
## Troubleshooting
- **`netlify login` hangs** — no browser on a headless shell; use
`NETLIFY_AUTH_TOKEN` from Vaultwarden instead.
- **Functions work locally, 404 in prod** — check `netlify.toml`
`[functions] directory` and that the deploy actually bundled them
(`netlify deploy --prod --build` logs show "Functions bundling").
- **Redirects not applied** — `_redirects` must end up in the publish dir;
verify with `netlify deploy --prod` output listing published files.
- **Wrong site linked** — `netlify unlink` then `netlify link` again.