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

Enable reading .node-version (or similarly structured) file to read the node version #664

Open
justinedelson opened this issue Feb 7, 2024 · 4 comments

Comments

@justinedelson
Copy link
Member

justinedelson commented Feb 7, 2024

Expected Behaviour

It is frequently important to have the runtime node version match the version used locally and in CI (e.g. to run tests). Similarly to how the setup-node or asdf-vm/actions/install actions work in GitHub Actions, it should be possible for hedy to read the node version from a file so that the following are controlled in one place:

  • Local node version (e.g. via asdf)
  • GitHub Actions (e.g. via the setup-node or asdf-vm/actions/install action)
  • Runtime version

Proposed Syntax

node-version-file CLI argument and nodeVersionFile package configuration should be able to contain a relative file path. If present and the file contains a parseable value, this should be used as the node version. If the value is a simple integer, that's the node version. If the value contains a two or three segment version (i.e. 20.1.2) then only the first segment is used.

Similar to the setup-node action, if both node-version-file and node-version are configured, node-version is used.

@tripodsan
Copy link
Contributor

I think this can be solved through https://docs.npmjs.com/cli/v6/configuring-npm/package-json#engines

@justinedelson
Copy link
Member Author

I think engines means something slightly different -- that is intended to represent a range of versions that can be used whereas .node-version (when used with a version manager), setup-node/node-version and node-version in hedy configuration say "this is the version to use"

@tripodsan
Copy link
Contributor

tripodsan commented Feb 7, 2024

but using package.json as node version would work:
https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file

so you can keep the build version (engines) and the deploy version (wsk.node-version) close together in the same file.

@justinedelson
Copy link
Member Author

Ah, I understand now. Yes, that provides some locality. And TBH if it was just a matter of GitHub Actions + hedy this wouldn't be necessary since you can extract the version set up by the setup-node action as an output and use it to generate a HLX_NODE_VERSION environment variable.

But this leaves local execution out. I clarified this in my original message.

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

No branches or pull requests

2 participants