package-versioner 0.7.1 → 0.8.1
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 +110 -6
- package/dist/index.cjs +358 -134
- package/dist/index.js +358 -134
- package/docs/versioning.md +182 -16
- package/package-versioner.schema.json +10 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,9 @@ npx package-versioner -t @scope/package-a,@scope/package-b
|
|
|
58
58
|
# Perform a dry run: calculates version, logs actions, but makes no file changes or Git commits/tags
|
|
59
59
|
npx package-versioner --dry-run
|
|
60
60
|
|
|
61
|
+
# Only use reachable tags (Git-semantic mode, no fallback to unreachable tags)
|
|
62
|
+
npx package-versioner --strict-reachable
|
|
63
|
+
|
|
61
64
|
# Output results as JSON (useful for CI/CD scripts)
|
|
62
65
|
npx package-versioner --json
|
|
63
66
|
|
|
@@ -67,6 +70,26 @@ npx package-versioner --dry-run --json
|
|
|
67
70
|
|
|
68
71
|
**Note on Targeting:** Using the `-t` flag creates package-specific tags (e.g., `@scope/package-a@1.2.0`) but *not* a global tag (like `v1.2.0`). If needed, create the global tag manually in your CI/CD script after this command.
|
|
69
72
|
|
|
73
|
+
### Git Tag Reachability
|
|
74
|
+
|
|
75
|
+
By default, `package-versioner` intelligently handles Git tag reachability to provide the best user experience:
|
|
76
|
+
|
|
77
|
+
- **Default behavior**: Uses reachable tags when available, but falls back to the latest repository tag if needed (common in feature branches)
|
|
78
|
+
- **Strict mode (`--strict-reachable`)**: Only uses tags reachable from the current commit, following strict Git semantics
|
|
79
|
+
|
|
80
|
+
This is particularly useful when working on feature branches that have diverged from the main branch where newer tags exist. The tool will automatically detect the Git context and provide helpful guidance:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# On a feature branch with unreachable tags
|
|
84
|
+
npx package-versioner --dry-run
|
|
85
|
+
# Output: "No tags reachable from current branch 'feature-x'. Using latest repository tag v1.2.3 as version base."
|
|
86
|
+
# Tip: Consider 'git merge main' or 'git rebase main' to include tag history in your branch.
|
|
87
|
+
|
|
88
|
+
# Force strict Git semantics
|
|
89
|
+
npx package-versioner --dry-run --strict-reachable
|
|
90
|
+
# Output: Uses only reachable tags, may result in "No reachable tags found"
|
|
91
|
+
```
|
|
92
|
+
|
|
70
93
|
## JSON Output
|
|
71
94
|
|
|
72
95
|
When using the `--json` flag, normal console output is suppressed and the tool outputs a structured JSON object that includes information about the versioning operation.
|
|
@@ -92,23 +115,24 @@ For detailed examples of how to use this in CI/CD pipelines, see [CI/CD Integrat
|
|
|
92
115
|
|
|
93
116
|
## Configuration
|
|
94
117
|
|
|
95
|
-
Customize
|
|
118
|
+
Customize behaviour by creating a `version.config.json` file in your project root:
|
|
96
119
|
|
|
97
120
|
```json
|
|
98
121
|
{
|
|
99
122
|
"preset": "angular",
|
|
100
123
|
"versionPrefix": "v",
|
|
101
|
-
"tagTemplate": "${prefix}${version}",
|
|
102
|
-
"
|
|
124
|
+
"tagTemplate": "${packageName}@${prefix}${version}",
|
|
125
|
+
"packageSpecificTags": true,
|
|
103
126
|
"commitMessage": "chore: release ${packageName}@${version} [skip ci]",
|
|
104
127
|
"updateChangelog": true,
|
|
105
128
|
"changelogFormat": "keep-a-changelog",
|
|
129
|
+
"strictReachable": false,
|
|
106
130
|
"synced": true,
|
|
107
131
|
"skip": [
|
|
108
132
|
"docs",
|
|
109
133
|
"e2e"
|
|
110
134
|
],
|
|
111
|
-
"packages": ["
|
|
135
|
+
"packages": ["@mycompany/*"],
|
|
112
136
|
"mainPackage": "primary-package",
|
|
113
137
|
"cargo": {
|
|
114
138
|
"enabled": true,
|
|
@@ -126,6 +150,7 @@ Customize behavior by creating a `version.config.json` file in your project root
|
|
|
126
150
|
- `commitMessage`: Template for commit messages (default: "chore(release): ${version}")
|
|
127
151
|
- `updateChangelog`: Whether to automatically update changelogs (default: true)
|
|
128
152
|
- `changelogFormat`: Format for changelogs - "keep-a-changelog" or "angular" (default: "keep-a-changelog")
|
|
153
|
+
- `strictReachable`: Only use reachable tags, no fallback to unreachable tags (default: false)
|
|
129
154
|
- `cargo`: Options for Rust projects:
|
|
130
155
|
- `enabled`: Whether to handle Cargo.toml files (default: true)
|
|
131
156
|
- `paths`: Directories to search for Cargo.toml files (optional)
|
|
@@ -133,13 +158,92 @@ Customize behavior by creating a `version.config.json` file in your project root
|
|
|
133
158
|
#### Monorepo-Specific Options
|
|
134
159
|
- `synced`: Whether all packages should be versioned together (default: true)
|
|
135
160
|
- `skip`: Array of package names to exclude from versioning
|
|
136
|
-
- `packages`:
|
|
161
|
+
- `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
162
|
- `mainPackage`: Package name whose commit history should drive version determination
|
|
138
|
-
- `
|
|
163
|
+
- `packageSpecificTags`: Whether to enable package-specific tagging behaviour (default: false)
|
|
139
164
|
- `updateInternalDependencies`: How to update internal dependencies ("patch", "minor", "major", or "inherit")
|
|
140
165
|
|
|
141
166
|
For more details on CI/CD integration and advanced usage, see [CI/CD Integration](./docs/CI_CD_INTEGRATION.md).
|
|
142
167
|
|
|
168
|
+
### Package Targeting
|
|
169
|
+
|
|
170
|
+
The `packages` configuration option allows you to specify which packages should be processed for versioning. It supports several pattern types:
|
|
171
|
+
|
|
172
|
+
#### Exact Package Names
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"packages": ["@mycompany/core", "@mycompany/utils", "standalone-package"]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Scope Wildcards
|
|
180
|
+
Target all packages within a specific scope:
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"packages": ["@mycompany/*"]
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Global Wildcard
|
|
188
|
+
Target all packages in the workspace:
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"packages": ["*"]
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Mixed Patterns
|
|
196
|
+
Combine different pattern types:
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"packages": ["@mycompany/*", "@utils/logger", "legacy-package"]
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**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.
|
|
204
|
+
|
|
205
|
+
### Package-Specific Tagging
|
|
206
|
+
|
|
207
|
+
The `packageSpecificTags` option controls whether the tool creates and searches for package-specific Git tags:
|
|
208
|
+
|
|
209
|
+
- **When `false` (default)**: Creates global tags like `v1.2.3` and searches for the latest global tag
|
|
210
|
+
- **When `true`**: Creates package-specific tags like `@scope/package-a@v1.2.3` and searches for package-specific tags
|
|
211
|
+
|
|
212
|
+
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:
|
|
213
|
+
|
|
214
|
+
- When `packageSpecificTags` is `false`: The `${packageName}` variable is empty, so templates should use `${prefix}${version}`
|
|
215
|
+
- When `packageSpecificTags` is `true`: The `${packageName}` variable contains the package name
|
|
216
|
+
|
|
217
|
+
**Examples:**
|
|
218
|
+
|
|
219
|
+
For single-package repositories or synced monorepos:
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"packageSpecificTags": true,
|
|
223
|
+
"tagTemplate": "${packageName}@${prefix}${version}"
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
Creates tags like `my-package@v1.2.3`
|
|
227
|
+
|
|
228
|
+
For global versioning:
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"packageSpecificTags": false,
|
|
232
|
+
"tagTemplate": "${prefix}${version}"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
Creates tags like `v1.2.3`
|
|
236
|
+
|
|
237
|
+
**Important Notes:**
|
|
238
|
+
- In **synced mode** with a single package, `packageSpecificTags: true` will use the package name even though all packages are versioned together
|
|
239
|
+
- In **synced mode** with multiple packages, package names are not used regardless of the setting
|
|
240
|
+
- In **async mode**, each package gets its own tag when `packageSpecificTags` is enabled
|
|
241
|
+
|
|
242
|
+
With package-specific tagging enabled, the tool will:
|
|
243
|
+
1. Look for existing tags matching the configured pattern for each package
|
|
244
|
+
2. Create new tags using the same pattern when releasing
|
|
245
|
+
3. Fall back to global tag lookup if no package-specific tags are found
|
|
246
|
+
|
|
143
247
|
## How Versioning Works
|
|
144
248
|
|
|
145
249
|
`package-versioner` determines the next version based on your configuration (`version.config.json`). The two main approaches are:
|