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

chore: Add .direnv file for automatic Node.js version switching with fnm #3009

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

Amosel
Copy link
Contributor

@Amosel Amosel commented Mar 29, 2024

What is the purpose of the change

Added .direnv config, to support that allows fnm to automatically switch Node.js version.

ClickUp Task

ClickUp Task URL

Brief Changelog

Testing and Verifying

Documentation and Release Note

Summary by CodeRabbit

  • Chores
    • Enhanced Node.js version management to automatically align with the version specified in package.json.

Copy link
Contributor

coderabbitai bot commented Mar 29, 2024

Walkthrough

The update introduces the use_node() function in the .envrc file, which dynamically sets the Node.js version for the project environment based on the version specified in the package.json file, using fnm.

Changes

Files Change Summary
.envrc, .nvmrc Added use_node() function to set Node.js version to v20.11.1 using fnm based on package.json

🐰✨
In the realm of code, under the digital sky,
A rabbit hopped, with a twinkle in its eye.
"Let's sync our Node, with a magical spell,"
It said, as fnm rang like a bell.
Now versions align, with a whisper of JSON,
In this digital burrow, where innovation is born.
🌟🐾

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>.
    • 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 show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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/coderabbit-overrides.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

vercel bot commented Mar 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 11:20pm
osmosis-frontend-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 11:20pm
osmosis-frontend-edgenet ❌ Failed (Inspect) Apr 2, 2024 11:20pm
osmosis-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 11:20pm

.envrc Outdated
@@ -0,0 +1,6 @@
use_node() {
local node_version=$(jq -r '.engines.node' package.json)
fnm use "$node_version"
Copy link
Member

@jonator jonator Mar 29, 2024

Choose a reason for hiding this comment

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

What about nvm? Also, do these tools offer this functionality of automatically switching version based on package.json engine?

Copy link
Member

Choose a reason for hiding this comment

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

It's worth mentioning- for my purposes I use nvm and set the latest as a default alias. Perhaps devs can do something similar then we don't have to concern ourselves with maintaining this for all devs.

Copy link
Contributor Author

@Amosel Amosel Apr 2, 2024

Choose a reason for hiding this comment

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

You're right, this is narrowing the solution. Plus, version resolution is not trivial.
With .nvmrc we don't get unpredictable results looking forwards.

(forced a new commit)

Copy link
Contributor Author

@Amosel Amosel Apr 2, 2024

Choose a reason for hiding this comment

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

I use fnm:

You can use fnm use --resolve-engines to get the version that is pegged.
You can also add eval "$(fnm env --use-on-cd)" your shell to automatically update

Add .nvmrc file pegging Node.js version to a concrete one.
@Amosel Amosel merged commit 4b0eab7 into stage Apr 8, 2024
18 checks passed
@Amosel Amosel deleted the amos/direnv-node-version-detection-for-fnm branch April 8, 2024 20:13
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.

4 participants