Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel sync env vars extension #1425

Merged
merged 8 commits into from
Oct 23, 2024
Merged

Vercel sync env vars extension #1425

merged 8 commits into from
Oct 23, 2024

Conversation

D-K-P
Copy link
Member

@D-K-P D-K-P commented Oct 22, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new extension for syncing environment variables with Vercel, enhancing deployment processes.
    • Added functionality to automate the synchronization of Vercel environment variables during Trigger.dev task deployments.
  • Documentation

    • Expanded module interface to include new export for Vercel environment variable synchronization.
    • Added a new function for synchronizing Vercel environment variables, requiring project ID and access token for operation.

Copy link

changeset-bot bot commented Oct 22, 2024

🦋 Changeset detected

Latest commit: abf51d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/core Patch
@trigger.dev/react-hooks Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@internal/redis-worker Patch
@internal/zod-worker Patch
@internal/testcontainers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

A new extension for synchronizing environment variables with Vercel has been implemented. This extension requires a Vercel project ID and an access token, automating the synchronization process during the deployment of Trigger.dev tasks. Additionally, the core module has been updated to export the new functionality, and a new function, syncVercelEnvVars, has been introduced to handle the synchronization logic, including validation and API interaction.

Changes

File Path Change Summary
.changeset/good-ligers-sit.md Introduced a new extension for syncing Vercel environment variables during deployment.
packages/build/src/extensions/core.ts Added export statement for vercelSyncEnvVars.js to make its functionality accessible.
packages/build/src/extensions/core/vercelSyncEnvVars.ts Created syncVercelEnvVars function to synchronize environment variables with Vercel, including validation and API requests.

Possibly related PRs

Suggested reviewers

  • ericallam
  • matt-aitken

🐇 In the meadow, where bunnies hop,
A new sync feature makes our hearts stop!
With Vercel's vars now in line,
Deployment's a breeze, oh how divine!
Hopping through code, we cheer and play,
Thanks to the changes that brighten our day! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c5e24a2 and abf51d1.

📒 Files selected for processing (1)
  • packages/build/src/extensions/core/vercelSyncEnvVars.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/build/src/extensions/core/vercelSyncEnvVars.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 768036a and 5571b06.

📒 Files selected for processing (1)
  • packages/build/src/extensions/vercelSyncEnvVars.ts (1 hunks)
🧰 Additional context used

Copy link

pkg-pr-new bot commented Oct 22, 2024

@trigger.dev/build

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1425

@trigger.dev/core

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1425

@trigger.dev/react-hooks

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/react-hooks@1425

trigger.dev

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev@1425

@trigger.dev/sdk

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1425

commit: abf51d1

matt-aitken and others added 2 commits October 22, 2024 17:23
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/build/src/extensions/vercelSyncEnvVars.ts (1)

14-24: Simplify and enhance error messages for clarity

Consider refining the error messages to be more concise and user-friendly. This improves readability and assists users in quickly understanding the issue.

Apply this diff to adjust the error messages:

-        "vercelSyncEnvVars: you did not pass in a projectId or set the VERCEL_PROJECT_ID env var.",
+        "Missing 'projectId'. Provide it via options or set the 'VERCEL_PROJECT_ID' environment variable.",

Similarly, adjust the vercelAccessToken error message:

-        "vercelSyncEnvVars: you did not pass in a vercelAccessToken or set the VERCEL_ACCESS_TOKEN env var.",
+        "Missing 'vercelAccessToken'. Provide it via options or set the 'VERCEL_ACCESS_TOKEN' environment variable.",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5571b06 and 772d7d0.

📒 Files selected for processing (2)
  • .changeset/good-ligers-sit.md (1 hunks)
  • packages/build/src/extensions/vercelSyncEnvVars.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/good-ligers-sit.md

[uncategorized] ~5-~5: Possible missing comma found.
Context: ...on. Given a Vercel projectId and access token it will sync Vercel env vars when deplo...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (7)
.changeset/good-ligers-sit.md (1)

1-5: LGTM! Minor grammatical suggestion and request for additional information.

The changeset file correctly documents the patch update for the "@trigger.dev/build" package. However, there's a minor grammatical issue in the description, and it could benefit from more details.

Consider adding a comma after "access token" in the description:

-Added a Vercel sync env vars extension. Given a Vercel projectId and access token it will sync Vercel env vars when deploying Trigger.dev tasks.
+Added a Vercel sync env vars extension. Given a Vercel projectId and access token, it will sync Vercel env vars when deploying Trigger.dev tasks.

Could you provide more information on how users can utilize this new extension? For example:

  • Are there any configuration steps required?
  • How does one specify the Vercel projectId and access token?
  • Are there any limitations or considerations users should be aware of?

Adding this information would make the changeset more informative for users and maintainers.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: Possible missing comma found.
Context: ...on. Given a Vercel projectId and access token it will sync Vercel env vars when deplo...

(AI_HYDRA_LEO_MISSING_COMMA)

packages/build/src/extensions/vercelSyncEnvVars.ts (6)

4-6: Function syncVercelEnvVars is well-defined

The syncVercelEnvVars function is correctly defined, exporting a BuildExtension and accepting optional parameters for flexibility.


8-12: Environment variables resolution order is appropriate

The code appropriately prioritizes options, then process.env, and finally ctx.env when retrieving projectId and vercelAccessToken.


35-39: Proper validation of vercelEnvironment

Excellent use of error handling to ensure vercelEnvironment is valid, enhancing robustness.


58-61: [Duplicate Comment] Extract inline types into interfaces for better maintainability

The inline type annotations in the filter function can reduce readability. Consider defining interfaces or type aliases for the environment variable objects.


69-73: [Duplicate Comment] Avoid logging potentially sensitive error information

Logging the entire error object may expose sensitive information. Consider logging only the error message to prevent leaking stack traces or other details.


77-82: Extension structure is correctly implemented

The returned object properly defines the extension name and the onBuildComplete method, ensuring integration with the build process.

D-K-P added 3 commits October 23, 2024 09:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
packages/build/src/extensions/core.ts (1)

6-6: Consider maintaining alphabetical order of exports.

For better maintainability, consider moving the new export statement to maintain alphabetical ordering with other exports.

 export * from "./core/additionalFiles.js";
 export * from "./core/additionalPackages.js";
-export * from "./core/syncEnvVars.js";
 export * from "./core/aptGet.js";
 export * from "./core/ffmpeg.js";
+export * from "./core/syncEnvVars.js";
 export * from "./core/vercelSyncEnvVars.js";
packages/build/src/extensions/core/vercelSyncEnvVars.ts (1)

69-74: Consider using a dedicated logging utility instead of console.error

For better log management and consistency across the application, consider using a logging framework or the existing logging infrastructure instead of console.error.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 772d7d0 and c5e24a2.

📒 Files selected for processing (2)
  • packages/build/src/extensions/core.ts (1 hunks)
  • packages/build/src/extensions/core/vercelSyncEnvVars.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/build/src/extensions/core.ts (1)

6-6: LGTM! Export statement follows established patterns.

The new export statement correctly follows the module's established patterns for exposing core functionality.

@matt-aitken matt-aitken merged commit 982906c into main Oct 23, 2024
9 checks passed
@matt-aitken matt-aitken deleted the vercel-sync-env-vars branch October 23, 2024 12:01
This was referenced Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants