Skip to content

Improve the update CLI command and fix missing tsconfig.json error #1315

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

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

ericallam
Copy link
Member

@ericallam ericallam commented Sep 18, 2024

  • Improve and fix the update command, it now no longer shows "mismatch" errors when using in non-embedded mode.
  • Make the "login" output silent during the dev CLI
  • Fix the "Missing tsconfig.json" error

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for missing configuration files to improve development workflow.
    • Updated trigger.dev CLI tool for better reliability and user experience, including a silent mode for commands.
    • Added flexibility to the whoami command and login process with optional silent operation.
    • Introduced a new property for specifying TypeScript configuration file paths.
    • Improved handling of environment variables during synchronization to prevent deployment errors.
  • Bug Fixes

    • Improved the update process for trigger packages with clearer messaging and error handling.

Copy link

changeset-bot bot commented Sep 18, 2024

🦋 Changeset detected

Latest commit: fcf34c9

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

This PR includes changesets to release 4 packages
Name Type
trigger.dev Patch
@trigger.dev/core Patch
@trigger.dev/build Patch
@trigger.dev/sdk 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 Sep 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduced in this pull request focus on improving the development experience by enhancing error handling, modifying command behaviors, and adding new configuration options. Key updates include a mechanism to gracefully handle missing tsconfig.json files, enhancements to the trigger.dev CLI tool commands, and the addition of a silent parameter to various functions to control output verbosity. These modifications aim to streamline workflows and improve the robustness of the system.

Changes

Files Change Summary
.changeset/clever-buses-watch.md Introduced a fix for handling missing tsconfig.json files during development and deployment processes.
.changeset/soft-ladybugs-promise.md Implemented fixes for the trigger.dev CLI tool, enhancing the update command and modifying the "whoami" command output in development environments.
.changeset/twelve-onions-decide.md Added a patch for @trigger.dev/build to strip TRIGGER_ keys during environment variable synchronization to prevent deployment errors.
packages/build/src/extensions/core/syncEnvVars.ts Introduced UNSYNCABLE_ENV_VARS_PREFIXES constant to exclude environment variables starting with TRIGGER_ from synchronization.
packages/cli-v3/src/commands/dev.ts Added silent: true option to the login function call in devCommand, suppressing output during login.
packages/cli-v3/src/commands/login.ts Introduced optional silent property in LoginOptions type to control logging behavior during login.
packages/cli-v3/src/commands/update.ts Enhanced update process logic, refined output messages, and modified error handling based on the embedded state.
packages/cli-v3/src/commands/whoami.ts Added silent parameter to whoAmI function to control loading spinner messages.
packages/cli-v3/src/config.ts Introduced safeResolveTsConfig function to handle errors during TypeScript configuration resolution gracefully.
packages/core/src/v3/build/resolvedConfig.ts Added optional tsconfigPath property to ResolvedConfig type for enhanced configurability regarding TypeScript settings.

Possibly related PRs

Suggested reviewers

  • No suggested reviewers provided.

Poem

🐇 In the meadow where bunnies play,
New changes hop in, brightening the day.
With silent whispers and configs so neat,
Development flows, a rhythm, a beat.
Errors now handled, no more dismay,
Hooray for the changes, hip-hip-hooray! 🌼


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 generate interesting stats about this repository and render them as a table.
    -- @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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 74c2076 and bb8b34b.

Files selected for processing (9)
  • .changeset/clever-buses-watch.md (1 hunks)
  • .changeset/soft-ladybugs-promise.md (1 hunks)
  • packages/cli-v3/src/commands/dev.ts (1 hunks)
  • packages/cli-v3/src/commands/login.ts (2 hunks)
  • packages/cli-v3/src/commands/update.ts (5 hunks)
  • packages/cli-v3/src/commands/whoami.ts (2 hunks)
  • packages/cli-v3/src/config.ts (3 hunks)
  • packages/cli-v3/src/utilities/sourceFiles.ts (1 hunks)
  • packages/core/src/v3/build/resolvedConfig.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/cli-v3/src/utilities/sourceFiles.ts
Additional comments not posted (14)
.changeset/soft-ladybugs-promise.md (1)

1-5: Changeset looks good!

The changeset clearly describes the purpose and impact of the changes made to the trigger.dev CLI tool. The fixes for the update command and the modification to hide the "whoami" command output in dev mode seem to be focused on improving the user experience and streamlining the development workflow.

.changeset/clever-buses-watch.md (1)

1-6: LGTM!

The changeset file looks good. The metadata and description align with the PR objectives and the AI-generated summary.

packages/core/src/v3/build/resolvedConfig.ts (1)

27-27: LGTM!

The addition of the optional tsconfigPath property to the ResolvedConfig type is a valid enhancement. It allows specifying a path to a TypeScript configuration file, which can be useful for projects that utilize TypeScript in their build processes. The change expands the configurability of the ResolvedConfig type without breaking existing code.

packages/cli-v3/src/commands/whoami.ts (1)

54-55: LGTM!

The addition of the silent parameter and the corresponding conditional checks for controlling the loading spinner messages are implemented correctly. This change enhances the flexibility of the whoAmI function by allowing it to operate in a silent mode when needed, without introducing any apparent issues.

Also applies to: 63-65, 71-71, 74-79, 118-118

packages/cli-v3/src/commands/dev.ts (1)

54-54: LGTM! The silent parameter provides flexibility in controlling login output verbosity.

The addition of the silent: true parameter to the login function call allows for suppressing the output typically displayed during the login operation. This can be beneficial in scenarios where a quieter execution is desired, such as in automated scripts or background processes.

However, please ensure that critical error messages or important login-related information is still communicated to the user when necessary, even in silent mode. This will help maintain a balance between verbosity control and providing essential feedback to the user.

packages/cli-v3/src/config.ts (2)

141-141: LGTM!

The change to use the new safeResolveTsConfig function instead of resolveTSConfig is a good improvement. It will handle potential errors more gracefully during the resolution of the TypeScript configuration file.


191-197: Great addition of the safeResolveTsConfig function!

The safeResolveTsConfig function is a nice addition to handle potential errors gracefully when resolving the TypeScript configuration file. Wrapping the resolveTSConfig function in a try-catch block and returning undefined if an error occurs is a good approach to improve the robustness of the configuration resolution process.

This change aligns with the AI-generated summary and enhances the overall error handling in the codebase.

packages/cli-v3/src/commands/login.ts (3)

62-62: LGTM!

The new optional silent property is correctly added to the LoginOptions type to control the verbosity of the login command. Making it optional ensures backward compatibility.


68-73: Looks good!

The opts object is correctly defined with default values, including silent set to false. Spreading the options object allows the caller to override these defaults. This ensures that the login command remains verbose by default unless explicitly silenced.


120-121: Verify the whoAmI function.

Please ensure that:

  1. The whoAmI function signature is updated to accept the new silent argument.
  2. The whoAmI function implementation handles the silent argument correctly to control its verbosity.

Run the following script to verify the whoAmI function:

packages/cli-v3/src/commands/update.ts (4)

130-130: LGTM!

The change from "Nothing to do" to "Nothing to update" improves clarity and aligns with the action being performed.


Line range hint 136-209: LGTM!

The updated error handling and user confirmation logic based on the embedded flag enhances the user experience by providing appropriate messages and actions in different scenarios.


46-46: Verify the impact of passing false for the embedded flag.

The change looks good, but please ensure that explicitly passing false as the embedded flag to updateTriggerPackages aligns with the expected behavior and doesn't introduce any unintended side effects.

Run the following script to analyze the usage of the embedded flag in updateTriggerPackages:

Verification successful

To continue our verification process, let's search for the implementation of updateTriggerPackages and analyze how it uses the embedded parameter.


To complete our verification, we need to examine how the embedded parameter is used within the updateTriggerPackages function. Let's search for its usage.


The change is safe and doesn't impact the behavior of updateTriggerPackages.

After thorough investigation, we can confirm that explicitly passing false for the embedded flag in updateCommand does not affect the execution of updateTriggerPackages. The embedded parameter is not used within the function body, suggesting it might be a remnant from previous versions or reserved for future use.

Consider removing the embedded parameter from the updateTriggerPackages function signature if it's not used elsewhere in the codebase, as this would improve code clarity.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Analyze the usage of the `embedded` flag in `updateTriggerPackages`.

# Test: Search for conditional logic based on the `embedded` flag. Expect: Relevant code snippets.
rg --type typescript -A 5 $'if \(embedded\)' $(fd -e ts -E node_modules -E dist -E build -E coverage -E .git)

Length of output: 42758


Script:

#!/bin/bash
# Search for the implementation of updateTriggerPackages
rg -A 10 -B 5 "function updateTriggerPackages" packages/cli-v3/src/

Length of output: 1163


Script:

#!/bin/bash
# Search for the usage of 'embedded' within updateTriggerPackages
rg -A 10 -B 10 "function updateTriggerPackages" packages/cli-v3/src/commands/update.ts | rg "embedded"

Length of output: 124


Line range hint 220-259: Verify the impact of silent package installation.

The changes to the spinner messages improve clarity and provide more context to the user. However, please ensure that running the package installation silently at line 254 doesn't hide any important information or errors that the user should be aware of.

Run the following script to analyze the impact of silent package installation:

Verification successful

Silent installation is handled with appropriate error messaging.

The installDependencies function is called with silent: true, but it's wrapped in a try-catch block. If an error occurs during installation, a failure message is displayed to the user. Additionally, there's an exitHandler mechanism that seems to handle cleanup or warnings about manual rollbacks.

While the silent installation might hide some information during the process, the error handling ensures that users are informed if something goes wrong. The implementation strikes a balance between a clean user experience and necessary error reporting.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Analyze the impact of silent package installation.

# Test: Search for error handling logic related to package installation. Expect: Relevant code snippets.
rg --type typescript -A 10 $'installDependencies\(' $(fd -e ts -E node_modules -E dist -E build -E coverage -E .git)

Length of output: 42765


Script:

#!/bin/bash
# Search for installDependencies function and its usage
rg -i "function\s+installDependencies|installDependencies\s*\(" packages/cli-v3/src

# Search for error handling related to package installation
rg -i "catch.*install|error.*install" packages/cli-v3/src

Length of output: 506


Script:

#!/bin/bash
# Check the implementation of installDependencies
rg -A 10 "function\s+installDependencies" packages/cli-v3/src

# Check usage of parseNpmInstallError
rg "parseNpmInstallError" packages/cli-v3/src

# Check error handling around installDependencies in update.ts
rg -A 10 -B 5 "installDependencies" packages/cli-v3/src/commands/update.ts

Length of output: 1588

@@ -179,7 +179,7 @@ async function resolveConfig(
conditions: [],
},
}
);
) as ResolvedConfig; // TODO: For some reason, without this, there is a weird type error complaining about tsconfigPath being string | nullish, which can't be assigned to string | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Investigate the root cause of the type error instead of using a type assertion.

The type assertion is used to suppress a type error related to the tsconfigPath property. However, it's better to investigate and fix the root cause of the type mismatch instead of relying on a type assertion.

Please consider the following:

  • Analyze why tsconfigPath is being treated as string | nullish instead of string | undefined.
  • Ensure that the type definitions for tsconfigPath are consistent throughout the codebase.
  • Consider updating the type definitions or the logic that assigns the value to tsconfigPath to resolve the type mismatch.

Using a type assertion may hide potential issues and make the code less maintainable in the long run.

Copy link

pkg-pr-new bot commented Sep 18, 2024

pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1315
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1315
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev@1315
pnpm add https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1315

commit: fcf34c9

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.

1 participant