@theholocron/holocron-plugin-vercel 5.0.0-alpha.4 → 5.0.0-alpha.400
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 +35 -1
- package/dist/index.d.mts +66 -33
- package/dist/index.mjs +131 -16
- package/package.json +27 -24
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!-- alex disable host-hostess -->
|
|
2
|
+
|
|
1
3
|
<!-- editorconfig-checker-disable-file -->
|
|
2
4
|
|
|
3
5
|
# `@theholocron/holocron-plugin-vercel`
|
|
@@ -55,10 +57,42 @@ Capability covers:
|
|
|
55
57
|
- `updateProjectSettings()` — toggle preview deploys, git-creates-deploys
|
|
56
58
|
- `setEnvVar()` / `listEnvVars()` — per-target env vars
|
|
57
59
|
- `triggerDeployment()` — branch deploys with optional named target
|
|
60
|
+
(requires a project already linked to a Git repo)
|
|
61
|
+
- `deployFunction()` — deploy directly from source files, bypassing Git
|
|
62
|
+
entirely: `POST /v13/deployments` with an inline `files` array, no
|
|
63
|
+
linked repo required. For a consumer with no repo to deploy from — a
|
|
64
|
+
webhook receiver shipped as an npm package, for instance. Always
|
|
65
|
+
deploys with `projectSettings.framework: null` (a bare function, not
|
|
66
|
+
an app) — `defaultFramework` only applies to `ensureProject()`'s
|
|
67
|
+
Git-linked path. If the files include a `vercel.json` with an
|
|
68
|
+
`installCommand`, it is sent as `projectSettings.installCommand` too,
|
|
69
|
+
because a deployment made from uploaded files takes that setting from
|
|
70
|
+
the project, not from the uploaded file.
|
|
58
71
|
- `getDeployment()` — fetch a deployment by id
|
|
72
|
+
- `ensureCustomDomain()` — idempotent add (list → add-if-missing →
|
|
73
|
+
check DNS routing). Ownership (`verified`) and DNS routing are
|
|
74
|
+
separate: once a team already owns a domain's apex, every new
|
|
75
|
+
subdomain auto-verifies immediately with no fresh challenge, so
|
|
76
|
+
attachment alone can't tell you whether traffic is actually routed
|
|
77
|
+
to Vercel yet. `domains.config()` answers that regardless of
|
|
78
|
+
ownership state, returning a per-project CNAME target — never a
|
|
79
|
+
fixed well-known host — only when DNS isn't already configured. The
|
|
80
|
+
returned DNS record is handed to the configured `dns` provider by
|
|
81
|
+
`holocron repo setup`.
|
|
82
|
+
|
|
83
|
+
Declare the production domain in the Vercel provider options. On `holocron repo setup`,
|
|
84
|
+
the domain is attached to the project and any Vercel verification CNAME is
|
|
85
|
+
upserted through the configured DNS provider:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
providers: {
|
|
89
|
+
deployment: ["vercel", { teamId: "team_…", domain: "sentinel.example.com" }],
|
|
90
|
+
dns: "cloudflare",
|
|
91
|
+
}
|
|
92
|
+
```
|
|
59
93
|
|
|
60
94
|
Out of scope for alpha.0 (file a follow-up if needed):
|
|
61
95
|
|
|
62
|
-
- Domain
|
|
96
|
+
- Domain removal (`removeDomain`)
|
|
63
97
|
- Deletion (`deleteProject`)
|
|
64
98
|
- Marketplace integrations (e.g. `vercel install neon` for vault-managed databases)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
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, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
2
2
|
import { VercelClient, VercelClient as VercelClient$1, VercelClientOptions, createVercelClient } from "@theholocron/vercel-client";
|
|
3
|
-
|
|
4
|
-
declare const resolveToken: (
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/** Resolves the Vercel token from `--token`, `HOLOCRON_VERCEL_TOKEN`, `VERCEL_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
|
|
4
|
+
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
5
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
6
|
+
export declare const tokens: PluginToken[];
|
|
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 repo setup` should attach to this project. */
|
|
11
|
+
domain?: string;
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
/** The `deployment` capability for Vercel: projects, environment variables, deployments, functions and custom domains. */
|
|
14
|
+
export declare class VercelDeployment implements Deployment {
|
|
12
15
|
private readonly client;
|
|
16
|
+
/** The capability key, always `deployment`. */
|
|
13
17
|
readonly key: "deployment";
|
|
18
|
+
/** The provider name, `vercel`. */
|
|
14
19
|
readonly providerName = "vercel";
|
|
20
|
+
readonly domain?: string;
|
|
15
21
|
private readonly defaultFramework;
|
|
16
22
|
constructor(client: () => VercelClient$1, opts?: DeploymentOptions);
|
|
23
|
+
/** Lists the projects the token can see, mapped to the provider-neutral shape. */
|
|
17
24
|
listProjects(): Promise<DeploymentProject[]>;
|
|
18
25
|
ensureProject(input: {
|
|
19
26
|
name: string;
|
|
@@ -21,58 +28,85 @@ declare class VercelDeployment implements Deployment {
|
|
|
21
28
|
repo?: string;
|
|
22
29
|
rootDirectory?: string;
|
|
23
30
|
}): Promise<DeploymentProject>;
|
|
31
|
+
/** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
|
|
24
32
|
updateProjectSettings(projectId: string, settings: DeploymentProjectSettings): Promise<DeploymentProject>;
|
|
33
|
+
/** Lists the names of the project's environment variables that apply to `target`. */
|
|
25
34
|
listEnvVars(projectId: string, target: DeploymentTarget): Promise<string[]>;
|
|
35
|
+
/** Creates or updates (upsert) an environment variable on the project for `target`. */
|
|
26
36
|
setEnvVar(projectId: string, target: DeploymentTarget, name: string, value: string): Promise<void>;
|
|
27
37
|
triggerDeployment(input: {
|
|
28
38
|
projectId: string;
|
|
29
39
|
branch: string;
|
|
30
40
|
target?: DeploymentTrigger;
|
|
31
41
|
}): Promise<DeploymentRecord>;
|
|
42
|
+
/** Fetches a deployment by id; the record's branch is the deployment's Git commit ref, or `null` when it has none. */
|
|
32
43
|
getDeployment(deploymentId: string): Promise<DeploymentRecord>;
|
|
44
|
+
deployFunction(projectId: string, config: DeployFunctionConfig): Promise<DeployFunctionResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Idempotent — matches `Deployment.ensureCustomDomain`'s contract
|
|
47
|
+
* (never break on re-runs, per CLAUDE.md's probe-then-act standard).
|
|
48
|
+
*
|
|
49
|
+
* Ownership (`domains.add`'s `verified`) and DNS routing are separate
|
|
50
|
+
* concerns: once a team already owns the domain's apex (true for any
|
|
51
|
+
* org with more than one project on the same domain), every new
|
|
52
|
+
* subdomain auto-verifies immediately with no `verification`
|
|
53
|
+
* challenge — re-adding an already-attached domain returns 409, not
|
|
54
|
+
* a fresh one. So attachment alone can't tell us whether traffic is
|
|
55
|
+
* actually routed to Vercel yet. `domains.config()` (Vercel's DNS
|
|
56
|
+
* *configuration* check) answers that regardless of ownership state:
|
|
57
|
+
* `misconfigured` + a `recommendedCNAME`, per-project, never a fixed
|
|
58
|
+
* well-known host — always read it from this response, never
|
|
59
|
+
* hardcode it. Returned as a `DnsRecordRequest` — the caller (e.g.
|
|
60
|
+
* `holocron repo setup`'s custom-domain step) hands it straight to
|
|
61
|
+
* `dns.upsertRecord()`, same as `Wiki.dnsRecord()` already does for
|
|
62
|
+
* the wiki's own domain.
|
|
63
|
+
*/
|
|
64
|
+
ensureCustomDomain(projectId: string, hostname: string): Promise<DnsRecordRequest | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Read-only: the CNAME Vercel recommends for `hostname`, whether or not the domain already resolves. Unlike
|
|
67
|
+
* `ensureCustomDomain` it never attaches the domain, and it keeps the answer when `misconfigured` is false, so
|
|
68
|
+
* `holocron doctor dns` can compare it with the zone. The record is DNS-only: a proxied record breaks Vercel's
|
|
69
|
+
* certificate issuance.
|
|
70
|
+
*/
|
|
71
|
+
expectedDomainRecord(projectId: string, hostname: string): Promise<DnsRecordRequest | null>;
|
|
33
72
|
private getProjectByName;
|
|
34
73
|
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/verify-token.d.ts
|
|
37
|
-
/**
|
|
38
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
39
|
-
* `holocron auth check`. Hits `GET /v2/user` and translates the
|
|
40
|
-
* response into the normalized `VerifyTokenResult` shape.
|
|
41
|
-
*/
|
|
42
|
-
interface VerifyTokenSuccess {
|
|
43
|
-
ok: true;
|
|
44
|
-
subject: string;
|
|
45
|
-
}
|
|
46
|
-
interface VerifyTokenFailure {
|
|
47
|
-
ok: false;
|
|
48
|
-
message: string;
|
|
49
|
-
}
|
|
50
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
51
74
|
interface VerifyTokenOptions {
|
|
52
75
|
baseUrl?: string;
|
|
53
76
|
fetch?: typeof fetch;
|
|
54
77
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
interface VercelPluginOptions extends ResolveTokenInput {
|
|
78
|
+
/** Checks a Vercel token by fetching the current user; the success subject is `user @` followed by the email, username, name or id, the failure carries the error message. */
|
|
79
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
80
|
+
/** Options for the Vercel plugin: token resolution, team, defaults for new projects and test overrides. */
|
|
81
|
+
export interface VercelPluginOptions extends ResolveTokenInput {
|
|
59
82
|
/** Vercel team id. Set when working with a team-owned project. */
|
|
60
83
|
teamId?: string;
|
|
61
84
|
/** Default framework slug for new project creates. Defaults to "nextjs". */
|
|
62
85
|
defaultFramework?: string;
|
|
86
|
+
/** Custom domain that `holocron repo setup` should attach to the Vercel project. */
|
|
87
|
+
domain?: string;
|
|
63
88
|
/** Override base URL for tests. */
|
|
64
89
|
baseUrl?: string;
|
|
65
90
|
/** Override `fetch` for tests. */
|
|
66
91
|
fetch?: typeof fetch;
|
|
67
92
|
}
|
|
68
|
-
|
|
93
|
+
/** What the plugin's capabilities share: the options and a lazily built client. */
|
|
94
|
+
export interface PluginContext {
|
|
95
|
+
/** The options the plugin was created with. */
|
|
69
96
|
options: VercelPluginOptions;
|
|
97
|
+
/** Builds the Vercel client on first call and reuses it; the token is resolved then, not at plugin load. */
|
|
70
98
|
client: () => VercelClient;
|
|
71
99
|
}
|
|
72
|
-
|
|
73
|
-
declare function
|
|
74
|
-
|
|
100
|
+
/** Creates the shared context for the given options; no token is resolved until `client()` is first called. */
|
|
101
|
+
export declare function createContext(options?: VercelPluginOptions): PluginContext;
|
|
102
|
+
/** Builds the `deployment` capability from a plugin context, passing on `defaultFramework` and `domain` when set. */
|
|
103
|
+
export declare function deployment(ctx: PluginContext): Deployment;
|
|
104
|
+
/** Creates the Vercel plugin: a `connection` probe and the `deployment` capability. */
|
|
105
|
+
export declare function createPlugin(options?: VercelPluginOptions): {
|
|
75
106
|
name: string;
|
|
107
|
+
probes: {
|
|
108
|
+
connection: import("@theholocron/cli").Probe;
|
|
109
|
+
};
|
|
76
110
|
capabilities: {
|
|
77
111
|
deployment: () => Deployment;
|
|
78
112
|
};
|
|
@@ -81,6 +115,5 @@ declare function createPlugin(options?: VercelPluginOptions): {
|
|
|
81
115
|
* One-line hint printed by `holocron auth set vercel` when no token
|
|
82
116
|
* is supplied or the supplied token is rejected.
|
|
83
117
|
*/
|
|
84
|
-
declare const AUTH_HINT: string;
|
|
85
|
-
|
|
86
|
-
export { AUTH_HINT, AuthError, PluginContext, type ResolveTokenInput, type VercelClient, type VercelClientOptions, VercelDeployment, VercelPluginOptions, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, createVercelClient, deployment, resolveToken, verifyToken };
|
|
118
|
+
export declare const AUTH_HINT: string;
|
|
119
|
+
export { AuthError, type ResolveTokenInput, type VercelClient, type VercelClientOptions, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createVercelClient };
|
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
2
2
|
import { createVercelClient } from "@theholocron/vercel-client";
|
|
3
|
-
|
|
3
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
|
+
// src/auth.ts
|
|
5
|
+
/** Resolves the Vercel token from `--token`, `HOLOCRON_VERCEL_TOKEN`, `VERCEL_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
|
|
4
6
|
const resolveToken = createResolveToken({
|
|
5
7
|
envName: "HOLOCRON_VERCEL_TOKEN",
|
|
6
8
|
vendorEnvName: "VERCEL_TOKEN",
|
|
7
9
|
keyringService: "vercel",
|
|
8
10
|
errorMessage: "no Vercel token found. Pass --token <PAT>, set HOLOCRON_VERCEL_TOKEN / VERCEL_TOKEN, or run: holocron auth set vercel <PAT>"
|
|
9
11
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
13
|
+
const tokens = [resolveToken.token];
|
|
14
|
+
// src/capabilities/deployment.ts
|
|
15
|
+
/** The `deployment` capability for Vercel: projects, environment variables, deployments, functions and custom domains. */
|
|
12
16
|
var VercelDeployment = class {
|
|
13
17
|
client;
|
|
18
|
+
/** The capability key, always `deployment`. */
|
|
14
19
|
key = "deployment";
|
|
20
|
+
/** The provider name, `vercel`. */
|
|
15
21
|
providerName = "vercel";
|
|
22
|
+
domain;
|
|
16
23
|
defaultFramework;
|
|
17
24
|
constructor(client, opts = {}) {
|
|
18
25
|
this.client = client;
|
|
19
26
|
this.defaultFramework = opts.defaultFramework ?? "nextjs";
|
|
27
|
+
this.domain = opts.domain;
|
|
20
28
|
}
|
|
29
|
+
/** Lists the projects the token can see, mapped to the provider-neutral shape. */
|
|
21
30
|
async listProjects() {
|
|
22
31
|
const { projects } = await this.client().projects.list();
|
|
23
32
|
return projects.map(mapProject);
|
|
@@ -32,16 +41,19 @@ var VercelDeployment = class {
|
|
|
32
41
|
rootDirectory: input.rootDirectory
|
|
33
42
|
}));
|
|
34
43
|
}
|
|
44
|
+
/** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
|
|
35
45
|
async updateProjectSettings(projectId, settings) {
|
|
36
46
|
return mapProject(await this.client().projects.update(projectId, {
|
|
37
47
|
previewDeploymentsDisabled: settings.previewDeploymentsDisabled,
|
|
38
48
|
gitProviderOptions: settings.gitProviderCreateDeployments !== void 0 ? { createDeployments: settings.gitProviderCreateDeployments } : void 0
|
|
39
49
|
}));
|
|
40
50
|
}
|
|
51
|
+
/** Lists the names of the project's environment variables that apply to `target`. */
|
|
41
52
|
async listEnvVars(projectId, target) {
|
|
42
53
|
const { envs } = await this.client().env.list(projectId);
|
|
43
54
|
return envs.filter((e) => e.target.includes(target)).map((e) => e.key);
|
|
44
55
|
}
|
|
56
|
+
/** Creates or updates (upsert) an environment variable on the project for `target`. */
|
|
45
57
|
async setEnvVar(projectId, target, name, value) {
|
|
46
58
|
await this.client().env.set(projectId, target, name, value);
|
|
47
59
|
}
|
|
@@ -56,10 +68,89 @@ var VercelDeployment = class {
|
|
|
56
68
|
target: input.target
|
|
57
69
|
}), input.branch);
|
|
58
70
|
}
|
|
71
|
+
/** Fetches a deployment by id; the record's branch is the deployment's Git commit ref, or `null` when it has none. */
|
|
59
72
|
async getDeployment(deploymentId) {
|
|
60
73
|
const raw = await this.client().deployments.get(deploymentId);
|
|
61
74
|
return mapDeployment(raw, raw.meta?.githubCommitRef ?? null);
|
|
62
75
|
}
|
|
76
|
+
async deployFunction(projectId, config) {
|
|
77
|
+
const raw = await this.client().deployments.create({
|
|
78
|
+
projectName: projectId,
|
|
79
|
+
files: Object.entries(config.files).map(([file, content]) => ({
|
|
80
|
+
file,
|
|
81
|
+
content
|
|
82
|
+
})),
|
|
83
|
+
framework: null,
|
|
84
|
+
...installCommandOf(config.files),
|
|
85
|
+
target: config.target
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
deploymentId: raw.id,
|
|
89
|
+
url: raw.url
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Idempotent — matches `Deployment.ensureCustomDomain`'s contract
|
|
94
|
+
* (never break on re-runs, per CLAUDE.md's probe-then-act standard).
|
|
95
|
+
*
|
|
96
|
+
* Ownership (`domains.add`'s `verified`) and DNS routing are separate
|
|
97
|
+
* concerns: once a team already owns the domain's apex (true for any
|
|
98
|
+
* org with more than one project on the same domain), every new
|
|
99
|
+
* subdomain auto-verifies immediately with no `verification`
|
|
100
|
+
* challenge — re-adding an already-attached domain returns 409, not
|
|
101
|
+
* a fresh one. So attachment alone can't tell us whether traffic is
|
|
102
|
+
* actually routed to Vercel yet. `domains.config()` (Vercel's DNS
|
|
103
|
+
* *configuration* check) answers that regardless of ownership state:
|
|
104
|
+
* `misconfigured` + a `recommendedCNAME`, per-project, never a fixed
|
|
105
|
+
* well-known host — always read it from this response, never
|
|
106
|
+
* hardcode it. Returned as a `DnsRecordRequest` — the caller (e.g.
|
|
107
|
+
* `holocron repo setup`'s custom-domain step) hands it straight to
|
|
108
|
+
* `dns.upsertRecord()`, same as `Wiki.dnsRecord()` already does for
|
|
109
|
+
* the wiki's own domain.
|
|
110
|
+
*/
|
|
111
|
+
async ensureCustomDomain(projectId, hostname) {
|
|
112
|
+
const { domains: existing } = await this.client().domains.list(projectId);
|
|
113
|
+
let apexName = existing.find((d) => d.name === hostname)?.apexName;
|
|
114
|
+
if (!apexName) try {
|
|
115
|
+
apexName = (await this.client().domains.add(projectId, hostname)).apexName;
|
|
116
|
+
} catch (err) {
|
|
117
|
+
if (!(err instanceof ProviderApiError && err.status === 409)) throw err;
|
|
118
|
+
const { domains: refreshed } = await this.client().domains.list(projectId);
|
|
119
|
+
apexName = refreshed.find((d) => d.name === hostname)?.apexName;
|
|
120
|
+
}
|
|
121
|
+
if (!apexName) return null;
|
|
122
|
+
const config = await this.client().domains.config(hostname, projectId);
|
|
123
|
+
if (!config.misconfigured) return null;
|
|
124
|
+
const cname = config.recommendedCNAME[0]?.value;
|
|
125
|
+
if (!cname) return null;
|
|
126
|
+
return {
|
|
127
|
+
zone: apexName,
|
|
128
|
+
record: {
|
|
129
|
+
type: "CNAME",
|
|
130
|
+
name: hostname,
|
|
131
|
+
content: cname
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Read-only: the CNAME Vercel recommends for `hostname`, whether or not the domain already resolves. Unlike
|
|
137
|
+
* `ensureCustomDomain` it never attaches the domain, and it keeps the answer when `misconfigured` is false, so
|
|
138
|
+
* `holocron doctor dns` can compare it with the zone. The record is DNS-only: a proxied record breaks Vercel's
|
|
139
|
+
* certificate issuance.
|
|
140
|
+
*/
|
|
141
|
+
async expectedDomainRecord(projectId, hostname) {
|
|
142
|
+
const cname = (await this.client().domains.config(hostname, projectId)).recommendedCNAME[0]?.value;
|
|
143
|
+
if (!cname) return null;
|
|
144
|
+
return {
|
|
145
|
+
zone: hostname,
|
|
146
|
+
record: {
|
|
147
|
+
type: "CNAME",
|
|
148
|
+
name: hostname,
|
|
149
|
+
content: cname,
|
|
150
|
+
proxied: false
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
63
154
|
async getProjectByName(name) {
|
|
64
155
|
try {
|
|
65
156
|
return mapProject(await this.client().projects.get(name));
|
|
@@ -69,6 +160,22 @@ var VercelDeployment = class {
|
|
|
69
160
|
}
|
|
70
161
|
}
|
|
71
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* The `installCommand` of an uploaded `vercel.json`, as the field `deployments.create()` takes.
|
|
165
|
+
* A deployment made from uploaded files ignores the file's `installCommand` in favour of the
|
|
166
|
+
* project's setting, so it is sent in the request too. Empty when there is no such file, it is
|
|
167
|
+
* not JSON, or it sets none.
|
|
168
|
+
*/
|
|
169
|
+
function installCommandOf(files) {
|
|
170
|
+
const raw = files["vercel.json"];
|
|
171
|
+
if (raw === void 0) return {};
|
|
172
|
+
try {
|
|
173
|
+
const { installCommand } = JSON.parse(raw);
|
|
174
|
+
return typeof installCommand === "string" && installCommand ? { installCommand } : {};
|
|
175
|
+
} catch {
|
|
176
|
+
return {};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
72
179
|
function mapProject(raw) {
|
|
73
180
|
const project = {
|
|
74
181
|
id: raw.id,
|
|
@@ -87,6 +194,7 @@ function mapDeployment(raw, branch) {
|
|
|
87
194
|
status: normalizeState(raw.readyState)
|
|
88
195
|
};
|
|
89
196
|
if (raw.target) record.target = raw.target;
|
|
197
|
+
if (raw.errorMessage) record.errorMessage = raw.errorMessage;
|
|
90
198
|
return record;
|
|
91
199
|
}
|
|
92
200
|
function normalizeState(s) {
|
|
@@ -99,13 +207,8 @@ function normalizeState(s) {
|
|
|
99
207
|
case "CANCELED": return "cancelled";
|
|
100
208
|
}
|
|
101
209
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
106
|
-
* `holocron auth check`. Hits `GET /v2/user` and translates the
|
|
107
|
-
* response into the normalized `VerifyTokenResult` shape.
|
|
108
|
-
*/
|
|
210
|
+
// src/verify-token.ts
|
|
211
|
+
/** Checks a Vercel token by fetching the current user; the success subject is `user @` followed by the email, username, name or id, the failure carries the error message. */
|
|
109
212
|
async function verifyToken(token, opts = {}) {
|
|
110
213
|
const client = createVercelClient({
|
|
111
214
|
token,
|
|
@@ -121,12 +224,12 @@ async function verifyToken(token, opts = {}) {
|
|
|
121
224
|
} catch (err) {
|
|
122
225
|
return {
|
|
123
226
|
ok: false,
|
|
124
|
-
message:
|
|
227
|
+
message: errorMessage(err)
|
|
125
228
|
};
|
|
126
229
|
}
|
|
127
230
|
}
|
|
128
|
-
|
|
129
|
-
|
|
231
|
+
// src/index.ts
|
|
232
|
+
/** Creates the shared context for the given options; no token is resolved until `client()` is first called. */
|
|
130
233
|
function createContext(options = {}) {
|
|
131
234
|
let client;
|
|
132
235
|
return {
|
|
@@ -139,15 +242,28 @@ function createContext(options = {}) {
|
|
|
139
242
|
})
|
|
140
243
|
};
|
|
141
244
|
}
|
|
245
|
+
/** Builds the `deployment` capability from a plugin context, passing on `defaultFramework` and `domain` when set. */
|
|
142
246
|
function deployment(ctx) {
|
|
143
247
|
const opts = {};
|
|
144
248
|
if (ctx.options.defaultFramework !== void 0) opts.defaultFramework = ctx.options.defaultFramework;
|
|
249
|
+
if (ctx.options.domain !== void 0) opts.domain = ctx.options.domain;
|
|
145
250
|
return new VercelDeployment(ctx.client, opts);
|
|
146
251
|
}
|
|
252
|
+
/** Creates the Vercel plugin: a `connection` probe and the `deployment` capability. */
|
|
147
253
|
function createPlugin(options = {}) {
|
|
148
254
|
const ctx = createContext(options);
|
|
149
255
|
return {
|
|
150
256
|
name: "@theholocron/holocron-plugin-vercel",
|
|
257
|
+
probes: { connection: connectionProbe({
|
|
258
|
+
provider: "Vercel",
|
|
259
|
+
url: options.baseUrl ?? "https://api.vercel.com",
|
|
260
|
+
fetch: options.fetch,
|
|
261
|
+
token: () => resolveToken(options),
|
|
262
|
+
verify: (token) => verifyToken(token, {
|
|
263
|
+
baseUrl: options.baseUrl,
|
|
264
|
+
fetch: options.fetch
|
|
265
|
+
})
|
|
266
|
+
}) },
|
|
151
267
|
capabilities: { deployment: () => deployment(ctx) }
|
|
152
268
|
};
|
|
153
269
|
}
|
|
@@ -156,5 +272,4 @@ function createPlugin(options = {}) {
|
|
|
156
272
|
* is supplied or the supplied token is rejected.
|
|
157
273
|
*/
|
|
158
274
|
const AUTH_HINT = "generate a Vercel Personal Access Token at https://vercel.com/account/tokens (scope: Full Account for team ops), then run: holocron auth set vercel <PAT>";
|
|
159
|
-
|
|
160
|
-
export { AUTH_HINT, AuthError, VercelDeployment, createContext, createPlugin, createVercelClient, deployment, resolveToken, verifyToken };
|
|
275
|
+
export { AUTH_HINT, AuthError, VercelDeployment, createContext, createPlugin, createVercelClient, deployment, resolveToken, tokens, verifyToken };
|
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.400",
|
|
4
4
|
"description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deployment",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"plugin",
|
|
9
9
|
"vercel"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.theholocron.dev/holocron/plugins/vercel/",
|
|
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-vercel"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,26 +30,29 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/eslint-config": "^8.0.0",
|
|
34
|
-
"@theholocron/tsconfig": "^8.0.0",
|
|
35
|
-
"@theholocron/tsdown-config": "^8.0.0",
|
|
36
|
-
"@theholocron/vercel-client": "^1.14.2",
|
|
37
|
-
"@theholocron/vitest-config": "^8.0.0",
|
|
38
33
|
"@types/node": "^26",
|
|
39
|
-
"@vitest/coverage-v8": "^
|
|
40
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
41
|
-
"eslint": "^10.
|
|
42
|
-
"eslint-plugin-n": "^18.
|
|
43
|
-
"globals": "^17.
|
|
44
|
-
"tsdown": "^0.
|
|
45
|
-
"tsx": "4.23.
|
|
34
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
35
|
+
"@vitest/eslint-plugin": "^1.6.28",
|
|
36
|
+
"eslint": "^10.14.0",
|
|
37
|
+
"eslint-plugin-n": "^18.5.0",
|
|
38
|
+
"globals": "^17.14.0",
|
|
39
|
+
"tsdown": "^0.23.5",
|
|
40
|
+
"tsx": "4.23.15",
|
|
46
41
|
"typescript": "^5.9.3",
|
|
47
|
-
"vitest": "^
|
|
48
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
42
|
+
"vitest": "^5.1.0",
|
|
43
|
+
"@theholocron/cli": "5.0.0-alpha.400",
|
|
44
|
+
"@theholocron/http-client": "^1.58.0-alpha.27",
|
|
45
|
+
"@theholocron/misc-utils": "^1.17.0-alpha.3",
|
|
46
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.15",
|
|
47
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.15",
|
|
48
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.15",
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.15",
|
|
50
|
+
"@theholocron/vercel-client": "^1.58.0-alpha.27"
|
|
49
51
|
},
|
|
50
52
|
"peerDependencies": {
|
|
51
|
-
"@theholocron/
|
|
52
|
-
"@theholocron/
|
|
53
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
54
|
+
"@theholocron/vercel-client": "^1.43.1",
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.400"
|
|
53
56
|
},
|
|
54
57
|
"peerDependenciesMeta": {
|
|
55
58
|
"@theholocron/vercel-client": {}
|
|
@@ -61,11 +64,11 @@
|
|
|
61
64
|
"access": "public"
|
|
62
65
|
},
|
|
63
66
|
"scripts": {
|
|
64
|
-
"
|
|
65
|
-
"
|
|
67
|
+
"build": "tsdown",
|
|
68
|
+
"lint:code": "eslint .",
|
|
69
|
+
"test:unit": "vitest run --coverage",
|
|
66
70
|
"test:watch": "vitest",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"verification.unitTests": "holocron run verification.unitTests --"
|
|
71
|
+
"typecheck": "tsc --noEmit",
|
|
72
|
+
"validate:plugin": "tsx scripts/validate.mjs"
|
|
70
73
|
}
|
|
71
74
|
}
|