nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.22k stars 2.31k forks source link

`nx release`: `version` command should allow for only updating dependency versions when not already in range #21457

Open Hotell opened 7 months ago

Hotell commented 7 months ago

Current Behavior

yarn nx release version patch -g <group-name> -d

updates package.json dependencies to following:


    "description": "Perf tests for fluentui.",
-   "version": "0.66.4",
+   "version": "0.66.5",
    "private": true,

    "dependencies": {
-     "@fluentui/react-northstar": "*",
-     "@fluentui/react-northstar-prototypes": "*",
-     "@fluentui/digest": "*",
+     "@fluentui/react-northstar": "0.66.5",
+     "@fluentui/react-northstar-prototypes": "0.66.5",
+     "@fluentui/digest": "0.66.5"

Expected Behavior

if dependency version is non numeric/prerelase it should ignore changing those


    "description": "Perf tests for fluentui.",
-   "version": "0.66.4",
+   "version": "0.66.5",
    "private": true,

    "dependencies": {
     "@fluentui/react-northstar": "*",
     "@fluentui/react-northstar-prototypes": "*",
     "@fluentui/digest": "*",

GitHub Repo

https://github.com/microsoft/fluentui/pull/30251

Steps to Reproduce

  1. pull branch
  2. yarn nx release version patch -g northstar -d

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.18.2
   OS     : darwin-arm64
   yarn   : 1.23.34

   nx                 : 17.3.0
   lerna              : 8.0.1
   @nx/js             : 17.3.0
   @nx/jest           : 17.3.0
   @nx/linter         : 17.3.0
   @nx/eslint         : 17.3.0
   @nx/workspace      : 17.3.0
   @nx/devkit         : 17.3.0
   @nx/eslint-plugin  : 17.3.0
   @nx/node           : 17.3.0
   @nx/plugin         : 17.3.0
   @nrwl/tao          : 17.3.0
   typescript         : 4.7.4
   ---------------------------------------
   Local workspace plugins:
         @fluentui/workspace-plugin

Failure Logs

No response

Package Manager Version

yarn

Operating System

Additional Information

No response

JamesHenry commented 7 months ago

I actually landed a change for this a while ago https://github.com/nrwl/nx/pull/20607 but we needed to revert it after unexpected consequences with our native packages.

We can add back more fine-grained control over how dependencies are updated (always vs out-of-range)

tinesoft commented 5 months ago

Any updates on this @JamesHenry ?

Facing the same issue on my repo http://github.com/tinesoft/nxrocks...

Hotell commented 5 months ago

AFAIR this was fixed already https://github.com/nrwl/nx/blob/master/packages/nx/src/command-line/release/version.ts#L70-L71 https://github.com/nrwl/nx/pull/21209

JamesHenry commented 5 months ago

@Hotell actually this one is a different, we do not currently evaluate the semver range and check if there is a match or not and alter the behaviour accordingly.

The enhancement you linked to relates to respecting or updating the prefix when writing the new version number, e.g. always prepend ~ or ^, or respect whatever the existing prefix is (by default).

I'll leave this one open until we offer an option to conditionally update versions only if an existing range (or *) is not a match. As mentioned the one that landed a special case for * https://github.com/nrwl/nx/pull/20607 caused weird side-effects initially and was reverted