Repository navigation
feat(cli): cloudhal build --published and the static not-published page (RFC-0043 PR 2) - #198
Merged
Merged
Conversation
…ge (RFC-0043 PR 2) `cloudhal build --published` builds the published snapshot only. A site that was never published gets the not-published status page as its whole output, written without an Astro run: index.html and 404.html from @cloudhal/astro-renderer/status-page in the site's default locale, a robots.txt that disallows everything, a _headers file (no-store, noindex, the page's CSP) and a .cloudhal-status marker. A published pointer to a missing snapshot is an error, never "not published". Plain `cloudhal build` is unchanged (published, then latest, then a fresh snapshot). The Docker image's site-build passes --published, so a fresh self-host no longer serves drafts before its first publish. The Caddyfile answers every path except robots.txt with the page, 503, Retry-After: 3600 and no-store while the marker exists. The self-host guide documents the headers and drops the latest-snapshot caveat. Tests: build-published.test.ts covers the status output (locale, a link at dist removed rather than followed, the English fallback), a spawned build before and after a publish, and --snapshot being refused. The docker smoke test now builds before the first publish and runs the compose Caddyfile in a caddy:2.11 container on the same volume: 503 with Retry-After before the publish, 200 after it, then the swap and the kept-previous checks on a third build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
…FC-0043 PR 2 review)
- build-published.test.ts proves "never the latest":
- an unpublished snapshot before the first publish still gives the
status page, which does not name that snapshot;
- a draft rename after the publish stays out of the build;
- a rollback from s2 to s1 builds s1.
- site-build passes --published only when `cloudhal build --help`
lists it. A CLI from 0.7.1 or older, in an image built from this
checkout with CLOUDHAL_VERSION, gets one warning and the old call.
- entrypoint runs one site-build in the background once Studio answers
and /data/cloudhal.json exists. tini reaps it, not `cloudhal studio`.
A never-published volume upgraded from 0.6.4–0.7.1 switches at once
to the 503 status page, a new volume gets it on its first start, and
a failed build only logs.
- docker-smoke waits for the start-up build and takes a draft snapshot
before the explicit first build, which must still be the 503. Where
the CLI has no --published, it skips the status-page checks. The
0.6.3 folder is simulated after the start-up build.
- self-host guide (upgrades, building the image), README, docker.yml
backfill note and the changeset follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC-0043 rollout PR 2 (§1.10, static builds). Part of the self-host work behind #150. The rebuild-on-publish hook comes in a separate PR after this one.
What changes
cloudhal build --publishedbuilds the published snapshot only (resolvePublishedBuildinsnapshot.ts).not-publishedstatus page as the whole output (commands/build-status.ts), without an Astro run:index.htmland404.html, fromstatusPageHtml(@cloudhal/astro-renderer/status-page) in the site's default locale, with the site's name and no logo or theme tokens (§1.6);robots.txtwithDisallow: /;_headerswithno-store,noindexand the status CSP;.cloudhal-statusmarker that holds the state.--published --snapshotis refused.@cloudhal/clinow depends on@cloudhal/astro-rendererdirectly. It was already in the tree through@cloudhal/cloudflare.cloudhal buildis unchanged: published, then latest, then a fresh snapshot. This is documented in--help(the CLI reference) and in the guide. A typed overload keepsbuild()'s return type for existing callers.deploy/docker/bin/site-buildpasses--publishedand says when it published the status page.deploy/docker/Caddyfile: an@statusmatcher (file /.cloudhal-status, not/robots.txt) rewrites to/index.htmland serves it withfile_server { status 503 }. It sendsRetry-After: 3600,Cache-Control: no-store,X-Robots-Tag: noindex,X-Cloudhal-State, the CSP,nosniffandno-referrer. The existingcaddy validatestep covers it.docs/guides/self-host.md: the latest-snapshot caveat is gone. A new "Before the first publish" paragraph has the header table, a recipe for other web servers, and a note that the theme'sstatusPagehook does not run in a static build. The upgrade step mentions the new Caddyfile.Tests
packages/cli/test/build-published.test.ts:trlocale, the English fallback, and a symlinkeddistthat is removed rather than followed;build --publishedbefore a publish: status page, no snapshot created, no drafts;--snapshotrefused.scripts/docker-smoke.ts:site-buildbefore the first publish, which also covers the 0.6.3 legacy move;caddy:2.11on the container's volume:/and deep paths answer 503 withRetry-After: 3600,no-storeandnoindex, androbots.txtanswers 200;apps/docsrepo-docs test passes;currentpoints at a real build.Patch changeset for
@cloudhal/cli.🤖 Generated with Claude Code