From 2dde2cbe1c8b831ec1b57c61902b34095a4f81c1 Mon Sep 17 00:00:00 2001 From: Nico Date: Fri, 8 Nov 2024 14:21:53 -0500 Subject: [PATCH 1/6] Update vercelSyncEnvVars.ts --- packages/build/src/extensions/core/vercelSyncEnvVars.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/build/src/extensions/core/vercelSyncEnvVars.ts b/packages/build/src/extensions/core/vercelSyncEnvVars.ts index c6c6f3b11b..fe638d5cf2 100644 --- a/packages/build/src/extensions/core/vercelSyncEnvVars.ts +++ b/packages/build/src/extensions/core/vercelSyncEnvVars.ts @@ -2,7 +2,7 @@ import { BuildExtension } from "@trigger.dev/core/v3/build"; import { syncEnvVars } from "../core.js"; export function syncVercelEnvVars( - options?: { projectId?: string; vercelAccessToken?: string }, + options?: { projectId?: string; vercelAccessToken?: string; vercelTeamId?: string }, ): BuildExtension { const sync = syncEnvVars(async (ctx) => { const projectId = options?.projectId ?? process.env.VERCEL_PROJECT_ID ?? @@ -10,6 +10,8 @@ export function syncVercelEnvVars( const vercelAccessToken = options?.vercelAccessToken ?? process.env.VERCEL_ACCESS_TOKEN ?? ctx.env.VERCEL_ACCESS_TOKEN; + const vercelTeamId = options?.vercelTeamId ?? process.env.VERCEL_TEAM_ID ?? + ctx.env.VERCEL_TEAM_ID; if (!projectId) { throw new Error( @@ -37,8 +39,9 @@ export function syncVercelEnvVars( `Invalid environment '${ctx.environment}'. Expected 'prod', 'staging', or 'dev'.`, ); } - const vercelApiUrl = - `https://api.vercel.com/v8/projects/${projectId}/env?decrypt=true`; + const params = new URLSearchParams(); + if (vercelTeamId) params.set("teamId", vercelTeamId); + const vercelApiUrl = `https://api.vercel.com/v8/projects/${projectId}/env?${params}`; try { const response = await fetch(vercelApiUrl, { From af77717d912a367233af99e55c46437676b01398 Mon Sep 17 00:00:00 2001 From: Nico Date: Fri, 8 Nov 2024 14:24:18 -0500 Subject: [PATCH 2/6] Update vercelSyncEnvVars.ts --- packages/build/src/extensions/core/vercelSyncEnvVars.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/build/src/extensions/core/vercelSyncEnvVars.ts b/packages/build/src/extensions/core/vercelSyncEnvVars.ts index fe638d5cf2..552e6e5622 100644 --- a/packages/build/src/extensions/core/vercelSyncEnvVars.ts +++ b/packages/build/src/extensions/core/vercelSyncEnvVars.ts @@ -41,7 +41,7 @@ export function syncVercelEnvVars( } const params = new URLSearchParams(); if (vercelTeamId) params.set("teamId", vercelTeamId); - const vercelApiUrl = `https://api.vercel.com/v8/projects/${projectId}/env?${params}`; + const vercelApiUrl = `https://api.vercel.com/v9/projects/${projectId}/env?${params}`; try { const response = await fetch(vercelApiUrl, { From 393ace849e534f33c088a08f11535e8cb029c5dc Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 9 Nov 2024 18:17:10 -0500 Subject: [PATCH 3/6] Update vercelSyncEnvVars.ts --- packages/build/src/extensions/core/vercelSyncEnvVars.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/build/src/extensions/core/vercelSyncEnvVars.ts b/packages/build/src/extensions/core/vercelSyncEnvVars.ts index 552e6e5622..ced2391a35 100644 --- a/packages/build/src/extensions/core/vercelSyncEnvVars.ts +++ b/packages/build/src/extensions/core/vercelSyncEnvVars.ts @@ -39,9 +39,9 @@ export function syncVercelEnvVars( `Invalid environment '${ctx.environment}'. Expected 'prod', 'staging', or 'dev'.`, ); } - const params = new URLSearchParams(); + const params = new URLSearchParams({ decrypt: "true" }); if (vercelTeamId) params.set("teamId", vercelTeamId); - const vercelApiUrl = `https://api.vercel.com/v9/projects/${projectId}/env?${params}`; + const vercelApiUrl = `https://api.vercel.com/v8/projects/${projectId}/env?${params}`; try { const response = await fetch(vercelApiUrl, { From b54fd1effcb750769518791983c1fb335a098619 Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 9 Nov 2024 18:24:14 -0500 Subject: [PATCH 4/6] Update vercelSyncEnvVars.ts --- packages/build/src/extensions/core/vercelSyncEnvVars.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/build/src/extensions/core/vercelSyncEnvVars.ts b/packages/build/src/extensions/core/vercelSyncEnvVars.ts index ced2391a35..16aeba4c47 100644 --- a/packages/build/src/extensions/core/vercelSyncEnvVars.ts +++ b/packages/build/src/extensions/core/vercelSyncEnvVars.ts @@ -1,7 +1,7 @@ import { BuildExtension } from "@trigger.dev/core/v3/build"; import { syncEnvVars } from "../core.js"; -export function syncVercelEnvVars( +export function vercelSyncEnvVars( options?: { projectId?: string; vercelAccessToken?: string; vercelTeamId?: string }, ): BuildExtension { const sync = syncEnvVars(async (ctx) => { From a3701db06193be590e4241a76b422e99489407fc Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 9 Nov 2024 18:40:08 -0500 Subject: [PATCH 5/6] Update docs --- docs/config/config-file.mdx | 8 ++++---- docs/guides/examples/vercel-sync-env-vars.mdx | 3 ++- docs/guides/frameworks/nextjs.mdx | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/config/config-file.mdx b/docs/config/config-file.mdx index dfc95fcb1c..b225834380 100644 --- a/docs/config/config-file.mdx +++ b/docs/config/config-file.mdx @@ -511,10 +511,10 @@ The `vercelSyncEnvVars` build extension syncs environment variables from your Ve You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables, or pass - in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. You can find - / generate the `VERCEL_ACCESS_TOKEN` in your Vercel - [dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers - the project you want to sync. + in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. If you're + working with a team project, you'll also need to set `VERCEL_TEAM_ID`. You can find / generate + the `VERCEL_ACCESS_TOKEN` in your Vercel [dashboard](https://vercel.com/account/settings/tokens). + Make sure the scope of the token covers the project you want to sync. ```ts diff --git a/docs/guides/examples/vercel-sync-env-vars.mdx b/docs/guides/examples/vercel-sync-env-vars.mdx index 9cd8cccef6..55aedd7c5c 100644 --- a/docs/guides/examples/vercel-sync-env-vars.mdx +++ b/docs/guides/examples/vercel-sync-env-vars.mdx @@ -13,7 +13,8 @@ To sync environment variables, you just need to add our build extension to your You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables in the Trigger.dev dashboard, or pass in the token and project ID as arguments to the `vercelSyncEnvVars` - build extension. You can find / generate the `VERCEL_ACCESS_TOKEN` in your Vercel + build extension. If you're working with a team project, you'll also need to set `VERCEL_TEAM_ID`. + You can find / generate the `VERCEL_ACCESS_TOKEN` in your Vercel [dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers the project with the environment variables you want to sync. diff --git a/docs/guides/frameworks/nextjs.mdx b/docs/guides/frameworks/nextjs.mdx index 8cd8ac1583..f6ec3c3ff9 100644 --- a/docs/guides/frameworks/nextjs.mdx +++ b/docs/guides/frameworks/nextjs.mdx @@ -251,10 +251,10 @@ If you want to automatically sync environment variables from your Vercel project You need to set the `VERCEL_ACCESS_TOKEN` and `VERCEL_PROJECT_ID` environment variables, or pass - in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. You can find - / generate the `VERCEL_ACCESS_TOKEN` in your Vercel - [dashboard](https://vercel.com/account/settings/tokens). Make sure the scope of the token covers - the project you want to sync. + in the token and project ID as arguments to the `vercelSyncEnvVars` build extension. If you're + working with a team project, you'll also need to set `VERCEL_TEAM_ID`. You can find / generate + the `VERCEL_ACCESS_TOKEN` in your Vercel [dashboard](https://vercel.com/account/settings/tokens). + Make sure the scope of the token covers the project you want to sync. ```ts trigger.config.ts From 2b2ed57c079baf8851fc76b7fc1e3aacc2e2cd5a Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 9 Nov 2024 18:56:08 -0500 Subject: [PATCH 6/6] Add changeset --- .changeset/rotten-dolphins-punch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/rotten-dolphins-punch.md diff --git a/.changeset/rotten-dolphins-punch.md b/.changeset/rotten-dolphins-punch.md new file mode 100644 index 0000000000..6cd2cf2b42 --- /dev/null +++ b/.changeset/rotten-dolphins-punch.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/build": minor +--- + +Add teamId option to vercelSyncEnvVars