package-versioner 0.3.0 → 0.4.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
@@ -39,6 +39,10 @@ npx package-versioner --bump minor
39
39
  # Create a prerelease (e.g., alpha)
40
40
  npx package-versioner --bump patch --prerelease alpha
41
41
 
42
+ # Promote a prerelease to a stable release (automatic cleaning)
43
+ # For example, 1.0.0-beta.1 -> 2.0.0:
44
+ npx package-versioner --bump major
45
+
42
46
  # Target specific packages (only in async/independent mode, comma-separated)
43
47
  npx package-versioner -t @scope/package-a,@scope/package-b
44
48
 
@@ -70,7 +74,7 @@ When using the `--json` flag, normal console output is suppressed and the tool o
70
74
  ],
71
75
  "commitMessage": "chore(release): v1.2.3",
72
76
  "tags": [
73
- "@scope/package-a@v1.2.3"
77
+ "v@scope/package-a@1.2.3"
74
78
  ]
75
79
  }
76
80
  ```
package/dist/index.cjs CHANGED
@@ -431,6 +431,14 @@ async function calculateVersion(config, options) {
431
431
  return initialVersion;
432
432
  }
433
433
  const currentVersion = import_semver.default.clean(latestTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
434
+ const standardBumpTypes = ["major", "minor", "patch"];
435
+ if (standardBumpTypes.includes(determinedReleaseType) && import_semver.default.prerelease(currentVersion)) {
436
+ log(
437
+ `Cleaning prerelease identifier from ${currentVersion} for ${determinedReleaseType} bump`,
438
+ "debug"
439
+ );
440
+ return import_semver.default.inc(currentVersion, determinedReleaseType) || "";
441
+ }
434
442
  return import_semver.default.inc(currentVersion, determinedReleaseType, prereleaseIdentifier) || "";
435
443
  }
436
444
  if (config.versionStrategy === "branchPattern" && (branchPattern == null ? void 0 : branchPattern.length)) {
package/dist/index.js CHANGED
@@ -407,6 +407,14 @@ async function calculateVersion(config, options) {
407
407
  return initialVersion;
408
408
  }
409
409
  const currentVersion = semver.clean(latestTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
410
+ const standardBumpTypes = ["major", "minor", "patch"];
411
+ if (standardBumpTypes.includes(determinedReleaseType) && semver.prerelease(currentVersion)) {
412
+ log(
413
+ `Cleaning prerelease identifier from ${currentVersion} for ${determinedReleaseType} bump`,
414
+ "debug"
415
+ );
416
+ return semver.inc(currentVersion, determinedReleaseType) || "";
417
+ }
410
418
  return semver.inc(currentVersion, determinedReleaseType, prereleaseIdentifier) || "";
411
419
  }
412
420
  if (config.versionStrategy === "branchPattern" && (branchPattern == null ? void 0 : branchPattern.length)) {
@@ -94,3 +94,42 @@ This is the default if the `synced` flag is present and true.
94
94
  - Finally, a **single commit** is created including all the updated `package.json` files, using a summary commit message (e.g., `chore(release): pkg-a, pkg-b 1.2.3 [skip-ci]`).
95
95
  - **Important:** Only package-specific tags are created. The global tag (e.g., `v1.2.3`) is **not** automatically generated in this mode. If your release process (like GitHub Releases) depends on a global tag, you'll need to create it manually in your CI/CD script *after* `package-versioner` completes.
96
96
  - **Use Case:** Releasing specific packages independently while still tagging each released package individually.
97
+
98
+ ## Prerelease Handling
99
+
100
+ `package-versioner` provides flexible handling for prerelease versions, allowing both creation of prereleases and promotion to stable releases.
101
+
102
+ ### Creating Prereleases
103
+
104
+ Use the `--prerelease` flag with an identifier to create a prerelease version:
105
+
106
+ ```bash
107
+ # Create a beta prerelease
108
+ npx package-versioner --bump minor --prerelease beta
109
+ # Result: 1.0.0 -> 1.1.0-beta.0
110
+ ```
111
+
112
+ You can also set a default prerelease identifier in your `version.config.json`:
113
+
114
+ ```json
115
+ {
116
+ "prereleaseIdentifier": "beta"
117
+ }
118
+ ```
119
+
120
+ ### Promoting Prereleases to Stable Releases
121
+
122
+ When using standard bump types (`major`, `minor`, `patch`) with the `--bump` flag on a prerelease version, `package-versioner` will automatically clean the prerelease identifier:
123
+
124
+ ```bash
125
+ # Starting from version 1.0.0-beta.1
126
+ npx package-versioner --bump major
127
+ # Result: 1.0.0-beta.1 -> 2.0.0 (not 2.0.0-beta.0)
128
+ ```
129
+
130
+ This intuitive behavior means you don't need to use an empty prerelease identifier (`--prerelease ""`) to promote a prerelease to a stable version. Simply specify the standard bump type and the tool will automatically produce a clean version number.
131
+
132
+ This applies to all standard bump types:
133
+ - `--bump major`: 1.0.0-beta.1 -> 2.0.0
134
+ - `--bump minor`: 1.0.0-beta.1 -> 1.1.0
135
+ - `--bump patch`: 1.0.0-beta.1 -> 1.0.1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "package-versioner",
3
3
  "description": "A lightweight yet powerful CLI tool for automated semantic versioning based on Git history and conventional commits.",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",