@releasekit/version 0.1.0 → 0.1.1-next.0

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 CHANGED
@@ -1,306 +1,144 @@
1
- # package-versioner
1
+ # @releasekit/version
2
2
 
3
-
4
- <a href="https://www.npmjs.com/package/package-versioner" alt="NPM Version">
5
- <img src="https://img.shields.io/npm/v/package-versioner" /></a>
6
- <a href="https://www.npmjs.com/package/package-versioner" alt="NPM Downloads">
7
- <img src="https://img.shields.io/npm/dw/package-versioner" /></a>
8
- <br/><br/>
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.
3
+ Semantic versioning based on Git history and conventional commits.
10
4
 
11
5
  ## Features
12
6
 
13
- - Automatically determines version bumps based on commit history (using conventional commits)
14
- - Supports both single package projects and monorepos with minimal configuration
15
- - Support for both npm (package.json) and Rust (Cargo.toml) projects
16
- - Flexible versioning strategies (e.g., based on commit types, branch patterns)
17
- - Integrates with conventional commits presets
18
- - Customizable through a `version.config.json` file or CLI options
19
- - Automatically updates `package.json` or `Cargo.toml` version
20
- - Creates appropriate Git tags for releases
21
- - CI/CD friendly with JSON output support
22
- - Changelog data included in JSON output for use with @releasekit/notes
23
-
24
- ## Supporting JavaScript and Rust Projects
25
-
26
- `package-versioner` provides version management for both JavaScript/TypeScript (via package.json) and Rust (via Cargo.toml) projects:
27
-
28
- - **JavaScript/TypeScript**: Automatically detects and updates version in package.json files
29
- - **Rust**: Detects and updates version in Cargo.toml files using the same versioning strategies
30
- - **Mixed Projects**: Supports repositories containing both package.json and Cargo.toml files
31
-
32
- When run, the tool will automatically discover and update the appropriate manifest file based on the project structure.
7
+ - **Conventional commits** — automatic version bumps from commit history (`feat:` minor, `fix:` → patch, `BREAKING CHANGE` → major)
8
+ - **Monorepo support** sync, single, or independent (async) versioning strategies
9
+ - **npm and Rust** — updates both `package.json` and `Cargo.toml` manifests
10
+ - **Branch patterns** determine bumps from branch names (e.g. `feature/*` minor)
11
+ - **Package targeting** version specific packages with `--target`
12
+ - **Prerelease support** create alpha, beta, or custom prerelease versions
13
+ - **Dry-run mode** preview changes without modifying files or creating tags
14
+ - **JSON output** structured results for piping to `@releasekit/notes` and CI scripts
15
+ - **Package-specific tags** configurable tag templates per package
33
16
 
34
- ## Usage
35
-
36
- `package-versioner` is designed to be run directly using your preferred package manager's execution command, without needing global installation.
17
+ ## Installation
37
18
 
38
19
  ```bash
39
- # Determine bump based on conventional commits since last tag
40
- npx package-versioner
41
-
42
- # Using pnpm
43
- pnpm dlx package-versioner
44
-
45
- # Using yarn
46
- yarn dlx package-versioner
47
-
48
- # Specify a bump type explicitly
49
- npx package-versioner --bump minor
50
-
51
- # Create a prerelease (e.g., alpha)
52
- npx package-versioner --bump patch --prerelease alpha
20
+ npm install -g @releasekit/version
21
+ # or
22
+ pnpm add -g @releasekit/version
23
+ ```
53
24
 
54
- # Target specific packages (only in async/independent mode, comma-separated)
55
- npx package-versioner -t @scope/package-a,@scope/package-b
25
+ ## Quick Start
56
26
 
57
- # Run from a different directory
58
- npx package-versioner --project-dir /path/to/project
27
+ ```bash
28
+ # Auto-detect bump from conventional commits
29
+ releasekit-version
59
30
 
60
- # Perform a dry run: calculates version, logs actions, but makes no file changes or Git commits/tags
61
- npx package-versioner --dry-run
31
+ # Force a specific bump type
32
+ releasekit-version --bump minor
62
33
 
63
- # Only use reachable tags (Git-semantic mode, no fallback to unreachable tags)
64
- npx package-versioner --strict-reachable
34
+ # Preview without side effects
35
+ releasekit-version --dry-run --json
65
36
 
66
- # Output results as JSON (useful for CI/CD scripts)
67
- npx package-versioner --json
37
+ # Target specific packages in a monorepo
38
+ releasekit-version --target @scope/core,@scope/cli
68
39
 
69
- # Combine with dry-run for CI planning
70
- npx package-versioner --dry-run --json
40
+ # Create a prerelease
41
+ releasekit-version --prerelease beta
71
42
  ```
72
43
 
73
- **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.
74
-
75
- ### Git Tag Reachability
76
-
77
- By default, `package-versioner` intelligently handles Git tag reachability to provide the best user experience:
78
-
79
- - **Default behaviour**: Uses reachable tags when available, but falls back to the latest repository tag if needed (common in feature branches)
80
- - **Strict mode (`--strict-reachable`)**: Only uses tags reachable from the current commit, following strict Git semantics
44
+ ## CLI Reference
81
45
 
82
- 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:
83
-
84
- ```bash
85
- # On a feature branch with unreachable tags
86
- npx package-versioner --dry-run
87
- # Output: "No tags reachable from current branch 'feature-x'. Using latest repository tag v1.2.3 as version base."
88
- # Tip: Consider 'git merge main' or 'git rebase main' to include tag history in your branch.
89
-
90
- # Force strict Git semantics
91
- npx package-versioner --dry-run --strict-reachable
92
- # Output: Uses only reachable tags, may result in "No reachable tags found"
93
- ```
46
+ | Flag | Description | Default |
47
+ |------|-------------|---------|
48
+ | `--bump <type>` | Force bump type: `patch`, `minor`, `major` | auto |
49
+ | `--prerelease [id]` | Create prerelease version (e.g. `beta`) | — |
50
+ | `--target <packages>` | Target specific packages (comma-separated) | all |
51
+ | `--project-dir <path>` | Project directory | cwd |
52
+ | `--dry-run` | Preview without file changes or git operations | `false` |
53
+ | `--json` | Output results as JSON | `false` |
54
+ | `--strict-reachable` | Only use tags reachable from current commit | `false` |
55
+ | `--verbose` | Verbose logging | `false` |
56
+ | `--quiet` | Suppress non-error output | `false` |
94
57
 
95
58
  ## JSON Output
96
59
 
97
- 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.
60
+ When using `--json`, the tool outputs structured data including version bumps and changelog entries:
98
61
 
99
62
  ```json
100
63
  {
101
64
  "dryRun": true,
102
65
  "updates": [
103
66
  {
104
- "packageName": "@scope/package-a",
67
+ "packageName": "@scope/core",
105
68
  "newVersion": "1.2.3",
106
69
  "filePath": "/path/to/package.json"
107
70
  }
108
71
  ],
109
72
  "changelogs": [
110
73
  {
111
- "packageName": "@scope/package-a",
74
+ "packageName": "@scope/core",
112
75
  "version": "1.2.3",
113
76
  "previousVersion": "v1.2.2",
114
77
  "revisionRange": "v1.2.2..HEAD",
115
78
  "repoUrl": "https://github.com/org/repo",
116
79
  "entries": [
117
- { "type": "added", "description": "New feature", "scope": "core" },
80
+ { "type": "added", "description": "New feature" },
118
81
  { "type": "fixed", "description": "Bug fix" }
119
82
  ]
120
83
  }
121
84
  ],
122
85
  "commitMessage": "chore(release): v1.2.3",
123
- "tags": [
124
- "v@scope/package-a@1.2.3"
125
- ]
86
+ "tags": ["v1.2.3"]
126
87
  }
127
88
  ```
128
89
 
129
- For detailed examples of how to use this in CI/CD pipelines, see [CI/CD Integration](./docs/CI_CD_INTEGRATION.md).
90
+ This JSON is consumed by `@releasekit/notes` for changelog generation and `@releasekit/publish` for the publish pipeline.
130
91
 
131
92
  ## Configuration
132
93
 
133
- Customize behaviour by creating a `version.config.json` file in your project root:
94
+ Configure via `releasekit.config.json`:
134
95
 
135
96
  ```json
136
97
  {
137
- "preset": "angular",
138
- "versionPrefix": "v",
139
- "tagTemplate": "${packageName}@${prefix}${version}",
140
- "packageSpecificTags": true,
141
- "commitMessage": "chore: release ${packageName}@${version} [skip ci]",
142
- "strictReachable": false,
143
- "sync": true,
144
- "skip": [
145
- "docs",
146
- "e2e"
147
- ],
148
- "packages": ["@mycompany/*"],
149
- "mainPackage": "primary-package",
150
- "cargo": {
151
- "enabled": true,
152
- "paths": ["src/", "crates/"]
98
+ "version": {
99
+ "preset": "conventionalcommits",
100
+ "versionPrefix": "v",
101
+ "tagTemplate": "${prefix}${version}",
102
+ "commitMessage": "chore(release): v${version}",
103
+ "sync": true,
104
+ "packages": ["@mycompany/*"],
105
+ "skip": ["docs", "e2e"],
106
+ "mainPackage": "primary-package",
107
+ "packageSpecificTags": false,
108
+ "strictReachable": false,
109
+ "cargo": {
110
+ "enabled": true,
111
+ "paths": ["crates/"]
112
+ }
153
113
  }
154
114
  }
155
115
  ```
156
116
 
157
- ### Configuration Options
158
-
159
- #### General Options (All Projects)
160
- - `preset`: Conventional commits preset to use for version calculation (default: "angular")
161
- - `versionPrefix`: Prefix for version numbers in tags (default: "v")
162
- - `tagTemplate`: Template for Git tags (default: "${prefix}${version}")
163
- - `commitMessage`: Template for commit messages (default: "chore(release): ${version}")
164
- - `strictReachable`: Only use reachable tags, no fallback to unreachable tags (default: false)
165
- - `prereleaseIdentifier`: Identifier for prerelease versions (e.g., "alpha", "beta", "next") used in versions like "1.2.0-alpha.3"
166
- - `mismatchStrategy`: How to handle version mismatches between git tags and package.json (default: "error"). Options:
167
- - `"error"`: Throw an error and stop execution, forcing the mismatch to be resolved
168
- - `"warn"`: Log a warning but continue with the higher version
169
- - `"prefer-package"`: Use the package.json version when a mismatch is detected
170
- - `"prefer-git"`: Use the git tag version when a mismatch is detected
171
- - `"ignore"`: Silently continue with the higher version
172
- - `cargo`: Options for Rust projects:
173
- - `enabled`: Whether to handle Cargo.toml files (default: true)
174
- - `paths`: Directories to search for Cargo.toml files (optional)
175
-
176
- #### Monorepo-Specific Options
177
- - `sync`: Whether all packages should be versioned together (default: true)
178
- - `skip`: Array of package names or patterns to exclude from versioning. Supports exact names, scope wildcards, path patterns, and global wildcards (e.g., ["@scope/package-a", "@scope/*", "packages/**/*"])
179
- - `packages`: Array of package names or patterns to target for versioning. Supports exact names, scope wildcards, path patterns and global wildcards (e.g., ["@scope/package-a", "@scope/*", "*"])
180
- - `mainPackage`: Package name whose commit history should drive version determination
181
- - `packageSpecificTags`: Whether to enable package-specific tagging behaviour (default: false)
182
- - `updateInternalDependencies`: How to update internal dependencies ("patch", "minor", "major", or "inherit")
183
-
184
- For more details on CI/CD integration and advanced usage, see [CI/CD Integration](./docs/CI_CD_INTEGRATION.md).
185
-
186
- ### Package Targeting
187
-
188
- The `packages` configuration option controls which packages are processed for versioning. It supports several pattern types:
189
-
190
- #### Exact Package Names
191
- ```json
192
- {
193
- "packages": ["@mycompany/core", "@mycompany/utils", "standalone-package"]
194
- }
195
- ```
196
-
197
- #### Scope Wildcards
198
- Target all packages within a specific scope:
199
- ```json
200
- {
201
- "packages": ["@mycompany/*"]
202
- }
203
- ```
204
-
205
- #### Path Patterns / Globs
206
- Target all packages in a directory or matching a path pattern:
207
- ```json
208
- {
209
- "packages": ["packages/**/*", "examples/**"]
210
- }
211
- ```
212
- This will match all packages in nested directories under `packages/` or `examples/`.
213
-
214
- #### Global Wildcard
215
- Target all packages in the workspace:
216
- ```json
217
- {
218
- "packages": ["*"]
219
- }
220
- ```
221
-
222
- #### Mixed Patterns
223
- Combine different pattern types:
224
- ```json
225
- {
226
- "packages": ["@mycompany/*", "@utils/logger", "legacy-package", "packages/**/*"]
227
- }
228
- ```
229
-
230
- **Behaviour:**
231
- - When `packages` is specified, **only** packages matching those patterns will be processed
232
- - When `packages` is empty or not specified, **all** workspace packages will be processed
233
- - The `skip` option can exclude specific packages from the selected set
234
-
235
- **Note**: Your workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.) determines which packages are available, but the `packages` option directly controls which ones get versioned.
236
-
237
- ### Package-Specific Tagging
238
-
239
- The `packageSpecificTags` option controls whether the tool creates and searches for package-specific Git tags:
240
-
241
- - **When `false` (default)**: Creates global tags like `v1.2.3` and searches for the latest global tag
242
- - **When `true`**: Creates package-specific tags like `@scope/package-a@v1.2.3` and searches for package-specific tags
243
-
244
- 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:
245
-
246
- - When `packageSpecificTags` is `false`: The `${packageName}` variable is empty, so templates should use `${prefix}${version}`
247
- - When `packageSpecificTags` is `true`: The `${packageName}` variable contains the package name
248
-
249
- **Examples:**
250
-
251
- For single-package repositories or sync monorepos:
252
- ```json
253
- {
254
- "packageSpecificTags": true,
255
- "tagTemplate": "${packageName}@${prefix}${version}"
256
- }
257
- ```
258
- Creates tags like `my-package@v1.2.3`
259
-
260
- For global versioning:
261
- ```json
262
- {
263
- "packageSpecificTags": false,
264
- "tagTemplate": "${prefix}${version}"
265
- }
266
- ```
267
- Creates tags like `v1.2.3`
268
-
269
- **Important Notes:**
270
- - In **sync mode** with a single package, `packageSpecificTags: true` will use the package name even though all packages are versioned together
271
- - In **sync mode** with multiple packages, package names are not used regardless of the setting
272
- - In **async mode**, each package gets its own tag when `packageSpecificTags` is enabled
273
-
274
- With package-specific tagging enabled, the tool will:
275
- 1. Look for existing tags matching the configured pattern for each package
276
- 2. Create new tags using the same pattern when releasing
277
- 3. Fall back to global tag lookup if no package-specific tags are found
278
-
279
- ## How Versioning Works
280
-
281
- `package-versioner` determines the next version based on your configuration (`version.config.json`). The two main approaches are:
282
-
283
- 1. **Conventional Commits:** Analyzes commit messages (like `feat:`, `fix:`, `BREAKING CHANGE:`) since the last tag.
284
- 2. **Branch Pattern:** Determines the bump based on the current or recently merged branch name matching predefined patterns.
285
-
286
- For a detailed explanation of these concepts and monorepo modes (Sync vs. Async), see [Versioning Strategies and Concepts](./docs/versioning.md).
117
+ ### Key Options
118
+
119
+ | Option | Description | Default |
120
+ |--------|-------------|---------|
121
+ | `preset` | Conventional commits preset | `"conventionalcommits"` |
122
+ | `versionPrefix` | Tag version prefix | `"v"` |
123
+ | `tagTemplate` | Git tag template | `"${prefix}${version}"` |
124
+ | `commitMessage` | Commit message template | `"chore(release): ${version}"` |
125
+ | `sync` | Version all packages together | `false` |
126
+ | `packages` | Package name patterns to include | all |
127
+ | `skip` | Package name patterns to exclude | `[]` |
128
+ | `mainPackage` | Package to drive version calculation | |
129
+ | `packageSpecificTags` | Create per-package tags | `false` |
130
+ | `strictReachable` | Only use reachable git tags | `false` |
131
+ | `cargo.enabled` | Update Cargo.toml files | `true` |
132
+ | `cargo.paths` | Directories containing Cargo.toml | auto-detect |
287
133
 
288
134
  ## Documentation
289
135
 
290
- - [Versioning Strategies and Concepts](./docs/versioning.md) - Detailed explanation of versioning approaches
291
- - [CI/CD Integration](./docs/CI_CD_INTEGRATION.md) - Guide for integrating with CI/CD pipelines
292
-
293
- For changelog generation, use [@releasekit/notes](../notes) which consumes the JSON output from this tool.
294
-
295
- For more details on available CLI options, run:
296
-
297
- ```bash
298
- npx package-versioner --help
299
- ```
136
+ - [Versioning Strategies and Concepts](./docs/versioning.md)
137
+ - [CI/CD Integration](./docs/CI_CD_INTEGRATION.md)
300
138
 
301
139
  ## Acknowledgements
302
140
 
303
- This project was originally forked from and inspired by [`jucian0/turbo-version`](https://github.com/jucian0/turbo-version). We appreciate the foundational work done by the original authors.
141
+ Originally forked from and inspired by [`jucian0/turbo-version`](https://github.com/jucian0/turbo-version).
304
142
 
305
143
  ## License
306
144
 
@@ -1273,7 +1273,10 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
1273
1273
  `);
1274
1274
  }
1275
1275
  addPackageUpdate(packageName, version, packagePath);
1276
- log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} package.json at ${packagePath} to version ${version}`, "success");
1276
+ log(
1277
+ `${dryRun ? "[DRY RUN] Would update" : "Updated"} package.json at ${packagePath} to version ${version}`,
1278
+ "success"
1279
+ );
1277
1280
  } catch (error) {
1278
1281
  log(`Failed to update package.json at ${packagePath}`, "error");
1279
1282
  if (error instanceof Error) {
package/dist/cli.cjs CHANGED
@@ -960,7 +960,10 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
960
960
  `);
961
961
  }
962
962
  addPackageUpdate(packageName, version, packagePath);
963
- log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} package.json at ${packagePath} to version ${version}`, "success");
963
+ log(
964
+ `${dryRun ? "[DRY RUN] Would update" : "Updated"} package.json at ${packagePath} to version ${version}`,
965
+ "success"
966
+ );
964
967
  } catch (error) {
965
968
  log(`Failed to update package.json at ${packagePath}`, "error");
966
969
  if (error instanceof Error) {
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  log,
7
7
  printJsonOutput
8
- } from "./chunk-GLFC564Q.js";
8
+ } from "./chunk-3JG7UWIT.js";
9
9
  import "./chunk-GQLJ7JQY.js";
10
10
 
11
11
  // src/cli.ts
package/dist/index.cjs CHANGED
@@ -1375,7 +1375,10 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
1375
1375
  `);
1376
1376
  }
1377
1377
  addPackageUpdate(packageName, version, packagePath);
1378
- log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} package.json at ${packagePath} to version ${version}`, "success");
1378
+ log(
1379
+ `${dryRun ? "[DRY RUN] Would update" : "Updated"} package.json at ${packagePath} to version ${version}`,
1380
+ "success"
1381
+ );
1379
1382
  } catch (error) {
1380
1383
  log(`Failed to update package.json at ${packagePath}`, "error");
1381
1384
  if (error instanceof Error) {
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  enableJsonOutput,
11
11
  getJsonData,
12
12
  loadConfig
13
- } from "./chunk-GLFC564Q.js";
13
+ } from "./chunk-3JG7UWIT.js";
14
14
  import {
15
15
  BaseVersionError
16
16
  } from "./chunk-GQLJ7JQY.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@releasekit/version",
3
- "version": "0.1.0",
4
- "description": "A lightweight yet powerful CLI tool for automated semantic versioning based on Git history and conventional commits.",
3
+ "version": "0.1.1-next.0",
4
+ "description": "Semantic versioning based on Git history and conventional commits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "bin": {
22
- "releasekit-version": "./dist/cli.js"
22
+ "releasekit-version": "dist/cli.js"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup src/index.ts src/cli.ts --format esm,cjs --dts",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
41
- "url": "https://github.com/goosewobbler/releasekit",
41
+ "url": "git+https://github.com/goosewobbler/releasekit.git",
42
42
  "directory": "packages/version"
43
43
  },
44
44
  "license": "MIT",
@@ -75,6 +75,6 @@
75
75
  "vitest": "catalog:"
76
76
  },
77
77
  "engines": {
78
- "node": ">=18 || >=20"
78
+ "node": ">=20"
79
79
  }
80
80
  }
@@ -1,6 +0,0 @@
1
- import {
2
- BasePackageVersionerError
3
- } from "./chunk-7GDPUNML.js";
4
- export {
5
- BasePackageVersionerError
6
- };