package-versioner 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -21
- package/dist/index.cjs +333 -122
- package/dist/index.js +388 -175
- package/docs/versioning.md +182 -16
- package/package-versioner.schema.json +10 -6
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<img src="https://img.shields.io/npm/v/package-versioner" /></a>
|
|
6
6
|
<a href="https://www.npmjs.com/package/package-versioner" alt="NPM Downloads">
|
|
7
7
|
<img src="https://img.shields.io/npm/dw/package-versioner" /></a>
|
|
8
|
-
|
|
8
|
+
<br/><br/>
|
|
9
9
|
A lightweight yet powerful CLI tool for automated semantic versioning based on Git history and conventional commits. Supports both single package projects and monorepos with flexible versioning strategies.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
@@ -92,25 +92,24 @@ For detailed examples of how to use this in CI/CD pipelines, see [CI/CD Integrat
|
|
|
92
92
|
|
|
93
93
|
## Configuration
|
|
94
94
|
|
|
95
|
-
Customize
|
|
95
|
+
Customize behaviour by creating a `version.config.json` file in your project root:
|
|
96
96
|
|
|
97
97
|
```json
|
|
98
98
|
{
|
|
99
99
|
"preset": "angular",
|
|
100
100
|
"versionPrefix": "v",
|
|
101
|
-
"tagTemplate": "${prefix}${version}",
|
|
102
|
-
"
|
|
101
|
+
"tagTemplate": "${packageName}@${prefix}${version}",
|
|
102
|
+
"packageSpecificTags": true,
|
|
103
103
|
"commitMessage": "chore: release ${packageName}@${version} [skip ci]",
|
|
104
104
|
"updateChangelog": true,
|
|
105
105
|
"changelogFormat": "keep-a-changelog",
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
106
|
+
"synced": true,
|
|
107
|
+
"skip": [
|
|
108
|
+
"docs",
|
|
109
|
+
"e2e"
|
|
110
|
+
],
|
|
111
|
+
"packages": ["@mycompany/*"],
|
|
112
|
+
"mainPackage": "primary-package",
|
|
114
113
|
"cargo": {
|
|
115
114
|
"enabled": true,
|
|
116
115
|
"paths": ["src/", "crates/"]
|
|
@@ -118,15 +117,107 @@ Customize behavior by creating a `version.config.json` file in your project root
|
|
|
118
117
|
}
|
|
119
118
|
```
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
### Configuration Options
|
|
121
|
+
|
|
122
|
+
#### General Options (All Projects)
|
|
123
|
+
- `preset`: Conventional commits preset to use for version calculation (default: "angular")
|
|
124
|
+
- `versionPrefix`: Prefix for version numbers in tags (default: "v")
|
|
125
|
+
- `tagTemplate`: Template for Git tags (default: "${prefix}${version}")
|
|
126
|
+
- `commitMessage`: Template for commit messages (default: "chore(release): ${version}")
|
|
127
|
+
- `updateChangelog`: Whether to automatically update changelogs (default: true)
|
|
128
|
+
- `changelogFormat`: Format for changelogs - "keep-a-changelog" or "angular" (default: "keep-a-changelog")
|
|
129
|
+
- `cargo`: Options for Rust projects:
|
|
130
|
+
- `enabled`: Whether to handle Cargo.toml files (default: true)
|
|
131
|
+
- `paths`: Directories to search for Cargo.toml files (optional)
|
|
132
|
+
|
|
133
|
+
#### Monorepo-Specific Options
|
|
134
|
+
- `synced`: Whether all packages should be versioned together (default: true)
|
|
135
|
+
- `skip`: Array of package names to exclude from versioning
|
|
136
|
+
- `packages`: Array of package names or patterns to target for versioning. Supports exact names, scope wildcards, and global wildcards (e.g., ["@scope/package-a", "@scope/*", "*"])
|
|
137
|
+
- `mainPackage`: Package name whose commit history should drive version determination
|
|
138
|
+
- `packageSpecificTags`: Whether to enable package-specific tagging behaviour (default: false)
|
|
139
|
+
- `updateInternalDependencies`: How to update internal dependencies ("patch", "minor", "major", or "inherit")
|
|
140
|
+
|
|
141
|
+
For more details on CI/CD integration and advanced usage, see [CI/CD Integration](./docs/CI_CD_INTEGRATION.md).
|
|
142
|
+
|
|
143
|
+
### Package Targeting
|
|
144
|
+
|
|
145
|
+
The `packages` configuration option allows you to specify which packages should be processed for versioning. It supports several pattern types:
|
|
146
|
+
|
|
147
|
+
#### Exact Package Names
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"packages": ["@mycompany/core", "@mycompany/utils", "standalone-package"]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Scope Wildcards
|
|
155
|
+
Target all packages within a specific scope:
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"packages": ["@mycompany/*"]
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Global Wildcard
|
|
163
|
+
Target all packages in the workspace:
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"packages": ["*"]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### Mixed Patterns
|
|
171
|
+
Combine different pattern types:
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"packages": ["@mycompany/*", "@utils/logger", "legacy-package"]
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Note**: Package discovery is handled by your workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.). The `packages` option only filters which discovered packages to process.
|
|
179
|
+
|
|
180
|
+
### Package-Specific Tagging
|
|
181
|
+
|
|
182
|
+
The `packageSpecificTags` option controls whether the tool creates and searches for package-specific Git tags:
|
|
183
|
+
|
|
184
|
+
- **When `false` (default)**: Creates global tags like `v1.2.3` and searches for the latest global tag
|
|
185
|
+
- **When `true`**: Creates package-specific tags like `@scope/package-a@v1.2.3` and searches for package-specific tags
|
|
186
|
+
|
|
187
|
+
This option works in conjunction with `tagTemplate` to control tag formatting. The `tagTemplate` is used for all tag creation, with the `packageSpecificTags` boolean controlling whether the `${packageName}` variable is populated:
|
|
188
|
+
|
|
189
|
+
- When `packageSpecificTags` is `false`: The `${packageName}` variable is empty, so templates should use `${prefix}${version}`
|
|
190
|
+
- When `packageSpecificTags` is `true`: The `${packageName}` variable contains the package name
|
|
191
|
+
|
|
192
|
+
**Examples:**
|
|
193
|
+
|
|
194
|
+
For single-package repositories or synced monorepos:
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"packageSpecificTags": true,
|
|
198
|
+
"tagTemplate": "${packageName}@${prefix}${version}"
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
Creates tags like `my-package@v1.2.3`
|
|
202
|
+
|
|
203
|
+
For global versioning:
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"packageSpecificTags": false,
|
|
207
|
+
"tagTemplate": "${prefix}${version}"
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
Creates tags like `v1.2.3`
|
|
211
|
+
|
|
212
|
+
**Important Notes:**
|
|
213
|
+
- In **synced mode** with a single package, `packageSpecificTags: true` will use the package name even though all packages are versioned together
|
|
214
|
+
- In **synced mode** with multiple packages, package names are not used regardless of the setting
|
|
215
|
+
- In **async mode**, each package gets its own tag when `packageSpecificTags` is enabled
|
|
216
|
+
|
|
217
|
+
With package-specific tagging enabled, the tool will:
|
|
218
|
+
1. Look for existing tags matching the configured pattern for each package
|
|
219
|
+
2. Create new tags using the same pattern when releasing
|
|
220
|
+
3. Fall back to global tag lookup if no package-specific tags are found
|
|
130
221
|
|
|
131
222
|
## How Versioning Works
|
|
132
223
|
|