package-versioner 0.7.1 → 0.7.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/README.md +85 -6
- package/dist/index.cjs +246 -111
- package/dist/index.js +246 -111
- package/docs/versioning.md +182 -16
- package/package-versioner.schema.json +5 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -105,7 +105,23 @@ function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
|
|
|
105
105
|
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
106
106
|
return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
|
|
107
107
|
} catch (error) {
|
|
108
|
-
|
|
108
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
109
|
+
if (errorMessage.includes("ambiguous argument") && errorMessage.includes("unknown revision")) {
|
|
110
|
+
const tagName = revisionRange.split("..")[0] || revisionRange;
|
|
111
|
+
if (tagName.startsWith("v") && !tagName.includes("@")) {
|
|
112
|
+
log(
|
|
113
|
+
`Error: Tag "${tagName}" not found. If you're using package-specific tags (like "package-name@v1.0.0"), you may need to configure "tagTemplate" in your version.config.json to use: \${packageName}@\${prefix}\${version}`,
|
|
114
|
+
"error"
|
|
115
|
+
);
|
|
116
|
+
} else {
|
|
117
|
+
log(
|
|
118
|
+
`Error: Tag or revision "${tagName}" not found in the repository. Please check if this tag exists or if you need to fetch it from the remote.`,
|
|
119
|
+
"error"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
log(`Error extracting commits: ${errorMessage}`, "error");
|
|
124
|
+
}
|
|
109
125
|
return [];
|
|
110
126
|
}
|
|
111
127
|
}
|
|
@@ -755,38 +771,42 @@ import { getSemverTags } from "git-semver-tags";
|
|
|
755
771
|
function escapeRegExp(string) {
|
|
756
772
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
757
773
|
}
|
|
758
|
-
function
|
|
759
|
-
|
|
760
|
-
version,
|
|
761
|
-
prefix: versionPrefix || "",
|
|
762
|
-
packageName: packageName || ""
|
|
763
|
-
};
|
|
764
|
-
const template = packageName ? packageTagTemplate : tagTemplate;
|
|
765
|
-
return createTemplateString(template, variables);
|
|
766
|
-
}
|
|
767
|
-
function formatVersionPrefix(versionPrefix, scope) {
|
|
768
|
-
if (!versionPrefix) return "";
|
|
769
|
-
const cleanPrefix = versionPrefix.replace(/\/$/, "");
|
|
770
|
-
if (scope) {
|
|
771
|
-
return `${cleanPrefix}/${scope}`;
|
|
772
|
-
}
|
|
773
|
-
return cleanPrefix;
|
|
774
|
-
}
|
|
775
|
-
function formatCommitMessage(template, version, packageName, scope) {
|
|
776
|
-
return createTemplateString(template, {
|
|
777
|
-
version,
|
|
778
|
-
scope,
|
|
779
|
-
packageName: packageName || ""
|
|
780
|
-
});
|
|
774
|
+
function formatVersionPrefix(prefix) {
|
|
775
|
+
return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
|
|
781
776
|
}
|
|
782
|
-
function
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
777
|
+
function formatTag(version, prefix, packageName, template, packageSpecificTags) {
|
|
778
|
+
if ((template == null ? void 0 : template.includes("${packageName}")) && !packageName) {
|
|
779
|
+
log(
|
|
780
|
+
'Warning: Your tagTemplate contains ${packageName} but no package name is available.\nThis will result in an empty package name in the tag (e.g., "@v1.0.0" instead of "my-package@v1.0.0").\n\nTo fix this:\n\u2022 If using synced mode: Set "packageSpecificTags": true in your config to enable package names in tags\n\u2022 If you want global tags: Remove ${packageName} from your tagTemplate (e.g., use "${prefix}${version}")\n\u2022 If using single/async mode: Ensure your package.json has a valid "name" field',
|
|
781
|
+
"warning"
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
if (template) {
|
|
785
|
+
return template.replace(/\$\{version\}/g, version).replace(/\$\{prefix\}/g, prefix).replace(/\$\{packageName\}/g, packageName || "");
|
|
786
|
+
}
|
|
787
|
+
if (packageSpecificTags && packageName) {
|
|
788
|
+
return `${packageName}@${prefix}${version}`;
|
|
789
|
+
}
|
|
790
|
+
return `${prefix}${version}`;
|
|
791
|
+
}
|
|
792
|
+
function formatCommitMessage(template, version, packageName, additionalContext) {
|
|
793
|
+
if (template.includes("${packageName}") && !packageName) {
|
|
794
|
+
log(
|
|
795
|
+
'Warning: Your commitMessage template contains ${packageName} but no package name is available.\nThis will result in an empty package name in the commit message (e.g., "Release @v1.0.0").\n\nTo fix this:\n\u2022 If using synced mode: Set "packageSpecificTags": true to enable package names in commits\n\u2022 If you want generic commit messages: Remove ${packageName} from your commitMessage template\n\u2022 If using single/async mode: Ensure your package.json has a valid "name" field',
|
|
796
|
+
"warning"
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
|
|
800
|
+
if (additionalContext) {
|
|
801
|
+
for (const [key, value] of Object.entries(additionalContext)) {
|
|
802
|
+
const placeholder = `\${${key}}`;
|
|
803
|
+
result = result.replace(
|
|
804
|
+
new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
|
|
805
|
+
value
|
|
806
|
+
);
|
|
786
807
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}, template);
|
|
808
|
+
}
|
|
809
|
+
return result;
|
|
790
810
|
}
|
|
791
811
|
|
|
792
812
|
// src/git/tagsAndBranches.ts
|
|
@@ -829,56 +849,71 @@ async function lastMergeBranchName(branches, baseBranch) {
|
|
|
829
849
|
return null;
|
|
830
850
|
}
|
|
831
851
|
}
|
|
832
|
-
async function getLatestTagForPackage(packageName, versionPrefix) {
|
|
852
|
+
async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
833
853
|
try {
|
|
854
|
+
const tagTemplate = (options == null ? void 0 : options.tagTemplate) || "${prefix}${version}";
|
|
855
|
+
const packageSpecificTags = (options == null ? void 0 : options.packageSpecificTags) ?? false;
|
|
834
856
|
const escapedPackageName = escapeRegExp(packageName);
|
|
857
|
+
const escapedPrefix = versionPrefix ? escapeRegExp(versionPrefix) : "";
|
|
835
858
|
log(
|
|
836
|
-
`Looking for tags for package ${packageName} with prefix ${versionPrefix || "none"}`,
|
|
859
|
+
`Looking for tags for package ${packageName} with prefix ${versionPrefix || "none"}, packageSpecificTags: ${packageSpecificTags}`,
|
|
837
860
|
"debug"
|
|
838
861
|
);
|
|
839
862
|
const allTags = await getSemverTags({
|
|
840
863
|
tagPrefix: versionPrefix
|
|
841
864
|
});
|
|
842
865
|
log(`Retrieved ${allTags.length} tags: ${allTags.join(", ")}`, "debug");
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
866
|
+
if (packageSpecificTags) {
|
|
867
|
+
const packageTagPattern = escapeRegExp(tagTemplate).replace(/\\\$\\\{packageName\\\}/g, `(?:${escapedPackageName})`).replace(/\\\$\\\{prefix\\\}/g, `(?:${escapedPrefix})`).replace(/\\\$\\\{version\\\}/g, "(?:[0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9.-]+)?)");
|
|
868
|
+
log(`Using package tag pattern: ${packageTagPattern}`, "debug");
|
|
869
|
+
const packageTagRegex = new RegExp(`^${packageTagPattern}$`);
|
|
870
|
+
let packageTags = allTags.filter((tag) => packageTagRegex.test(tag));
|
|
847
871
|
if (packageTags.length > 0) {
|
|
848
|
-
log(
|
|
849
|
-
`Found ${packageTags.length} package tags using pattern: packageName@${versionPrefix}...`,
|
|
850
|
-
"debug"
|
|
851
|
-
);
|
|
872
|
+
log(`Found ${packageTags.length} package tags using configured pattern`, "debug");
|
|
852
873
|
log(`Using tag: ${packageTags[0]}`, "debug");
|
|
853
874
|
return packageTags[0];
|
|
854
875
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
876
|
+
if (versionPrefix) {
|
|
877
|
+
const pattern1 = new RegExp(`^${escapedPackageName}@${escapeRegExp(versionPrefix)}`);
|
|
878
|
+
packageTags = allTags.filter((tag) => pattern1.test(tag));
|
|
879
|
+
if (packageTags.length > 0) {
|
|
880
|
+
log(
|
|
881
|
+
`Found ${packageTags.length} package tags using pattern: packageName@${versionPrefix}...`,
|
|
882
|
+
"debug"
|
|
883
|
+
);
|
|
884
|
+
log(`Using tag: ${packageTags[0]}`, "debug");
|
|
885
|
+
return packageTags[0];
|
|
886
|
+
}
|
|
866
887
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
888
|
+
if (versionPrefix) {
|
|
889
|
+
const pattern2 = new RegExp(`^${escapeRegExp(versionPrefix)}${escapedPackageName}@`);
|
|
890
|
+
packageTags = allTags.filter((tag) => pattern2.test(tag));
|
|
891
|
+
if (packageTags.length > 0) {
|
|
892
|
+
log(
|
|
893
|
+
`Found ${packageTags.length} package tags using pattern: ${versionPrefix}packageName@...`,
|
|
894
|
+
"debug"
|
|
895
|
+
);
|
|
896
|
+
log(`Using tag: ${packageTags[0]}`, "debug");
|
|
897
|
+
return packageTags[0];
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
const pattern3 = new RegExp(`^${escapedPackageName}@`);
|
|
901
|
+
packageTags = allTags.filter((tag) => pattern3.test(tag));
|
|
902
|
+
log(`Found ${packageTags.length} package tags for ${packageName}`, "debug");
|
|
903
|
+
if (packageTags.length === 0) {
|
|
904
|
+
log("No matching tags found for pattern: packageName@version", "debug");
|
|
905
|
+
if (allTags.length > 0) {
|
|
906
|
+
log(`Available tags: ${allTags.join(", ")}`, "debug");
|
|
907
|
+
} else {
|
|
908
|
+
log("No tags available in the repository", "debug");
|
|
909
|
+
}
|
|
875
910
|
} else {
|
|
876
|
-
log(
|
|
911
|
+
log(`Using tag: ${packageTags[0]}`, "debug");
|
|
877
912
|
}
|
|
878
|
-
|
|
879
|
-
log(`Using tag: ${packageTags[0]}`, "debug");
|
|
913
|
+
return packageTags[0] || "";
|
|
880
914
|
}
|
|
881
|
-
|
|
915
|
+
log(`Package-specific tags disabled for ${packageName}, falling back to global tags`, "debug");
|
|
916
|
+
return "";
|
|
882
917
|
} catch (error) {
|
|
883
918
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
884
919
|
log(`Failed to get latest tag for package ${packageName}: ${errorMessage}`, "error");
|
|
@@ -1413,32 +1448,90 @@ function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
|
|
|
1413
1448
|
// src/core/versionCalculator.ts
|
|
1414
1449
|
async function calculateVersion(config, options) {
|
|
1415
1450
|
const {
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
versionPrefix
|
|
1451
|
+
type: configType,
|
|
1452
|
+
preset = "angular",
|
|
1453
|
+
versionPrefix,
|
|
1454
|
+
prereleaseIdentifier: configPrereleaseIdentifier,
|
|
1419
1455
|
branchPattern,
|
|
1420
|
-
baseBranch
|
|
1421
|
-
|
|
1456
|
+
baseBranch
|
|
1457
|
+
} = config;
|
|
1458
|
+
const {
|
|
1459
|
+
latestTag,
|
|
1460
|
+
name,
|
|
1422
1461
|
path: pkgPath,
|
|
1423
|
-
|
|
1462
|
+
type: optionsType,
|
|
1463
|
+
prereleaseIdentifier: optionsPrereleaseIdentifier
|
|
1424
1464
|
} = options;
|
|
1425
|
-
const
|
|
1465
|
+
const type = optionsType || configType;
|
|
1466
|
+
const prereleaseIdentifier = optionsPrereleaseIdentifier || configPrereleaseIdentifier;
|
|
1426
1467
|
const initialVersion = "0.1.0";
|
|
1468
|
+
const hasNoTags = !latestTag || latestTag.trim() === "";
|
|
1427
1469
|
const normalizedPrereleaseId = normalizePrereleaseIdentifier(prereleaseIdentifier, config);
|
|
1428
1470
|
try {
|
|
1429
1471
|
let determineTagSearchPattern2 = function(packageName, prefix) {
|
|
1430
|
-
if (packageName) {
|
|
1431
|
-
|
|
1432
|
-
const escapedPrefix = escapeRegExp(prefix);
|
|
1433
|
-
return `${escapedPackageName}[@]?${escapedPrefix}`;
|
|
1472
|
+
if (!packageName) {
|
|
1473
|
+
return prefix;
|
|
1434
1474
|
}
|
|
1435
|
-
return
|
|
1475
|
+
return `${packageName}@${prefix}`;
|
|
1476
|
+
}, escapeRegExp3 = function(string) {
|
|
1477
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1436
1478
|
};
|
|
1437
|
-
var determineTagSearchPattern = determineTagSearchPattern2;
|
|
1438
|
-
const
|
|
1439
|
-
const originalPrefix = versionPrefix;
|
|
1479
|
+
var determineTagSearchPattern = determineTagSearchPattern2, escapeRegExp2 = escapeRegExp3;
|
|
1480
|
+
const originalPrefix = versionPrefix || "";
|
|
1440
1481
|
const tagSearchPattern = determineTagSearchPattern2(name, originalPrefix);
|
|
1441
|
-
const escapedTagPattern =
|
|
1482
|
+
const escapedTagPattern = escapeRegExp3(tagSearchPattern);
|
|
1483
|
+
if (!hasNoTags && pkgPath) {
|
|
1484
|
+
const packageDir = pkgPath || cwd3();
|
|
1485
|
+
const manifestResult = getVersionFromManifests(packageDir);
|
|
1486
|
+
if (manifestResult.manifestFound && manifestResult.version) {
|
|
1487
|
+
const cleanedTag = semver2.clean(latestTag) || latestTag;
|
|
1488
|
+
const tagVersion = semver2.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
1489
|
+
const packageVersion = manifestResult.version;
|
|
1490
|
+
if (semver2.gt(packageVersion, tagVersion)) {
|
|
1491
|
+
log(
|
|
1492
|
+
`Warning: Version mismatch detected!
|
|
1493
|
+
\u2022 ${manifestResult.manifestType} version: ${packageVersion}
|
|
1494
|
+
\u2022 Latest Git tag version: ${tagVersion} (from ${latestTag})
|
|
1495
|
+
\u2022 Package version is AHEAD of Git tags
|
|
1496
|
+
|
|
1497
|
+
This usually happens when:
|
|
1498
|
+
\u2022 A version was released but the tag wasn't pushed to the remote repository
|
|
1499
|
+
\u2022 The ${manifestResult.manifestType} was manually updated without creating a corresponding tag
|
|
1500
|
+
\u2022 You're running in CI and the latest tag isn't available yet
|
|
1501
|
+
|
|
1502
|
+
The tool will use the Git tag version (${tagVersion}) as the base for calculation.
|
|
1503
|
+
Expected next version will be based on ${tagVersion}, not ${packageVersion}.
|
|
1504
|
+
|
|
1505
|
+
To fix this mismatch:
|
|
1506
|
+
\u2022 Push missing tags: git push origin --tags
|
|
1507
|
+
\u2022 Or use package version as base by ensuring tags are up to date`,
|
|
1508
|
+
"warning"
|
|
1509
|
+
);
|
|
1510
|
+
} else if (semver2.gt(tagVersion, packageVersion)) {
|
|
1511
|
+
log(
|
|
1512
|
+
`Warning: Version mismatch detected!
|
|
1513
|
+
\u2022 ${manifestResult.manifestType} version: ${packageVersion}
|
|
1514
|
+
\u2022 Latest Git tag version: ${tagVersion} (from ${latestTag})
|
|
1515
|
+
\u2022 Git tag version is AHEAD of package version
|
|
1516
|
+
|
|
1517
|
+
This usually happens when:
|
|
1518
|
+
\u2022 A release was tagged but the ${manifestResult.manifestType} wasn't updated
|
|
1519
|
+
\u2022 You're on an older branch that hasn't been updated with the latest version
|
|
1520
|
+
\u2022 Automated release process created tags but didn't update manifest files
|
|
1521
|
+
\u2022 You pulled tags but not the corresponding commits that update the package version
|
|
1522
|
+
|
|
1523
|
+
The tool will use the Git tag version (${tagVersion}) as the base for calculation.
|
|
1524
|
+
This will likely result in a version that's already been released.
|
|
1525
|
+
|
|
1526
|
+
To fix this mismatch:
|
|
1527
|
+
\u2022 Update ${manifestResult.manifestType}: Set version to ${tagVersion} or higher
|
|
1528
|
+
\u2022 Or checkout the branch/commit that corresponds to the tag
|
|
1529
|
+
\u2022 Or ensure your branch is up to date with the latest changes`,
|
|
1530
|
+
"warning"
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1442
1535
|
const specifiedType = type;
|
|
1443
1536
|
if (specifiedType) {
|
|
1444
1537
|
if (hasNoTags) {
|
|
@@ -1585,13 +1678,39 @@ function calculateNextVersion(version, manifestType, name, releaseType, prerelea
|
|
|
1585
1678
|
return result || initialVersion;
|
|
1586
1679
|
}
|
|
1587
1680
|
|
|
1681
|
+
// src/utils/packageMatching.ts
|
|
1682
|
+
function matchesPackageTarget(packageName, target) {
|
|
1683
|
+
if (packageName === target) {
|
|
1684
|
+
return true;
|
|
1685
|
+
}
|
|
1686
|
+
if (target.endsWith("/*")) {
|
|
1687
|
+
const scope = target.slice(0, -2);
|
|
1688
|
+
if (scope.startsWith("@")) {
|
|
1689
|
+
return packageName.startsWith(`${scope}/`);
|
|
1690
|
+
}
|
|
1691
|
+
return packageName.startsWith(`${scope}/`);
|
|
1692
|
+
}
|
|
1693
|
+
if (target === "*") {
|
|
1694
|
+
return true;
|
|
1695
|
+
}
|
|
1696
|
+
return false;
|
|
1697
|
+
}
|
|
1698
|
+
function shouldProcessPackage(packageName, targets = [], skip = []) {
|
|
1699
|
+
if (skip.includes(packageName)) {
|
|
1700
|
+
return false;
|
|
1701
|
+
}
|
|
1702
|
+
if (targets.length === 0) {
|
|
1703
|
+
return true;
|
|
1704
|
+
}
|
|
1705
|
+
return targets.some((target) => matchesPackageTarget(packageName, target));
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1588
1708
|
// src/package/packageProcessor.ts
|
|
1589
1709
|
var PackageProcessor = class {
|
|
1590
1710
|
skip;
|
|
1591
1711
|
targets;
|
|
1592
1712
|
versionPrefix;
|
|
1593
1713
|
tagTemplate;
|
|
1594
|
-
packageTagTemplate;
|
|
1595
1714
|
commitMessageTemplate;
|
|
1596
1715
|
dryRun;
|
|
1597
1716
|
skipHooks;
|
|
@@ -1604,7 +1723,6 @@ var PackageProcessor = class {
|
|
|
1604
1723
|
this.targets = options.targets || [];
|
|
1605
1724
|
this.versionPrefix = options.versionPrefix || "v";
|
|
1606
1725
|
this.tagTemplate = options.tagTemplate;
|
|
1607
|
-
this.packageTagTemplate = options.packageTagTemplate;
|
|
1608
1726
|
this.commitMessageTemplate = options.commitMessageTemplate || "";
|
|
1609
1727
|
this.dryRun = options.dryRun || false;
|
|
1610
1728
|
this.skipHooks = options.skipHooks || false;
|
|
@@ -1632,18 +1750,15 @@ var PackageProcessor = class {
|
|
|
1632
1750
|
const pkgsToConsider = packages.filter((pkg) => {
|
|
1633
1751
|
var _a2;
|
|
1634
1752
|
const pkgName = pkg.packageJson.name;
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
const isTargeted = this.targets.includes(pkgName);
|
|
1643
|
-
if (!isTargeted) {
|
|
1644
|
-
log(`Package ${pkgName} not in target list, skipping.`, "info");
|
|
1753
|
+
const shouldProcess = shouldProcessPackage(pkgName, this.targets, this.skip);
|
|
1754
|
+
if (!shouldProcess) {
|
|
1755
|
+
if ((_a2 = this.skip) == null ? void 0 : _a2.includes(pkgName)) {
|
|
1756
|
+
log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
|
|
1757
|
+
} else {
|
|
1758
|
+
log(`Package ${pkgName} not in target list, skipping.`, "info");
|
|
1759
|
+
}
|
|
1645
1760
|
}
|
|
1646
|
-
return
|
|
1761
|
+
return shouldProcess;
|
|
1647
1762
|
});
|
|
1648
1763
|
log(`Found ${pkgsToConsider.length} targeted package(s) to process after filtering.`, "info");
|
|
1649
1764
|
if (pkgsToConsider.length === 0) {
|
|
@@ -1656,7 +1771,10 @@ var PackageProcessor = class {
|
|
|
1656
1771
|
const formattedPrefix = formatVersionPrefix(this.versionPrefix);
|
|
1657
1772
|
let latestTagResult = "";
|
|
1658
1773
|
try {
|
|
1659
|
-
latestTagResult = await getLatestTagForPackage(name, this.versionPrefix
|
|
1774
|
+
latestTagResult = await getLatestTagForPackage(name, this.versionPrefix, {
|
|
1775
|
+
tagTemplate: this.tagTemplate,
|
|
1776
|
+
packageSpecificTags: this.fullConfig.packageSpecificTags
|
|
1777
|
+
});
|
|
1660
1778
|
} catch (error) {
|
|
1661
1779
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1662
1780
|
log(
|
|
@@ -1788,7 +1906,7 @@ var PackageProcessor = class {
|
|
|
1788
1906
|
this.versionPrefix,
|
|
1789
1907
|
name,
|
|
1790
1908
|
this.tagTemplate,
|
|
1791
|
-
this.
|
|
1909
|
+
this.fullConfig.packageSpecificTags
|
|
1792
1910
|
);
|
|
1793
1911
|
const tagMessage = `chore(release): ${name} ${nextVersion}`;
|
|
1794
1912
|
addTag(packageTag);
|
|
@@ -1874,16 +1992,9 @@ var PackageProcessor = class {
|
|
|
1874
1992
|
};
|
|
1875
1993
|
|
|
1876
1994
|
// src/core/versionStrategies.ts
|
|
1877
|
-
function
|
|
1878
|
-
var _a;
|
|
1995
|
+
function shouldProcessPackage2(pkg, config, targets = []) {
|
|
1879
1996
|
const pkgName = pkg.packageJson.name;
|
|
1880
|
-
|
|
1881
|
-
return false;
|
|
1882
|
-
}
|
|
1883
|
-
if (!targets || targets.length === 0) {
|
|
1884
|
-
return true;
|
|
1885
|
-
}
|
|
1886
|
-
return targets.includes(pkgName);
|
|
1997
|
+
return shouldProcessPackage(pkgName, targets, config.skip);
|
|
1887
1998
|
}
|
|
1888
1999
|
function createSyncedStrategy(config) {
|
|
1889
2000
|
return async (packages) => {
|
|
@@ -1939,6 +2050,7 @@ function createSyncedStrategy(config) {
|
|
|
1939
2050
|
}
|
|
1940
2051
|
const files = [];
|
|
1941
2052
|
const updatedPackages = [];
|
|
2053
|
+
const processedPaths = /* @__PURE__ */ new Set();
|
|
1942
2054
|
try {
|
|
1943
2055
|
if (packages.root) {
|
|
1944
2056
|
const rootPkgPath = path7.join(packages.root, "package.json");
|
|
@@ -1946,6 +2058,7 @@ function createSyncedStrategy(config) {
|
|
|
1946
2058
|
updatePackageVersion(rootPkgPath, nextVersion);
|
|
1947
2059
|
files.push(rootPkgPath);
|
|
1948
2060
|
updatedPackages.push("root");
|
|
2061
|
+
processedPaths.add(rootPkgPath);
|
|
1949
2062
|
}
|
|
1950
2063
|
} else {
|
|
1951
2064
|
log("Root package path is undefined, skipping root package.json update", "warning");
|
|
@@ -1955,13 +2068,17 @@ function createSyncedStrategy(config) {
|
|
|
1955
2068
|
log(`Failed to update root package.json: ${errMessage}`, "error");
|
|
1956
2069
|
}
|
|
1957
2070
|
for (const pkg of packages.packages) {
|
|
1958
|
-
if (!
|
|
2071
|
+
if (!shouldProcessPackage2(pkg, config)) {
|
|
1959
2072
|
continue;
|
|
1960
2073
|
}
|
|
1961
2074
|
const packageJsonPath = path7.join(pkg.dir, "package.json");
|
|
2075
|
+
if (processedPaths.has(packageJsonPath)) {
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
1962
2078
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
1963
2079
|
files.push(packageJsonPath);
|
|
1964
2080
|
updatedPackages.push(pkg.packageJson.name);
|
|
2081
|
+
processedPaths.add(packageJsonPath);
|
|
1965
2082
|
}
|
|
1966
2083
|
if (updatedPackages.length > 0) {
|
|
1967
2084
|
log(`Updated ${updatedPackages.length} package(s) to version ${nextVersion}`, "success");
|
|
@@ -1969,8 +2086,25 @@ function createSyncedStrategy(config) {
|
|
|
1969
2086
|
log("No packages were updated", "warning");
|
|
1970
2087
|
return;
|
|
1971
2088
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
2089
|
+
let tagPackageName = null;
|
|
2090
|
+
let commitPackageName = void 0;
|
|
2091
|
+
if (config.packageSpecificTags && packages.packages.length === 1) {
|
|
2092
|
+
tagPackageName = packages.packages[0].packageJson.name;
|
|
2093
|
+
commitPackageName = packages.packages[0].packageJson.name;
|
|
2094
|
+
}
|
|
2095
|
+
const nextTag = formatTag(
|
|
2096
|
+
nextVersion,
|
|
2097
|
+
formattedPrefix,
|
|
2098
|
+
tagPackageName,
|
|
2099
|
+
tagTemplate,
|
|
2100
|
+
config.packageSpecificTags || false
|
|
2101
|
+
);
|
|
2102
|
+
const formattedCommitMessage = formatCommitMessage(
|
|
2103
|
+
commitMessage,
|
|
2104
|
+
nextVersion,
|
|
2105
|
+
commitPackageName,
|
|
2106
|
+
void 0
|
|
2107
|
+
);
|
|
1974
2108
|
await createGitCommitAndTag(files, nextTag, formattedCommitMessage, skipHooks, dryRun);
|
|
1975
2109
|
} catch (error) {
|
|
1976
2110
|
if (error instanceof VersionError || error instanceof GitError) {
|
|
@@ -1991,7 +2125,6 @@ function createSingleStrategy(config) {
|
|
|
1991
2125
|
mainPackage,
|
|
1992
2126
|
versionPrefix,
|
|
1993
2127
|
tagTemplate,
|
|
1994
|
-
packageTagTemplate,
|
|
1995
2128
|
commitMessage = "chore(release): ${version}",
|
|
1996
2129
|
dryRun,
|
|
1997
2130
|
skipHooks
|
|
@@ -2013,7 +2146,10 @@ function createSingleStrategy(config) {
|
|
|
2013
2146
|
}
|
|
2014
2147
|
const pkgPath = pkg.dir;
|
|
2015
2148
|
const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
|
|
2016
|
-
let latestTagResult = await getLatestTagForPackage(packageName, formattedPrefix
|
|
2149
|
+
let latestTagResult = await getLatestTagForPackage(packageName, formattedPrefix, {
|
|
2150
|
+
tagTemplate,
|
|
2151
|
+
packageSpecificTags: config.packageSpecificTags
|
|
2152
|
+
});
|
|
2017
2153
|
if (!latestTagResult) {
|
|
2018
2154
|
const globalTagResult = await getLatestTag();
|
|
2019
2155
|
latestTagResult = globalTagResult || "";
|
|
@@ -2044,7 +2180,7 @@ function createSingleStrategy(config) {
|
|
|
2044
2180
|
formattedPrefix,
|
|
2045
2181
|
packageName,
|
|
2046
2182
|
tagTemplate,
|
|
2047
|
-
|
|
2183
|
+
config.packageSpecificTags
|
|
2048
2184
|
);
|
|
2049
2185
|
const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
2050
2186
|
await createGitCommitAndTag(
|
|
@@ -2077,7 +2213,6 @@ function createAsyncStrategy(config) {
|
|
|
2077
2213
|
targets: config.packages || [],
|
|
2078
2214
|
versionPrefix: config.versionPrefix || "v",
|
|
2079
2215
|
tagTemplate: config.tagTemplate,
|
|
2080
|
-
packageTagTemplate: config.packageTagTemplate,
|
|
2081
2216
|
commitMessageTemplate: config.commitMessage || "",
|
|
2082
2217
|
dryRun: config.dryRun || false,
|
|
2083
2218
|
skipHooks: config.skipHooks || false,
|