@theholocron/holocron-plugin-vercel 5.0.0-alpha.32 → 5.0.0-alpha.327

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
@@ -1,3 +1,5 @@
1
+ <!-- alex disable host-hostess -->
2
+
1
3
  <!-- editorconfig-checker-disable-file -->
2
4
 
3
5
  # `@theholocron/holocron-plugin-vercel`
@@ -73,9 +75,9 @@ Capability covers:
73
75
  ownership state, returning a per-project CNAME target — never a
74
76
  fixed well-known host — only when DNS isn't already configured. The
75
77
  returned DNS record is handed to the configured `dns` provider by
76
- `holocron setup`.
78
+ `holocron repo setup`.
77
79
 
78
- Declare the production domain in the Vercel provider options. On `holocron setup`,
80
+ Declare the production domain in the Vercel provider options. On `holocron repo setup`,
79
81
  the domain is attached to the project and any Vercel verification CNAME is
80
82
  upserted through the configured DNS provider:
81
83
 
package/dist/index.d.mts CHANGED
@@ -1,22 +1,26 @@
1
- import { AuthError, DeployFunctionConfig, DeployFunctionResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, DnsRecordRequest, 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
- //#region src/auth.d.ts
4
- declare const resolveToken: (input?: ResolveTokenInput) => string;
5
- //#endregion
6
- //#region src/capabilities/deployment.d.ts
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 setup` should attach to this project. */
10
+ /** Custom domain that `holocron repo setup` should attach to this project. */
11
11
  domain?: string;
12
12
  }
13
- declare class VercelDeployment implements Deployment {
13
+ /** The `deployment` capability for Vercel: projects, environment variables, deployments, functions and custom domains. */
14
+ export declare class VercelDeployment implements Deployment {
14
15
  private readonly client;
16
+ /** The capability key, always `deployment`. */
15
17
  readonly key: "deployment";
18
+ /** The provider name, `vercel`. */
16
19
  readonly providerName = "vercel";
17
20
  readonly domain?: string;
18
21
  private readonly defaultFramework;
19
22
  constructor(client: () => VercelClient$1, opts?: DeploymentOptions);
23
+ /** Lists the projects the token can see, mapped to the provider-neutral shape. */
20
24
  listProjects(): Promise<DeploymentProject[]>;
21
25
  ensureProject(input: {
22
26
  name: string;
@@ -24,14 +28,18 @@ declare class VercelDeployment implements Deployment {
24
28
  repo?: string;
25
29
  rootDirectory?: string;
26
30
  }): Promise<DeploymentProject>;
31
+ /** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
27
32
  updateProjectSettings(projectId: string, settings: DeploymentProjectSettings): Promise<DeploymentProject>;
33
+ /** Lists the names of the project's environment variables that apply to `target`. */
28
34
  listEnvVars(projectId: string, target: DeploymentTarget): Promise<string[]>;
35
+ /** Creates or updates (upsert) an environment variable on the project for `target`. */
29
36
  setEnvVar(projectId: string, target: DeploymentTarget, name: string, value: string): Promise<void>;
30
37
  triggerDeployment(input: {
31
38
  projectId: string;
32
39
  branch: string;
33
40
  target?: DeploymentTrigger;
34
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. */
35
43
  getDeployment(deploymentId: string): Promise<DeploymentRecord>;
36
44
  deployFunction(projectId: string, config: DeployFunctionConfig): Promise<DeployFunctionResult>;
37
45
  /**
@@ -49,56 +57,56 @@ declare class VercelDeployment implements Deployment {
49
57
  * `misconfigured` + a `recommendedCNAME`, per-project, never a fixed
50
58
  * well-known host — always read it from this response, never
51
59
  * hardcode it. Returned as a `DnsRecordRequest` — the caller (e.g.
52
- * `holocron setup`'s custom-domain step) hands it straight to
60
+ * `holocron repo setup`'s custom-domain step) hands it straight to
53
61
  * `dns.upsertRecord()`, same as `Wiki.dnsRecord()` already does for
54
62
  * the wiki's own domain.
55
63
  */
56
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>;
57
72
  private getProjectByName;
58
73
  }
59
- //#endregion
60
- //#region src/verify-token.d.ts
61
- /**
62
- * `verifyToken` — plugin-level export used by `holocron auth set` +
63
- * `holocron auth check`. Hits `GET /v2/user` and translates the
64
- * response into the normalized `VerifyTokenResult` shape.
65
- */
66
- interface VerifyTokenSuccess {
67
- ok: true;
68
- subject: string;
69
- }
70
- interface VerifyTokenFailure {
71
- ok: false;
72
- message: string;
73
- }
74
- type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
75
74
  interface VerifyTokenOptions {
76
75
  baseUrl?: string;
77
76
  fetch?: typeof fetch;
78
77
  }
79
- declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
80
- //#endregion
81
- //#region src/index.d.ts
82
- 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 {
83
82
  /** Vercel team id. Set when working with a team-owned project. */
84
83
  teamId?: string;
85
84
  /** Default framework slug for new project creates. Defaults to "nextjs". */
86
85
  defaultFramework?: string;
87
- /** Custom domain that `holocron setup` should attach to the Vercel project. */
86
+ /** Custom domain that `holocron repo setup` should attach to the Vercel project. */
88
87
  domain?: string;
89
88
  /** Override base URL for tests. */
90
89
  baseUrl?: string;
91
90
  /** Override `fetch` for tests. */
92
91
  fetch?: typeof fetch;
93
92
  }
94
- interface PluginContext {
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. */
95
96
  options: VercelPluginOptions;
97
+ /** Builds the Vercel client on first call and reuses it; the token is resolved then, not at plugin load. */
96
98
  client: () => VercelClient;
97
99
  }
98
- declare function createContext(options?: VercelPluginOptions): PluginContext;
99
- declare function deployment(ctx: PluginContext): Deployment;
100
- declare function createPlugin(options?: VercelPluginOptions): {
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): {
101
106
  name: string;
107
+ probes: {
108
+ connection: import("@theholocron/cli").Probe;
109
+ };
102
110
  capabilities: {
103
111
  deployment: () => Deployment;
104
112
  };
@@ -107,6 +115,5 @@ declare function createPlugin(options?: VercelPluginOptions): {
107
115
  * One-line hint printed by `holocron auth set vercel` when no token
108
116
  * is supplied or the supplied token is rejected.
109
117
  */
110
- declare const AUTH_HINT: string;
111
- //#endregion
112
- 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,17 +1,23 @@
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
- //#region src/auth.ts
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
- //#endregion
11
- //#region src/capabilities/deployment.ts
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";
16
22
  domain;
17
23
  defaultFramework;
@@ -20,6 +26,7 @@ var VercelDeployment = class {
20
26
  this.defaultFramework = opts.defaultFramework ?? "nextjs";
21
27
  this.domain = opts.domain;
22
28
  }
29
+ /** Lists the projects the token can see, mapped to the provider-neutral shape. */
23
30
  async listProjects() {
24
31
  const { projects } = await this.client().projects.list();
25
32
  return projects.map(mapProject);
@@ -34,16 +41,19 @@ var VercelDeployment = class {
34
41
  rootDirectory: input.rootDirectory
35
42
  }));
36
43
  }
44
+ /** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
37
45
  async updateProjectSettings(projectId, settings) {
38
46
  return mapProject(await this.client().projects.update(projectId, {
39
47
  previewDeploymentsDisabled: settings.previewDeploymentsDisabled,
40
48
  gitProviderOptions: settings.gitProviderCreateDeployments !== void 0 ? { createDeployments: settings.gitProviderCreateDeployments } : void 0
41
49
  }));
42
50
  }
51
+ /** Lists the names of the project's environment variables that apply to `target`. */
43
52
  async listEnvVars(projectId, target) {
44
53
  const { envs } = await this.client().env.list(projectId);
45
54
  return envs.filter((e) => e.target.includes(target)).map((e) => e.key);
46
55
  }
56
+ /** Creates or updates (upsert) an environment variable on the project for `target`. */
47
57
  async setEnvVar(projectId, target, name, value) {
48
58
  await this.client().env.set(projectId, target, name, value);
49
59
  }
@@ -58,6 +68,7 @@ var VercelDeployment = class {
58
68
  target: input.target
59
69
  }), input.branch);
60
70
  }
71
+ /** Fetches a deployment by id; the record's branch is the deployment's Git commit ref, or `null` when it has none. */
61
72
  async getDeployment(deploymentId) {
62
73
  const raw = await this.client().deployments.get(deploymentId);
63
74
  return mapDeployment(raw, raw.meta?.githubCommitRef ?? null);
@@ -92,7 +103,7 @@ var VercelDeployment = class {
92
103
  * `misconfigured` + a `recommendedCNAME`, per-project, never a fixed
93
104
  * well-known host — always read it from this response, never
94
105
  * hardcode it. Returned as a `DnsRecordRequest` — the caller (e.g.
95
- * `holocron setup`'s custom-domain step) hands it straight to
106
+ * `holocron repo setup`'s custom-domain step) hands it straight to
96
107
  * `dns.upsertRecord()`, same as `Wiki.dnsRecord()` already does for
97
108
  * the wiki's own domain.
98
109
  */
@@ -120,6 +131,25 @@ var VercelDeployment = class {
120
131
  }
121
132
  };
122
133
  }
134
+ /**
135
+ * Read-only: the CNAME Vercel recommends for `hostname`, whether or not the domain already resolves. Unlike
136
+ * `ensureCustomDomain` it never attaches the domain, and it keeps the answer when `misconfigured` is false, so
137
+ * `holocron doctor dns` can compare it with the zone. The record is DNS-only: a proxied record breaks Vercel's
138
+ * certificate issuance.
139
+ */
140
+ async expectedDomainRecord(projectId, hostname) {
141
+ const cname = (await this.client().domains.config(hostname, projectId)).recommendedCNAME[0]?.value;
142
+ if (!cname) return null;
143
+ return {
144
+ zone: hostname,
145
+ record: {
146
+ type: "CNAME",
147
+ name: hostname,
148
+ content: cname,
149
+ proxied: false
150
+ }
151
+ };
152
+ }
123
153
  async getProjectByName(name) {
124
154
  try {
125
155
  return mapProject(await this.client().projects.get(name));
@@ -147,6 +177,7 @@ function mapDeployment(raw, branch) {
147
177
  status: normalizeState(raw.readyState)
148
178
  };
149
179
  if (raw.target) record.target = raw.target;
180
+ if (raw.errorMessage) record.errorMessage = raw.errorMessage;
150
181
  return record;
151
182
  }
152
183
  function normalizeState(s) {
@@ -159,13 +190,8 @@ function normalizeState(s) {
159
190
  case "CANCELED": return "cancelled";
160
191
  }
161
192
  }
162
- //#endregion
163
- //#region src/verify-token.ts
164
- /**
165
- * `verifyToken` — plugin-level export used by `holocron auth set` +
166
- * `holocron auth check`. Hits `GET /v2/user` and translates the
167
- * response into the normalized `VerifyTokenResult` shape.
168
- */
193
+ // src/verify-token.ts
194
+ /** 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. */
169
195
  async function verifyToken(token, opts = {}) {
170
196
  const client = createVercelClient({
171
197
  token,
@@ -181,12 +207,12 @@ async function verifyToken(token, opts = {}) {
181
207
  } catch (err) {
182
208
  return {
183
209
  ok: false,
184
- message: err instanceof Error ? err.message : String(err)
210
+ message: errorMessage(err)
185
211
  };
186
212
  }
187
213
  }
188
- //#endregion
189
- //#region src/index.ts
214
+ // src/index.ts
215
+ /** Creates the shared context for the given options; no token is resolved until `client()` is first called. */
190
216
  function createContext(options = {}) {
191
217
  let client;
192
218
  return {
@@ -199,16 +225,28 @@ function createContext(options = {}) {
199
225
  })
200
226
  };
201
227
  }
228
+ /** Builds the `deployment` capability from a plugin context, passing on `defaultFramework` and `domain` when set. */
202
229
  function deployment(ctx) {
203
230
  const opts = {};
204
231
  if (ctx.options.defaultFramework !== void 0) opts.defaultFramework = ctx.options.defaultFramework;
205
232
  if (ctx.options.domain !== void 0) opts.domain = ctx.options.domain;
206
233
  return new VercelDeployment(ctx.client, opts);
207
234
  }
235
+ /** Creates the Vercel plugin: a `connection` probe and the `deployment` capability. */
208
236
  function createPlugin(options = {}) {
209
237
  const ctx = createContext(options);
210
238
  return {
211
239
  name: "@theholocron/holocron-plugin-vercel",
240
+ probes: { connection: connectionProbe({
241
+ provider: "Vercel",
242
+ url: options.baseUrl ?? "https://api.vercel.com",
243
+ fetch: options.fetch,
244
+ token: () => resolveToken(options),
245
+ verify: (token) => verifyToken(token, {
246
+ baseUrl: options.baseUrl,
247
+ fetch: options.fetch
248
+ })
249
+ }) },
212
250
  capabilities: { deployment: () => deployment(ctx) }
213
251
  };
214
252
  }
@@ -217,5 +255,4 @@ function createPlugin(options = {}) {
217
255
  * is supplied or the supplied token is rejected.
218
256
  */
219
257
  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>";
220
- //#endregion
221
- export { AUTH_HINT, AuthError, VercelDeployment, createContext, createPlugin, createVercelClient, deployment, resolveToken, verifyToken };
258
+ 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.32",
3
+ "version": "5.0.0-alpha.327",
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://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-vercel#readme",
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": "packages/holocron-plugin-vercel"
16
+ "directory": "plugins/holocron-plugin-vercel"
17
17
  },
18
18
  "license": "MIT",
19
19
  "author": "Newton Koumantzelis",
@@ -30,27 +30,29 @@
30
30
  "dist"
31
31
  ],
32
32
  "devDependencies": {
33
- "@theholocron/eslint-config": "^8.0.0",
34
- "@theholocron/http-client": "^1.24.0",
35
- "@theholocron/tsconfig": "^8.0.0",
36
- "@theholocron/tsdown-config": "^8.0.0",
37
- "@theholocron/vercel-client": "^1.24.0",
38
- "@theholocron/vitest-config": "^8.0.0",
39
33
  "@types/node": "^26",
40
- "@vitest/coverage-v8": "^4.1.11",
34
+ "@vitest/coverage-v8": "^5.0.5",
41
35
  "@vitest/eslint-plugin": "^1.6.27",
42
36
  "eslint": "^10.8.1",
43
37
  "eslint-plugin-n": "^18.3.0",
44
38
  "globals": "^17.11.0",
45
- "tsdown": "^0.22.14",
46
- "tsx": "4.23.12",
39
+ "tsdown": "^0.23.3",
40
+ "tsx": "4.23.15",
47
41
  "typescript": "^5.9.3",
48
- "vitest": "^4.1.11",
49
- "@theholocron/cli": "5.0.0-alpha.32"
42
+ "vitest": "^5.0.5",
43
+ "@theholocron/cli": "5.0.0-alpha.327",
44
+ "@theholocron/eslint-config": "^8.9.0-alpha.8",
45
+ "@theholocron/http-client": "^1.58.0-alpha.7",
46
+ "@theholocron/misc-utils": "^1.17.0-alpha.1",
47
+ "@theholocron/tsdown-config": "^8.9.0-alpha.8",
48
+ "@theholocron/vercel-client": "^1.58.0-alpha.7",
49
+ "@theholocron/tsconfig": "^8.9.0-alpha.8",
50
+ "@theholocron/vitest-config": "^8.9.0-alpha.8"
50
51
  },
51
52
  "peerDependencies": {
52
- "@theholocron/vercel-client": "^1.24.0",
53
- "@theholocron/cli": "5.0.0-alpha.32"
53
+ "@theholocron/misc-utils": "^1.16.0",
54
+ "@theholocron/vercel-client": "^1.43.1",
55
+ "@theholocron/cli": "5.0.0-alpha.327"
54
56
  },
55
57
  "peerDependenciesMeta": {
56
58
  "@theholocron/vercel-client": {}
@@ -62,11 +64,11 @@
62
64
  "access": "public"
63
65
  },
64
66
  "scripts": {
65
- "delivery.build": "tsdown",
66
- "sourceQuality.staticAnalysis": "holocron run sourceQuality.staticAnalysis --",
67
+ "build": "tsdown",
68
+ "lint:code": "eslint .",
69
+ "test:unit": "vitest run --coverage",
67
70
  "test:watch": "vitest",
68
- "validate": "tsx scripts/validate.mjs",
69
- "verification.typeSafety": "holocron run verification.typeSafety --",
70
- "verification.unitTests": "holocron run verification.unitTests --"
71
+ "typecheck": "tsc --noEmit",
72
+ "validate:plugin": "tsx scripts/validate.mjs"
71
73
  }
72
74
  }