@theholocron/holocron-plugin-vercel 5.0.0-alpha.509 → 5.0.0-alpha.510
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 +5 -1
- package/dist/index.mjs +53 -0
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the `deployment` capability against Vercel's REST API.
|
|
5
5
|
* See README for auth + config docs.
|
|
6
6
|
*/
|
|
7
|
-
import { AuthError, DeployFunctionConfig, DeployFunctionResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, DnsRecordRequest, PluginToken, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
7
|
+
import { AuthError, DeployFunctionConfig, DeployFunctionResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, DnsRecordRequest, EnsureRelaySourceInput, EnsureRelaySourceResult, InspectRelaySourceInput, PluginToken, RelaySourceState, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
8
8
|
import { VercelClient, VercelClient as VercelClient$1, VercelClientOptions, createVercelClient } from "@theholocron/vercel-client";
|
|
9
9
|
/** Resolves the Vercel token from `--token`, `HOLOCRON_VERCEL_TOKEN`, `VERCEL_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
|
|
10
10
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
@@ -36,6 +36,10 @@ export declare class VercelDeployment implements Deployment {
|
|
|
36
36
|
}): Promise<DeploymentProject>;
|
|
37
37
|
/** Updates a project's preview-deployment and Git-provider deployment settings and returns the updated project. */
|
|
38
38
|
updateProjectSettings(projectId: string, settings: DeploymentProjectSettings): Promise<DeploymentProject>;
|
|
39
|
+
/** Makes (or adopts) the team webhook for a Comlink relay source, found by its URL; returns the secret only when made now. */
|
|
40
|
+
ensureRelaySource(input: EnsureRelaySourceInput): Promise<EnsureRelaySourceResult>;
|
|
41
|
+
/** Reads the relay source's webhook back without changing it. */
|
|
42
|
+
inspectRelaySource(input: InspectRelaySourceInput): Promise<RelaySourceState>;
|
|
39
43
|
/** Lists the names of the project's environment variables that apply to `target`. */
|
|
40
44
|
listEnvVars(projectId: string, target: DeploymentTarget): Promise<string[]>;
|
|
41
45
|
/** Creates or updates (upsert) an environment variable on the project for `target`. */
|
package/dist/index.mjs
CHANGED
|
@@ -26,6 +26,51 @@ const tokens = [{
|
|
|
26
26
|
...resolveToken.token,
|
|
27
27
|
expect: EXPECTED
|
|
28
28
|
}];
|
|
29
|
+
// src/capabilities/relay-source.ts
|
|
30
|
+
async function findByUrl(client, url) {
|
|
31
|
+
return (await client.webhooks.list()).find((w) => w.url === url);
|
|
32
|
+
}
|
|
33
|
+
/** Make the webhook for `input.url`, or adopt the one already there. Returns the secret only when it was made now. */
|
|
34
|
+
async function ensureVercelRelaySource(client, input) {
|
|
35
|
+
if (await findByUrl(client, input.url)) return {
|
|
36
|
+
created: false,
|
|
37
|
+
updated: []
|
|
38
|
+
};
|
|
39
|
+
if (!input.events || input.events.length === 0) return {
|
|
40
|
+
created: false,
|
|
41
|
+
updated: [],
|
|
42
|
+
todo: [`Vercel needs at least one event to make a webhook: set \`events\` on relay.sources.${input.source}.`]
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
const made = await client.webhooks.create({
|
|
46
|
+
url: input.url,
|
|
47
|
+
events: input.events,
|
|
48
|
+
...input.scope && input.scope.length > 0 ? { projectIds: input.scope } : {}
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
created: true,
|
|
52
|
+
updated: [],
|
|
53
|
+
...made.secret ? { secret: made.secret } : {}
|
|
54
|
+
};
|
|
55
|
+
} catch (err) {
|
|
56
|
+
if (err instanceof ProviderApiError && (err.status === 402 || err.status === 403)) return {
|
|
57
|
+
created: false,
|
|
58
|
+
updated: [],
|
|
59
|
+
todo: [`Vercel refused to make the webhook (HTTP ${err.status}): account webhooks need a Pro or Enterprise team and a token for that team. Make it in Team Settings, Webhooks, for ${input.url}.`]
|
|
60
|
+
};
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Read the webhook for `input.url` back. Vercel's list carries no secret, so `hasSecret` is left out. */
|
|
65
|
+
async function inspectVercelRelaySource(client, input) {
|
|
66
|
+
const found = await findByUrl(client, input.url);
|
|
67
|
+
if (!found) return { exists: false };
|
|
68
|
+
return {
|
|
69
|
+
exists: true,
|
|
70
|
+
events: found.events,
|
|
71
|
+
scope: found.projectIds ?? []
|
|
72
|
+
};
|
|
73
|
+
}
|
|
29
74
|
// src/capabilities/deployment.ts
|
|
30
75
|
/** The `meta` key a file deploy tags a preview with: the pull request it belongs to, as `<repo>-pr-<number>`. */
|
|
31
76
|
const PREVIEW_META_KEY = "holocronPreview";
|
|
@@ -67,6 +112,14 @@ var VercelDeployment = class {
|
|
|
67
112
|
gitProviderOptions: settings.gitProviderCreateDeployments !== void 0 ? { createDeployments: settings.gitProviderCreateDeployments } : void 0
|
|
68
113
|
}));
|
|
69
114
|
}
|
|
115
|
+
/** Makes (or adopts) the team webhook for a Comlink relay source, found by its URL; returns the secret only when made now. */
|
|
116
|
+
ensureRelaySource(input) {
|
|
117
|
+
return ensureVercelRelaySource(this.client(), input);
|
|
118
|
+
}
|
|
119
|
+
/** Reads the relay source's webhook back without changing it. */
|
|
120
|
+
inspectRelaySource(input) {
|
|
121
|
+
return inspectVercelRelaySource(this.client(), input);
|
|
122
|
+
}
|
|
70
123
|
/** Lists the names of the project's environment variables that apply to `target`. */
|
|
71
124
|
async listEnvVars(projectId, target) {
|
|
72
125
|
const { envs } = await this.client().env.list(projectId);
|
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.510",
|
|
4
4
|
"description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deployment",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"tsx": "4.23.15",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"vitest": "^5.1.0",
|
|
43
|
-
"@theholocron/cli": "5.0.0-alpha.509",
|
|
44
|
-
"@theholocron/http-client": "^1.58.0-alpha.47",
|
|
45
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.21",
|
|
46
43
|
"@theholocron/eslint-config": "^8.9.0-alpha.21",
|
|
47
|
-
"@theholocron/
|
|
44
|
+
"@theholocron/cli": "5.0.0-alpha.510",
|
|
45
|
+
"@theholocron/http-client": "^1.58.0-alpha.48",
|
|
48
46
|
"@theholocron/misc-utils": "^1.17.0-alpha.5",
|
|
49
|
-
"@theholocron/
|
|
47
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.21",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.21",
|
|
49
|
+
"@theholocron/vercel-client": "^1.58.0-alpha.48",
|
|
50
50
|
"@theholocron/vitest-config": "^8.9.0-alpha.21"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@theholocron/misc-utils": "^1.16.0",
|
|
54
54
|
"@theholocron/vercel-client": "^1.43.1",
|
|
55
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.510"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@theholocron/vercel-client": {}
|