diff --git a/.baseline/product/README.md b/.baseline/product/README.md index 145454f..736f069 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -100,3 +100,8 @@ environments: env: DEPLOYED_URL: https://hono-api.example.com ``` + +The repository names the domain in one place, `BASE_DOMAIN` in `intent.yaml` +(one line per environment), which the API was born with as the reserved +placeholder `hono-api.example.com` — the example above carries it too. +Replace it with your domain in the same change that attaches it. diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index 109707d..3c81548 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -91,7 +91,6 @@ jobs: --out "$(mktemp -d)" \ --set reponame=acme-api \ --set "productname=Acme API" \ - --set productdomain=acme.dev \ --set githuborg=acme-inc - name: the leak gate — what an API carries run: bash testing/leak.test.sh diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 93ce216..eede899 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -50,7 +50,7 @@ cd hono-api orun new --blueprint repo-blueprint.yaml \ --out ~/apis/acme-api --run-hooks --resume \ --set reponame=acme-api --set productname="Acme API" \ - --set productdomain=acme.dev --set githuborg=acme-inc \ + --set githuborg=acme-inc \ --set orunWorkspace=ws_XXXXXXXX \ --set subdomain= ``` @@ -87,9 +87,13 @@ orun new --blueprint repo-blueprint.yaml --out ~/apis/acme-api --run-hooks \ `02-docs` reads the identity back from `.rebrand/values.json` in the placed tree, but the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before anything runs, so pass -them every time (a `--values` file is easier). The full guide, one page per -phase: [docs/phases/README.md](docs/phases/README.md). +`githuborg` — are validated before anything runs, so pass them every time (a +`--values` file is easier). The domain is not one of them: the API goes live +on workers.dev, and `productdomain` defaults to empty, which brands the +reserved placeholder `.example.com` into `BASE_DOMAIN` for an owner +to replace when they attach a domain (README, "Custom domain"). Pass +`--set productdomain=` only for an API that already has its domain. +The full guide, one page per phase: [docs/phases/README.md](docs/phases/README.md). | flag | what it does | |---|---| @@ -192,7 +196,7 @@ at the tag and refuses the whole catalogue if it 404s. | Convergence failed AFTER the PR merged; re-running lands nothing | expected on its own — the files are on main. Re-run the phase (`--phase 01-product`, `--redo 01-product`, or the console's Retry): its `retouch` hook gives the landing a diff and the API redeploys | | The API's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` | | A bootstrap stopped before `02-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `02-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` | -| `✕ input "productdomain" is required` | all four required inputs must be set on every invocation, single-phase ones included | +| `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included | | `unknown flag: --phase` or a parse error in the blueprint | the CLI is below the v2.58.11 floor | | the convergence reported green, then `verify` got 404 from both URLs | a second workflow ran on the push to main and the watch took its run. Only `ci.yml` runs on a push to main (`testing/coverage.test.sh` holds it); read the CI run on main for the real result | | the convergence planned no lanes at all | the merge's push had no `before` to diff against (a first push straight onto an unborn `main`). The landing merges a pull request into orun's `Initial commit`, so its push has one; re-run the phase and its retouch marker re-plans the API | diff --git a/README.md b/README.md index 8f88525..380e071 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ milestones and the as-built status. git clone --depth 1 --branch https://github.com/sourceplane/hono-api cd hono-api orun new --blueprint repo-blueprint.yaml --out ~/apis/acme-api --run-hooks --resume \ - --set reponame=acme-api --set productname="Acme API" --set productdomain=acme.dev \ + --set reponame=acme-api --set productname="Acme API" \ --set githuborg=acme-inc --set subdomain= ``` diff --git a/ai/context/current.md b/ai/context/current.md index e979dbe..4230926 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -16,8 +16,8 @@ own repository and takes it to live on stage and prod in one landing | | | |---|---| -| Latest tag | `baseline-v2` (HA4 — the cirrus standard: no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | -| Before it | `baseline-v1` (HA3 — the baseline) | +| Latest tag | `baseline-v3` (HA5 — the domain is set later: the console asks for no domain, and an API is born with the placeholder `.example.com` for an owner to replace) | +| Before it | `baseline-v2` (HA4 — the cirrus standard: no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked); `baseline-v1` (HA3 — the baseline) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI; a live bootstrap from a tag is still to come (risk HA-F) | ## Where to read @@ -32,5 +32,5 @@ own repository and takes it to live on stage and prod in one landing ## Next -1. Bootstrap one API from `baseline-v2` against a workspace, and record its +1. Bootstrap one API from `baseline-v3` against a workspace, and record its timings (closes HA-F). diff --git a/ai/context/decisions.md b/ai/context/decisions.md index 94e64a0..74aa9d2 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -17,3 +17,4 @@ reads in order. | 9 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version nothing ran | IMPLEMENTATION-STATUS (HA4) | | 10 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` | | 11 | `subdomain` is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), never asked | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and showed up after deploy in the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (HA-6) | +| 12 | The console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` | The API goes live on workers.dev and nothing in the build needs a domain; attaching one is an owner's step, and the placeholder keeps every place the domain goes in the repository, ready to replace | `repo-blueprint.yaml`, `tooling/rebrand/rebrand.mjs`, IMPLEMENTATION-STATUS (HA-7) | diff --git a/ai/context/operations.md b/ai/context/operations.md index 1d7c95f..94619a3 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -96,7 +96,7 @@ orun integrations list --org --json && orun cloud check --org | deploy a change | merge to `main`; watch the run; failed lanes → `gh run rerun --failed` | | redeploy without a change | edit the last line of `apps/api/component.yaml` (`# orun: redeploy `) and merge — it is a deploy trigger, nothing reads it | | rename the API | `API_NAME` in `apps/api/src/identity.ts` — what `/health` answers with | -| serve a custom domain | attach it to the Worker in Cloudflare (README, "Custom domain"); the workers.dev URL keeps answering for the smoke | +| serve a custom domain | attach it to the Worker in Cloudflare (README, "Custom domain"), then replace the placeholder `hono-api.example.com` in `intent.yaml`'s `BASE_DOMAIN` (every environment) with it; the workers.dev URL keeps answering for the smoke | | add a runtime secret | `orun secrets set --org --env `, then declare it in the component's `optionalSecretEnv` and name it in `runtimeSecrets` | | headless credentials | `ORUN_TOKEN` (workspace-scoped) + `GITHUB_TOKEN` | diff --git a/blueprint.yaml b/blueprint.yaml index 01e6b18..838ad1c 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -59,6 +59,12 @@ spec: # already holds says so with `from`. repo-blueprint.yaml declares the same # names; `repoPrivate`, `orunWorkspace` and `epicSlug` are build inputs with # defaults (or filled from the build's workspace) and are not asked. + # + # NOR IS THE DOMAIN. The API goes live on workers.dev, and a domain is an + # owner's step after the bootstrap: `productdomain` defaults to empty, the + # rebrand writes the reserved placeholder `.example.com` where + # the domain goes, and the API's README ("Custom domain") says how to set + # it. Nothing that needs a domain is removed — it waits for one. inputs: - key: reponame label: Repo name @@ -70,11 +76,6 @@ spec: pattern: "^[A-Za-z0-9][A-Za-z0-9 .,'&-]{1,48}$" help: The name the API answers with — GET /health reports it beside the environment. example: Acme API - - key: productdomain - label: API domain - pattern: "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$" - help: The domain the API will answer on. It does not need to exist — the API goes live on workers.dev first. - example: acme.dev - key: githuborg label: GitHub organisation pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/docs/phases/README.md b/docs/phases/README.md index ab7e9b4..46ece6a 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -60,9 +60,15 @@ domain", says how. `01-product` takes the API's identity once and writes it into the repo (`.rebrand/values.json`); `02-docs` reads it back from the placed tree. But the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before any phase runs, so they -must be supplied on every invocation, single-phase ones included. A -`--values` file is easier than repeating `--set`. +`githuborg` — are validated before any phase runs, so they must be supplied +on every invocation, single-phase ones included. A `--values` file is easier +than repeating `--set`. + +- `productdomain` — NOT ASKED, default empty. The API goes live on + workers.dev; empty brands the reserved placeholder `.example.com` + into `BASE_DOMAIN`, for an owner to replace when they attach a domain (the + API's README, "Custom domain"). Pass it only for an API that already has + its domain. - `subdomain` — the workers.dev subdomain of the Cloudflare account you deploy into. It is in every URL the phases probe and in the URL the diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index cc8a0d4..0753f75 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -33,11 +33,16 @@ inputs: description: The API's display name (e.g. "Acme API") — what GET /health answers with. productdomain: type: string - required: true + default: "" description: >- - The domain the API will answer on (e.g. acme.dev) — BASE_DOMAIN and the - custom-domain guidance. It does not need to exist: the API answers on - workers.dev from its first deploy. + The API's own domain, once it has one (e.g. acme.dev). NOT ASKED: the + API answers on workers.dev from its first deploy, and a domain is an + owner's step after it. Empty, the rebrand writes the reserved + placeholder `.example.com` where the domain goes (BASE_DOMAIN + in intent.yaml, for every environment, and the README's DEPLOYED_URL + example), so setting it later is replacing that one string — the API's + README, "Custom domain", says how. Pass it with --set only to brand a + hand-run build with a domain it already has. githuborg: type: string pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/specs/epics/README.md b/specs/epics/README.md index 2d29edf..48f3dd5 100644 --- a/specs/epics/README.md +++ b/specs/epics/README.md @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace. | Epic | Cluster | Status | What it is | |------|---------|--------|------------| -| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | +| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v3`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md index 762fcdc..1f9cf33 100644 --- a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md +++ b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md @@ -10,6 +10,7 @@ the code departed from `design.md` or from the upstream template. | HA2 — ready to instantiate | ✅ Shipped | [#3](https://github.com/sourceplane/hono-api/pull/3) | | HA3 — a baseline | ✅ Shipped | [#4](https://github.com/sourceplane/hono-api/pull/4) (HA-4), tagged `baseline-v1` | | HA4 — the cirrus standard | ✅ Shipped | [#5](https://github.com/sourceplane/hono-api/pull/5) (HA-5), [#6](https://github.com/sourceplane/hono-api/pull/6) (HA-6), tagged `baseline-v2` | +| HA5 — the domain is set later | ✅ Shipped | [#7](https://github.com/sourceplane/hono-api/pull/7) (HA-7), tagged `baseline-v3` | ## Departures from the upstream template @@ -103,6 +104,53 @@ Verified: landings, the API's own plan deploys `api` to stage and prod. - `orun task check HA-6` complete. +## The domain is set later (HA5, HA-7) + +The console asked for the API's domain, with help text that said it did not +need to exist — and nothing in the build needed one: the API answers on +workers.dev from its first deploy, the deploy's smoke and the phase probes +read the workers.dev URL, and the one place the repository names the domain +is `BASE_DOMAIN` in `intent.yaml` (one line per environment: dev, stage, +prod), plus the README's `DEPLOYED_URL` example. A domain is an owner's step +after the bootstrap (README, "Custom domain"), so the form no longer asks for +it. + +- `blueprint.yaml` declares no `productdomain` input; the console asks for + the API's name alone. +- `repo-blueprint.yaml`'s `productdomain` is optional, default empty. Nothing + else in the build reads it — no hook, probe or `when:` — so an empty value + is harmless; `.rebrand/values.json` records `""`. A hand-run build may still + pass `--set productdomain=` for an API that already has its domain. +- `rebrand.mjs` no longer requires it. Empty, it brands the reserved + placeholder `.example.com` (RFC 2606 — never someone else's + domain) where the domain goes, so setting it later is replacing one + string; the product README and `ai/context/operations.md` say so. +- `testing/fixtures/acme.json` carries no domain, so the leak gate and the + offline bootstrap exercise exactly what a console build supplies; + `testing/rebrand.test.sh` pins the placeholder for an absent and an empty + domain, and for the fixture's own slug, whose placeholder + `acme-hono-api.example.com` ends in the baseline's `hono-api.example.com` + (three passes, unchanged); `baseline.yml`'s blueprint read sets no domain. + +Nothing that needs a domain was removed — it waits for one. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green (rebrand: the three new checks among them; with the previous + `rebrand.mjs` all three fail, restored they pass); `gen-component-docs.py + --check` green (2 components). +- At v2.58.11 (the blueprint job's pin): `orun new --status` with no + `productdomain` reads the document (`01-product` pending, 44 files); + `testing/leak.test.sh` 44 files derived, 44 read; `testing/placement.test.sh` + 44 files placed, both landings, the API's own plan deploys `api` to stage + and prod. +- The offline bootstrap of the fixture leaves `.rebrand/values.json` + `productdomain` empty and `BASE_DOMAIN: acme-hono-api.example.com` in all + three environments of the API's `intent.yaml` (and the same string in its + README and `operations.md`); no line names `hono-api.example.com` on its own. +- `orun task check HA-7` complete. + ## Verified (HA4) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/hono-api/README.md b/specs/epics/hono-api/README.md index 4f0ceb9..50efacf 100644 --- a/specs/epics/hono-api/README.md +++ b/specs/epics/hono-api/README.md @@ -8,15 +8,15 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | Field | Value | |-------|-------| -| Status | ✅ HA0–HA3 shipped (#1–#4), tagged `baseline-v1`; HA4 (the cirrus standard, HA-5 #5 and HA-6 #6) tagged `baseline-v2`. Not yet proven by a live bootstrap (risk HA-F) | -| Cluster | **HA** (HA0–HA4) | +| Status | ✅ HA0–HA5 shipped (#1–#7): HA3 tagged `baseline-v1`; HA4 (the cirrus standard, HA-5 #5 and HA-6 #6) tagged `baseline-v2`; HA5 (the domain is set later, HA-7 #7) tagged `baseline-v3`. Not yet proven by a live bootstrap (risk HA-F) | +| Cluster | **HA** (HA0–HA5) | | Owner(s) | `apps/api` (the Worker) · `tests/api` (the in-process request tests) | | Builds on | `cirrus-baseline` conventions (intent, components, `checks.yml` gate, gated `ci.yml`) and the `cloudflare-worker-turbo` composition its workers deploy with — no bounded context of the fleet is needed | | Upstream | [vercel/examples `framework-boilerplates/hono`](https://github.com/vercel/examples/tree/main/framework-boilerplates/hono) | | Changes | Adds the Worker config, the monorepo wrapper, tests and the deploy contract; the template's app code is untouched but for the welcome line's link | | Decisions locked | (1) A plain Worker (`cloudflare-worker-turbo`), not Pages Functions and not an adapter: Hono's default export is already a Workers module handler. (2) `wrangler.jsonc` is committed, not rendered: the Worker binds nothing, so there is nothing to wire. (3) Per-environment deploys through wrangler `env` sections (`--env stage` / `--env prod`), naming `hono-api-api-{stage,prod}`. (4) No infra root. | | Gate | HA1 is the first user-visible rung (the API serves from a Worker). | -| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)), then `baseline-v2` (HA4: [#5](https://github.com/sourceplane/hono-api/pull/5), [#6](https://github.com/sourceplane/hono-api/pull/6)); proven offline (Baseline CI), deploy gated until a workspace is linked | +| Shipped as | `baseline-v3` ([#7](https://github.com/sourceplane/hono-api/pull/7), HA5: no domain asked), `baseline-v2` (HA4: [#5](https://github.com/sourceplane/hono-api/pull/5), [#6](https://github.com/sourceplane/hono-api/pull/6)), `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)); proven offline (Baseline CI), deploy gated until a workspace is linked | ## Read order @@ -34,3 +34,4 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | HA2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | HA3 — a baseline | card, build document, rename, bootstrap tooling, tests | a new API goes from nothing to live in one landing; Baseline CI green | | HA4 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the subdomain read from the Cloudflare connection | Baseline CI green with the docs check; the card asks for no subdomain | +| HA5 — the domain is set later | the console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` for an owner to replace | Baseline CI green on a fixture with no domain | diff --git a/specs/epics/hono-api/epic.yaml b/specs/epics/hono-api/epic.yaml index d40067a..633d300 100644 --- a/specs/epics/hono-api/epic.yaml +++ b/specs/epics/hono-api/epic.yaml @@ -40,3 +40,9 @@ spec: - "every milestone's status row agrees with the tags" - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" tasks: [HA-5, HA-6] + - name: "HA5 — the domain is set later" + exitCriteria: + - "the console card asks for no domain: an API goes live on workers.dev, and productdomain is an optional build input that defaults to empty" + - "an API built without a domain is branded with the reserved placeholder .example.com wherever the domain goes (BASE_DOMAIN), and its README says how an owner sets the real one" + - "Baseline CI places, leak-checks and plans an API built with no domain" + tasks: [HA-7] diff --git a/specs/epics/hono-api/implementation-plan.md b/specs/epics/hono-api/implementation-plan.md index 4759e43..0c6d1ee 100644 --- a/specs/epics/hono-api/implementation-plan.md +++ b/specs/epics/hono-api/implementation-plan.md @@ -77,6 +77,15 @@ itself changing. - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree +## HA5 — the domain is set later (HA-7) ✅ + +**Done when** the console card asks for no domain; `productdomain` is an +optional build input, empty by default; an API built without one is branded +with the reserved placeholder `.example.com` where the domain goes +(`BASE_DOMAIN` in `intent.yaml`) and its README says how an owner sets the +real one; Baseline CI places, leak-checks and plans an API built with no +domain. Shipped in `baseline-v3`. + ## After HA3 (outside this repository) 1. Cut `baseline-v1` with `tag.yml` from the merged `main`. diff --git a/tasks/HA-7.TaskContract.yaml b/tasks/HA-7.TaskContract.yaml new file mode 100644 index 0000000..805c925 --- /dev/null +++ b/tasks/HA-7.TaskContract.yaml @@ -0,0 +1,30 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: HA-7 + title: "The domain is set later" +spec: + goal: "The console no longer asks for the API's domain. An API goes live on workers.dev; productdomain is an optional build input (default empty), the rebrand writes the reserved placeholder .example.com where the domain goes (BASE_DOMAIN in intent.yaml), and the API's README says how an owner replaces it once a domain is attached" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - tooling/rebrand/rebrand.mjs + - testing/rebrand.test.sh + - testing/fixtures/acme.json + - .github/workflows/baseline.yml + - .baseline/product/README.md + - BOOTSTRAP.md + - README.md + - docs/phases/README.md + - ai/context/operations.md + - ai/context/current.md + - ai/context/decisions.md + - specs/** + - tasks/** + doneWhen: + - blueprint.yaml declares no productdomain input, and repo-blueprint.yaml's productdomain is optional with an empty default + - "rebrand.mjs no longer requires productdomain and brands .example.com when it is empty (testing/rebrand.test.sh)" + - testing/fixtures/acme.json carries no domain, so the leak gate and the offline bootstrap exercise what a console build supplies + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/fixtures/acme.json b/testing/fixtures/acme.json index b3163b2..b5d7779 100644 --- a/testing/fixtures/acme.json +++ b/testing/fixtures/acme.json @@ -6,16 +6,16 @@ "AWKWARD rather than tidy — an API name with an apostrophe and an ampersand", "(both legal in the card's pattern, both special in TypeScript strings,", "shell words and JSON), a hyphenated repo slug that CONTAINS the word", - "`hono` and ends in `api`, an owner other than the baseline's, and a", - "multi-label domain — because a fixture that only uses values the templates", - "were written against proves the templates work on the values they were", - "written against.", + "`hono` and ends in `api`, an owner other than the baseline's, and NO", + "domain — a console build asks for none, so the placeholder", + ".example.com is what an API is born with — because a fixture", + "that only uses values the templates were written against proves the", + "templates work on the values they were written against.", "Every key here is an input repo-blueprint.yaml declares. A key it does not", "declare is a fixture that has drifted, and orun refuses it." ], "reponame": "acme-hono-api", "productname": "Sam's Tools & Things", - "productdomain": "api.acme.dev", "githuborg": "acme-inc", "subdomain": "acme", "orunWorkspace": "ws_0000000000000000000000000000000f", diff --git a/testing/rebrand.test.sh b/testing/rebrand.test.sh index a907a28..ce98bc4 100755 --- a/testing/rebrand.test.sh +++ b/testing/rebrand.test.sh @@ -84,6 +84,14 @@ check "an environment URL in the intent" \ check "the placeholder domain is the product's domain, not a renamed slug" \ "$acme" intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ ' BASE_DOMAIN: acme.dev' +check "no domain given: the reserved placeholder, for an owner to replace later" \ + '{"reponame":"acme-api","productname":"Acme API","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ + ' BASE_DOMAIN: acme-api.example.com' +check "an empty domain is no domain" \ + '{"reponame":"acme-api","productname":"Acme API","productdomain":""}' \ + intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ + ' BASE_DOMAIN: acme-api.example.com' check "the repo slug" \ "$acme" package.json ' "name": "hono-api",' \ ' "name": "acme-api",' @@ -124,6 +132,10 @@ check "a repo slug ending in the baseline's slug survives three passes" \ check "…and its Worker name in the smoke URL" \ "$suffixed" apps/api/component.yaml 'x: https://hono-api-api-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev' \ 'x: https://acme-hono-api-api-${ORUN_ENVIRONMENT}.acme.workers.dev' 3 +check "…and, with no domain, its placeholder (which ends in the baseline's domain)" \ + '{"reponame":"acme-hono-api","productname":"Acme","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ + ' BASE_DOMAIN: acme-hono-api.example.com' 3 # --verify runs in every phase. Without the product's values it cannot tell # the product's own identity from a leftover; with them it can. A real diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index 49017bc..38a5045 100755 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -24,7 +24,7 @@ // { // "reponame": "acme-api", // required — repo slug // "productname": "Acme API", // required — the API's display name -// "productdomain": "acme.dev", // required — the product domain +// "productdomain": "acme.dev", // optional — default .example.com (set later) // "githuborg": "acme-inc", // owner of the product repo (source link) // "brandSlug": "acme", // default: reponame — worker name prefix // "subdomain": "acme", // default: your-workers-subdomain @@ -65,7 +65,7 @@ if (!verifyOnly && !valuesPath) { } if (valuesPath) { values = JSON.parse(fs.readFileSync(valuesPath, "utf8")); - for (const required of ["reponame", "productname", "productdomain"]) { + for (const required of ["reponame", "productname"]) { if (typeof values[required] !== "string" || values[required].length === 0) { console.error(`rebrand: values file is missing required field "${required}"`); process.exit(2); @@ -128,7 +128,11 @@ const rx = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // All fields are unused under --verify; the fallbacks keep derivation total. const reponame = values.reponame ?? ""; const productname = values.productname ?? ""; -const productdomain = values.productdomain ?? ""; +// The domain is NOT ASKED at bootstrap: an API goes live on workers.dev and an +// owner sets a domain later. Until then the reserved placeholder +// `.example.com` (RFC 2606 — it can never be someone else's) stands +// wherever the domain goes, so setting it is replacing one string. +const productdomain = (values.productdomain ?? "").trim() || (reponame ? `${reponame}.example.com` : ""); const githuborg = (values.githuborg ?? "").trim() || baseline.githubOwner; const brandSlug = (values.brandSlug ?? "").trim() || reponame; const subdomain = (values.subdomain ?? "").trim() || "your-workers-subdomain";