Skip to content

Give helpful hint if you pass a bad directory when deploying #2013

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 1 commit into from
May 2, 2025

Conversation

matt-aitken
Copy link
Member

@matt-aitken matt-aitken commented May 1, 2025

Closes #1990

If you pass in a directory that isn't found, we tell you it doesn't exist and where we looked.

If you pass in prod staging stg or production we tell you how you should be running the command: --env prod or --env staging. Please note you don't need to pass prod it's the default.

Copy link

changeset-bot bot commented May 1, 2025

🦋 Changeset detected

Latest commit: d3c10af

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

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 May 1, 2025

Walkthrough

A patch update was made to the deployment command in the CLI, introducing validation for the directory argument. When the deploy command is invoked with a directory, the code now checks if the specified directory exists and is indeed a directory. If common mistaken directory names are used (such as "staging" or "prod"), the user is advised to use the --env flag instead. For any other invalid directory, a clear error message is shown. No changes were made to exported or public entities.

Changes

File(s) Change Summary
.changeset/wet-steaks-reflect.md Added a changeset describing the new validation logic for deploy directory arguments.
packages/cli-v3/src/commands/deploy.ts Added directory existence/type validation to the deploy command; specific errors for common mistakes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant FileSystem

    User->>CLI: Run deploy command with directory argument
    CLI->>FileSystem: Check if directory exists and is a directory
    alt Directory does not exist or is not a directory
        alt Argument is "staging", "prod", etc.
            CLI-->>User: Show error - use --env flag
        else Argument is another invalid directory
            CLI-->>User: Show error - directory not found at path
        end
    else Directory is valid
        CLI->>User: Proceed with deployment
    end
Loading

Suggested reviewers

  • ericallam

Poem

A bunny hopped to deploy with glee,
But checked the path most carefully—
"Is it a folder? Is it real?
Or just a typo in your zeal?"
Now errors guide with gentle cheer,
So every launch is crystal clear! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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: 0

🧹 Nitpick comments (1)
.changeset/wet-steaks-reflect.md (1)

1-6: Add a comma in the changeset description for better readability.

The description would be more readable with a comma after "deploy".

-If you pass a directory when calling deploy we validate it exists and give helpful hints
+If you pass a directory when calling deploy, we validate it exists and give helpful hints
🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: Possible missing comma found.
Context: ...- If you pass a directory when calling deploy we validate it exists and give helpful ...

(AI_HYDRA_LEO_MISSING_COMMA)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2448242 and d3c10af.

📒 Files selected for processing (2)
  • .changeset/wet-steaks-reflect.md (1 hunks)
  • packages/cli-v3/src/commands/deploy.ts (2 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/wet-steaks-reflect.md

[uncategorized] ~5-~5: Possible missing comma found.
Context: ...- If you pass a directory when calling deploy we validate it exists and give helpful ...

(AI_HYDRA_LEO_MISSING_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/cli-v3/src/commands/deploy.ts (3)

37-37: Good addition of isDirectory import.

The import of isDirectory is used appropriately for the new validation functionality.


172-174: Good setup for path resolution.

Properly resolving project paths relative to the current working directory is essential for correct directory validation.


175-189: Excellent user experience improvement with clear error messages.

The implementation provides helpful, specific guidance when users make common mistakes with environment deployment. The error messages clearly explain what the user should do instead, which greatly improves the user experience.

  • For common environment names like "staging" and "prod", users are guided to use the --env flag
  • Special cases like "production" → "prod" and "stg" → "staging" are handled with specific instructions
  • For any other invalid directory, a clear error message shows the resolved path that was checked

This validation prevents confusing deployment errors that would occur later in the process.

@matt-aitken matt-aitken merged commit 4232096 into main May 2, 2025
12 checks passed
@matt-aitken matt-aitken deleted the deploy-directory-fix branch May 2, 2025 09:54
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.

[TRI-5258] CLI: Throw an error if the trigger.config file isn't found
2 participants