package-versioner 0.9.1 → 0.9.3
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/baseError-XWEU2UI6.js +6 -0
- package/dist/chunk-IXZZQDKS.js +122 -0
- package/dist/index.cjs +276 -63
- package/dist/index.js +172 -119
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// src/utils/logging.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import figlet from "figlet";
|
|
4
|
+
|
|
5
|
+
// src/utils/jsonOutput.ts
|
|
6
|
+
var _jsonOutputMode = false;
|
|
7
|
+
var _jsonData = {
|
|
8
|
+
dryRun: false,
|
|
9
|
+
updates: [],
|
|
10
|
+
tags: []
|
|
11
|
+
};
|
|
12
|
+
function enableJsonOutput(dryRun = false) {
|
|
13
|
+
_jsonOutputMode = true;
|
|
14
|
+
_jsonData.dryRun = dryRun;
|
|
15
|
+
_jsonData.updates = [];
|
|
16
|
+
_jsonData.tags = [];
|
|
17
|
+
_jsonData.commitMessage = void 0;
|
|
18
|
+
}
|
|
19
|
+
function isJsonOutputMode() {
|
|
20
|
+
return _jsonOutputMode;
|
|
21
|
+
}
|
|
22
|
+
function addPackageUpdate(packageName, newVersion, filePath) {
|
|
23
|
+
if (!_jsonOutputMode) return;
|
|
24
|
+
_jsonData.updates.push({
|
|
25
|
+
packageName,
|
|
26
|
+
newVersion,
|
|
27
|
+
filePath
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function addTag(tag) {
|
|
31
|
+
if (!_jsonOutputMode) return;
|
|
32
|
+
_jsonData.tags.push(tag);
|
|
33
|
+
}
|
|
34
|
+
function setCommitMessage(message) {
|
|
35
|
+
if (!_jsonOutputMode) return;
|
|
36
|
+
_jsonData.commitMessage = message;
|
|
37
|
+
}
|
|
38
|
+
function printJsonOutput() {
|
|
39
|
+
if (_jsonOutputMode) {
|
|
40
|
+
console.log(JSON.stringify(_jsonData, null, 2));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/utils/logging.ts
|
|
45
|
+
function log(message, level = "info") {
|
|
46
|
+
const showDebug = process.env.DEBUG === "true" || process.env.DEBUG === "1";
|
|
47
|
+
if (level === "debug" && !showDebug) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let chalkFn;
|
|
51
|
+
switch (level) {
|
|
52
|
+
case "success":
|
|
53
|
+
chalkFn = chalk.green;
|
|
54
|
+
break;
|
|
55
|
+
case "warning":
|
|
56
|
+
chalkFn = chalk.yellow;
|
|
57
|
+
break;
|
|
58
|
+
case "error":
|
|
59
|
+
chalkFn = chalk.red;
|
|
60
|
+
break;
|
|
61
|
+
case "debug":
|
|
62
|
+
chalkFn = chalk.gray;
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
chalkFn = chalk.blue;
|
|
66
|
+
}
|
|
67
|
+
if (isJsonOutputMode()) {
|
|
68
|
+
if (level === "error") {
|
|
69
|
+
chalkFn(message);
|
|
70
|
+
console.error(message);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const formattedMessage = level === "debug" ? `[DEBUG] ${message}` : message;
|
|
75
|
+
if (level === "error") {
|
|
76
|
+
console.error(chalkFn(formattedMessage));
|
|
77
|
+
} else {
|
|
78
|
+
console.log(chalkFn(formattedMessage));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/errors/baseError.ts
|
|
83
|
+
var BasePackageVersionerError = class _BasePackageVersionerError extends Error {
|
|
84
|
+
constructor(message, code, suggestions) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.code = code;
|
|
87
|
+
this.suggestions = suggestions;
|
|
88
|
+
this.name = this.constructor.name;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Log the error with consistent formatting and optional suggestions
|
|
92
|
+
* This centralizes all error output formatting and behavior
|
|
93
|
+
*/
|
|
94
|
+
logError() {
|
|
95
|
+
var _a;
|
|
96
|
+
log(this.message, "error");
|
|
97
|
+
if ((_a = this.suggestions) == null ? void 0 : _a.length) {
|
|
98
|
+
log("\nSuggested solutions:", "info");
|
|
99
|
+
this.suggestions.forEach((suggestion, i) => {
|
|
100
|
+
log(`${i + 1}. ${suggestion}`, "info");
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type guard to check if an error is a package-versioner error
|
|
106
|
+
* @param error Error to check
|
|
107
|
+
* @returns true if error is a BasePackageVersionerError
|
|
108
|
+
*/
|
|
109
|
+
static isPackageVersionerError(error) {
|
|
110
|
+
return error instanceof _BasePackageVersionerError;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
enableJsonOutput,
|
|
116
|
+
addPackageUpdate,
|
|
117
|
+
addTag,
|
|
118
|
+
setCommitMessage,
|
|
119
|
+
printJsonOutput,
|
|
120
|
+
log,
|
|
121
|
+
BasePackageVersionerError
|
|
122
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
9
12
|
var __export = (target, all) => {
|
|
10
13
|
for (var name in all)
|
|
11
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,32 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
31
|
));
|
|
29
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
33
|
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
run: () => run
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var fs10 = __toESM(require("fs"), 1);
|
|
38
|
-
var import_node_path8 = __toESM(require("path"), 1);
|
|
39
|
-
var import_commander = require("commander");
|
|
40
|
-
|
|
41
|
-
// src/changelog/changelogRegenerator.ts
|
|
42
|
-
var import_node_child_process2 = require("child_process");
|
|
43
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
44
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
45
|
-
|
|
46
|
-
// src/utils/logging.ts
|
|
47
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
48
|
-
var import_figlet = __toESM(require("figlet"), 1);
|
|
49
|
-
|
|
50
34
|
// src/utils/jsonOutput.ts
|
|
51
|
-
var _jsonOutputMode = false;
|
|
52
|
-
var _jsonData = {
|
|
53
|
-
dryRun: false,
|
|
54
|
-
updates: [],
|
|
55
|
-
tags: []
|
|
56
|
-
};
|
|
57
35
|
function enableJsonOutput(dryRun = false) {
|
|
58
36
|
_jsonOutputMode = true;
|
|
59
37
|
_jsonData.dryRun = dryRun;
|
|
@@ -85,6 +63,18 @@ function printJsonOutput() {
|
|
|
85
63
|
console.log(JSON.stringify(_jsonData, null, 2));
|
|
86
64
|
}
|
|
87
65
|
}
|
|
66
|
+
var _jsonOutputMode, _jsonData;
|
|
67
|
+
var init_jsonOutput = __esm({
|
|
68
|
+
"src/utils/jsonOutput.ts"() {
|
|
69
|
+
"use strict";
|
|
70
|
+
_jsonOutputMode = false;
|
|
71
|
+
_jsonData = {
|
|
72
|
+
dryRun: false,
|
|
73
|
+
updates: [],
|
|
74
|
+
tags: []
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
88
78
|
|
|
89
79
|
// src/utils/logging.ts
|
|
90
80
|
function log(message, level = "info") {
|
|
@@ -123,9 +113,78 @@ function log(message, level = "info") {
|
|
|
123
113
|
console.log(chalkFn(formattedMessage));
|
|
124
114
|
}
|
|
125
115
|
}
|
|
116
|
+
var import_chalk, import_figlet;
|
|
117
|
+
var init_logging = __esm({
|
|
118
|
+
"src/utils/logging.ts"() {
|
|
119
|
+
"use strict";
|
|
120
|
+
import_chalk = __toESM(require("chalk"), 1);
|
|
121
|
+
import_figlet = __toESM(require("figlet"), 1);
|
|
122
|
+
init_jsonOutput();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/errors/baseError.ts
|
|
127
|
+
var baseError_exports = {};
|
|
128
|
+
__export(baseError_exports, {
|
|
129
|
+
BasePackageVersionerError: () => BasePackageVersionerError
|
|
130
|
+
});
|
|
131
|
+
var BasePackageVersionerError;
|
|
132
|
+
var init_baseError = __esm({
|
|
133
|
+
"src/errors/baseError.ts"() {
|
|
134
|
+
"use strict";
|
|
135
|
+
init_logging();
|
|
136
|
+
BasePackageVersionerError = class _BasePackageVersionerError extends Error {
|
|
137
|
+
constructor(message, code, suggestions) {
|
|
138
|
+
super(message);
|
|
139
|
+
this.code = code;
|
|
140
|
+
this.suggestions = suggestions;
|
|
141
|
+
this.name = this.constructor.name;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Log the error with consistent formatting and optional suggestions
|
|
145
|
+
* This centralizes all error output formatting and behavior
|
|
146
|
+
*/
|
|
147
|
+
logError() {
|
|
148
|
+
var _a;
|
|
149
|
+
log(this.message, "error");
|
|
150
|
+
if ((_a = this.suggestions) == null ? void 0 : _a.length) {
|
|
151
|
+
log("\nSuggested solutions:", "info");
|
|
152
|
+
this.suggestions.forEach((suggestion, i) => {
|
|
153
|
+
log(`${i + 1}. ${suggestion}`, "info");
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Type guard to check if an error is a package-versioner error
|
|
159
|
+
* @param error Error to check
|
|
160
|
+
* @returns true if error is a BasePackageVersionerError
|
|
161
|
+
*/
|
|
162
|
+
static isPackageVersionerError(error) {
|
|
163
|
+
return error instanceof _BasePackageVersionerError;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// src/index.ts
|
|
170
|
+
var index_exports = {};
|
|
171
|
+
__export(index_exports, {
|
|
172
|
+
run: () => run
|
|
173
|
+
});
|
|
174
|
+
module.exports = __toCommonJS(index_exports);
|
|
175
|
+
var fs10 = __toESM(require("fs"), 1);
|
|
176
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
177
|
+
var import_commander = require("commander");
|
|
178
|
+
|
|
179
|
+
// src/changelog/changelogRegenerator.ts
|
|
180
|
+
var import_node_child_process2 = require("child_process");
|
|
181
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
182
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
183
|
+
init_logging();
|
|
126
184
|
|
|
127
185
|
// src/changelog/commitParser.ts
|
|
128
186
|
var import_node_child_process = require("child_process");
|
|
187
|
+
init_logging();
|
|
129
188
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
130
189
|
var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
|
|
131
190
|
function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
|
|
@@ -618,7 +677,7 @@ var import_node_process = require("process");
|
|
|
618
677
|
function loadConfig(configPath) {
|
|
619
678
|
const localProcess = (0, import_node_process.cwd)();
|
|
620
679
|
const filePath = configPath || `${localProcess}/version.config.json`;
|
|
621
|
-
return new Promise((
|
|
680
|
+
return new Promise((resolve2, reject) => {
|
|
622
681
|
fs2.readFile(filePath, "utf-8", (err, data) => {
|
|
623
682
|
if (err) {
|
|
624
683
|
reject(new Error(`Could not locate the config file at ${filePath}: ${err.message}`));
|
|
@@ -626,7 +685,7 @@ function loadConfig(configPath) {
|
|
|
626
685
|
}
|
|
627
686
|
try {
|
|
628
687
|
const config = JSON.parse(data);
|
|
629
|
-
|
|
688
|
+
resolve2(config);
|
|
630
689
|
} catch (err2) {
|
|
631
690
|
const errorMessage = err2 instanceof Error ? err2.message : String(err2);
|
|
632
691
|
reject(new Error(`Failed to parse config file ${filePath}: ${errorMessage}`));
|
|
@@ -640,12 +699,8 @@ var import_node_process5 = require("process");
|
|
|
640
699
|
var import_get_packages = require("@manypkg/get-packages");
|
|
641
700
|
|
|
642
701
|
// src/errors/gitError.ts
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
super(message);
|
|
646
|
-
this.code = code;
|
|
647
|
-
this.name = "GitError";
|
|
648
|
-
}
|
|
702
|
+
init_baseError();
|
|
703
|
+
var GitError = class extends BasePackageVersionerError {
|
|
649
704
|
};
|
|
650
705
|
function createGitError(code, details) {
|
|
651
706
|
const messages = {
|
|
@@ -653,20 +708,32 @@ function createGitError(code, details) {
|
|
|
653
708
|
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: "Failed to create new version",
|
|
654
709
|
["NO_FILES" /* NO_FILES */]: "No files specified for commit",
|
|
655
710
|
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: "Commit message is required",
|
|
656
|
-
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed"
|
|
711
|
+
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed",
|
|
712
|
+
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: "Git tag already exists"
|
|
713
|
+
};
|
|
714
|
+
const suggestions = {
|
|
715
|
+
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: [
|
|
716
|
+
"Initialize git repository with: git init",
|
|
717
|
+
"Ensure you are in the correct directory"
|
|
718
|
+
],
|
|
719
|
+
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: [
|
|
720
|
+
"Delete the existing tag: git tag -d <tag-name>",
|
|
721
|
+
"Use a different version by incrementing manually",
|
|
722
|
+
"Check if this version was already released"
|
|
723
|
+
],
|
|
724
|
+
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: void 0,
|
|
725
|
+
["NO_FILES" /* NO_FILES */]: void 0,
|
|
726
|
+
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: void 0,
|
|
727
|
+
["GIT_ERROR" /* GIT_ERROR */]: void 0
|
|
657
728
|
};
|
|
658
729
|
const baseMessage = messages[code];
|
|
659
730
|
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
660
|
-
return new GitError(fullMessage, code);
|
|
731
|
+
return new GitError(fullMessage, code, suggestions[code]);
|
|
661
732
|
}
|
|
662
733
|
|
|
663
734
|
// src/errors/versionError.ts
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
super(message);
|
|
667
|
-
this.code = code;
|
|
668
|
-
this.name = "VersionError";
|
|
669
|
-
}
|
|
735
|
+
init_baseError();
|
|
736
|
+
var VersionError = class extends BasePackageVersionerError {
|
|
670
737
|
};
|
|
671
738
|
function createVersionError(code, details) {
|
|
672
739
|
const messages = {
|
|
@@ -677,14 +744,49 @@ function createVersionError(code, details) {
|
|
|
677
744
|
["PACKAGE_NOT_FOUND" /* PACKAGE_NOT_FOUND */]: "Package not found",
|
|
678
745
|
["VERSION_CALCULATION_ERROR" /* VERSION_CALCULATION_ERROR */]: "Failed to calculate version"
|
|
679
746
|
};
|
|
747
|
+
const suggestions = {
|
|
748
|
+
["CONFIG_REQUIRED" /* CONFIG_REQUIRED */]: [
|
|
749
|
+
"Create a version.config.json file in your project root",
|
|
750
|
+
"Check the documentation for configuration examples"
|
|
751
|
+
],
|
|
752
|
+
["PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */]: [
|
|
753
|
+
"Ensure package.json or Cargo.toml files exist in your project",
|
|
754
|
+
"Check workspace configuration (pnpm-workspace.yaml, etc.)",
|
|
755
|
+
"Verify file permissions and paths"
|
|
756
|
+
],
|
|
757
|
+
["WORKSPACE_ERROR" /* WORKSPACE_ERROR */]: [
|
|
758
|
+
"Verify workspace configuration files are valid",
|
|
759
|
+
"Check that workspace packages are accessible",
|
|
760
|
+
"Ensure proper monorepo structure"
|
|
761
|
+
],
|
|
762
|
+
["INVALID_CONFIG" /* INVALID_CONFIG */]: [
|
|
763
|
+
"Validate version.config.json syntax",
|
|
764
|
+
"Check configuration against schema",
|
|
765
|
+
"Review documentation for valid configuration options"
|
|
766
|
+
],
|
|
767
|
+
["PACKAGE_NOT_FOUND" /* PACKAGE_NOT_FOUND */]: [
|
|
768
|
+
"Verify package name spelling and case",
|
|
769
|
+
"Check if package exists in workspace",
|
|
770
|
+
"Review packages configuration in version.config.json"
|
|
771
|
+
],
|
|
772
|
+
["VERSION_CALCULATION_ERROR" /* VERSION_CALCULATION_ERROR */]: [
|
|
773
|
+
"Ensure git repository has commits",
|
|
774
|
+
"Check conventional commit message format",
|
|
775
|
+
"Verify git tags are properly formatted"
|
|
776
|
+
]
|
|
777
|
+
};
|
|
680
778
|
const baseMessage = messages[code];
|
|
681
779
|
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
682
|
-
return new VersionError(fullMessage, code);
|
|
780
|
+
return new VersionError(fullMessage, code, suggestions[code]);
|
|
683
781
|
}
|
|
684
782
|
|
|
783
|
+
// src/core/versionEngine.ts
|
|
784
|
+
init_logging();
|
|
785
|
+
|
|
685
786
|
// src/utils/packageFiltering.ts
|
|
686
787
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
687
788
|
var import_micromatch = __toESM(require("micromatch"), 1);
|
|
789
|
+
init_logging();
|
|
688
790
|
function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
|
|
689
791
|
if (configTargets.length === 0) {
|
|
690
792
|
log("No config targets specified, returning all packages", "debug");
|
|
@@ -770,6 +872,7 @@ var path8 = __toESM(require("path"), 1);
|
|
|
770
872
|
// src/changelog/changelogManager.ts
|
|
771
873
|
var fs3 = __toESM(require("fs"), 1);
|
|
772
874
|
var path3 = __toESM(require("path"), 1);
|
|
875
|
+
init_logging();
|
|
773
876
|
function updateChangelog(packagePath, packageName, version, entries, repoUrl, format = "keep-a-changelog") {
|
|
774
877
|
try {
|
|
775
878
|
const changelogPath = path3.join(packagePath, "CHANGELOG.md");
|
|
@@ -844,14 +947,19 @@ ${newVersionContent}
|
|
|
844
947
|
}
|
|
845
948
|
}
|
|
846
949
|
|
|
950
|
+
// src/core/versionStrategies.ts
|
|
951
|
+
init_baseError();
|
|
952
|
+
|
|
847
953
|
// src/git/commands.ts
|
|
848
954
|
var import_node_process2 = require("process");
|
|
955
|
+
init_jsonOutput();
|
|
956
|
+
init_logging();
|
|
849
957
|
|
|
850
958
|
// src/git/commandExecutor.ts
|
|
851
959
|
var import_node_child_process3 = require("child_process");
|
|
852
960
|
var execAsync = (command, options) => {
|
|
853
961
|
const defaultOptions = { maxBuffer: 1024 * 1024 * 10, ...options };
|
|
854
|
-
return new Promise((
|
|
962
|
+
return new Promise((resolve2, reject) => {
|
|
855
963
|
(0, import_node_child_process3.exec)(
|
|
856
964
|
command,
|
|
857
965
|
defaultOptions,
|
|
@@ -859,7 +967,7 @@ var execAsync = (command, options) => {
|
|
|
859
967
|
if (error) {
|
|
860
968
|
reject(error);
|
|
861
969
|
} else {
|
|
862
|
-
|
|
970
|
+
resolve2({ stdout: stdout.toString(), stderr: stderr.toString() });
|
|
863
971
|
}
|
|
864
972
|
}
|
|
865
973
|
);
|
|
@@ -916,7 +1024,18 @@ async function gitCommit(options) {
|
|
|
916
1024
|
async function createGitTag(options) {
|
|
917
1025
|
const { tag, message = "", args = "" } = options;
|
|
918
1026
|
const command = `git tag -a -m "${message}" ${tag} ${args}`;
|
|
919
|
-
|
|
1027
|
+
try {
|
|
1028
|
+
return await execAsync(command);
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1031
|
+
if (errorMessage.includes("already exists")) {
|
|
1032
|
+
throw createGitError(
|
|
1033
|
+
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
1034
|
+
`Tag '${tag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
throw createGitError("GIT_ERROR" /* GIT_ERROR */, errorMessage);
|
|
1038
|
+
}
|
|
920
1039
|
}
|
|
921
1040
|
async function gitProcess(options) {
|
|
922
1041
|
const { files, nextTag, commitMessage, skipHooks, dryRun } = options;
|
|
@@ -949,6 +1068,13 @@ async function gitProcess(options) {
|
|
|
949
1068
|
}
|
|
950
1069
|
} catch (err) {
|
|
951
1070
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1071
|
+
if (errorMessage.includes("already exists") && nextTag) {
|
|
1072
|
+
log(`Tag '${nextTag}' already exists in the repository.`, "error");
|
|
1073
|
+
throw createGitError(
|
|
1074
|
+
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
1075
|
+
`Tag '${nextTag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
952
1078
|
log(`Git process error: ${errorMessage}`, "error");
|
|
953
1079
|
if (err instanceof Error && err.stack) {
|
|
954
1080
|
console.error("Git process stack trace:");
|
|
@@ -980,6 +1106,9 @@ async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, d
|
|
|
980
1106
|
log(`Created tag: ${nextTag}`, "success");
|
|
981
1107
|
}
|
|
982
1108
|
} catch (error) {
|
|
1109
|
+
if (error instanceof GitError) {
|
|
1110
|
+
throw error;
|
|
1111
|
+
}
|
|
983
1112
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
984
1113
|
log(`Failed to create git commit and tag: ${errorMessage}`, "error");
|
|
985
1114
|
if (error instanceof Error) {
|
|
@@ -1003,6 +1132,7 @@ var import_git_semver_tags = require("git-semver-tags");
|
|
|
1003
1132
|
var import_semver = __toESM(require("semver"), 1);
|
|
1004
1133
|
|
|
1005
1134
|
// src/utils/formatting.ts
|
|
1135
|
+
init_logging();
|
|
1006
1136
|
function escapeRegExp(string) {
|
|
1007
1137
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1008
1138
|
}
|
|
@@ -1045,6 +1175,7 @@ function formatCommitMessage(template, version, packageName, additionalContext)
|
|
|
1045
1175
|
}
|
|
1046
1176
|
|
|
1047
1177
|
// src/git/tagsAndBranches.ts
|
|
1178
|
+
init_logging();
|
|
1048
1179
|
function getCommitsLength(pkgRoot, sinceTag) {
|
|
1049
1180
|
try {
|
|
1050
1181
|
let gitCommand;
|
|
@@ -1242,6 +1373,8 @@ var import_node_path5 = __toESM(require("path"), 1);
|
|
|
1242
1373
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
1243
1374
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
1244
1375
|
var TOML = __toESM(require("smol-toml"), 1);
|
|
1376
|
+
init_jsonOutput();
|
|
1377
|
+
init_logging();
|
|
1245
1378
|
function getCargoInfo(cargoPath) {
|
|
1246
1379
|
var _a;
|
|
1247
1380
|
if (!import_node_fs3.default.existsSync(cargoPath)) {
|
|
@@ -1302,6 +1435,8 @@ function updateCargoVersion(cargoPath, version) {
|
|
|
1302
1435
|
}
|
|
1303
1436
|
|
|
1304
1437
|
// src/package/packageManagement.ts
|
|
1438
|
+
init_jsonOutput();
|
|
1439
|
+
init_logging();
|
|
1305
1440
|
function updatePackageVersion(packagePath, version) {
|
|
1306
1441
|
if (isCargoToml(packagePath)) {
|
|
1307
1442
|
updateCargoVersion(packagePath, version);
|
|
@@ -1334,10 +1469,12 @@ var import_node_process4 = require("process");
|
|
|
1334
1469
|
var import_node_process3 = require("process");
|
|
1335
1470
|
var import_conventional_recommended_bump = require("conventional-recommended-bump");
|
|
1336
1471
|
var import_semver3 = __toESM(require("semver"), 1);
|
|
1472
|
+
init_logging();
|
|
1337
1473
|
|
|
1338
1474
|
// src/utils/manifestHelpers.ts
|
|
1339
1475
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
1340
1476
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
1477
|
+
init_logging();
|
|
1341
1478
|
function getVersionFromManifests(packageDir) {
|
|
1342
1479
|
const packageJsonPath = import_node_path6.default.join(packageDir, "package.json");
|
|
1343
1480
|
const cargoTomlPath = import_node_path6.default.join(packageDir, "Cargo.toml");
|
|
@@ -1419,6 +1556,7 @@ function verifyTag(tagName, cwd5) {
|
|
|
1419
1556
|
}
|
|
1420
1557
|
|
|
1421
1558
|
// src/utils/versionUtils.ts
|
|
1559
|
+
init_logging();
|
|
1422
1560
|
var STANDARD_BUMP_TYPES = ["major", "minor", "patch"];
|
|
1423
1561
|
function normalizePrereleaseIdentifier(prereleaseIdentifier, config) {
|
|
1424
1562
|
if (prereleaseIdentifier === true) {
|
|
@@ -1668,8 +1806,13 @@ async function calculateVersion(config, options) {
|
|
|
1668
1806
|
}
|
|
1669
1807
|
}
|
|
1670
1808
|
|
|
1809
|
+
// src/package/packageProcessor.ts
|
|
1810
|
+
init_jsonOutput();
|
|
1811
|
+
init_logging();
|
|
1812
|
+
|
|
1671
1813
|
// src/utils/packageMatching.ts
|
|
1672
1814
|
var import_micromatch2 = __toESM(require("micromatch"), 1);
|
|
1815
|
+
init_logging();
|
|
1673
1816
|
function matchesPackageTarget(packageName, target) {
|
|
1674
1817
|
if (packageName === target) {
|
|
1675
1818
|
return true;
|
|
@@ -1754,6 +1897,7 @@ var PackageProcessor = class {
|
|
|
1754
1897
|
for (const pkg of pkgsToConsider) {
|
|
1755
1898
|
const name = pkg.packageJson.name;
|
|
1756
1899
|
const pkgPath = pkg.dir;
|
|
1900
|
+
log(`Processing package ${name} at path: ${pkgPath}`, "info");
|
|
1757
1901
|
const formattedPrefix = formatVersionPrefix(this.versionPrefix);
|
|
1758
1902
|
let latestTagResult = "";
|
|
1759
1903
|
try {
|
|
@@ -1886,21 +2030,36 @@ var PackageProcessor = class {
|
|
|
1886
2030
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
1887
2031
|
}
|
|
1888
2032
|
const cargoEnabled = ((_a = this.fullConfig.cargo) == null ? void 0 : _a.enabled) !== false;
|
|
2033
|
+
log(
|
|
2034
|
+
`Cargo enabled for ${name}: ${cargoEnabled}, config: ${JSON.stringify(this.fullConfig.cargo)}`,
|
|
2035
|
+
"debug"
|
|
2036
|
+
);
|
|
1889
2037
|
if (cargoEnabled) {
|
|
1890
2038
|
const cargoPaths = (_b = this.fullConfig.cargo) == null ? void 0 : _b.paths;
|
|
2039
|
+
log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
|
|
1891
2040
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
1892
2041
|
for (const cargoPath of cargoPaths) {
|
|
1893
2042
|
const resolvedCargoPath = import_node_path7.default.resolve(pkgPath, cargoPath, "Cargo.toml");
|
|
2043
|
+
log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
|
|
1894
2044
|
if (fs8.existsSync(resolvedCargoPath)) {
|
|
2045
|
+
log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
|
|
1895
2046
|
updatePackageVersion(resolvedCargoPath, nextVersion);
|
|
2047
|
+
} else {
|
|
2048
|
+
log(`Cargo.toml not found at ${resolvedCargoPath}`, "debug");
|
|
1896
2049
|
}
|
|
1897
2050
|
}
|
|
1898
2051
|
} else {
|
|
1899
2052
|
const cargoTomlPath = import_node_path7.default.join(pkgPath, "Cargo.toml");
|
|
2053
|
+
log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
|
|
1900
2054
|
if (fs8.existsSync(cargoTomlPath)) {
|
|
2055
|
+
log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
|
|
1901
2056
|
updatePackageVersion(cargoTomlPath, nextVersion);
|
|
2057
|
+
} else {
|
|
2058
|
+
log(`Cargo.toml not found for ${name} at ${cargoTomlPath}`, "debug");
|
|
1902
2059
|
}
|
|
1903
2060
|
}
|
|
2061
|
+
} else {
|
|
2062
|
+
log(`Cargo disabled for ${name}`, "debug");
|
|
1904
2063
|
}
|
|
1905
2064
|
const packageTag = formatTag(
|
|
1906
2065
|
nextVersion,
|
|
@@ -1993,10 +2152,35 @@ var PackageProcessor = class {
|
|
|
1993
2152
|
};
|
|
1994
2153
|
|
|
1995
2154
|
// src/core/versionStrategies.ts
|
|
2155
|
+
init_logging();
|
|
1996
2156
|
function shouldProcessPackage2(pkg, config) {
|
|
1997
2157
|
const pkgName = pkg.packageJson.name;
|
|
1998
2158
|
return shouldProcessPackage(pkgName, config.skip);
|
|
1999
2159
|
}
|
|
2160
|
+
function updateCargoFiles(packageDir, version, cargoConfig) {
|
|
2161
|
+
const updatedFiles = [];
|
|
2162
|
+
const cargoEnabled = (cargoConfig == null ? void 0 : cargoConfig.enabled) !== false;
|
|
2163
|
+
if (!cargoEnabled) {
|
|
2164
|
+
return updatedFiles;
|
|
2165
|
+
}
|
|
2166
|
+
const cargoPaths = cargoConfig == null ? void 0 : cargoConfig.paths;
|
|
2167
|
+
if (cargoPaths && cargoPaths.length > 0) {
|
|
2168
|
+
for (const cargoPath of cargoPaths) {
|
|
2169
|
+
const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
|
|
2170
|
+
if (import_node_fs7.default.existsSync(resolvedCargoPath)) {
|
|
2171
|
+
updatePackageVersion(resolvedCargoPath, version);
|
|
2172
|
+
updatedFiles.push(resolvedCargoPath);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
} else {
|
|
2176
|
+
const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
|
|
2177
|
+
if (import_node_fs7.default.existsSync(cargoTomlPath)) {
|
|
2178
|
+
updatePackageVersion(cargoTomlPath, version);
|
|
2179
|
+
updatedFiles.push(cargoTomlPath);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
return updatedFiles;
|
|
2183
|
+
}
|
|
2000
2184
|
function createSyncStrategy(config) {
|
|
2001
2185
|
return async (packages) => {
|
|
2002
2186
|
try {
|
|
@@ -2076,6 +2260,8 @@ function createSyncStrategy(config) {
|
|
|
2076
2260
|
files.push(rootPkgPath);
|
|
2077
2261
|
updatedPackages.push("root");
|
|
2078
2262
|
processedPaths.add(rootPkgPath);
|
|
2263
|
+
const rootCargoFiles = updateCargoFiles(packages.root, nextVersion, config.cargo);
|
|
2264
|
+
files.push(...rootCargoFiles);
|
|
2079
2265
|
}
|
|
2080
2266
|
} else {
|
|
2081
2267
|
log("Root package path is undefined, skipping root package.json update", "warning");
|
|
@@ -2096,6 +2282,8 @@ function createSyncStrategy(config) {
|
|
|
2096
2282
|
files.push(packageJsonPath);
|
|
2097
2283
|
updatedPackages.push(pkg.packageJson.name);
|
|
2098
2284
|
processedPaths.add(packageJsonPath);
|
|
2285
|
+
const pkgCargoFiles = updateCargoFiles(pkg.dir, nextVersion, config.cargo);
|
|
2286
|
+
files.push(...pkgCargoFiles);
|
|
2099
2287
|
}
|
|
2100
2288
|
if (updatedPackages.length > 0) {
|
|
2101
2289
|
log(`Updated ${updatedPackages.length} package(s) to version ${nextVersion}`, "success");
|
|
@@ -2124,8 +2312,8 @@ function createSyncStrategy(config) {
|
|
|
2124
2312
|
);
|
|
2125
2313
|
await createGitCommitAndTag(files, nextTag, formattedCommitMessage, skipHooks, dryRun);
|
|
2126
2314
|
} catch (error) {
|
|
2127
|
-
if (error
|
|
2128
|
-
log(`Synced Strategy failed: ${error.message} (${error.code
|
|
2315
|
+
if (BasePackageVersionerError.isPackageVersionerError(error)) {
|
|
2316
|
+
log(`Synced Strategy failed: ${error.message} (${error.code})`, "error");
|
|
2129
2317
|
} else {
|
|
2130
2318
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2131
2319
|
log(`Synced Strategy failed: ${errorMessage}`, "error");
|
|
@@ -2258,6 +2446,9 @@ function createSingleStrategy(config) {
|
|
|
2258
2446
|
}
|
|
2259
2447
|
const packageJsonPath = path8.join(pkgPath, "package.json");
|
|
2260
2448
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
2449
|
+
const filesToCommit = [packageJsonPath];
|
|
2450
|
+
const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo);
|
|
2451
|
+
filesToCommit.push(...cargoFiles);
|
|
2261
2452
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
2262
2453
|
const tagName = formatTag(
|
|
2263
2454
|
nextVersion,
|
|
@@ -2268,14 +2459,14 @@ function createSingleStrategy(config) {
|
|
|
2268
2459
|
);
|
|
2269
2460
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
2270
2461
|
if (!dryRun) {
|
|
2271
|
-
await createGitCommitAndTag(
|
|
2462
|
+
await createGitCommitAndTag(filesToCommit, tagName, commitMsg, skipHooks, dryRun);
|
|
2272
2463
|
log(`Created tag: ${tagName}`, "success");
|
|
2273
2464
|
} else {
|
|
2274
2465
|
log(`Would create tag: ${tagName}`, "info");
|
|
2275
2466
|
}
|
|
2276
2467
|
} catch (error) {
|
|
2277
|
-
if (error
|
|
2278
|
-
log(`Single Strategy failed: ${error.message} (${error.code
|
|
2468
|
+
if (BasePackageVersionerError.isPackageVersionerError(error)) {
|
|
2469
|
+
log(`Single Strategy failed: ${error.message} (${error.code})`, "error");
|
|
2279
2470
|
} else {
|
|
2280
2471
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2281
2472
|
log(`Single Strategy failed: ${errorMessage}`, "error");
|
|
@@ -2306,10 +2497,21 @@ function createAsyncStrategy(config) {
|
|
|
2306
2497
|
}
|
|
2307
2498
|
};
|
|
2308
2499
|
const packageProcessor = new PackageProcessor(processorOptions);
|
|
2309
|
-
return async (packages,
|
|
2500
|
+
return async (packages, targets = []) => {
|
|
2310
2501
|
try {
|
|
2311
|
-
|
|
2312
|
-
|
|
2502
|
+
let packagesToProcess = packages.packages;
|
|
2503
|
+
if (targets.length > 0) {
|
|
2504
|
+
const beforeCount = packagesToProcess.length;
|
|
2505
|
+
packagesToProcess = packagesToProcess.filter(
|
|
2506
|
+
(pkg) => targets.includes(pkg.packageJson.name)
|
|
2507
|
+
);
|
|
2508
|
+
log(
|
|
2509
|
+
`Runtime targets filter: ${beforeCount} \u2192 ${packagesToProcess.length} packages (${targets.join(", ")})`,
|
|
2510
|
+
"info"
|
|
2511
|
+
);
|
|
2512
|
+
}
|
|
2513
|
+
log(`Processing ${packagesToProcess.length} packages`, "info");
|
|
2514
|
+
const result = await packageProcessor.processPackages(packagesToProcess);
|
|
2313
2515
|
if (result.updatedPackages.length === 0) {
|
|
2314
2516
|
log("No packages required a version update.", "info");
|
|
2315
2517
|
} else {
|
|
@@ -2323,8 +2525,8 @@ function createAsyncStrategy(config) {
|
|
|
2323
2525
|
}
|
|
2324
2526
|
}
|
|
2325
2527
|
} catch (error) {
|
|
2326
|
-
if (error
|
|
2327
|
-
log(`Async Strategy failed: ${error.message} (${error.code
|
|
2528
|
+
if (BasePackageVersionerError.isPackageVersionerError(error)) {
|
|
2529
|
+
log(`Async Strategy failed: ${error.message} (${error.code})`, "error");
|
|
2328
2530
|
} else {
|
|
2329
2531
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2330
2532
|
log(`Async Strategy failed: ${errorMessage}`, "error");
|
|
@@ -2450,6 +2652,8 @@ var VersionEngine = class {
|
|
|
2450
2652
|
};
|
|
2451
2653
|
|
|
2452
2654
|
// src/index.ts
|
|
2655
|
+
init_jsonOutput();
|
|
2656
|
+
init_logging();
|
|
2453
2657
|
var import_meta = {};
|
|
2454
2658
|
function getPackageVersion() {
|
|
2455
2659
|
try {
|
|
@@ -2503,6 +2707,10 @@ async function run() {
|
|
|
2503
2707
|
config.isPrerelease = true;
|
|
2504
2708
|
}
|
|
2505
2709
|
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
2710
|
+
if (cliTargets.length > 0) {
|
|
2711
|
+
config.packages = cliTargets;
|
|
2712
|
+
log(`CLI targets specified: ${cliTargets.join(", ")}`, "info");
|
|
2713
|
+
}
|
|
2506
2714
|
const engine = new VersionEngine(config, !!options.json);
|
|
2507
2715
|
const pkgsResult = await engine.getWorkspacePackages();
|
|
2508
2716
|
const resolvedCount = pkgsResult.packages.length;
|
|
@@ -2533,14 +2741,19 @@ async function run() {
|
|
|
2533
2741
|
log("Versioning process completed.", "success");
|
|
2534
2742
|
printJsonOutput();
|
|
2535
2743
|
} catch (error) {
|
|
2536
|
-
|
|
2537
|
-
if (error
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2744
|
+
const { BasePackageVersionerError: BasePackageVersionerError2 } = await Promise.resolve().then(() => (init_baseError(), baseError_exports));
|
|
2745
|
+
if (BasePackageVersionerError2.isPackageVersionerError(error)) {
|
|
2746
|
+
error.logError();
|
|
2747
|
+
} else {
|
|
2748
|
+
log(error instanceof Error ? error.message : String(error), "error");
|
|
2749
|
+
if (error instanceof Error) {
|
|
2750
|
+
console.error("Error details:");
|
|
2751
|
+
console.error(error.stack || error.message);
|
|
2752
|
+
if (error.message.includes("Command failed:")) {
|
|
2753
|
+
const cmdOutput = error.message.split("Command failed:")[1];
|
|
2754
|
+
if (cmdOutput) {
|
|
2755
|
+
console.error("Command output:", cmdOutput.trim());
|
|
2756
|
+
}
|
|
2544
2757
|
}
|
|
2545
2758
|
}
|
|
2546
2759
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
BasePackageVersionerError,
|
|
4
|
+
addPackageUpdate,
|
|
5
|
+
addTag,
|
|
6
|
+
enableJsonOutput,
|
|
7
|
+
log,
|
|
8
|
+
printJsonOutput,
|
|
9
|
+
setCommitMessage
|
|
10
|
+
} from "./chunk-IXZZQDKS.js";
|
|
2
11
|
|
|
3
12
|
// src/index.ts
|
|
4
13
|
import * as fs10 from "fs";
|
|
@@ -10,87 +19,6 @@ import { execSync as execSync2 } from "child_process";
|
|
|
10
19
|
import fs from "fs";
|
|
11
20
|
import path from "path";
|
|
12
21
|
|
|
13
|
-
// src/utils/logging.ts
|
|
14
|
-
import chalk from "chalk";
|
|
15
|
-
import figlet from "figlet";
|
|
16
|
-
|
|
17
|
-
// src/utils/jsonOutput.ts
|
|
18
|
-
var _jsonOutputMode = false;
|
|
19
|
-
var _jsonData = {
|
|
20
|
-
dryRun: false,
|
|
21
|
-
updates: [],
|
|
22
|
-
tags: []
|
|
23
|
-
};
|
|
24
|
-
function enableJsonOutput(dryRun = false) {
|
|
25
|
-
_jsonOutputMode = true;
|
|
26
|
-
_jsonData.dryRun = dryRun;
|
|
27
|
-
_jsonData.updates = [];
|
|
28
|
-
_jsonData.tags = [];
|
|
29
|
-
_jsonData.commitMessage = void 0;
|
|
30
|
-
}
|
|
31
|
-
function isJsonOutputMode() {
|
|
32
|
-
return _jsonOutputMode;
|
|
33
|
-
}
|
|
34
|
-
function addPackageUpdate(packageName, newVersion, filePath) {
|
|
35
|
-
if (!_jsonOutputMode) return;
|
|
36
|
-
_jsonData.updates.push({
|
|
37
|
-
packageName,
|
|
38
|
-
newVersion,
|
|
39
|
-
filePath
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function addTag(tag) {
|
|
43
|
-
if (!_jsonOutputMode) return;
|
|
44
|
-
_jsonData.tags.push(tag);
|
|
45
|
-
}
|
|
46
|
-
function setCommitMessage(message) {
|
|
47
|
-
if (!_jsonOutputMode) return;
|
|
48
|
-
_jsonData.commitMessage = message;
|
|
49
|
-
}
|
|
50
|
-
function printJsonOutput() {
|
|
51
|
-
if (_jsonOutputMode) {
|
|
52
|
-
console.log(JSON.stringify(_jsonData, null, 2));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/utils/logging.ts
|
|
57
|
-
function log(message, level = "info") {
|
|
58
|
-
const showDebug = process.env.DEBUG === "true" || process.env.DEBUG === "1";
|
|
59
|
-
if (level === "debug" && !showDebug) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
let chalkFn;
|
|
63
|
-
switch (level) {
|
|
64
|
-
case "success":
|
|
65
|
-
chalkFn = chalk.green;
|
|
66
|
-
break;
|
|
67
|
-
case "warning":
|
|
68
|
-
chalkFn = chalk.yellow;
|
|
69
|
-
break;
|
|
70
|
-
case "error":
|
|
71
|
-
chalkFn = chalk.red;
|
|
72
|
-
break;
|
|
73
|
-
case "debug":
|
|
74
|
-
chalkFn = chalk.gray;
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
chalkFn = chalk.blue;
|
|
78
|
-
}
|
|
79
|
-
if (isJsonOutputMode()) {
|
|
80
|
-
if (level === "error") {
|
|
81
|
-
chalkFn(message);
|
|
82
|
-
console.error(message);
|
|
83
|
-
}
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const formattedMessage = level === "debug" ? `[DEBUG] ${message}` : message;
|
|
87
|
-
if (level === "error") {
|
|
88
|
-
console.error(chalkFn(formattedMessage));
|
|
89
|
-
} else {
|
|
90
|
-
console.log(chalkFn(formattedMessage));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
22
|
// src/changelog/commitParser.ts
|
|
95
23
|
import { execSync } from "child_process";
|
|
96
24
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
@@ -585,7 +513,7 @@ import { cwd } from "process";
|
|
|
585
513
|
function loadConfig(configPath) {
|
|
586
514
|
const localProcess = cwd();
|
|
587
515
|
const filePath = configPath || `${localProcess}/version.config.json`;
|
|
588
|
-
return new Promise((
|
|
516
|
+
return new Promise((resolve2, reject) => {
|
|
589
517
|
fs2.readFile(filePath, "utf-8", (err, data) => {
|
|
590
518
|
if (err) {
|
|
591
519
|
reject(new Error(`Could not locate the config file at ${filePath}: ${err.message}`));
|
|
@@ -593,7 +521,7 @@ function loadConfig(configPath) {
|
|
|
593
521
|
}
|
|
594
522
|
try {
|
|
595
523
|
const config = JSON.parse(data);
|
|
596
|
-
|
|
524
|
+
resolve2(config);
|
|
597
525
|
} catch (err2) {
|
|
598
526
|
const errorMessage = err2 instanceof Error ? err2.message : String(err2);
|
|
599
527
|
reject(new Error(`Failed to parse config file ${filePath}: ${errorMessage}`));
|
|
@@ -607,12 +535,7 @@ import { cwd as cwd4 } from "process";
|
|
|
607
535
|
import { getPackagesSync } from "@manypkg/get-packages";
|
|
608
536
|
|
|
609
537
|
// src/errors/gitError.ts
|
|
610
|
-
var GitError = class extends
|
|
611
|
-
constructor(message, code) {
|
|
612
|
-
super(message);
|
|
613
|
-
this.code = code;
|
|
614
|
-
this.name = "GitError";
|
|
615
|
-
}
|
|
538
|
+
var GitError = class extends BasePackageVersionerError {
|
|
616
539
|
};
|
|
617
540
|
function createGitError(code, details) {
|
|
618
541
|
const messages = {
|
|
@@ -620,20 +543,31 @@ function createGitError(code, details) {
|
|
|
620
543
|
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: "Failed to create new version",
|
|
621
544
|
["NO_FILES" /* NO_FILES */]: "No files specified for commit",
|
|
622
545
|
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: "Commit message is required",
|
|
623
|
-
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed"
|
|
546
|
+
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed",
|
|
547
|
+
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: "Git tag already exists"
|
|
548
|
+
};
|
|
549
|
+
const suggestions = {
|
|
550
|
+
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: [
|
|
551
|
+
"Initialize git repository with: git init",
|
|
552
|
+
"Ensure you are in the correct directory"
|
|
553
|
+
],
|
|
554
|
+
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: [
|
|
555
|
+
"Delete the existing tag: git tag -d <tag-name>",
|
|
556
|
+
"Use a different version by incrementing manually",
|
|
557
|
+
"Check if this version was already released"
|
|
558
|
+
],
|
|
559
|
+
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: void 0,
|
|
560
|
+
["NO_FILES" /* NO_FILES */]: void 0,
|
|
561
|
+
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: void 0,
|
|
562
|
+
["GIT_ERROR" /* GIT_ERROR */]: void 0
|
|
624
563
|
};
|
|
625
564
|
const baseMessage = messages[code];
|
|
626
565
|
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
627
|
-
return new GitError(fullMessage, code);
|
|
566
|
+
return new GitError(fullMessage, code, suggestions[code]);
|
|
628
567
|
}
|
|
629
568
|
|
|
630
569
|
// src/errors/versionError.ts
|
|
631
|
-
var VersionError = class extends
|
|
632
|
-
constructor(message, code) {
|
|
633
|
-
super(message);
|
|
634
|
-
this.code = code;
|
|
635
|
-
this.name = "VersionError";
|
|
636
|
-
}
|
|
570
|
+
var VersionError = class extends BasePackageVersionerError {
|
|
637
571
|
};
|
|
638
572
|
function createVersionError(code, details) {
|
|
639
573
|
const messages = {
|
|
@@ -644,9 +578,40 @@ function createVersionError(code, details) {
|
|
|
644
578
|
["PACKAGE_NOT_FOUND" /* PACKAGE_NOT_FOUND */]: "Package not found",
|
|
645
579
|
["VERSION_CALCULATION_ERROR" /* VERSION_CALCULATION_ERROR */]: "Failed to calculate version"
|
|
646
580
|
};
|
|
581
|
+
const suggestions = {
|
|
582
|
+
["CONFIG_REQUIRED" /* CONFIG_REQUIRED */]: [
|
|
583
|
+
"Create a version.config.json file in your project root",
|
|
584
|
+
"Check the documentation for configuration examples"
|
|
585
|
+
],
|
|
586
|
+
["PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */]: [
|
|
587
|
+
"Ensure package.json or Cargo.toml files exist in your project",
|
|
588
|
+
"Check workspace configuration (pnpm-workspace.yaml, etc.)",
|
|
589
|
+
"Verify file permissions and paths"
|
|
590
|
+
],
|
|
591
|
+
["WORKSPACE_ERROR" /* WORKSPACE_ERROR */]: [
|
|
592
|
+
"Verify workspace configuration files are valid",
|
|
593
|
+
"Check that workspace packages are accessible",
|
|
594
|
+
"Ensure proper monorepo structure"
|
|
595
|
+
],
|
|
596
|
+
["INVALID_CONFIG" /* INVALID_CONFIG */]: [
|
|
597
|
+
"Validate version.config.json syntax",
|
|
598
|
+
"Check configuration against schema",
|
|
599
|
+
"Review documentation for valid configuration options"
|
|
600
|
+
],
|
|
601
|
+
["PACKAGE_NOT_FOUND" /* PACKAGE_NOT_FOUND */]: [
|
|
602
|
+
"Verify package name spelling and case",
|
|
603
|
+
"Check if package exists in workspace",
|
|
604
|
+
"Review packages configuration in version.config.json"
|
|
605
|
+
],
|
|
606
|
+
["VERSION_CALCULATION_ERROR" /* VERSION_CALCULATION_ERROR */]: [
|
|
607
|
+
"Ensure git repository has commits",
|
|
608
|
+
"Check conventional commit message format",
|
|
609
|
+
"Verify git tags are properly formatted"
|
|
610
|
+
]
|
|
611
|
+
};
|
|
647
612
|
const baseMessage = messages[code];
|
|
648
613
|
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
649
|
-
return new VersionError(fullMessage, code);
|
|
614
|
+
return new VersionError(fullMessage, code, suggestions[code]);
|
|
650
615
|
}
|
|
651
616
|
|
|
652
617
|
// src/utils/packageFiltering.ts
|
|
@@ -818,7 +783,7 @@ import { cwd as cwd2 } from "process";
|
|
|
818
783
|
import { exec, execSync as nativeExecSync } from "child_process";
|
|
819
784
|
var execAsync = (command, options) => {
|
|
820
785
|
const defaultOptions = { maxBuffer: 1024 * 1024 * 10, ...options };
|
|
821
|
-
return new Promise((
|
|
786
|
+
return new Promise((resolve2, reject) => {
|
|
822
787
|
exec(
|
|
823
788
|
command,
|
|
824
789
|
defaultOptions,
|
|
@@ -826,7 +791,7 @@ var execAsync = (command, options) => {
|
|
|
826
791
|
if (error) {
|
|
827
792
|
reject(error);
|
|
828
793
|
} else {
|
|
829
|
-
|
|
794
|
+
resolve2({ stdout: stdout.toString(), stderr: stderr.toString() });
|
|
830
795
|
}
|
|
831
796
|
}
|
|
832
797
|
);
|
|
@@ -883,7 +848,18 @@ async function gitCommit(options) {
|
|
|
883
848
|
async function createGitTag(options) {
|
|
884
849
|
const { tag, message = "", args = "" } = options;
|
|
885
850
|
const command = `git tag -a -m "${message}" ${tag} ${args}`;
|
|
886
|
-
|
|
851
|
+
try {
|
|
852
|
+
return await execAsync(command);
|
|
853
|
+
} catch (error) {
|
|
854
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
855
|
+
if (errorMessage.includes("already exists")) {
|
|
856
|
+
throw createGitError(
|
|
857
|
+
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
858
|
+
`Tag '${tag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
throw createGitError("GIT_ERROR" /* GIT_ERROR */, errorMessage);
|
|
862
|
+
}
|
|
887
863
|
}
|
|
888
864
|
async function gitProcess(options) {
|
|
889
865
|
const { files, nextTag, commitMessage, skipHooks, dryRun } = options;
|
|
@@ -916,6 +892,13 @@ async function gitProcess(options) {
|
|
|
916
892
|
}
|
|
917
893
|
} catch (err) {
|
|
918
894
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
895
|
+
if (errorMessage.includes("already exists") && nextTag) {
|
|
896
|
+
log(`Tag '${nextTag}' already exists in the repository.`, "error");
|
|
897
|
+
throw createGitError(
|
|
898
|
+
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
899
|
+
`Tag '${nextTag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
900
|
+
);
|
|
901
|
+
}
|
|
919
902
|
log(`Git process error: ${errorMessage}`, "error");
|
|
920
903
|
if (err instanceof Error && err.stack) {
|
|
921
904
|
console.error("Git process stack trace:");
|
|
@@ -947,6 +930,9 @@ async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, d
|
|
|
947
930
|
log(`Created tag: ${nextTag}`, "success");
|
|
948
931
|
}
|
|
949
932
|
} catch (error) {
|
|
933
|
+
if (error instanceof GitError) {
|
|
934
|
+
throw error;
|
|
935
|
+
}
|
|
950
936
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
951
937
|
log(`Failed to create git commit and tag: ${errorMessage}`, "error");
|
|
952
938
|
if (error instanceof Error) {
|
|
@@ -1721,6 +1707,7 @@ var PackageProcessor = class {
|
|
|
1721
1707
|
for (const pkg of pkgsToConsider) {
|
|
1722
1708
|
const name = pkg.packageJson.name;
|
|
1723
1709
|
const pkgPath = pkg.dir;
|
|
1710
|
+
log(`Processing package ${name} at path: ${pkgPath}`, "info");
|
|
1724
1711
|
const formattedPrefix = formatVersionPrefix(this.versionPrefix);
|
|
1725
1712
|
let latestTagResult = "";
|
|
1726
1713
|
try {
|
|
@@ -1853,21 +1840,36 @@ var PackageProcessor = class {
|
|
|
1853
1840
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
1854
1841
|
}
|
|
1855
1842
|
const cargoEnabled = ((_a = this.fullConfig.cargo) == null ? void 0 : _a.enabled) !== false;
|
|
1843
|
+
log(
|
|
1844
|
+
`Cargo enabled for ${name}: ${cargoEnabled}, config: ${JSON.stringify(this.fullConfig.cargo)}`,
|
|
1845
|
+
"debug"
|
|
1846
|
+
);
|
|
1856
1847
|
if (cargoEnabled) {
|
|
1857
1848
|
const cargoPaths = (_b = this.fullConfig.cargo) == null ? void 0 : _b.paths;
|
|
1849
|
+
log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
|
|
1858
1850
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
1859
1851
|
for (const cargoPath of cargoPaths) {
|
|
1860
1852
|
const resolvedCargoPath = path7.resolve(pkgPath, cargoPath, "Cargo.toml");
|
|
1853
|
+
log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
|
|
1861
1854
|
if (fs8.existsSync(resolvedCargoPath)) {
|
|
1855
|
+
log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
|
|
1862
1856
|
updatePackageVersion(resolvedCargoPath, nextVersion);
|
|
1857
|
+
} else {
|
|
1858
|
+
log(`Cargo.toml not found at ${resolvedCargoPath}`, "debug");
|
|
1863
1859
|
}
|
|
1864
1860
|
}
|
|
1865
1861
|
} else {
|
|
1866
1862
|
const cargoTomlPath = path7.join(pkgPath, "Cargo.toml");
|
|
1863
|
+
log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
|
|
1867
1864
|
if (fs8.existsSync(cargoTomlPath)) {
|
|
1865
|
+
log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
|
|
1868
1866
|
updatePackageVersion(cargoTomlPath, nextVersion);
|
|
1867
|
+
} else {
|
|
1868
|
+
log(`Cargo.toml not found for ${name} at ${cargoTomlPath}`, "debug");
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
|
+
} else {
|
|
1872
|
+
log(`Cargo disabled for ${name}`, "debug");
|
|
1871
1873
|
}
|
|
1872
1874
|
const packageTag = formatTag(
|
|
1873
1875
|
nextVersion,
|
|
@@ -1964,6 +1966,30 @@ function shouldProcessPackage2(pkg, config) {
|
|
|
1964
1966
|
const pkgName = pkg.packageJson.name;
|
|
1965
1967
|
return shouldProcessPackage(pkgName, config.skip);
|
|
1966
1968
|
}
|
|
1969
|
+
function updateCargoFiles(packageDir, version, cargoConfig) {
|
|
1970
|
+
const updatedFiles = [];
|
|
1971
|
+
const cargoEnabled = (cargoConfig == null ? void 0 : cargoConfig.enabled) !== false;
|
|
1972
|
+
if (!cargoEnabled) {
|
|
1973
|
+
return updatedFiles;
|
|
1974
|
+
}
|
|
1975
|
+
const cargoPaths = cargoConfig == null ? void 0 : cargoConfig.paths;
|
|
1976
|
+
if (cargoPaths && cargoPaths.length > 0) {
|
|
1977
|
+
for (const cargoPath of cargoPaths) {
|
|
1978
|
+
const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
|
|
1979
|
+
if (fs9.existsSync(resolvedCargoPath)) {
|
|
1980
|
+
updatePackageVersion(resolvedCargoPath, version);
|
|
1981
|
+
updatedFiles.push(resolvedCargoPath);
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
} else {
|
|
1985
|
+
const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
|
|
1986
|
+
if (fs9.existsSync(cargoTomlPath)) {
|
|
1987
|
+
updatePackageVersion(cargoTomlPath, version);
|
|
1988
|
+
updatedFiles.push(cargoTomlPath);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
return updatedFiles;
|
|
1992
|
+
}
|
|
1967
1993
|
function createSyncStrategy(config) {
|
|
1968
1994
|
return async (packages) => {
|
|
1969
1995
|
try {
|
|
@@ -2043,6 +2069,8 @@ function createSyncStrategy(config) {
|
|
|
2043
2069
|
files.push(rootPkgPath);
|
|
2044
2070
|
updatedPackages.push("root");
|
|
2045
2071
|
processedPaths.add(rootPkgPath);
|
|
2072
|
+
const rootCargoFiles = updateCargoFiles(packages.root, nextVersion, config.cargo);
|
|
2073
|
+
files.push(...rootCargoFiles);
|
|
2046
2074
|
}
|
|
2047
2075
|
} else {
|
|
2048
2076
|
log("Root package path is undefined, skipping root package.json update", "warning");
|
|
@@ -2063,6 +2091,8 @@ function createSyncStrategy(config) {
|
|
|
2063
2091
|
files.push(packageJsonPath);
|
|
2064
2092
|
updatedPackages.push(pkg.packageJson.name);
|
|
2065
2093
|
processedPaths.add(packageJsonPath);
|
|
2094
|
+
const pkgCargoFiles = updateCargoFiles(pkg.dir, nextVersion, config.cargo);
|
|
2095
|
+
files.push(...pkgCargoFiles);
|
|
2066
2096
|
}
|
|
2067
2097
|
if (updatedPackages.length > 0) {
|
|
2068
2098
|
log(`Updated ${updatedPackages.length} package(s) to version ${nextVersion}`, "success");
|
|
@@ -2091,8 +2121,8 @@ function createSyncStrategy(config) {
|
|
|
2091
2121
|
);
|
|
2092
2122
|
await createGitCommitAndTag(files, nextTag, formattedCommitMessage, skipHooks, dryRun);
|
|
2093
2123
|
} catch (error) {
|
|
2094
|
-
if (error
|
|
2095
|
-
log(`Synced Strategy failed: ${error.message} (${error.code
|
|
2124
|
+
if (BasePackageVersionerError.isPackageVersionerError(error)) {
|
|
2125
|
+
log(`Synced Strategy failed: ${error.message} (${error.code})`, "error");
|
|
2096
2126
|
} else {
|
|
2097
2127
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2098
2128
|
log(`Synced Strategy failed: ${errorMessage}`, "error");
|
|
@@ -2225,6 +2255,9 @@ function createSingleStrategy(config) {
|
|
|
2225
2255
|
}
|
|
2226
2256
|
const packageJsonPath = path8.join(pkgPath, "package.json");
|
|
2227
2257
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
2258
|
+
const filesToCommit = [packageJsonPath];
|
|
2259
|
+
const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo);
|
|
2260
|
+
filesToCommit.push(...cargoFiles);
|
|
2228
2261
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
2229
2262
|
const tagName = formatTag(
|
|
2230
2263
|
nextVersion,
|
|
@@ -2235,14 +2268,14 @@ function createSingleStrategy(config) {
|
|
|
2235
2268
|
);
|
|
2236
2269
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
2237
2270
|
if (!dryRun) {
|
|
2238
|
-
await createGitCommitAndTag(
|
|
2271
|
+
await createGitCommitAndTag(filesToCommit, tagName, commitMsg, skipHooks, dryRun);
|
|
2239
2272
|
log(`Created tag: ${tagName}`, "success");
|
|
2240
2273
|
} else {
|
|
2241
2274
|
log(`Would create tag: ${tagName}`, "info");
|
|
2242
2275
|
}
|
|
2243
2276
|
} catch (error) {
|
|
2244
|
-
if (error
|
|
2245
|
-
log(`Single Strategy failed: ${error.message} (${error.code
|
|
2277
|
+
if (BasePackageVersionerError.isPackageVersionerError(error)) {
|
|
2278
|
+
log(`Single Strategy failed: ${error.message} (${error.code})`, "error");
|
|
2246
2279
|
} else {
|
|
2247
2280
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2248
2281
|
log(`Single Strategy failed: ${errorMessage}`, "error");
|
|
@@ -2273,10 +2306,21 @@ function createAsyncStrategy(config) {
|
|
|
2273
2306
|
}
|
|
2274
2307
|
};
|
|
2275
2308
|
const packageProcessor = new PackageProcessor(processorOptions);
|
|
2276
|
-
return async (packages,
|
|
2309
|
+
return async (packages, targets = []) => {
|
|
2277
2310
|
try {
|
|
2278
|
-
|
|
2279
|
-
|
|
2311
|
+
let packagesToProcess = packages.packages;
|
|
2312
|
+
if (targets.length > 0) {
|
|
2313
|
+
const beforeCount = packagesToProcess.length;
|
|
2314
|
+
packagesToProcess = packagesToProcess.filter(
|
|
2315
|
+
(pkg) => targets.includes(pkg.packageJson.name)
|
|
2316
|
+
);
|
|
2317
|
+
log(
|
|
2318
|
+
`Runtime targets filter: ${beforeCount} \u2192 ${packagesToProcess.length} packages (${targets.join(", ")})`,
|
|
2319
|
+
"info"
|
|
2320
|
+
);
|
|
2321
|
+
}
|
|
2322
|
+
log(`Processing ${packagesToProcess.length} packages`, "info");
|
|
2323
|
+
const result = await packageProcessor.processPackages(packagesToProcess);
|
|
2280
2324
|
if (result.updatedPackages.length === 0) {
|
|
2281
2325
|
log("No packages required a version update.", "info");
|
|
2282
2326
|
} else {
|
|
@@ -2290,8 +2334,8 @@ function createAsyncStrategy(config) {
|
|
|
2290
2334
|
}
|
|
2291
2335
|
}
|
|
2292
2336
|
} catch (error) {
|
|
2293
|
-
if (error
|
|
2294
|
-
log(`Async Strategy failed: ${error.message} (${error.code
|
|
2337
|
+
if (BasePackageVersionerError.isPackageVersionerError(error)) {
|
|
2338
|
+
log(`Async Strategy failed: ${error.message} (${error.code})`, "error");
|
|
2295
2339
|
} else {
|
|
2296
2340
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2297
2341
|
log(`Async Strategy failed: ${errorMessage}`, "error");
|
|
@@ -2469,6 +2513,10 @@ async function run() {
|
|
|
2469
2513
|
config.isPrerelease = true;
|
|
2470
2514
|
}
|
|
2471
2515
|
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
2516
|
+
if (cliTargets.length > 0) {
|
|
2517
|
+
config.packages = cliTargets;
|
|
2518
|
+
log(`CLI targets specified: ${cliTargets.join(", ")}`, "info");
|
|
2519
|
+
}
|
|
2472
2520
|
const engine = new VersionEngine(config, !!options.json);
|
|
2473
2521
|
const pkgsResult = await engine.getWorkspacePackages();
|
|
2474
2522
|
const resolvedCount = pkgsResult.packages.length;
|
|
@@ -2499,14 +2547,19 @@ async function run() {
|
|
|
2499
2547
|
log("Versioning process completed.", "success");
|
|
2500
2548
|
printJsonOutput();
|
|
2501
2549
|
} catch (error) {
|
|
2502
|
-
|
|
2503
|
-
if (error
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2550
|
+
const { BasePackageVersionerError: BasePackageVersionerError2 } = await import("./baseError-XWEU2UI6.js");
|
|
2551
|
+
if (BasePackageVersionerError2.isPackageVersionerError(error)) {
|
|
2552
|
+
error.logError();
|
|
2553
|
+
} else {
|
|
2554
|
+
log(error instanceof Error ? error.message : String(error), "error");
|
|
2555
|
+
if (error instanceof Error) {
|
|
2556
|
+
console.error("Error details:");
|
|
2557
|
+
console.error(error.stack || error.message);
|
|
2558
|
+
if (error.message.includes("Command failed:")) {
|
|
2559
|
+
const cmdOutput = error.message.split("Command failed:")[1];
|
|
2560
|
+
if (cmdOutput) {
|
|
2561
|
+
console.error("Command output:", cmdOutput.trim());
|
|
2562
|
+
}
|
|
2510
2563
|
}
|
|
2511
2564
|
}
|
|
2512
2565
|
}
|
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.9.
|
|
4
|
+
"version": "0.9.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|