# Local Development Setup

## Prerequisites

- **Node.js 20 or newer.** The project has been run on Node 24.
- npm (bundled with Node)
- Git, with access to `github.com/pmgasset/fortadamswebsite`

## First run

```bash
git clone https://github.com/pmgasset/fortadamswebsite.git
cd fortadamswebsite
npm install
cp .env.example .env.local     # fill in what you need (see below)
npm run dev                    # http://localhost:3000
```

`.env*` files are git-ignored except `.env.example`. Never commit real secrets.

## Scripts

| Command | Purpose |
| --- | --- |
| `npm run dev` | Dev server with hot reload |
| `npm run build` | Production static export to `out/`. Run this before pushing; it catches type errors and export-incompatible code. |
| `npm run start` | Not useful with `output: "export"`. Serve `out/` with any static server instead, for example `npx serve out`. |
| `npm run lint` | ESLint |
| `npm run format` | Prettier (writes), including Tailwind class sorting |
| `npm run format:check` | Prettier check (CI-friendly) |

## Environment for local development

Most features work with an empty `.env.local`:

- **Webhook forms** (volunteer, corporate, newsletter) detect placeholder or empty URLs (anything without `http(s)://`, or containing `example.com`). Instead of sending, they simulate success after 500 ms. That's safe locally, but see *Known Issues and Open Items* for production.
- **Explore the Fort** videos default to `https://cdn.r2.fortadams.org`.
- **FareHarbor** reads its URL from `content/tour-booking.json`, so no environment variable is needed.

## Testing the event inquiry function locally

`next dev` doesn't run Cloudflare Pages Functions, so `POST /api/event-inquiry` returns 404 and the form shows its error state. To test end to end, build and run with Wrangler:

```bash
npm run build
npx wrangler pages dev out
```

Wrangler reads the `GHL_*` secrets from a `.dev.vars` file in the project root. The existing `.env*` ignore rule does **not** cover `.dev.vars`, so add `.dev.vars` to `.gitignore` before creating it. Use a HighLevel **test** pipeline or sub-account, because this creates real contacts and opportunities.

## Editing CMS content locally

`public/admin/config.yml` has `local_backend: true`, so you can use the CMS without GitHub auth:

```bash
npm run dev            # terminal 1
npx decap-server       # terminal 2 (proxy on port 8081)
```

Then open `http://localhost:3000/admin/edit/` (or start from the workspace at `/admin/`). Changes are written straight to your working copy. Review them with `git diff` and commit as usual.

## Before you push

```bash
npm run lint && npm run format:check && npm run build
```

There's no CI in the repository (no `.github/workflows`). Cloudflare Pages is the only automated build, so a broken build only shows up there. Run the build locally.