repomatic.cloudflare.pages module¶
Reconcile a Cloudflare Pages project against the state its repository declares.
A Direct Upload project is not reproducible from anything committed:
wrangler.toml only describes what a build would need, and these projects
are never built by Cloudflare. Everything that actually shapes the live site
(the compatibility date, Smart Placement, the build image, whether a git
source got attached) lives server-side in the project’s deployment_configs
and is invisible to anyone reading the repository. One project’s compatibility
date sat three years behind the live value with nothing noticing. This module
makes that state explicit, diffable and re-applicable, from the
[tool.repomatic] site.* keys.
Backs the cloudflare-pages command, in the modes of PagesMode.
repomatic.cloudflare.api resolves the credential and the account.
- repomatic.cloudflare.pages.MISSING: Final = <object object>¶
What a lookup in the live project answers when the path names nothing.
- repomatic.cloudflare.pages.SECRET_KEYS: Final = frozenset({'api_token', 'oauth_token', 'refresh_token', 'secret'})¶
Response keys whose values must never be printed.
- class repomatic.cloudflare.pages.PagesMode(*values)[source]¶
Bases:
StrEnumWhat one run of
cloudflare-pagesdoes, named after its flag.- APPLY = 'apply'¶
Write every managed drifted setting back to its declared value.
- ATTACH_DOMAIN = 'attach-domain'¶
Serve the project at a custom domain, DNS record included.
- CHECK = 'check'¶
Diff the live project against the declared state.
- CREATE = 'create'¶
Create the project when missing, then apply the declared settings.
- DUMP = 'dump'¶
Print the live project state as JSON, secrets redacted.
- class repomatic.cloudflare.pages.Setting(path, desired, default, why, verified=False, managed=True)[source]¶
Bases:
objectOne server-side setting, with enough context to justify its value.
Where the stock default is quoted from Cloudflare’s documentation,
verifiedis true. Where it is inferred from how the product behaves, it is false and the diff labels it as such: an unverified default is a reasonable guess, not a fact, and this module should not launder one into the other.
- repomatic.cloudflare.pages.desired_settings(compatibility_date='', placement='')[source]¶
The settings to enforce, from the repository’s
site.*declarations.Only what the repository declares is managed, plus one documented floor: the build image major version, which Cloudflare auto-migrates old projects onto (v1 on 2026-09-15, v2 on 2027-02-23) and then freezes, so asserting
3requests nothing from a current project and names the stragglers.Pages supports exactly
productionandpreview, so the two environments are enumerated rather than globbed, and every managed setting applies identically to both.
- repomatic.cloudflare.pages.run_cloudflare_pages(project, mode, *, domain='', compatibility_date='', placement='')[source]¶
Drive one mode of the Pages reconciliation against project project.
--createmakes the project when it does not exist yet (Direct Upload,mainas its production branch), then applies the declared settings to it like--applydoes. Read-only drift is reported by every mode, and keeps the exit code non-zero.- Parameters:
project (
str) – Cloudflare Pages project name to reconcile.mode (
PagesMode) – What to do with the project.domain (
str) – The hostnamePagesMode.ATTACH_DOMAINserves the project at, creating the DNS record it needs when the credential can.compatibility_date (
str) – Declared Workers runtime date, empty for unmanaged.placement (
str) – Declared Smart Placement mode, empty for unmanaged.
- Return type:
- Returns:
Exit code:
0clean,1drift found (or left, for the read-only settings no write can change).