@theholocron/holocron-plugin-cloudflare 3.32.0 → 3.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  # `@theholocron/holocron-plugin-cloudflare`
4
4
 
5
- Cloudflare plugin for [Holocron](../cli). Implements the `dns`
6
- capability against the [Cloudflare v4 API](https://developers.cloudflare.com/api/).
5
+ Cloudflare plugin for [Holocron](../cli). Implements the `dns` and `deployment`
6
+ capabilities against the [Cloudflare v4 API](https://developers.cloudflare.com/api/).
7
7
 
8
8
  ## Install
9
9
 
@@ -23,8 +23,10 @@ Token resolution order:
23
23
  4. Keyring `cloudflare.<org>` — tried first when an org is active via `--org`, `HOLOCRON_ORG`, or `org` in `holocron.config.ts`
24
24
  5. Keyring `cloudflare` — unnamespaced fallback; set via `holocron auth set cloudflare <token>`
25
25
 
26
- Generate a scoped API token at **dash.cloudflare.com/profile/api-tokens**
27
- with `Zone:Read` and `DNS:Edit` permissions.
26
+ Generate a scoped API token at **dash.cloudflare.com/profile/api-tokens**.
27
+
28
+ - **DNS only:** `Zone:Read`, `Zone:DNS:Edit`
29
+ - **DNS + Pages (deployment):** `Zone:Read`, `Zone:DNS:Edit`, `Cloudflare Pages:Edit`
28
30
 
29
31
  ## Config
30
32
 
@@ -32,16 +34,33 @@ with `Zone:Read` and `DNS:Edit` permissions.
32
34
  ```jsonc
33
35
  {
34
36
  "providers": {
35
- "dns": ["cloudflare", { "accountId": "optional-account-id" }],
37
+ // DNS management only
38
+ "dns": "cloudflare",
39
+
40
+ // Cloudflare Pages deployments (requires accountId)
41
+ // accountId falls back to CLOUDFLARE_ACCOUNT_ID env var when omitted
42
+ "deployment": "cloudflare",
36
43
  },
37
44
  }
38
45
 
39
46
  ```
40
47
 
41
- - `accountId` (optional) Cloudflare account id. Not required for DNS
42
- operations; needed only if you extend the plugin to tunnel management.
48
+ Both capabilities can be enabled together:
49
+
50
+ <!-- prettier-ignore -->
51
+ ```jsonc
52
+ {
53
+ "providers": {
54
+ "dns": "cloudflare",
55
+ "deployment": "cloudflare",
56
+ },
57
+ }
43
58
 
44
- ## What's implemented
59
+ ```
60
+
61
+ The `deployment` capability is only exposed when `accountId` is resolvable — either passed explicitly in options or set via the `CLOUDFLARE_ACCOUNT_ID` env var.
62
+
63
+ ## `dns` capability
45
64
 
46
65
  | Method | What it does |
47
66
  | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -50,3 +69,26 @@ with `Zone:Read` and `DNS:Edit` permissions.
50
69
  | `deleteRecord` | Deletes a record by id within the zone that contains the given domain. |
51
70
 
52
71
  Zone ids are cached per plugin instance for the lifetime of the process.
72
+
73
+ ## `deployment` capability
74
+
75
+ Manages [Cloudflare Pages](https://developers.cloudflare.com/pages/) projects. Used by `holocron setup` to provision per-PR preview deployments.
76
+
77
+ | Method | What it does |
78
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------- |
79
+ | `listProjects` | Lists all Cloudflare Pages projects in the account. |
80
+ | `ensureProject` | Creates the Pages project if it does not exist; returns the existing project otherwise. |
81
+ | `ensureCustomDomain` | Attaches a custom domain (or wildcard) to the project if not already attached; idempotent. |
82
+ | `listDeployments` | Lists recent deployments for the project. |
83
+ | `triggerDeployment` | Triggers a new Pages deployment from the latest production branch commit. |
84
+ | `updateProjectSettings` | Updates project-level settings (currently a no-op; CF Pages REST API has no direct settings endpoint for these fields). |
85
+
86
+ ### Preview deployment setup
87
+
88
+ When `preview: true` (or `preview: { project, domain }`) is set in a repo's deploy config, `holocron setup` calls:
89
+
90
+ 1. `ensureProject` — creates `<org>-preview` if it doesn't exist
91
+ 2. `ensureCustomDomain` — attaches `*.<domain>` to the project
92
+ 3. `dns.upsertRecord` — adds a wildcard CNAME `*.<domain>` → `<project>.pages.dev`
93
+
94
+ The combined `deploy.yml` thin caller then routes `push` events to GitHub Pages and `pull_request` events to Cloudflare Pages via `cloudflare/pages-action`. Preview URLs resolve as `<repo>-pr-<n>.<domain>`.
package/dist/index.mjs CHANGED
@@ -195,10 +195,15 @@ async function verifyToken(token, opts = {}) {
195
195
  //#endregion
196
196
  //#region src/index.ts
197
197
  function createContext(options = {}) {
198
+ const token = resolveToken(options);
199
+ const accountId = options.accountId ?? process.env.CLOUDFLARE_ACCOUNT_ID;
198
200
  return {
199
- options,
201
+ options: {
202
+ ...options,
203
+ accountId
204
+ },
200
205
  client: createCloudflareClient({
201
- token: resolveToken(options),
206
+ token,
202
207
  baseUrl: options.baseUrl,
203
208
  fetch: options.fetch
204
209
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-cloudflare",
3
- "version": "3.32.0",
3
+ "version": "3.33.1",
4
4
  "description": "Holocron plugin for Cloudflare. Implements the dns capability against Cloudflare's REST API — zone resolution, DNS record management.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,11 +46,11 @@
46
46
  "tsx": "4.23.12",
47
47
  "typescript": "^5.9.3",
48
48
  "vitest": "^4.1.10",
49
- "@theholocron/cli": "3.32.0"
49
+ "@theholocron/cli": "3.33.1"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@theholocron/cloudflare-client": "^1.11.2",
53
- "@theholocron/cli": "3.32.0"
53
+ "@theholocron/cli": "3.33.1"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@theholocron/cloudflare-client": {}