@theholocron/holocron-plugin-vercel 5.0.0-alpha.4 → 5.0.0-alpha.41
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 +30 -1
- package/dist/index.d.mts +27 -1
- package/dist/index.mjs +61 -0
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -55,10 +55,39 @@ Capability covers:
|
|
|
55
55
|
- `updateProjectSettings()` — toggle preview deploys, git-creates-deploys
|
|
56
56
|
- `setEnvVar()` / `listEnvVars()` — per-target env vars
|
|
57
57
|
- `triggerDeployment()` — branch deploys with optional named target
|
|
58
|
+
(requires a project already linked to a Git repo)
|
|
59
|
+
- `deployFunction()` — deploy directly from source files, bypassing Git
|
|
60
|
+
entirely: `POST /v13/deployments` with an inline `files` array, no
|
|
61
|
+
linked repo required. For a consumer with no repo to deploy from — a
|
|
62
|
+
webhook receiver shipped as an npm package, for instance. Always
|
|
63
|
+
deploys with `projectSettings.framework: null` (a bare function, not
|
|
64
|
+
an app) — `defaultFramework` only applies to `ensureProject()`'s
|
|
65
|
+
Git-linked path.
|
|
58
66
|
- `getDeployment()` — fetch a deployment by id
|
|
67
|
+
- `ensureCustomDomain()` — idempotent add (list → add-if-missing →
|
|
68
|
+
check DNS routing). Ownership (`verified`) and DNS routing are
|
|
69
|
+
separate: once a team already owns a domain's apex, every new
|
|
70
|
+
subdomain auto-verifies immediately with no fresh challenge, so
|
|
71
|
+
attachment alone can't tell you whether traffic is actually routed
|
|
72
|
+
to Vercel yet. `domains.config()` answers that regardless of
|
|
73
|
+
ownership state, returning a per-project CNAME target — never a
|
|
74
|
+
fixed well-known host — only when DNS isn't already configured. The
|
|
75
|
+
returned DNS record is handed to the configured `dns` provider by
|
|
76
|
+
`holocron setup`.
|
|
77
|
+
|
|
78
|
+
Declare the production domain in the Vercel provider options. On `holocron setup`,
|
|
79
|
+
the domain is attached to the project and any Vercel verification CNAME is
|
|
80
|
+
upserted through the configured DNS provider:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
providers: {
|
|
84
|
+
deployment: ["vercel", { teamId: "team_…", domain: "sentinel.example.com" }],
|
|
85
|
+
dns: "cloudflare",
|
|
86
|
+
}
|
|
87
|
+
```
|
|
59
88
|
|
|
60
89
|
Out of scope for alpha.0 (file a follow-up if needed):
|
|
61
90
|
|
|
62
|
-
- Domain
|
|
91
|
+
- Domain removal (`removeDomain`)
|
|
63
92
|
- Deletion (`deleteProject`)
|
|
64
93
|
- Marketplace integrations (e.g. `vercel install neon` for vault-managed databases)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthError, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, ResolveTokenInput } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, DeployFunctionConfig, DeployFunctionResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, DnsRecordRequest, ResolveTokenInput } from "@theholocron/cli";
|
|
2
2
|
import { VercelClient, VercelClient as VercelClient$1, VercelClientOptions, createVercelClient } from "@theholocron/vercel-client";
|
|
3
3
|
//#region src/auth.d.ts
|
|
4
4
|
declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
@@ -7,11 +7,14 @@ declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
|
7
7
|
interface DeploymentOptions {
|
|
8
8
|
/** Optional framework hint passed to project creates. Defaults to "nextjs". */
|
|
9
9
|
defaultFramework?: string;
|
|
10
|
+
/** Custom domain that `holocron setup` should attach to this project. */
|
|
11
|
+
domain?: string;
|
|
10
12
|
}
|
|
11
13
|
declare class VercelDeployment implements Deployment {
|
|
12
14
|
private readonly client;
|
|
13
15
|
readonly key: "deployment";
|
|
14
16
|
readonly providerName = "vercel";
|
|
17
|
+
readonly domain?: string;
|
|
15
18
|
private readonly defaultFramework;
|
|
16
19
|
constructor(client: () => VercelClient$1, opts?: DeploymentOptions);
|
|
17
20
|
listProjects(): Promise<DeploymentProject[]>;
|
|
@@ -30,6 +33,27 @@ declare class VercelDeployment implements Deployment {
|
|
|
30
33
|
target?: DeploymentTrigger;
|
|
31
34
|
}): Promise<DeploymentRecord>;
|
|
32
35
|
getDeployment(deploymentId: string): Promise<DeploymentRecord>;
|
|
36
|
+
deployFunction(projectId: string, config: DeployFunctionConfig): Promise<DeployFunctionResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Idempotent — matches `Deployment.ensureCustomDomain`'s contract
|
|
39
|
+
* (never break on re-runs, per CLAUDE.md's probe-then-act standard).
|
|
40
|
+
*
|
|
41
|
+
* Ownership (`domains.add`'s `verified`) and DNS routing are separate
|
|
42
|
+
* concerns: once a team already owns the domain's apex (true for any
|
|
43
|
+
* org with more than one project on the same domain), every new
|
|
44
|
+
* subdomain auto-verifies immediately with no `verification`
|
|
45
|
+
* challenge — re-adding an already-attached domain returns 409, not
|
|
46
|
+
* a fresh one. So attachment alone can't tell us whether traffic is
|
|
47
|
+
* actually routed to Vercel yet. `domains.config()` (Vercel's DNS
|
|
48
|
+
* *configuration* check) answers that regardless of ownership state:
|
|
49
|
+
* `misconfigured` + a `recommendedCNAME`, per-project, never a fixed
|
|
50
|
+
* well-known host — always read it from this response, never
|
|
51
|
+
* hardcode it. Returned as a `DnsRecordRequest` — the caller (e.g.
|
|
52
|
+
* `holocron setup`'s custom-domain step) hands it straight to
|
|
53
|
+
* `dns.upsertRecord()`, same as `Wiki.dnsRecord()` already does for
|
|
54
|
+
* the wiki's own domain.
|
|
55
|
+
*/
|
|
56
|
+
ensureCustomDomain(projectId: string, hostname: string): Promise<DnsRecordRequest | null>;
|
|
33
57
|
private getProjectByName;
|
|
34
58
|
}
|
|
35
59
|
//#endregion
|
|
@@ -60,6 +84,8 @@ interface VercelPluginOptions extends ResolveTokenInput {
|
|
|
60
84
|
teamId?: string;
|
|
61
85
|
/** Default framework slug for new project creates. Defaults to "nextjs". */
|
|
62
86
|
defaultFramework?: string;
|
|
87
|
+
/** Custom domain that `holocron setup` should attach to the Vercel project. */
|
|
88
|
+
domain?: string;
|
|
63
89
|
/** Override base URL for tests. */
|
|
64
90
|
baseUrl?: string;
|
|
65
91
|
/** Override `fetch` for tests. */
|
package/dist/index.mjs
CHANGED
|
@@ -13,10 +13,12 @@ var VercelDeployment = class {
|
|
|
13
13
|
client;
|
|
14
14
|
key = "deployment";
|
|
15
15
|
providerName = "vercel";
|
|
16
|
+
domain;
|
|
16
17
|
defaultFramework;
|
|
17
18
|
constructor(client, opts = {}) {
|
|
18
19
|
this.client = client;
|
|
19
20
|
this.defaultFramework = opts.defaultFramework ?? "nextjs";
|
|
21
|
+
this.domain = opts.domain;
|
|
20
22
|
}
|
|
21
23
|
async listProjects() {
|
|
22
24
|
const { projects } = await this.client().projects.list();
|
|
@@ -60,6 +62,64 @@ var VercelDeployment = class {
|
|
|
60
62
|
const raw = await this.client().deployments.get(deploymentId);
|
|
61
63
|
return mapDeployment(raw, raw.meta?.githubCommitRef ?? null);
|
|
62
64
|
}
|
|
65
|
+
async deployFunction(projectId, config) {
|
|
66
|
+
const raw = await this.client().deployments.create({
|
|
67
|
+
projectName: projectId,
|
|
68
|
+
files: Object.entries(config.files).map(([file, content]) => ({
|
|
69
|
+
file,
|
|
70
|
+
content
|
|
71
|
+
})),
|
|
72
|
+
framework: null,
|
|
73
|
+
target: config.target
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
deploymentId: raw.id,
|
|
77
|
+
url: raw.url
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Idempotent — matches `Deployment.ensureCustomDomain`'s contract
|
|
82
|
+
* (never break on re-runs, per CLAUDE.md's probe-then-act standard).
|
|
83
|
+
*
|
|
84
|
+
* Ownership (`domains.add`'s `verified`) and DNS routing are separate
|
|
85
|
+
* concerns: once a team already owns the domain's apex (true for any
|
|
86
|
+
* org with more than one project on the same domain), every new
|
|
87
|
+
* subdomain auto-verifies immediately with no `verification`
|
|
88
|
+
* challenge — re-adding an already-attached domain returns 409, not
|
|
89
|
+
* a fresh one. So attachment alone can't tell us whether traffic is
|
|
90
|
+
* actually routed to Vercel yet. `domains.config()` (Vercel's DNS
|
|
91
|
+
* *configuration* check) answers that regardless of ownership state:
|
|
92
|
+
* `misconfigured` + a `recommendedCNAME`, per-project, never a fixed
|
|
93
|
+
* well-known host — always read it from this response, never
|
|
94
|
+
* hardcode it. Returned as a `DnsRecordRequest` — the caller (e.g.
|
|
95
|
+
* `holocron setup`'s custom-domain step) hands it straight to
|
|
96
|
+
* `dns.upsertRecord()`, same as `Wiki.dnsRecord()` already does for
|
|
97
|
+
* the wiki's own domain.
|
|
98
|
+
*/
|
|
99
|
+
async ensureCustomDomain(projectId, hostname) {
|
|
100
|
+
const { domains: existing } = await this.client().domains.list(projectId);
|
|
101
|
+
let apexName = existing.find((d) => d.name === hostname)?.apexName;
|
|
102
|
+
if (!apexName) try {
|
|
103
|
+
apexName = (await this.client().domains.add(projectId, hostname)).apexName;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
if (!(err instanceof ProviderApiError && err.status === 409)) throw err;
|
|
106
|
+
const { domains: refreshed } = await this.client().domains.list(projectId);
|
|
107
|
+
apexName = refreshed.find((d) => d.name === hostname)?.apexName;
|
|
108
|
+
}
|
|
109
|
+
if (!apexName) return null;
|
|
110
|
+
const config = await this.client().domains.config(hostname, projectId);
|
|
111
|
+
if (!config.misconfigured) return null;
|
|
112
|
+
const cname = config.recommendedCNAME[0]?.value;
|
|
113
|
+
if (!cname) return null;
|
|
114
|
+
return {
|
|
115
|
+
zone: apexName,
|
|
116
|
+
record: {
|
|
117
|
+
type: "CNAME",
|
|
118
|
+
name: hostname,
|
|
119
|
+
content: cname
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
63
123
|
async getProjectByName(name) {
|
|
64
124
|
try {
|
|
65
125
|
return mapProject(await this.client().projects.get(name));
|
|
@@ -142,6 +202,7 @@ function createContext(options = {}) {
|
|
|
142
202
|
function deployment(ctx) {
|
|
143
203
|
const opts = {};
|
|
144
204
|
if (ctx.options.defaultFramework !== void 0) opts.defaultFramework = ctx.options.defaultFramework;
|
|
205
|
+
if (ctx.options.domain !== void 0) opts.domain = ctx.options.domain;
|
|
145
206
|
return new VercelDeployment(ctx.client, opts);
|
|
146
207
|
}
|
|
147
208
|
function createPlugin(options = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-vercel",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.41",
|
|
4
4
|
"description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deployment",
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@theholocron/eslint-config": "^8.0.0",
|
|
34
|
+
"@theholocron/http-client": "^1.24.0",
|
|
34
35
|
"@theholocron/tsconfig": "^8.0.0",
|
|
35
36
|
"@theholocron/tsdown-config": "^8.0.0",
|
|
36
|
-
"@theholocron/vercel-client": "^1.
|
|
37
|
+
"@theholocron/vercel-client": "^1.24.0",
|
|
37
38
|
"@theholocron/vitest-config": "^8.0.0",
|
|
38
39
|
"@types/node": "^26",
|
|
39
40
|
"@vitest/coverage-v8": "^4.1.11",
|
|
@@ -45,11 +46,11 @@
|
|
|
45
46
|
"tsx": "4.23.12",
|
|
46
47
|
"typescript": "^5.9.3",
|
|
47
48
|
"vitest": "^4.1.11",
|
|
48
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
49
|
+
"@theholocron/cli": "5.0.0-alpha.41"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@theholocron/vercel-client": "^1.
|
|
52
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
52
|
+
"@theholocron/vercel-client": "^1.24.0",
|
|
53
|
+
"@theholocron/cli": "5.0.0-alpha.41"
|
|
53
54
|
},
|
|
54
55
|
"peerDependenciesMeta": {
|
|
55
56
|
"@theholocron/vercel-client": {}
|