package-versioner 0.5.4 → 0.6.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 +20 -2
- package/dist/index.cjs +318 -170
- package/dist/index.js +317 -170
- package/docs/VERSIONING_STRATEGIES.md +30 -1
- package/package.json +10 -8
package/dist/index.cjs
CHANGED
|
@@ -34,8 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
run: () => run
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var
|
|
38
|
-
var
|
|
37
|
+
var fs8 = __toESM(require("fs"), 1);
|
|
38
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
39
39
|
var import_commander = require("commander");
|
|
40
40
|
|
|
41
41
|
// src/config.ts
|
|
@@ -190,8 +190,8 @@ function log(message, level = "info") {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// src/core/versionStrategies.ts
|
|
193
|
-
var
|
|
194
|
-
var
|
|
193
|
+
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
194
|
+
var path5 = __toESM(require("path"), 1);
|
|
195
195
|
|
|
196
196
|
// src/git/commands.ts
|
|
197
197
|
var import_node_process2 = require("process");
|
|
@@ -473,15 +473,84 @@ async function getLatestTagForPackage(packageName, versionPrefix) {
|
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
// src/package/packageManagement.ts
|
|
476
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
477
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
478
|
+
|
|
479
|
+
// src/cargo/cargoHandler.ts
|
|
476
480
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
477
481
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
482
|
+
var TOML = __toESM(require("smol-toml"), 1);
|
|
483
|
+
function getCargoInfo(cargoPath) {
|
|
484
|
+
var _a;
|
|
485
|
+
if (!import_node_fs2.default.existsSync(cargoPath)) {
|
|
486
|
+
log(`Cargo.toml file not found at: ${cargoPath}`, "error");
|
|
487
|
+
throw new Error(`Cargo.toml file not found at: ${cargoPath}`);
|
|
488
|
+
}
|
|
489
|
+
try {
|
|
490
|
+
const fileContent = import_node_fs2.default.readFileSync(cargoPath, "utf8");
|
|
491
|
+
const cargo = TOML.parse(fileContent);
|
|
492
|
+
if (!((_a = cargo.package) == null ? void 0 : _a.name)) {
|
|
493
|
+
log(`Package name not found in: ${cargoPath}`, "error");
|
|
494
|
+
throw new Error(`Package name not found in: ${cargoPath}`);
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
name: cargo.package.name,
|
|
498
|
+
version: cargo.package.version || "0.0.0",
|
|
499
|
+
path: cargoPath,
|
|
500
|
+
dir: import_node_path2.default.dirname(cargoPath),
|
|
501
|
+
content: cargo
|
|
502
|
+
};
|
|
503
|
+
} catch (error) {
|
|
504
|
+
log(`Error reading Cargo.toml: ${cargoPath}`, "error");
|
|
505
|
+
if (error instanceof Error) {
|
|
506
|
+
log(error.message, "error");
|
|
507
|
+
throw error;
|
|
508
|
+
}
|
|
509
|
+
throw new Error(`Failed to process Cargo.toml at ${cargoPath}`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function isCargoToml(filePath) {
|
|
513
|
+
return import_node_path2.default.basename(filePath) === "Cargo.toml";
|
|
514
|
+
}
|
|
515
|
+
function updateCargoVersion(cargoPath, version) {
|
|
516
|
+
var _a;
|
|
517
|
+
try {
|
|
518
|
+
const originalContent = import_node_fs2.default.readFileSync(cargoPath, "utf8");
|
|
519
|
+
const cargo = TOML.parse(originalContent);
|
|
520
|
+
const packageName = (_a = cargo.package) == null ? void 0 : _a.name;
|
|
521
|
+
if (!packageName) {
|
|
522
|
+
throw new Error(`No package name found in ${cargoPath}`);
|
|
523
|
+
}
|
|
524
|
+
if (!cargo.package) {
|
|
525
|
+
cargo.package = { name: packageName, version };
|
|
526
|
+
} else {
|
|
527
|
+
cargo.package.version = version;
|
|
528
|
+
}
|
|
529
|
+
const updatedContent = TOML.stringify(cargo);
|
|
530
|
+
import_node_fs2.default.writeFileSync(cargoPath, updatedContent);
|
|
531
|
+
addPackageUpdate(packageName, version, cargoPath);
|
|
532
|
+
log(`Updated Cargo.toml at ${cargoPath} to version ${version}`, "success");
|
|
533
|
+
} catch (error) {
|
|
534
|
+
log(`Failed to update Cargo.toml at ${cargoPath}`, "error");
|
|
535
|
+
if (error instanceof Error) {
|
|
536
|
+
log(error.message, "error");
|
|
537
|
+
}
|
|
538
|
+
throw error;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// src/package/packageManagement.ts
|
|
478
543
|
function updatePackageVersion(packagePath, version) {
|
|
544
|
+
if (isCargoToml(packagePath)) {
|
|
545
|
+
updateCargoVersion(packagePath, version);
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
479
548
|
try {
|
|
480
|
-
const packageContent =
|
|
549
|
+
const packageContent = import_node_fs3.default.readFileSync(packagePath, "utf8");
|
|
481
550
|
const packageJson = JSON.parse(packageContent);
|
|
482
551
|
const packageName = packageJson.name;
|
|
483
552
|
packageJson.version = version;
|
|
484
|
-
|
|
553
|
+
import_node_fs3.default.writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}
|
|
485
554
|
`);
|
|
486
555
|
addPackageUpdate(packageName, version, packagePath);
|
|
487
556
|
log(`Updated package.json at ${packagePath} to version ${version}`, "success");
|
|
@@ -495,125 +564,218 @@ function updatePackageVersion(packagePath, version) {
|
|
|
495
564
|
}
|
|
496
565
|
|
|
497
566
|
// src/package/packageProcessor.ts
|
|
498
|
-
var
|
|
499
|
-
var
|
|
567
|
+
var fs6 = __toESM(require("fs"), 1);
|
|
568
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
500
569
|
var import_node_process4 = require("process");
|
|
501
570
|
|
|
502
571
|
// src/core/versionCalculator.ts
|
|
503
|
-
var fs3 = __toESM(require("fs"), 1);
|
|
504
|
-
var path2 = __toESM(require("path"), 1);
|
|
505
572
|
var import_node_process3 = require("process");
|
|
506
573
|
var import_conventional_recommended_bump = require("conventional-recommended-bump");
|
|
507
|
-
var
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
const
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
574
|
+
var import_semver2 = __toESM(require("semver"), 1);
|
|
575
|
+
|
|
576
|
+
// src/utils/manifestHelpers.ts
|
|
577
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
578
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
579
|
+
function getVersionFromManifests(packageDir) {
|
|
580
|
+
const packageJsonPath = import_node_path4.default.join(packageDir, "package.json");
|
|
581
|
+
const cargoTomlPath = import_node_path4.default.join(packageDir, "Cargo.toml");
|
|
582
|
+
if (import_node_fs4.default.existsSync(packageJsonPath)) {
|
|
583
|
+
try {
|
|
584
|
+
const packageJson = JSON.parse(import_node_fs4.default.readFileSync(packageJsonPath, "utf-8"));
|
|
585
|
+
if (packageJson.version) {
|
|
586
|
+
log(`Found version ${packageJson.version} in package.json`, "debug");
|
|
587
|
+
return {
|
|
588
|
+
version: packageJson.version,
|
|
589
|
+
manifestFound: true,
|
|
590
|
+
manifestPath: packageJsonPath,
|
|
591
|
+
manifestType: "package.json"
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
log("No version field found in package.json", "debug");
|
|
595
|
+
} catch (packageJsonError) {
|
|
596
|
+
const errMsg = packageJsonError instanceof Error ? packageJsonError.message : String(packageJsonError);
|
|
597
|
+
log(`Error reading package.json: ${errMsg}`, "warning");
|
|
519
598
|
}
|
|
520
|
-
return prefix;
|
|
521
599
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
log(
|
|
539
|
-
`Cleaning prerelease identifier from ${currentVersion} for ${specifiedType} bump`,
|
|
540
|
-
"debug"
|
|
541
|
-
);
|
|
542
|
-
return bumpVersion(currentVersion, specifiedType, prereleaseIdentifier);
|
|
600
|
+
if (import_node_fs4.default.existsSync(cargoTomlPath)) {
|
|
601
|
+
try {
|
|
602
|
+
const cargoInfo = getCargoInfo(cargoTomlPath);
|
|
603
|
+
if (cargoInfo.version) {
|
|
604
|
+
log(`Found version ${cargoInfo.version} in Cargo.toml`, "debug");
|
|
605
|
+
return {
|
|
606
|
+
version: cargoInfo.version,
|
|
607
|
+
manifestFound: true,
|
|
608
|
+
manifestPath: cargoTomlPath,
|
|
609
|
+
manifestType: "Cargo.toml"
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
log("No version field found in Cargo.toml", "debug");
|
|
613
|
+
} catch (cargoTomlError) {
|
|
614
|
+
const errMsg = cargoTomlError instanceof Error ? cargoTomlError.message : String(cargoTomlError);
|
|
615
|
+
log(`Error reading Cargo.toml: ${errMsg}`, "warning");
|
|
543
616
|
}
|
|
544
|
-
return import_semver.default.inc(currentVersion, specifiedType, prereleaseIdentifier) || "";
|
|
545
617
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
618
|
+
return {
|
|
619
|
+
version: null,
|
|
620
|
+
manifestFound: false,
|
|
621
|
+
manifestPath: "",
|
|
622
|
+
manifestType: null
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function throwIfNoManifestsFound(packageDir) {
|
|
626
|
+
const packageJsonPath = import_node_path4.default.join(packageDir, "package.json");
|
|
627
|
+
const cargoTomlPath = import_node_path4.default.join(packageDir, "Cargo.toml");
|
|
628
|
+
throw new Error(
|
|
629
|
+
`Neither package.json nor Cargo.toml found at ${packageDir}. Checked paths: ${packageJsonPath}, ${cargoTomlPath}. Cannot determine version.`
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// src/utils/versionUtils.ts
|
|
634
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
635
|
+
var import_semver = __toESM(require("semver"), 1);
|
|
636
|
+
var TOML2 = __toESM(require("smol-toml"), 1);
|
|
637
|
+
var STANDARD_BUMP_TYPES = ["major", "minor", "patch"];
|
|
638
|
+
function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
|
|
639
|
+
if (import_semver.default.prerelease(currentVersion) && STANDARD_BUMP_TYPES.includes(bumpType)) {
|
|
640
|
+
const parsed = import_semver.default.parse(currentVersion);
|
|
641
|
+
if (bumpType === "major" && (parsed == null ? void 0 : parsed.major) === 1 && parsed.minor === 0 && parsed.patch === 0 && import_semver.default.prerelease(currentVersion)) {
|
|
642
|
+
return `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
551
643
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
644
|
+
log(`Cleaning prerelease identifier from ${currentVersion} for ${bumpType} bump`, "debug");
|
|
645
|
+
return import_semver.default.inc(currentVersion, bumpType) || "";
|
|
646
|
+
}
|
|
647
|
+
return import_semver.default.inc(currentVersion, bumpType, prereleaseIdentifier) || "";
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// src/core/versionCalculator.ts
|
|
651
|
+
async function calculateVersion(config, options) {
|
|
652
|
+
const {
|
|
653
|
+
latestTag = "",
|
|
654
|
+
type,
|
|
655
|
+
versionPrefix = "",
|
|
656
|
+
branchPattern,
|
|
657
|
+
baseBranch,
|
|
658
|
+
prereleaseIdentifier,
|
|
659
|
+
path: pkgPath,
|
|
660
|
+
name
|
|
661
|
+
} = options;
|
|
662
|
+
const preset = config.preset || "conventional-commits";
|
|
663
|
+
const initialVersion = "0.1.0";
|
|
664
|
+
try {
|
|
665
|
+
let determineTagSearchPattern2 = function(packageName, prefix) {
|
|
666
|
+
if (packageName) {
|
|
667
|
+
const escapedPackageName = escapeRegExp(packageName);
|
|
668
|
+
const escapedPrefix = escapeRegExp(prefix);
|
|
669
|
+
return `${escapedPackageName}[@]?${escapedPrefix}`;
|
|
564
670
|
}
|
|
565
|
-
|
|
566
|
-
|
|
671
|
+
return escapeRegExp(prefix);
|
|
672
|
+
};
|
|
673
|
+
var determineTagSearchPattern = determineTagSearchPattern2;
|
|
674
|
+
const hasNoTags = !latestTag;
|
|
675
|
+
const originalPrefix = versionPrefix;
|
|
676
|
+
const tagSearchPattern = determineTagSearchPattern2(name, originalPrefix);
|
|
677
|
+
const escapedTagPattern = escapeRegExp(tagSearchPattern);
|
|
678
|
+
const specifiedType = type;
|
|
679
|
+
if (specifiedType) {
|
|
567
680
|
if (hasNoTags) {
|
|
568
681
|
return getPackageVersionFallback(
|
|
569
682
|
pkgPath,
|
|
570
683
|
name,
|
|
571
|
-
|
|
684
|
+
specifiedType,
|
|
572
685
|
prereleaseIdentifier,
|
|
573
686
|
initialVersion
|
|
574
687
|
);
|
|
575
688
|
}
|
|
576
|
-
const cleanedTag =
|
|
577
|
-
const currentVersion =
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
try {
|
|
583
|
-
const bumper = new import_conventional_recommended_bump.Bumper();
|
|
584
|
-
bumper.loadPreset(preset);
|
|
585
|
-
const recommendedBump = await bumper.bump();
|
|
586
|
-
const releaseTypeFromCommits = recommendedBump == null ? void 0 : recommendedBump.releaseType;
|
|
587
|
-
if (hasNoTags) {
|
|
588
|
-
if (releaseTypeFromCommits) {
|
|
589
|
-
return getPackageVersionFallback(
|
|
590
|
-
pkgPath,
|
|
591
|
-
name,
|
|
592
|
-
releaseTypeFromCommits,
|
|
593
|
-
prereleaseIdentifier,
|
|
594
|
-
initialVersion
|
|
689
|
+
const cleanedTag = import_semver2.default.clean(latestTag) || latestTag;
|
|
690
|
+
const currentVersion = import_semver2.default.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
691
|
+
if (STANDARD_BUMP_TYPES.includes(specifiedType) && import_semver2.default.prerelease(currentVersion)) {
|
|
692
|
+
log(
|
|
693
|
+
`Cleaning prerelease identifier from ${currentVersion} for ${specifiedType} bump`,
|
|
694
|
+
"debug"
|
|
595
695
|
);
|
|
696
|
+
return bumpVersion(currentVersion, specifiedType, prereleaseIdentifier);
|
|
596
697
|
}
|
|
597
|
-
return
|
|
698
|
+
return import_semver2.default.inc(currentVersion, specifiedType, prereleaseIdentifier) || "";
|
|
598
699
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
700
|
+
if (branchPattern && branchPattern.length > 0) {
|
|
701
|
+
const currentBranch = getCurrentBranch();
|
|
702
|
+
if (baseBranch) {
|
|
703
|
+
lastMergeBranchName(branchPattern, baseBranch);
|
|
704
|
+
}
|
|
705
|
+
const branchToCheck = currentBranch;
|
|
706
|
+
let branchVersionType;
|
|
707
|
+
for (const pattern of branchPattern) {
|
|
708
|
+
if (!pattern.includes(":")) {
|
|
709
|
+
log(`Invalid branch pattern "${pattern}" - missing colon. Skipping.`, "warning");
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
const [patternRegex, releaseType] = pattern.split(":");
|
|
713
|
+
if (new RegExp(patternRegex).test(branchToCheck)) {
|
|
714
|
+
branchVersionType = releaseType;
|
|
715
|
+
log(`Using branch pattern ${patternRegex} for version type ${releaseType}`, "debug");
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
if (branchVersionType) {
|
|
720
|
+
if (hasNoTags) {
|
|
721
|
+
return getPackageVersionFallback(
|
|
722
|
+
pkgPath,
|
|
723
|
+
name,
|
|
724
|
+
branchVersionType,
|
|
725
|
+
prereleaseIdentifier,
|
|
726
|
+
initialVersion
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
const cleanedTag = import_semver2.default.clean(latestTag) || latestTag;
|
|
730
|
+
const currentVersion = import_semver2.default.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
731
|
+
log(`Applying ${branchVersionType} bump based on branch pattern`, "debug");
|
|
732
|
+
return import_semver2.default.inc(currentVersion, branchVersionType, void 0) || "";
|
|
733
|
+
}
|
|
607
734
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
735
|
+
try {
|
|
736
|
+
const bumper = new import_conventional_recommended_bump.Bumper();
|
|
737
|
+
bumper.loadPreset(preset);
|
|
738
|
+
const recommendedBump = await bumper.bump();
|
|
739
|
+
const releaseTypeFromCommits = recommendedBump == null ? void 0 : recommendedBump.releaseType;
|
|
740
|
+
if (hasNoTags) {
|
|
741
|
+
if (releaseTypeFromCommits) {
|
|
742
|
+
return getPackageVersionFallback(
|
|
743
|
+
pkgPath,
|
|
744
|
+
name,
|
|
745
|
+
releaseTypeFromCommits,
|
|
746
|
+
prereleaseIdentifier,
|
|
747
|
+
initialVersion
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
return initialVersion;
|
|
751
|
+
}
|
|
752
|
+
const checkPath = pkgPath || (0, import_node_process3.cwd)();
|
|
753
|
+
const commitsLength = getCommitsLength(checkPath);
|
|
754
|
+
if (commitsLength === 0) {
|
|
755
|
+
log(
|
|
756
|
+
`No new commits found for ${name || "project"} since ${latestTag}, skipping version bump`,
|
|
757
|
+
"info"
|
|
758
|
+
);
|
|
759
|
+
return "";
|
|
760
|
+
}
|
|
761
|
+
if (!releaseTypeFromCommits) {
|
|
762
|
+
log(
|
|
763
|
+
`No relevant commits found for ${name || "project"} since ${latestTag}, skipping version bump`,
|
|
764
|
+
"info"
|
|
765
|
+
);
|
|
766
|
+
return "";
|
|
767
|
+
}
|
|
768
|
+
const currentVersion = import_semver2.default.clean(latestTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
769
|
+
return import_semver2.default.inc(currentVersion, releaseTypeFromCommits, prereleaseIdentifier) || "";
|
|
770
|
+
} catch (error) {
|
|
771
|
+
log(`Failed to calculate version for ${name || "project"}`, "error");
|
|
772
|
+
console.error(error);
|
|
773
|
+
if (error instanceof Error && error.message.includes("No names found")) {
|
|
774
|
+
log("No tags found, proceeding with initial version calculation (if applicable).", "info");
|
|
775
|
+
return initialVersion;
|
|
776
|
+
}
|
|
777
|
+
throw error;
|
|
614
778
|
}
|
|
615
|
-
const currentVersion = import_semver.default.clean(latestTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
616
|
-
return import_semver.default.inc(currentVersion, releaseTypeFromCommits, prereleaseIdentifier) || "";
|
|
617
779
|
} catch (error) {
|
|
618
780
|
log(`Failed to calculate version for ${name || "project"}`, "error");
|
|
619
781
|
console.error(error);
|
|
@@ -626,51 +788,37 @@ async function calculateVersion(config, options) {
|
|
|
626
788
|
}
|
|
627
789
|
function getPackageVersionFallback(pkgPath, name, releaseType, prereleaseIdentifier, initialVersion) {
|
|
628
790
|
const packageDir = pkgPath || (0, import_node_process3.cwd)();
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
631
|
-
throw new Error(`package.json not found at ${packageJsonPath}. Cannot determine version.`);
|
|
632
|
-
}
|
|
633
|
-
try {
|
|
634
|
-
const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
635
|
-
if (!packageJson.version) {
|
|
636
|
-
log(`No version found in package.json. Using initial version ${initialVersion}`, "info");
|
|
637
|
-
return initialVersion;
|
|
638
|
-
}
|
|
791
|
+
const manifestResult = getVersionFromManifests(packageDir);
|
|
792
|
+
if (manifestResult.manifestFound && manifestResult.version) {
|
|
639
793
|
log(
|
|
640
|
-
`No tags found for ${name || "package"}, using
|
|
794
|
+
`No tags found for ${name || "package"}, using ${manifestResult.manifestType} version: ${manifestResult.version} as base`,
|
|
641
795
|
"info"
|
|
642
796
|
);
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
log(
|
|
652
|
-
`Cleaning prerelease identifier from ${packageJson.version} for ${releaseType} bump`,
|
|
653
|
-
"debug"
|
|
654
|
-
);
|
|
655
|
-
return bumpVersion(packageJson.version, releaseType, prereleaseIdentifier);
|
|
656
|
-
}
|
|
657
|
-
return import_semver.default.inc(packageJson.version, releaseType, prereleaseIdentifier) || initialVersion;
|
|
658
|
-
} catch (err) {
|
|
659
|
-
throw new Error(
|
|
660
|
-
`Error reading package.json: ${err instanceof Error ? err.message : String(err)}`
|
|
797
|
+
return calculateNextVersion(
|
|
798
|
+
manifestResult.version,
|
|
799
|
+
manifestResult.manifestType || "manifest",
|
|
800
|
+
name,
|
|
801
|
+
releaseType,
|
|
802
|
+
prereleaseIdentifier,
|
|
803
|
+
initialVersion
|
|
661
804
|
);
|
|
662
805
|
}
|
|
806
|
+
throwIfNoManifestsFound(packageDir);
|
|
663
807
|
}
|
|
664
|
-
function
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
808
|
+
function calculateNextVersion(version, manifestType, name, releaseType, prereleaseIdentifier, initialVersion) {
|
|
809
|
+
log(
|
|
810
|
+
`No tags found for ${name || "package"}, using ${manifestType} version: ${version} as base`,
|
|
811
|
+
"info"
|
|
812
|
+
);
|
|
813
|
+
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";
|
|
669
817
|
}
|
|
670
|
-
log(`Cleaning prerelease identifier from ${
|
|
671
|
-
return
|
|
818
|
+
log(`Cleaning prerelease identifier from ${version} for ${releaseType} bump`, "debug");
|
|
819
|
+
return bumpVersion(version, releaseType, prereleaseIdentifier);
|
|
672
820
|
}
|
|
673
|
-
return
|
|
821
|
+
return import_semver2.default.inc(version, releaseType, prereleaseIdentifier) || initialVersion;
|
|
674
822
|
}
|
|
675
823
|
|
|
676
824
|
// src/package/packageProcessor.ts
|
|
@@ -754,29 +902,22 @@ var PackageProcessor = class {
|
|
|
754
902
|
}
|
|
755
903
|
if (!latestTagResult) {
|
|
756
904
|
try {
|
|
757
|
-
const
|
|
758
|
-
let
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
latestTagResult = `${this.versionPrefix || ""}${packageJson.version}`;
|
|
772
|
-
usedPackageJsonFallback = true;
|
|
773
|
-
}
|
|
774
|
-
} catch (packageJsonError) {
|
|
775
|
-
const errMsg = packageJsonError instanceof Error ? packageJsonError.message : String(packageJsonError);
|
|
776
|
-
log(`Error reading package.json for ${name}: ${errMsg}`, "warning");
|
|
777
|
-
}
|
|
905
|
+
const packageDir = pkgPath;
|
|
906
|
+
let manifestFallbackUsed = false;
|
|
907
|
+
const manifestResult = getVersionFromManifests(packageDir);
|
|
908
|
+
if (manifestResult.manifestFound && manifestResult.version) {
|
|
909
|
+
log(
|
|
910
|
+
`Using ${manifestResult.manifestType} version ${manifestResult.version} for ${name} as no package-specific tags found`,
|
|
911
|
+
"info"
|
|
912
|
+
);
|
|
913
|
+
log(
|
|
914
|
+
`FALLBACK: Using package version from ${manifestResult.manifestType} instead of global tag`,
|
|
915
|
+
"debug"
|
|
916
|
+
);
|
|
917
|
+
latestTagResult = `${this.versionPrefix || ""}${manifestResult.version}`;
|
|
918
|
+
manifestFallbackUsed = true;
|
|
778
919
|
}
|
|
779
|
-
if (!
|
|
920
|
+
if (!manifestFallbackUsed) {
|
|
780
921
|
const globalTagResult = await this.getLatestTag();
|
|
781
922
|
if (globalTagResult) {
|
|
782
923
|
latestTagResult = globalTagResult;
|
|
@@ -802,7 +943,14 @@ var PackageProcessor = class {
|
|
|
802
943
|
if (!nextVersion) {
|
|
803
944
|
continue;
|
|
804
945
|
}
|
|
805
|
-
|
|
946
|
+
const packageJsonPath = import_node_path5.default.join(pkgPath, "package.json");
|
|
947
|
+
const cargoTomlPath = import_node_path5.default.join(pkgPath, "Cargo.toml");
|
|
948
|
+
if (fs6.existsSync(packageJsonPath)) {
|
|
949
|
+
updatePackageVersion(packageJsonPath, nextVersion);
|
|
950
|
+
}
|
|
951
|
+
if (fs6.existsSync(cargoTomlPath)) {
|
|
952
|
+
updatePackageVersion(cargoTomlPath, nextVersion);
|
|
953
|
+
}
|
|
806
954
|
const packageTag = formatTag(
|
|
807
955
|
nextVersion,
|
|
808
956
|
this.versionPrefix,
|
|
@@ -833,7 +981,7 @@ var PackageProcessor = class {
|
|
|
833
981
|
log("No targeted packages required a version update.", "info");
|
|
834
982
|
return { updatedPackages: [], tags };
|
|
835
983
|
}
|
|
836
|
-
const filesToCommit = updatedPackagesInfo.map((info) =>
|
|
984
|
+
const filesToCommit = updatedPackagesInfo.map((info) => import_node_path5.default.join(info.path, "package.json"));
|
|
837
985
|
const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
|
|
838
986
|
const representativeVersion = ((_a = updatedPackagesInfo[0]) == null ? void 0 : _a.version) || "multiple";
|
|
839
987
|
let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
|
|
@@ -910,8 +1058,8 @@ function createSyncedStrategy(config) {
|
|
|
910
1058
|
const files = [];
|
|
911
1059
|
const updatedPackages = [];
|
|
912
1060
|
try {
|
|
913
|
-
const rootPkgPath =
|
|
914
|
-
if (
|
|
1061
|
+
const rootPkgPath = path5.join(packages.root, "package.json");
|
|
1062
|
+
if (import_node_fs6.default.existsSync(rootPkgPath)) {
|
|
915
1063
|
updatePackageVersion(rootPkgPath, nextVersion);
|
|
916
1064
|
files.push(rootPkgPath);
|
|
917
1065
|
updatedPackages.push("root");
|
|
@@ -923,7 +1071,7 @@ function createSyncedStrategy(config) {
|
|
|
923
1071
|
if (!shouldProcessPackage(pkg, config)) {
|
|
924
1072
|
continue;
|
|
925
1073
|
}
|
|
926
|
-
const packageJsonPath =
|
|
1074
|
+
const packageJsonPath = path5.join(pkg.dir, "package.json");
|
|
927
1075
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
928
1076
|
files.push(packageJsonPath);
|
|
929
1077
|
updatedPackages.push(pkg.packageJson.name);
|
|
@@ -996,7 +1144,7 @@ function createSingleStrategy(config) {
|
|
|
996
1144
|
log(`No version change needed for ${packageName}`, "info");
|
|
997
1145
|
return;
|
|
998
1146
|
}
|
|
999
|
-
const packageJsonPath =
|
|
1147
|
+
const packageJsonPath = path5.join(pkgPath, "package.json");
|
|
1000
1148
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
1001
1149
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
1002
1150
|
const nextTag = formatTag(
|
|
@@ -1175,11 +1323,11 @@ var VersionEngine = class {
|
|
|
1175
1323
|
var import_meta = {};
|
|
1176
1324
|
function getPackageVersion() {
|
|
1177
1325
|
try {
|
|
1178
|
-
const packageJsonPath =
|
|
1179
|
-
|
|
1326
|
+
const packageJsonPath = import_node_path6.default.resolve(
|
|
1327
|
+
import_node_path6.default.dirname(import_meta.url.replace("file:", "")),
|
|
1180
1328
|
"../package.json"
|
|
1181
1329
|
);
|
|
1182
|
-
const packageJsonContent =
|
|
1330
|
+
const packageJsonContent = fs8.readFileSync(packageJsonPath, "utf-8");
|
|
1183
1331
|
const packageJson = JSON.parse(packageJsonContent);
|
|
1184
1332
|
return packageJson.version || "0.0.0";
|
|
1185
1333
|
} catch (error) {
|
|
@@ -1209,7 +1357,7 @@ async function run() {
|
|
|
1209
1357
|
if (options.synced) config.synced = true;
|
|
1210
1358
|
if (options.bump) config.type = options.bump;
|
|
1211
1359
|
if (options.prerelease)
|
|
1212
|
-
config.prereleaseIdentifier = options.prerelease === true ? "
|
|
1360
|
+
config.prereleaseIdentifier = options.prerelease === true ? "next" : options.prerelease;
|
|
1213
1361
|
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
1214
1362
|
const engine = new VersionEngine(config, !!options.json);
|
|
1215
1363
|
if (config.synced) {
|