package-versioner 0.6.1 → 0.6.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/dist/index.cjs +30 -12
- package/dist/index.js +30 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -635,13 +635,34 @@ var import_node_fs5 = __toESM(require("fs"), 1);
|
|
|
635
635
|
var import_semver = __toESM(require("semver"), 1);
|
|
636
636
|
var TOML2 = __toESM(require("smol-toml"), 1);
|
|
637
637
|
var STANDARD_BUMP_TYPES = ["major", "minor", "patch"];
|
|
638
|
+
function normalizePrereleaseIdentifier(prereleaseIdentifier, config) {
|
|
639
|
+
if (prereleaseIdentifier === true) {
|
|
640
|
+
return (config == null ? void 0 : config.prereleaseIdentifier) || "next";
|
|
641
|
+
}
|
|
642
|
+
if (typeof prereleaseIdentifier === "string") {
|
|
643
|
+
return prereleaseIdentifier;
|
|
644
|
+
}
|
|
645
|
+
return void 0;
|
|
646
|
+
}
|
|
638
647
|
function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
|
|
648
|
+
if (prereleaseIdentifier && STANDARD_BUMP_TYPES.includes(bumpType) && !import_semver.default.prerelease(currentVersion)) {
|
|
649
|
+
const preBumpType = `pre${bumpType}`;
|
|
650
|
+
log(
|
|
651
|
+
`Creating prerelease version with identifier '${prereleaseIdentifier}' using ${preBumpType}`,
|
|
652
|
+
"debug"
|
|
653
|
+
);
|
|
654
|
+
return import_semver.default.inc(currentVersion, preBumpType, prereleaseIdentifier) || "";
|
|
655
|
+
}
|
|
639
656
|
if (import_semver.default.prerelease(currentVersion) && STANDARD_BUMP_TYPES.includes(bumpType)) {
|
|
640
657
|
const parsed = import_semver.default.parse(currentVersion);
|
|
641
|
-
if (
|
|
658
|
+
if (!parsed) {
|
|
659
|
+
return import_semver.default.inc(currentVersion, bumpType) || "";
|
|
660
|
+
}
|
|
661
|
+
if (bumpType === "major" && parsed.minor === 0 && parsed.patch === 0 || bumpType === "minor" && parsed.patch === 0 || bumpType === "patch") {
|
|
662
|
+
log(`Cleaning prerelease identifier from ${currentVersion} for ${bumpType} bump`, "debug");
|
|
642
663
|
return `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
643
664
|
}
|
|
644
|
-
log(`
|
|
665
|
+
log(`Standard increment for ${currentVersion} with ${bumpType} bump`, "debug");
|
|
645
666
|
return import_semver.default.inc(currentVersion, bumpType) || "";
|
|
646
667
|
}
|
|
647
668
|
return import_semver.default.inc(currentVersion, bumpType, prereleaseIdentifier) || "";
|
|
@@ -661,6 +682,7 @@ async function calculateVersion(config, options) {
|
|
|
661
682
|
} = options;
|
|
662
683
|
const preset = config.preset || "conventional-commits";
|
|
663
684
|
const initialVersion = "0.1.0";
|
|
685
|
+
const normalizedPrereleaseId = normalizePrereleaseIdentifier(prereleaseIdentifier, config);
|
|
664
686
|
try {
|
|
665
687
|
let determineTagSearchPattern2 = function(packageName, prefix) {
|
|
666
688
|
if (packageName) {
|
|
@@ -682,7 +704,7 @@ async function calculateVersion(config, options) {
|
|
|
682
704
|
pkgPath,
|
|
683
705
|
name,
|
|
684
706
|
specifiedType,
|
|
685
|
-
|
|
707
|
+
normalizedPrereleaseId,
|
|
686
708
|
initialVersion
|
|
687
709
|
);
|
|
688
710
|
}
|
|
@@ -693,9 +715,9 @@ async function calculateVersion(config, options) {
|
|
|
693
715
|
`Cleaning prerelease identifier from ${currentVersion} for ${specifiedType} bump`,
|
|
694
716
|
"debug"
|
|
695
717
|
);
|
|
696
|
-
return bumpVersion(currentVersion, specifiedType,
|
|
718
|
+
return bumpVersion(currentVersion, specifiedType, normalizedPrereleaseId);
|
|
697
719
|
}
|
|
698
|
-
return import_semver2.default.inc(currentVersion, specifiedType,
|
|
720
|
+
return import_semver2.default.inc(currentVersion, specifiedType, normalizedPrereleaseId) || "";
|
|
699
721
|
}
|
|
700
722
|
if (branchPattern && branchPattern.length > 0) {
|
|
701
723
|
const currentBranch = getCurrentBranch();
|
|
@@ -722,7 +744,7 @@ async function calculateVersion(config, options) {
|
|
|
722
744
|
pkgPath,
|
|
723
745
|
name,
|
|
724
746
|
branchVersionType,
|
|
725
|
-
|
|
747
|
+
normalizedPrereleaseId,
|
|
726
748
|
initialVersion
|
|
727
749
|
);
|
|
728
750
|
}
|
|
@@ -743,7 +765,7 @@ async function calculateVersion(config, options) {
|
|
|
743
765
|
pkgPath,
|
|
744
766
|
name,
|
|
745
767
|
releaseTypeFromCommits,
|
|
746
|
-
|
|
768
|
+
normalizedPrereleaseId,
|
|
747
769
|
initialVersion
|
|
748
770
|
);
|
|
749
771
|
}
|
|
@@ -766,7 +788,7 @@ async function calculateVersion(config, options) {
|
|
|
766
788
|
return "";
|
|
767
789
|
}
|
|
768
790
|
const currentVersion = import_semver2.default.clean(latestTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
769
|
-
return import_semver2.default.inc(currentVersion, releaseTypeFromCommits,
|
|
791
|
+
return import_semver2.default.inc(currentVersion, releaseTypeFromCommits, normalizedPrereleaseId) || "";
|
|
770
792
|
} catch (error) {
|
|
771
793
|
log(`Failed to calculate version for ${name || "project"}`, "error");
|
|
772
794
|
console.error(error);
|
|
@@ -811,10 +833,6 @@ function calculateNextVersion(version, manifestType, name, releaseType, prerelea
|
|
|
811
833
|
"info"
|
|
812
834
|
);
|
|
813
835
|
if (STANDARD_BUMP_TYPES.includes(releaseType) && import_semver2.default.prerelease(version)) {
|
|
814
|
-
if (version === "1.0.0-next.0" && releaseType === "major") {
|
|
815
|
-
log(`Cleaning prerelease identifier from ${version} for ${releaseType} bump`, "debug");
|
|
816
|
-
return "1.0.0";
|
|
817
|
-
}
|
|
818
836
|
log(`Cleaning prerelease identifier from ${version} for ${releaseType} bump`, "debug");
|
|
819
837
|
return bumpVersion(version, releaseType, prereleaseIdentifier);
|
|
820
838
|
}
|
package/dist/index.js
CHANGED
|
@@ -600,13 +600,34 @@ function throwIfNoManifestsFound(packageDir) {
|
|
|
600
600
|
import semver from "semver";
|
|
601
601
|
import * as TOML2 from "smol-toml";
|
|
602
602
|
var STANDARD_BUMP_TYPES = ["major", "minor", "patch"];
|
|
603
|
+
function normalizePrereleaseIdentifier(prereleaseIdentifier, config) {
|
|
604
|
+
if (prereleaseIdentifier === true) {
|
|
605
|
+
return (config == null ? void 0 : config.prereleaseIdentifier) || "next";
|
|
606
|
+
}
|
|
607
|
+
if (typeof prereleaseIdentifier === "string") {
|
|
608
|
+
return prereleaseIdentifier;
|
|
609
|
+
}
|
|
610
|
+
return void 0;
|
|
611
|
+
}
|
|
603
612
|
function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
|
|
613
|
+
if (prereleaseIdentifier && STANDARD_BUMP_TYPES.includes(bumpType) && !semver.prerelease(currentVersion)) {
|
|
614
|
+
const preBumpType = `pre${bumpType}`;
|
|
615
|
+
log(
|
|
616
|
+
`Creating prerelease version with identifier '${prereleaseIdentifier}' using ${preBumpType}`,
|
|
617
|
+
"debug"
|
|
618
|
+
);
|
|
619
|
+
return semver.inc(currentVersion, preBumpType, prereleaseIdentifier) || "";
|
|
620
|
+
}
|
|
604
621
|
if (semver.prerelease(currentVersion) && STANDARD_BUMP_TYPES.includes(bumpType)) {
|
|
605
622
|
const parsed = semver.parse(currentVersion);
|
|
606
|
-
if (
|
|
623
|
+
if (!parsed) {
|
|
624
|
+
return semver.inc(currentVersion, bumpType) || "";
|
|
625
|
+
}
|
|
626
|
+
if (bumpType === "major" && parsed.minor === 0 && parsed.patch === 0 || bumpType === "minor" && parsed.patch === 0 || bumpType === "patch") {
|
|
627
|
+
log(`Cleaning prerelease identifier from ${currentVersion} for ${bumpType} bump`, "debug");
|
|
607
628
|
return `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
608
629
|
}
|
|
609
|
-
log(`
|
|
630
|
+
log(`Standard increment for ${currentVersion} with ${bumpType} bump`, "debug");
|
|
610
631
|
return semver.inc(currentVersion, bumpType) || "";
|
|
611
632
|
}
|
|
612
633
|
return semver.inc(currentVersion, bumpType, prereleaseIdentifier) || "";
|
|
@@ -626,6 +647,7 @@ async function calculateVersion(config, options) {
|
|
|
626
647
|
} = options;
|
|
627
648
|
const preset = config.preset || "conventional-commits";
|
|
628
649
|
const initialVersion = "0.1.0";
|
|
650
|
+
const normalizedPrereleaseId = normalizePrereleaseIdentifier(prereleaseIdentifier, config);
|
|
629
651
|
try {
|
|
630
652
|
let determineTagSearchPattern2 = function(packageName, prefix) {
|
|
631
653
|
if (packageName) {
|
|
@@ -647,7 +669,7 @@ async function calculateVersion(config, options) {
|
|
|
647
669
|
pkgPath,
|
|
648
670
|
name,
|
|
649
671
|
specifiedType,
|
|
650
|
-
|
|
672
|
+
normalizedPrereleaseId,
|
|
651
673
|
initialVersion
|
|
652
674
|
);
|
|
653
675
|
}
|
|
@@ -658,9 +680,9 @@ async function calculateVersion(config, options) {
|
|
|
658
680
|
`Cleaning prerelease identifier from ${currentVersion} for ${specifiedType} bump`,
|
|
659
681
|
"debug"
|
|
660
682
|
);
|
|
661
|
-
return bumpVersion(currentVersion, specifiedType,
|
|
683
|
+
return bumpVersion(currentVersion, specifiedType, normalizedPrereleaseId);
|
|
662
684
|
}
|
|
663
|
-
return semver2.inc(currentVersion, specifiedType,
|
|
685
|
+
return semver2.inc(currentVersion, specifiedType, normalizedPrereleaseId) || "";
|
|
664
686
|
}
|
|
665
687
|
if (branchPattern && branchPattern.length > 0) {
|
|
666
688
|
const currentBranch = getCurrentBranch();
|
|
@@ -687,7 +709,7 @@ async function calculateVersion(config, options) {
|
|
|
687
709
|
pkgPath,
|
|
688
710
|
name,
|
|
689
711
|
branchVersionType,
|
|
690
|
-
|
|
712
|
+
normalizedPrereleaseId,
|
|
691
713
|
initialVersion
|
|
692
714
|
);
|
|
693
715
|
}
|
|
@@ -708,7 +730,7 @@ async function calculateVersion(config, options) {
|
|
|
708
730
|
pkgPath,
|
|
709
731
|
name,
|
|
710
732
|
releaseTypeFromCommits,
|
|
711
|
-
|
|
733
|
+
normalizedPrereleaseId,
|
|
712
734
|
initialVersion
|
|
713
735
|
);
|
|
714
736
|
}
|
|
@@ -731,7 +753,7 @@ async function calculateVersion(config, options) {
|
|
|
731
753
|
return "";
|
|
732
754
|
}
|
|
733
755
|
const currentVersion = semver2.clean(latestTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
734
|
-
return semver2.inc(currentVersion, releaseTypeFromCommits,
|
|
756
|
+
return semver2.inc(currentVersion, releaseTypeFromCommits, normalizedPrereleaseId) || "";
|
|
735
757
|
} catch (error) {
|
|
736
758
|
log(`Failed to calculate version for ${name || "project"}`, "error");
|
|
737
759
|
console.error(error);
|
|
@@ -776,10 +798,6 @@ function calculateNextVersion(version, manifestType, name, releaseType, prerelea
|
|
|
776
798
|
"info"
|
|
777
799
|
);
|
|
778
800
|
if (STANDARD_BUMP_TYPES.includes(releaseType) && semver2.prerelease(version)) {
|
|
779
|
-
if (version === "1.0.0-next.0" && releaseType === "major") {
|
|
780
|
-
log(`Cleaning prerelease identifier from ${version} for ${releaseType} bump`, "debug");
|
|
781
|
-
return "1.0.0";
|
|
782
|
-
}
|
|
783
801
|
log(`Cleaning prerelease identifier from ${version} for ${releaseType} bump`, "debug");
|
|
784
802
|
return bumpVersion(version, releaseType, prereleaseIdentifier);
|
|
785
803
|
}
|
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.6.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|