package-versioner 0.5.0 → 0.5.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/dist/index.cjs +36 -10
- package/dist/index.js +36 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -141,9 +141,6 @@ function printJsonOutput() {
|
|
|
141
141
|
|
|
142
142
|
// src/utils/logging.ts
|
|
143
143
|
function log(message, status = "info") {
|
|
144
|
-
if (isJsonOutputMode() && status !== "error") {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
144
|
let chalkFn;
|
|
148
145
|
switch (status) {
|
|
149
146
|
case "success":
|
|
@@ -161,7 +158,18 @@ function log(message, status = "info") {
|
|
|
161
158
|
default:
|
|
162
159
|
chalkFn = import_chalk.default.blue;
|
|
163
160
|
}
|
|
164
|
-
|
|
161
|
+
if (isJsonOutputMode()) {
|
|
162
|
+
if (status === "error") {
|
|
163
|
+
chalkFn(message);
|
|
164
|
+
console.error(message);
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (status === "error") {
|
|
169
|
+
console.error(chalkFn(message));
|
|
170
|
+
} else {
|
|
171
|
+
console.log(chalkFn(message));
|
|
172
|
+
}
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
// src/core/versionStrategies.ts
|
|
@@ -389,11 +397,12 @@ async function lastMergeBranchName(branches, baseBranch) {
|
|
|
389
397
|
}
|
|
390
398
|
async function getLatestTagForPackage(packageName, tagPrefix) {
|
|
391
399
|
try {
|
|
392
|
-
const
|
|
393
|
-
package: packageName,
|
|
400
|
+
const allTags = await (0, import_git_semver_tags.getSemverTags)({
|
|
394
401
|
tagPrefix
|
|
395
402
|
});
|
|
396
|
-
|
|
403
|
+
const packageTagPattern = tagPrefix ? new RegExp(`^${escapeRegExp(tagPrefix)}${escapeRegExp(packageName)}@`) : new RegExp(`^${escapeRegExp(packageName)}@`);
|
|
404
|
+
const packageTags = allTags.filter((tag) => packageTagPattern.test(tag));
|
|
405
|
+
return packageTags[0] || "";
|
|
397
406
|
} catch (error) {
|
|
398
407
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
399
408
|
log(`Failed to get latest tag for package ${packageName}: ${errorMessage}`, "error");
|
|
@@ -673,10 +682,27 @@ var PackageProcessor = class {
|
|
|
673
682
|
const name = pkg.packageJson.name;
|
|
674
683
|
const pkgPath = pkg.dir;
|
|
675
684
|
const formattedPrefix = formatTagPrefix(this.versionPrefix);
|
|
676
|
-
let latestTagResult =
|
|
685
|
+
let latestTagResult = "";
|
|
686
|
+
try {
|
|
687
|
+
latestTagResult = await getLatestTagForPackage(name, this.versionPrefix);
|
|
688
|
+
} catch (error) {
|
|
689
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
690
|
+
log(
|
|
691
|
+
`Error getting package-specific tag for ${name}, falling back to global tag: ${errorMessage}`,
|
|
692
|
+
"warning"
|
|
693
|
+
);
|
|
694
|
+
}
|
|
677
695
|
if (!latestTagResult) {
|
|
678
|
-
|
|
679
|
-
|
|
696
|
+
try {
|
|
697
|
+
const globalTagResult = await this.getLatestTag();
|
|
698
|
+
latestTagResult = globalTagResult || "";
|
|
699
|
+
if (globalTagResult) {
|
|
700
|
+
log(`Using global tag ${globalTagResult} as fallback for package ${name}`, "info");
|
|
701
|
+
}
|
|
702
|
+
} catch (error) {
|
|
703
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
704
|
+
log(`Error getting global tag, using empty tag value: ${errorMessage}`, "warning");
|
|
705
|
+
}
|
|
680
706
|
}
|
|
681
707
|
const latestTag = latestTagResult;
|
|
682
708
|
const nextVersion = await calculateVersion(this.fullConfig, {
|
package/dist/index.js
CHANGED
|
@@ -118,9 +118,6 @@ function printJsonOutput() {
|
|
|
118
118
|
|
|
119
119
|
// src/utils/logging.ts
|
|
120
120
|
function log(message, status = "info") {
|
|
121
|
-
if (isJsonOutputMode() && status !== "error") {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
121
|
let chalkFn;
|
|
125
122
|
switch (status) {
|
|
126
123
|
case "success":
|
|
@@ -138,7 +135,18 @@ function log(message, status = "info") {
|
|
|
138
135
|
default:
|
|
139
136
|
chalkFn = chalk.blue;
|
|
140
137
|
}
|
|
141
|
-
|
|
138
|
+
if (isJsonOutputMode()) {
|
|
139
|
+
if (status === "error") {
|
|
140
|
+
chalkFn(message);
|
|
141
|
+
console.error(message);
|
|
142
|
+
}
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (status === "error") {
|
|
146
|
+
console.error(chalkFn(message));
|
|
147
|
+
} else {
|
|
148
|
+
console.log(chalkFn(message));
|
|
149
|
+
}
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
// src/core/versionStrategies.ts
|
|
@@ -366,11 +374,12 @@ async function lastMergeBranchName(branches, baseBranch) {
|
|
|
366
374
|
}
|
|
367
375
|
async function getLatestTagForPackage(packageName, tagPrefix) {
|
|
368
376
|
try {
|
|
369
|
-
const
|
|
370
|
-
package: packageName,
|
|
377
|
+
const allTags = await getSemverTags({
|
|
371
378
|
tagPrefix
|
|
372
379
|
});
|
|
373
|
-
|
|
380
|
+
const packageTagPattern = tagPrefix ? new RegExp(`^${escapeRegExp(tagPrefix)}${escapeRegExp(packageName)}@`) : new RegExp(`^${escapeRegExp(packageName)}@`);
|
|
381
|
+
const packageTags = allTags.filter((tag) => packageTagPattern.test(tag));
|
|
382
|
+
return packageTags[0] || "";
|
|
374
383
|
} catch (error) {
|
|
375
384
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
376
385
|
log(`Failed to get latest tag for package ${packageName}: ${errorMessage}`, "error");
|
|
@@ -649,10 +658,27 @@ var PackageProcessor = class {
|
|
|
649
658
|
const name = pkg.packageJson.name;
|
|
650
659
|
const pkgPath = pkg.dir;
|
|
651
660
|
const formattedPrefix = formatTagPrefix(this.versionPrefix);
|
|
652
|
-
let latestTagResult =
|
|
661
|
+
let latestTagResult = "";
|
|
662
|
+
try {
|
|
663
|
+
latestTagResult = await getLatestTagForPackage(name, this.versionPrefix);
|
|
664
|
+
} catch (error) {
|
|
665
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
666
|
+
log(
|
|
667
|
+
`Error getting package-specific tag for ${name}, falling back to global tag: ${errorMessage}`,
|
|
668
|
+
"warning"
|
|
669
|
+
);
|
|
670
|
+
}
|
|
653
671
|
if (!latestTagResult) {
|
|
654
|
-
|
|
655
|
-
|
|
672
|
+
try {
|
|
673
|
+
const globalTagResult = await this.getLatestTag();
|
|
674
|
+
latestTagResult = globalTagResult || "";
|
|
675
|
+
if (globalTagResult) {
|
|
676
|
+
log(`Using global tag ${globalTagResult} as fallback for package ${name}`, "info");
|
|
677
|
+
}
|
|
678
|
+
} catch (error) {
|
|
679
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
680
|
+
log(`Error getting global tag, using empty tag value: ${errorMessage}`, "warning");
|
|
681
|
+
}
|
|
656
682
|
}
|
|
657
683
|
const latestTag = latestTagResult;
|
|
658
684
|
const nextVersion = await calculateVersion(this.fullConfig, {
|
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.5.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|