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

Be able to keep full semver requirement in package.json #21

Open
ThomasTrepanier opened this issue Jul 17, 2024 · 0 comments · May be fixed by #22
Open

Be able to keep full semver requirement in package.json #21

ThomasTrepanier opened this issue Jul 17, 2024 · 0 comments · May be fixed by #22

Comments

@ThomasTrepanier
Copy link

Context

I want to enforce a specific Node version in my repository with the full semantic versioning (i.e 20.15.1).
This Action however truncates the Node version to the major number, which means that we can only enforce a major of Node locally using the engines field of the package.json

Desired behaviour

When using this workflow, I can update the engines field in my package.json to match the full version resolved by Node from the inputted version.

Example

Workflow file configuration

# workflow.yml

- uses: hongaar/update-node-versions@v2
  with:
    versions: lts
    updaters.workflows: false
    updaters.engines: true

Desired package.json Output (using LTS = 20.15.1)

"engines": {
  "node": ">=20.15.1"
}

Current package.json Output (using LTS = 20.15.1)

"engines": {
  "node": ">=20"
}

Proposition

This could be an input provided for the engines field, like updaters.engines.fullVersion or something like that. It could be used for updaters.files too, but it's not necessary for updaters.workflows as Github Action automatically pulls the latest version when specifying a major anyway.

hongaar added a commit that referenced this issue Nov 7, 2024
Fixes #21

Add support for full semantic versioning in `engines` field of `package.json`.

* **action.yml**
  - Add a new input `updaters.engines.fullVersion` to enable full semantic versioning.

* **src/index.ts**
  - Add a new constant `updatersEnginesFullVersion` to get the input for full semantic versioning.
  - Add `updatersEnginesFullVersion` to the `inputs` object.

* **src/updateNodeVersions.ts**
  - Add `updatersEnginesFullVersion` to the `Inputs` type.
  - Pass `updatersEnginesFullVersion` to the `engines` function.

* **src/updaters/engines.ts**
  - Add a new parameter `fullVersion` to the `engines` function.
  - Update the `engines` function to set the `engines.node` field to `>=` followed by the full version if `fullVersion` is true.

* **README.md**
  - Update the `Engines` section to mention support for full semantic versioning.
  - Add an example of using the `updaters.engines.fullVersion` input.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/hongaar/update-node-versions/issues/21?shareId=XXXX-XXXX-XXXX-XXXX).
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 a pull request may close this issue.

1 participant