# Development & publishing — Pip: Sparkle Journey

## Repository layout

```text
.
├── index.html          # offline entry point
├── styles.css          # local pastel styling
├── src/
│   ├── logic.js        # pure game logic (testable in Node)
│   ├── levels.js       # local level data (no fetch)
│   └── app.js          # DOM, input, rendering, saves, audio
├── tests/              # node:test logic + browser smoke
├── docs/               # the player documentation set
├── README.md
├── package.json
└── unni-test.cmd
```

## Local validation

```powershell
node --test tests\*.test.js
node tests/browser-smoke.mjs   # optional: real Chrome/Edge CDP check, skips if no browser
```

`unni-test.cmd` is the one-command gate. A game is done only when logic tests, the offline structure check and a real browser input/DOM-change check pass.

## Building for the local site

The hub site lives at `C:\GitHub\Unni-Games`. After a game has an `index.html`, run:

```powershell
powershell -ExecutionPolicy Bypass -File C:\GitHub\Unni-Games\tools\sync-site.ps1
```

It copies only games that actually have a playable entry point into `Unni-Games\games\`. Open `C:\GitHub\Unni-Games\index.html` directly to see the hub.

## GitHub Actions → Cloudflare Pages

This repository ships a `.github/workflows/deploy.yml`. Every push to `main` (and every manual **Run workflow**) does, in order:

1. `npm test` — logic and offline-structure checks;
2. `npm run test:browser` — a real headless Chrome/Edge `file://` interaction test;
3. `npm run build` — assembles `dist/` from local files only;
4. `cloudflare/wrangler-action` publishes `dist/` to the Cloudflare Pages project named after this repository.

Deployment is skipped automatically if any test fails. The token and account id are stored as the masked repository secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`; the token is scoped to Pages access on this account only. Manual deploy: `gh workflow run deploy.yml --repo HensonHenson/game-10-pip-sparkle-journey`.

## Publishing flow

1. **Validate** — artifacts and engine selection are checked by the Game Factory.
2. **Build** — reuse the registered engine and modules; never rebuild them.
3. **Test** — logic, offline structure and a real browser input check.
4. **Judge** — Bloom score and hard gates decide promote / repair / archive.
5. **Approve** — a human chooses **PUBLISH**, **HOLD** or **ARCHIVE**. Public release never happens automatically.
6. **Publish** — staging first, then production. This repository is currently on the local-static path; GitHub Pages / Cloudflare are prepared but not connected.

## Content rules

- Original kawaii-chibi cartoon SVG/CSS art only; no external or baked-in asset text.
- No network calls after load; all assets and data local and versioned.
- Sprout titles carry the 18+ gate and the content restrictions in [Instructions](INSTRUCTIONS.md).
