@theholocron/holocron-plugin-cloudflare 5.0.0-alpha.21 → 5.0.0-alpha.210
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 +2 -2
- package/dist/index.d.mts +13 -12
- package/dist/index.mjs +24 -3
- package/package.json +15 -13
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ Zone ids are cached per plugin instance for the lifetime of the process.
|
|
|
79
79
|
|
|
80
80
|
## `deployment` capability
|
|
81
81
|
|
|
82
|
-
Manages [Cloudflare Pages](https://developers.cloudflare.com/pages/) projects. Used by `holocron setup` to provision per-PR preview deployments.
|
|
82
|
+
Manages [Cloudflare Pages](https://developers.cloudflare.com/pages/) projects. Used by `holocron repo setup` to provision per-PR preview deployments.
|
|
83
83
|
|
|
84
84
|
| Method | What it does |
|
|
85
85
|
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -106,7 +106,7 @@ cache, separate from `dns`'s.
|
|
|
106
106
|
|
|
107
107
|
### Preview deployment setup
|
|
108
108
|
|
|
109
|
-
When `preview: true` (or `preview: { project, domain }`) is set in a repo's deploy config, `holocron setup` calls:
|
|
109
|
+
When `preview: true` (or `preview: { project, domain }`) is set in a repo's deploy config, `holocron repo setup` calls:
|
|
110
110
|
|
|
111
111
|
1. `ensureProject` — creates `<org>-preview` if it doesn't exist
|
|
112
112
|
2. `ensureCustomDomain` — attaches `*.<domain>` to the project
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthError, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, ResolveTokenInput, WikiProxyConfig, Workers } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordRequest, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, WikiProxyConfig, Workers } from "@theholocron/cli";
|
|
2
2
|
import { CloudflareClient, CloudflareClient as CloudflareClient$1, CloudflareClientOptions, createCloudflareClient } from "@theholocron/cloudflare-client";
|
|
3
3
|
//#region src/auth.d.ts
|
|
4
4
|
declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
@@ -28,7 +28,7 @@ declare class CloudflareDeployment implements Deployment {
|
|
|
28
28
|
getDeployment(deploymentId: string): Promise<DeploymentRecord>;
|
|
29
29
|
listPreviewDeployments(projectId: string, branch: string): Promise<DeploymentRecord[]>;
|
|
30
30
|
deletePreviewDeployments(projectId: string, deploymentIds: string[]): Promise<number>;
|
|
31
|
-
ensureCustomDomain(projectId: string, hostname: string): Promise<
|
|
31
|
+
ensureCustomDomain(projectId: string, hostname: string): Promise<DnsRecordRequest | null>;
|
|
32
32
|
private getProjectByName;
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
@@ -42,6 +42,11 @@ declare class CloudflareDns implements Dns {
|
|
|
42
42
|
listRecords(domain: string): Promise<DnsRecord[]>;
|
|
43
43
|
upsertRecord(domain: string, record: DnsRecord): Promise<DnsRecord>;
|
|
44
44
|
deleteRecord(domain: string, id: string): Promise<void>;
|
|
45
|
+
/** `holocron doctor` has no specific domain to check — lists every zone the token can see instead. */
|
|
46
|
+
whoami(): Promise<{
|
|
47
|
+
ok: boolean;
|
|
48
|
+
zones: number;
|
|
49
|
+
}>;
|
|
45
50
|
/**
|
|
46
51
|
* Walk from full domain up to apex to find the Cloudflare zone.
|
|
47
52
|
* E.g. "api.staging.example.com" tries:
|
|
@@ -61,6 +66,11 @@ declare class CloudflareWorkers implements Workers {
|
|
|
61
66
|
private readonly zoneCache;
|
|
62
67
|
constructor(client: () => Pick<CloudflareClient$1, "workers" | "zones">, accountId: string);
|
|
63
68
|
upsertProxy(hostname: string, config: WikiProxyConfig): Promise<void>;
|
|
69
|
+
/** `holocron doctor` has no specific script to check — lists every script the token can see instead. */
|
|
70
|
+
whoami(): Promise<{
|
|
71
|
+
ok: boolean;
|
|
72
|
+
scripts: number;
|
|
73
|
+
}>;
|
|
64
74
|
deployScript(name: string, config: DeployScriptConfig): Promise<DeployScriptResult>;
|
|
65
75
|
/** Idempotent create-or-update for one route pattern — shared by both public methods. */
|
|
66
76
|
private upsertRoute;
|
|
@@ -68,20 +78,11 @@ declare class CloudflareWorkers implements Workers {
|
|
|
68
78
|
}
|
|
69
79
|
//#endregion
|
|
70
80
|
//#region src/verify-token.d.ts
|
|
71
|
-
interface VerifyTokenSuccess {
|
|
72
|
-
ok: true;
|
|
73
|
-
subject: string;
|
|
74
|
-
}
|
|
75
|
-
interface VerifyTokenFailure {
|
|
76
|
-
ok: false;
|
|
77
|
-
message: string;
|
|
78
|
-
}
|
|
79
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
80
81
|
interface VerifyTokenOptions {
|
|
81
82
|
baseUrl?: string;
|
|
82
83
|
fetch?: typeof fetch;
|
|
83
84
|
}
|
|
84
|
-
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
|
|
85
|
+
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
85
86
|
//#endregion
|
|
86
87
|
//#region src/index.d.ts
|
|
87
88
|
interface CloudflarePluginOptions extends ResolveTokenInput {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
|
|
2
2
|
import { createCloudflareClient } from "@theholocron/cloudflare-client";
|
|
3
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
3
4
|
//#region src/auth.ts
|
|
4
5
|
const resolveToken = createResolveToken({
|
|
5
6
|
envName: "HOLOCRON_CLOUDFLARE_TOKEN",
|
|
@@ -74,8 +75,9 @@ var CloudflareDeployment = class {
|
|
|
74
75
|
return deploymentIds.length;
|
|
75
76
|
}
|
|
76
77
|
async ensureCustomDomain(projectId, hostname) {
|
|
77
|
-
if ((await this.client().pages.listDomains(this.accountId, projectId)).some((d) => d.name === hostname)) return;
|
|
78
|
+
if ((await this.client().pages.listDomains(this.accountId, projectId)).some((d) => d.name === hostname)) return null;
|
|
78
79
|
await this.client().pages.addDomain(this.accountId, projectId, hostname);
|
|
80
|
+
return null;
|
|
79
81
|
}
|
|
80
82
|
async getProjectByName(name) {
|
|
81
83
|
try {
|
|
@@ -153,6 +155,13 @@ var CloudflareDns = class {
|
|
|
153
155
|
const zoneId = await this.resolveZone(domain);
|
|
154
156
|
await this.client().dns.delete(zoneId, id);
|
|
155
157
|
}
|
|
158
|
+
/** `holocron doctor` has no specific domain to check — lists every zone the token can see instead. */
|
|
159
|
+
async whoami() {
|
|
160
|
+
return {
|
|
161
|
+
ok: true,
|
|
162
|
+
zones: (await this.client().zones.list()).length
|
|
163
|
+
};
|
|
164
|
+
}
|
|
156
165
|
/**
|
|
157
166
|
* Walk from full domain up to apex to find the Cloudflare zone.
|
|
158
167
|
* E.g. "api.staging.example.com" tries:
|
|
@@ -202,6 +211,13 @@ var CloudflareWorkers = class {
|
|
|
202
211
|
await this.client().workers.putScript(this.accountId, scriptName, script);
|
|
203
212
|
await this.upsertRoute(`${hostname}/*`, scriptName);
|
|
204
213
|
}
|
|
214
|
+
/** `holocron doctor` has no specific script to check — lists every script the token can see instead. */
|
|
215
|
+
async whoami() {
|
|
216
|
+
return {
|
|
217
|
+
ok: true,
|
|
218
|
+
scripts: (await this.client().workers.listScripts(this.accountId)).length
|
|
219
|
+
};
|
|
220
|
+
}
|
|
205
221
|
async deployScript(name, config) {
|
|
206
222
|
await this.client().workers.putScript(this.accountId, name, config.code);
|
|
207
223
|
for (const [secretName, value] of Object.entries(config.secrets ?? {})) await this.client().workers.putSecret(this.accountId, name, secretName, value);
|
|
@@ -266,14 +282,19 @@ async function verifyToken(token, opts = {}) {
|
|
|
266
282
|
};
|
|
267
283
|
} catch {}
|
|
268
284
|
try {
|
|
285
|
+
const names = (await client.zones.list()).map((z) => z.name);
|
|
286
|
+
if (names.length === 0) return {
|
|
287
|
+
ok: true,
|
|
288
|
+
subject: "no zones visible"
|
|
289
|
+
};
|
|
269
290
|
return {
|
|
270
291
|
ok: true,
|
|
271
|
-
subject: `
|
|
292
|
+
subject: `zones: ${names.length <= 5 ? names.join(", ") : `${names.slice(0, 5).join(", ")} (+${names.length - 5} more)`}`
|
|
272
293
|
};
|
|
273
294
|
} catch (err) {
|
|
274
295
|
return {
|
|
275
296
|
ok: false,
|
|
276
|
-
message:
|
|
297
|
+
message: errorMessage(err)
|
|
277
298
|
};
|
|
278
299
|
}
|
|
279
300
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-cloudflare",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.210",
|
|
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",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"holocron",
|
|
9
9
|
"plugin"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/theholocron/holocron/tree/main/
|
|
11
|
+
"homepage": "https://github.com/theholocron/holocron/tree/main/plugins/holocron-plugin-cloudflare#readme",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-cloudflare"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,12 +30,13 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/cloudflare-client": "^1.
|
|
34
|
-
"@theholocron/eslint-config": "^8.
|
|
35
|
-
"@theholocron/http-client": "^1.
|
|
36
|
-
"@theholocron/
|
|
37
|
-
"@theholocron/
|
|
38
|
-
"@theholocron/
|
|
33
|
+
"@theholocron/cloudflare-client": "^1.43.1",
|
|
34
|
+
"@theholocron/eslint-config": "^8.8.2",
|
|
35
|
+
"@theholocron/http-client": "^1.43.1",
|
|
36
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
37
|
+
"@theholocron/tsconfig": "^8.8.2",
|
|
38
|
+
"@theholocron/tsdown-config": "^8.8.2",
|
|
39
|
+
"@theholocron/vitest-config": "^8.8.2",
|
|
39
40
|
"@types/node": "^26",
|
|
40
41
|
"@vitest/coverage-v8": "^4.1.11",
|
|
41
42
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
@@ -44,14 +45,15 @@
|
|
|
44
45
|
"eslint-plugin-n": "^18.3.0",
|
|
45
46
|
"globals": "^17.11.0",
|
|
46
47
|
"tsdown": "^0.22.14",
|
|
47
|
-
"tsx": "4.23.
|
|
48
|
+
"tsx": "4.23.15",
|
|
48
49
|
"typescript": "^5.9.3",
|
|
49
50
|
"vitest": "^4.1.11",
|
|
50
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
51
|
+
"@theholocron/cli": "5.0.0-alpha.210"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
|
-
"@theholocron/cloudflare-client": "^1.
|
|
54
|
-
"@theholocron/
|
|
54
|
+
"@theholocron/cloudflare-client": "^1.43.1",
|
|
55
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
56
|
+
"@theholocron/cli": "5.0.0-alpha.210"
|
|
55
57
|
},
|
|
56
58
|
"peerDependenciesMeta": {
|
|
57
59
|
"@theholocron/cloudflare-client": {}
|