# Deploy — Shoe Customizer plugin

The plugin is **code**, so it's installed by putting its folder in `wp-content/plugins/` — not
via the REST API (WordPress can't install arbitrary plugin zips over REST, only wp.org plugins).
The repo remote is **AWS CodeCommit**, so git-pull deploy tools like *WP Pusher* (GitHub/
Bitbucket/GitLab only) don't apply unless you mirror the repo to one of those hosts.

Three supported paths, simplest first.

## 1. Zip upload (no server access needed)

```bash
cd shoe_customizer/plugin
./build.sh                 # -> dist/shoe-customizer-<version>.zip
```

WordPress admin → **Plugins → Add New → Upload Plugin** → choose the zip → **Install** →
**Activate**. Then **Shoe Customizer → Import seed shoes**.

Uploading a newer zip over an existing install upgrades it (WP replaces the folder; the schema
self-upgrades on load via `SC_Install::maybe_upgrade()`).

## 2. SFTP / rsync (if you give me SSH or SFTP access)

```bash
./build.sh
# then, on your machine or a runner with access:
rsync -az --delete shoe_customizer/plugin/shoe-customizer/ \
    user@corporatekicks-host:/var/www/.../wp-content/plugins/shoe-customizer/
```

Activate once from **Plugins**; subsequent syncs are just file copies (schema self-upgrades).

## 3. CI from CodeCommit (unattended)

Mirror the deploy step in AWS CodePipeline/CodeBuild: on push to `shoe-customizer`, run
`plugin/build.sh` and rsync the folder to the site over SSH (store the SSH key in Secrets
Manager). This is the "push → live" option once the manual paths are proven.

---

## Verify after deploy

```bash
# WooCommerce auth + our endpoints (read-only, safe on production)
SC_NETRC=/path/to/ck.netrc ./smoke-test.sh https://corporatekicks.com.au
```

Expect `GET /shoe-customizer/v1/shoes` and `/shoe/af1` to return **200** once the plugin is
active and the seed shoes are imported. Or just open a config in the browser:
`https://corporatekicks.com.au/wp-json/shoe-customizer/v1/shoe/af1`.

## Notes

- `build.sh` reads the version from the plugin header, uses `zip` / `python3` / `php` —
  whichever is present.
- `dist/` is a build artefact and is git-ignored.
- **Staging first.** This plugin hasn't been runtime-tested inside WordPress yet; validate on a
  staging site before activating on the production store.
- Never commit `ck.netrc` (or the ck/cs values). Keep the netrc outside the repo.
