@theholocron/holocron-plugin-vercel 2.0.0-alpha.51 → 2.0.0-alpha.53

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/dist/index.d.mts CHANGED
@@ -1,27 +1,20 @@
1
- import { AuthError, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, ResolveTokenInput, RestClient, RestClient as RestClient$1 } from "@theholocron/cli";
1
+ import { AuthError, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, ResolveTokenInput } from "@theholocron/cli";
2
+ import { VercelClient, VercelClient as VercelClient$1, createVercelClient } from "@theholocron/vercel-client";
2
3
 
3
4
  //#region src/auth.d.ts
4
5
  declare const resolveToken: (input?: import("@theholocron/http-client").ResolveTokenInput) => string;
5
6
  //#endregion
6
- //#region src/rest.d.ts
7
- declare function createVercelRestClient(opts: {
8
- token: string;
9
- teamId?: string;
10
- baseUrl?: string;
11
- fetch?: typeof fetch;
12
- }): RestClient$1;
13
- //#endregion
14
7
  //#region src/capabilities/deployment.d.ts
15
8
  interface DeploymentOptions {
16
9
  /** Optional framework hint passed to project creates. Defaults to "nextjs". */
17
10
  defaultFramework?: string;
18
11
  }
19
12
  declare class VercelDeployment implements Deployment {
20
- private readonly rest;
13
+ private readonly client;
21
14
  readonly key: "deployment";
22
15
  readonly providerName = "vercel";
23
16
  private readonly defaultFramework;
24
- constructor(rest: RestClient, opts?: DeploymentOptions);
17
+ constructor(client: VercelClient$1, opts?: DeploymentOptions);
25
18
  listProjects(): Promise<DeploymentProject[]>;
26
19
  ensureProject(input: {
27
20
  name: string;
@@ -38,7 +31,6 @@ declare class VercelDeployment implements Deployment {
38
31
  target?: DeploymentTrigger;
39
32
  }): Promise<DeploymentRecord>;
40
33
  getDeployment(deploymentId: string): Promise<DeploymentRecord>;
41
- /** GET project by name with 404→null soft-skip. */
42
34
  private getProjectByName;
43
35
  }
44
36
  //#endregion
@@ -76,7 +68,7 @@ interface VercelPluginOptions extends ResolveTokenInput {
76
68
  }
77
69
  interface PluginContext {
78
70
  options: VercelPluginOptions;
79
- rest: RestClient;
71
+ client: VercelClient;
80
72
  }
81
73
  declare function createContext(options?: VercelPluginOptions): PluginContext;
82
74
  declare function deployment(ctx: PluginContext): Deployment;
@@ -88,10 +80,8 @@ declare function createPlugin(options?: VercelPluginOptions): {
88
80
  };
89
81
  /**
90
82
  * One-line hint printed by `holocron auth set vercel` when no token
91
- * is supplied or the supplied token is rejected. Points operators at
92
- * https://vercel.com/account/tokens where PATs are minted with
93
- * "Full Account" scope for team-level ops.
83
+ * is supplied or the supplied token is rejected.
94
84
  */
95
85
  declare const AUTH_HINT: string;
96
86
  //#endregion
97
- export { AUTH_HINT, AuthError, PluginContext, type ResolveTokenInput, VercelDeployment, VercelPluginOptions, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, createVercelRestClient, deployment, resolveToken, verifyToken };
87
+ export { AUTH_HINT, AuthError, PluginContext, type ResolveTokenInput, type VercelClient, VercelDeployment, VercelPluginOptions, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, createVercelClient, deployment, resolveToken, verifyToken };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { AuthError, ProviderApiError, createResolveToken, createRestClient } from "@theholocron/cli";
1
+ import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
2
+ import { createVercelClient } from "@theholocron/vercel-client";
2
3
  //#region src/auth.ts
3
4
  const resolveToken = createResolveToken({
4
5
  envName: "HOLOCRON_VERCEL_TOKEN",
@@ -27,83 +28,59 @@ const resolveToken = createResolveToken({
27
28
  * sealed-box / libsodium step on the client.
28
29
  */
29
30
  var VercelDeployment = class {
30
- rest;
31
+ client;
31
32
  key = "deployment";
32
33
  providerName = "vercel";
33
34
  defaultFramework;
34
- constructor(rest, opts = {}) {
35
- this.rest = rest;
35
+ constructor(client, opts = {}) {
36
+ this.client = client;
36
37
  this.defaultFramework = opts.defaultFramework ?? "nextjs";
37
38
  }
38
39
  async listProjects() {
39
- return (await this.rest.request("/v10/projects")).projects.map(mapProject);
40
+ const { projects } = await this.client.projects.list();
41
+ return projects.map(mapProject);
40
42
  }
41
43
  async ensureProject(input) {
42
44
  const existing = await this.getProjectByName(input.name);
43
45
  if (existing) return existing;
44
- const body = {
46
+ return mapProject(await this.client.projects.create({
45
47
  name: input.name,
46
- framework: input.framework ?? this.defaultFramework
47
- };
48
- if (input.repo) body.gitRepository = {
49
- type: "github",
50
- repo: input.repo
51
- };
52
- if (input.rootDirectory) body.rootDirectory = input.rootDirectory;
53
- return mapProject(await this.rest.request("/v11/projects", {
54
- method: "POST",
55
- body
48
+ framework: input.framework ?? this.defaultFramework,
49
+ repo: input.repo,
50
+ rootDirectory: input.rootDirectory
56
51
  }));
57
52
  }
58
53
  async updateProjectSettings(projectId, settings) {
59
- const body = {};
60
- if (settings.previewDeploymentsDisabled !== void 0) body.previewDeploymentsDisabled = settings.previewDeploymentsDisabled;
61
- if (settings.gitProviderCreateDeployments !== void 0) body.gitProviderOptions = { createDeployments: settings.gitProviderCreateDeployments };
62
- return mapProject(await this.rest.request(`/v9/projects/${encodeURIComponent(projectId)}`, {
63
- method: "PATCH",
64
- body
54
+ return mapProject(await this.client.projects.update(projectId, {
55
+ previewDeploymentsDisabled: settings.previewDeploymentsDisabled,
56
+ gitProviderOptions: settings.gitProviderCreateDeployments !== void 0 ? { createDeployments: settings.gitProviderCreateDeployments } : void 0
65
57
  }));
66
58
  }
67
59
  async listEnvVars(projectId, target) {
68
- return (await this.rest.request(`/v9/projects/${encodeURIComponent(projectId)}/env`)).envs.filter((e) => e.target.includes(target)).map((e) => e.key);
60
+ const { envs } = await this.client.env.list(projectId);
61
+ return envs.filter((e) => e.target.includes(target)).map((e) => e.key);
69
62
  }
70
63
  async setEnvVar(projectId, target, name, value) {
71
- await this.rest.request(`/v10/projects/${encodeURIComponent(projectId)}/env`, {
72
- method: "POST",
73
- query: { upsert: "true" },
74
- body: {
75
- key: name,
76
- value,
77
- target: [target],
78
- type: "encrypted"
79
- }
80
- });
64
+ await this.client.env.set(projectId, target, name, value);
81
65
  }
82
66
  async triggerDeployment(input) {
83
- const project = await this.rest.request(`/v10/projects/${encodeURIComponent(input.projectId)}`);
67
+ const project = await this.client.projects.get(input.projectId);
84
68
  const repoId = project.link?.repoId;
85
69
  if (!repoId) throw new ProviderApiError(`Vercel project "${project.name}" has no linked GitHub repo — cannot trigger a deployment. Link the repo first.`, 400, void 0);
86
- return mapDeployment(await this.rest.request("/v13/deployments", {
87
- method: "POST",
88
- body: {
89
- name: project.name,
90
- gitSource: {
91
- type: "github",
92
- ref: input.branch,
93
- repoId
94
- },
95
- ...input.target ? { target: input.target } : {}
96
- }
70
+ return mapDeployment(await this.client.deployments.trigger({
71
+ projectName: project.name,
72
+ branch: input.branch,
73
+ repoId,
74
+ target: input.target
97
75
  }), input.branch);
98
76
  }
99
77
  async getDeployment(deploymentId) {
100
- const raw = await this.rest.request(`/v13/deployments/${encodeURIComponent(deploymentId)}`);
78
+ const raw = await this.client.deployments.get(deploymentId);
101
79
  return mapDeployment(raw, raw.meta?.githubCommitRef ?? null);
102
80
  }
103
- /** GET project by name with 404→null soft-skip. */
104
81
  async getProjectByName(name) {
105
82
  try {
106
- return mapProject(await this.rest.request(`/v10/projects/${encodeURIComponent(name)}`));
83
+ return mapProject(await this.client.projects.get(name));
107
84
  } catch (err) {
108
85
  if (err instanceof ProviderApiError && err.status === 404) return null;
109
86
  throw err;
@@ -141,17 +118,6 @@ function normalizeState(s) {
141
118
  }
142
119
  }
143
120
  //#endregion
144
- //#region src/rest.ts
145
- function createVercelRestClient(opts) {
146
- return createRestClient({
147
- baseUrl: opts.baseUrl ?? "https://api.vercel.com",
148
- token: opts.token,
149
- defaultQuery: opts.teamId ? { teamId: opts.teamId } : void 0,
150
- vendor: "Vercel",
151
- fetch: opts.fetch
152
- });
153
- }
154
- //#endregion
155
121
  //#region src/verify-token.ts
156
122
  /**
157
123
  * `verifyToken` — plugin-level export used by `holocron auth set` +
@@ -159,13 +125,13 @@ function createVercelRestClient(opts) {
159
125
  * response into the normalized `VerifyTokenResult` shape.
160
126
  */
161
127
  async function verifyToken(token, opts = {}) {
162
- const rest = createVercelRestClient({
128
+ const client = createVercelClient({
163
129
  token,
164
130
  baseUrl: opts.baseUrl,
165
131
  fetch: opts.fetch
166
132
  });
167
133
  try {
168
- const res = await rest.request("/v2/user");
134
+ const res = await client.user.get();
169
135
  return {
170
136
  ok: true,
171
137
  subject: `user @ ${res?.user?.email ?? res?.user?.username ?? res?.user?.name ?? res?.user?.id ?? "unknown"}`
@@ -182,7 +148,7 @@ async function verifyToken(token, opts = {}) {
182
148
  function createContext(options = {}) {
183
149
  return {
184
150
  options,
185
- rest: createVercelRestClient({
151
+ client: createVercelClient({
186
152
  token: resolveToken(options),
187
153
  teamId: options.teamId,
188
154
  baseUrl: options.baseUrl,
@@ -193,7 +159,7 @@ function createContext(options = {}) {
193
159
  function deployment(ctx) {
194
160
  const opts = {};
195
161
  if (ctx.options.defaultFramework !== void 0) opts.defaultFramework = ctx.options.defaultFramework;
196
- return new VercelDeployment(ctx.rest, opts);
162
+ return new VercelDeployment(ctx.client, opts);
197
163
  }
198
164
  function createPlugin(options = {}) {
199
165
  const ctx = createContext(options);
@@ -204,10 +170,8 @@ function createPlugin(options = {}) {
204
170
  }
205
171
  /**
206
172
  * One-line hint printed by `holocron auth set vercel` when no token
207
- * is supplied or the supplied token is rejected. Points operators at
208
- * https://vercel.com/account/tokens where PATs are minted with
209
- * "Full Account" scope for team-level ops.
173
+ * is supplied or the supplied token is rejected.
210
174
  */
211
175
  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>";
212
176
  //#endregion
213
- export { AUTH_HINT, AuthError, VercelDeployment, createContext, createPlugin, createVercelRestClient, deployment, resolveToken, verifyToken };
177
+ export { AUTH_HINT, AuthError, VercelDeployment, createContext, createPlugin, createVercelClient, deployment, resolveToken, verifyToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-vercel",
3
- "version": "2.0.0-alpha.51",
3
+ "version": "2.0.0-alpha.53",
4
4
  "description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
5
5
  "homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-vercel#readme",
6
6
  "bugs": "https://github.com/theholocron/holocron/issues",
@@ -21,9 +21,16 @@
21
21
  }
22
22
  },
23
23
  "peerDependencies": {
24
- "@theholocron/cli": "2.0.0-alpha.51"
24
+ "@theholocron/vercel-client": "^0.10.0",
25
+ "@theholocron/cli": "2.0.0-alpha.53"
26
+ },
27
+ "peerDependenciesMeta": {
28
+ "@theholocron/vercel-client": {
29
+ "optional": false
30
+ }
25
31
  },
26
32
  "devDependencies": {
33
+ "@theholocron/vercel-client": "^0.10.0",
27
34
  "@types/node": "^26",
28
35
  "@theholocron/eslint-config": "^7.0.0",
29
36
  "@theholocron/tsconfig": "^7.0.0",
@@ -37,7 +44,7 @@
37
44
  "tsx": "^4.22.4",
38
45
  "typescript": "^5.9.3",
39
46
  "vitest": "^4.1.10",
40
- "@theholocron/cli": "2.0.0-alpha.51"
47
+ "@theholocron/cli": "2.0.0-alpha.53"
41
48
  },
42
49
  "publishConfig": {
43
50
  "access": "public"