Skip to content

Commit

Permalink
docs(release): version prefix dependents (#28729)
Browse files Browse the repository at this point in the history
(cherry picked from commit bd40a56)
  • Loading branch information
vctqs1 authored and FrozenPandaz committed Nov 6, 2024
1 parent 85178d3 commit 5f8bc64
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,14 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Configuring Version Prefix for Dependency Versions",
"path": "/recipes/nx-release/configuration-version-prefix",
"id": "configuration-version-prefix",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
Expand Down Expand Up @@ -3751,6 +3759,14 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Configuring Version Prefix for Dependency Versions",
"path": "/recipes/nx-release/configuration-version-prefix",
"id": "configuration-version-prefix",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
Expand Down Expand Up @@ -3859,6 +3875,14 @@
"children": [],
"disableCollapsible": false
},
{
"name": "Configuring Version Prefix for Dependency Versions",
"path": "/recipes/nx-release/configuration-version-prefix",
"id": "configuration-version-prefix",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Enterprise",
"path": "/nx-enterprise",
Expand Down
33 changes: 33 additions & 0 deletions docs/generated/manifests/nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,17 @@
"isExternal": false,
"path": "/recipes/nx-release/build-before-versioning",
"tags": ["nx-release"]
},
{
"id": "configuration-version-prefix",
"name": "Configuring Version Prefix for Dependency Versions",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/configuration-version-prefix",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/configuration-version-prefix",
"tags": ["nx-release"]
}
],
"isExternal": false,
Expand Down Expand Up @@ -5135,6 +5146,17 @@
"isExternal": false,
"path": "/recipes/nx-release/build-before-versioning",
"tags": ["nx-release"]
},
{
"id": "configuration-version-prefix",
"name": "Configuring Version Prefix for Dependency Versions",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/configuration-version-prefix",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/configuration-version-prefix",
"tags": ["nx-release"]
}
],
"isExternal": false,
Expand Down Expand Up @@ -5284,6 +5306,17 @@
"path": "/recipes/nx-release/build-before-versioning",
"tags": ["nx-release"]
},
"/recipes/nx-release/configuration-version-prefix": {
"id": "configuration-version-prefix",
"name": "Configuring Version Prefix for Dependency Versions",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/configuration-version-prefix",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/configuration-version-prefix",
"tags": ["nx-release"]
},
"/nx-enterprise": {
"id": "nx-enterprise",
"name": "Enterprise",
Expand Down
7 changes: 7 additions & 0 deletions docs/generated/manifests/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@
"name": "Build Before Versioning",
"path": "/recipes/nx-release/build-before-versioning"
},
{
"description": "",
"file": "shared/recipes/nx-release/configuration-version-prefix",
"id": "configuration-version-prefix",
"name": "Configuring Version Prefix for Dependency Versions",
"path": "/recipes/nx-release/configuration-version-prefix"
},
{
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/release",
Expand Down
6 changes: 6 additions & 0 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,12 @@
"id": "build-before-versioning",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/build-before-versioning"
},
{
"name": "Configuring Version Prefix for Dependency Versions",
"id": "configuration-version-prefix",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/configuration-version-prefix"
}
]
}
Expand Down
93 changes: 93 additions & 0 deletions docs/shared/recipes/nx-release/configuration-version-prefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Configuring Version Prefix for Dependency Versions

This guide explains how to configure a custom version prefix in Nx Release using the `versionPrefix` option. The version prefix allows you to automatically add a specific prefix format to dependencies, providing control over how dependency versions are specified in your project’s `package.json` files.

## The `versionPrefix` Option

The `versionPrefix` option controls which prefix is applied to dependency versions during the versioning process. By default, `versionPrefix` is set to `"auto"`, which selects a prefix format (either `""`, `"~"`, `"^"`, or `"="`) by respecting what is already in the `package.json` file.

For example, having the following `package.json` file:

```json
{
"name": "my-package",
"version": "0.1.1",
"dependencies": {
"dependency-one": "~1.2.3",
"dependency-two": "^2.3.4",
"dependency-three": "3.0.0"
}
}
```

Then next patch bump will be:

```json
{
"name": "my-package",
"version": "0.1.2",
"dependencies": {
"dependency-one": "~1.2.4",
"dependency-two": "^2.3.4",
"dependency-three": "3.0.0"
}
}
```

Preserving the prefix for `dependency-one` and `dependency-two` and continuing to use no prefix for `dependency-three`.

### Available Prefix Options

You can set `versionPrefix` to one of the following values:

- `"auto"`: Automatically chooses a prefix based on the existing declaration in the `package.json` file. This is the default value.
- `""`: Uses the exact version without a prefix.
- `"~"`: Specifies compatibility with patch-level updates.
- `"^"`: Specifies compatibility with minor-level updates.
- `"="`: Locks the version to an exact match (the `=` is not commonly used in the JavaScript ecosystem, but is in others such as Cargo for Rust).

Example configuration:

```json
{
"release": {
"version": {
"generatorOptions": {
"versionPrefix": "~"
}
}
}
}
```

## Configuring Version Prefix in `nx.json` or `project.json`

To set the versionPrefix option globally or for a specific project, add it to either your `nx.json` or `project.json` configuration files:

```jsonc
{
"release": {
"version": {
"generatorOptions": {
"versionPrefix": "^" // or "", "~", "^", "=" depending on your preference
}
}
}
}
```

With the `versionPrefix` option set to `^`, your `package.json` dependencies might look like this:

```json
{
"name": "my-package",
"version": "0.1.1",
"dependencies": {
"dependency-one": "^1.0.0",
"dependency-two": "^2.3.4",
"dependency-three": "^3.0.0"
}
}
```

This configuration helps enforce a consistent approach to dependency management, allowing flexibility in how updates to dependencies are tracked and managed across your project.
1 change: 1 addition & 0 deletions docs/shared/reference/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
- [Configure Changelog Format](/recipes/nx-release/configure-changelog-format)
- [Publish a Custom Dist Directory](/recipes/nx-release/publish-custom-dist-directory)
- [Build Before Versioning](/recipes/nx-release/build-before-versioning)
- [Configuring Version Prefix for Dependency Versions](/recipes/nx-release/configuration-version-prefix)
- [Troubleshoot Nx Console Issues](/recipes/nx-console/console-troubleshooting)
- [Enterprise](/nx-enterprise)
- [Activate Powerpack](/nx-enterprise/activate-powerpack)
Expand Down

0 comments on commit 5f8bc64

Please sign in to comment.