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

feat: default node version to .nvmrc when available, fixes #6071 #6108

Conversation

GuySartorelli
Copy link
Collaborator

The Issue

Projects with a .nvmrc need to duplicate the node version into DDEV config as well.
When collaborating with developers who aren't using DDEV, there is a risk of the .nvmrc value being updated without updating the reference in .ddev/config.yaml for that project.
There are other scenarios as well where this desync could be problematic.

How This PR Solves The Issue

If a .nvmrc exists in the project root and no nodejs_version is defined in the project's .ddev/config.yaml file, the .nvmrc file is used to define the default node js version.
If that file doesn't exist, the existing hardcoded DDEV default value is used.

Manual Testing Instructions

Run ddev status in a project with/without a .nvmrc file and see the nodejs version update.
Validate that adding nodejs_version in config.yaml still overrides any default values.

Automated Testing Overview

I'm not sure how to test this. Options include:

  1. Make getNodeJSDefault a public function so it can be called directly by tests
  2. Use reflection in tests and call the function using reflection (are there other cases where that's happening in existing tests?)
  3. Change the way the default value is cached - it's currently cached after the first time it's grabbed primarily to avoid outputting warnings multiple times if something goes wrong, which makes it hard to test as part of an integration test.
  4. ?? I'm open to suggestions about how to test this.

Related Issue Link(s)

Release/Deployment Notes

Projects which have a .nvmrc file in the project root and which have not explicitly defined the nodejs version for that project with nodejs_version will swap to using the version defined in .nvmrc instead of the hardcoded DDEV default value.

@GuySartorelli GuySartorelli force-pushed the 20240417_GuySartorelli_nodejs-default-to-nvmrc branch from d6fdd9e to 66a38aa Compare April 16, 2024 22:45
@GuySartorelli GuySartorelli marked this pull request as draft April 16, 2024 23:47
@GuySartorelli
Copy link
Collaborator Author

Marking as draft as there have been concerns raised around this approach in the linked issue.

@rfay
Copy link
Member

rfay commented May 10, 2024

I'm open to general solutions to this issue, but unfortunately the problem with .nvmrc is that it pushes nvm onto people, and that certainly is not a majority workflow. We don't need to integrate one population's workflow onto another population.

Closing this for now, we can continue the conversation in the issue.

@rfay rfay closed this May 10, 2024
@GuySartorelli GuySartorelli deleted the 20240417_GuySartorelli_nodejs-default-to-nvmrc branch May 10, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants