From 00967fc6db3bf944d7ddd9d62d20be35245da4e8 Mon Sep 17 00:00:00 2001 From: kchindam-infy Date: Thu, 9 Jan 2025 14:25:54 -0800 Subject: [PATCH 1/3] docs: Add section on workspace version bumps --- docs/lib/content/commands/npm-version.md | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/lib/content/commands/npm-version.md b/docs/lib/content/commands/npm-version.md index 08e74ef307afd..063552e2b4fd6 100644 --- a/docs/lib/content/commands/npm-version.md +++ b/docs/lib/content/commands/npm-version.md @@ -95,6 +95,43 @@ This runs all your tests and proceeds only if they pass. Then runs your After the commit, it pushes the new commit and tag up to the server, and deletes the `build/temp` directory. +#### Workspaces and Inter-Dependencies + +When using `npm workspaces`, you might have multiple packages that depend on one another. For example: + +```json +// package-a/package.json +{ + "name": "package-a", + "version": "1.0.2" +} + +// package-b/package.json +{ + "name": "package-b", + "version": "1.0.2", + "dependencies": { + "package-a": "^1.0.2" + } +} +``` + +#### Changes When Running `npm version -ws --save` + +1. **Bump the versions in each workspace’s `package.json`.** +2. **Attempt to update cross-dependencies** where the new version fits into the declared semver range. + +#### Note on `--save` +By default, `npm version -ws` will bump the versions in each workspace without automatically +updating dependency references across workspaces. Including the `--save` flag triggers a +minimal reify operation that updates references **if** your semver range allows it. + +For example, if a dependency is declared as `^1.0.2`, a minor bump from `1.0.2` to `1.1.0` +is valid under the caret range, so npm updates the reference to `^1.1.0`. However, +moving from `1.x.x` to `2.x.x` is outside of the caret range. In that case, +you must broaden the range (e.g., `">=1.0.0 <3.0.0"`, `"^1.0.0 || ^2.0.0"`, etc.) or +manually update it to allow a major bump. + ### See Also * [npm init](/commands/npm-init) From 66ce190852f9104a135515c42996dd18874a502a Mon Sep 17 00:00:00 2001 From: kchindam-infy Date: Fri, 10 Jan 2025 09:40:57 -0800 Subject: [PATCH 2/3] add noteon npm version without save --- docs/lib/content/commands/npm-version.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/lib/content/commands/npm-version.md b/docs/lib/content/commands/npm-version.md index 063552e2b4fd6..1d1971e288cc8 100644 --- a/docs/lib/content/commands/npm-version.md +++ b/docs/lib/content/commands/npm-version.md @@ -132,6 +132,9 @@ moving from `1.x.x` to `2.x.x` is outside of the caret range. In that case, you must broaden the range (e.g., `">=1.0.0 <3.0.0"`, `"^1.0.0 || ^2.0.0"`, etc.) or manually update it to allow a major bump. +It's important to note, Reify takes place even without the `--save` flag. However, in that case, +package.json is not modified to reflect updated dependency references. + ### See Also * [npm init](/commands/npm-init) From c17fe6344581531d7e3feccfd5b516870b471829 Mon Sep 17 00:00:00 2001 From: kchindam-infy Date: Fri, 10 Jan 2025 10:21:17 -0800 Subject: [PATCH 3/3] resolve comment --- docs/lib/content/commands/npm-version.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/lib/content/commands/npm-version.md b/docs/lib/content/commands/npm-version.md index 1d1971e288cc8..49433a6ba227e 100644 --- a/docs/lib/content/commands/npm-version.md +++ b/docs/lib/content/commands/npm-version.md @@ -123,8 +123,8 @@ When using `npm workspaces`, you might have multiple packages that depend on one #### Note on `--save` By default, `npm version -ws` will bump the versions in each workspace without automatically -updating dependency references across workspaces. Including the `--save` flag triggers a -minimal reify operation that updates references **if** your semver range allows it. +updating dependency references across workspaces. Including the `--save` flag ensures that dependency +references are updated when the sember range allows it. For example, if a dependency is declared as `^1.0.2`, a minor bump from `1.0.2` to `1.1.0` is valid under the caret range, so npm updates the reference to `^1.1.0`. However, @@ -132,9 +132,6 @@ moving from `1.x.x` to `2.x.x` is outside of the caret range. In that case, you must broaden the range (e.g., `">=1.0.0 <3.0.0"`, `"^1.0.0 || ^2.0.0"`, etc.) or manually update it to allow a major bump. -It's important to note, Reify takes place even without the `--save` flag. However, in that case, -package.json is not modified to reflect updated dependency references. - ### See Also * [npm init](/commands/npm-init)