@releasekit/version 0.2.0-next.9 → 0.3.0-next.0
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/LICENSE +21 -0
- package/dist/{chunk-7F6RMN2K.js → chunk-4OGOAITO.js} +129 -265
- package/dist/cli.cjs +145 -282
- package/dist/cli.js +1 -1
- package/dist/index.cjs +124 -259
- package/dist/index.d.cts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +1 -1
- package/package.json +40 -31
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sam Maister
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from "./chunk-LMPZV35Z.js";
|
|
8
8
|
|
|
9
9
|
// src/config.ts
|
|
10
|
-
import {
|
|
10
|
+
import { loadConfig as loadReleaseKitConfig } from "@releasekit/config";
|
|
11
11
|
|
|
12
12
|
// src/types.ts
|
|
13
|
-
function toVersionConfig(config) {
|
|
13
|
+
function toVersionConfig(config, gitConfig) {
|
|
14
14
|
if (!config) {
|
|
15
15
|
return {
|
|
16
16
|
tagTemplate: "v{version}",
|
|
@@ -19,7 +19,8 @@ function toVersionConfig(config) {
|
|
|
19
19
|
sync: true,
|
|
20
20
|
packages: [],
|
|
21
21
|
updateInternalDependencies: "minor",
|
|
22
|
-
versionPrefix: ""
|
|
22
|
+
versionPrefix: "",
|
|
23
|
+
baseBranch: gitConfig?.branch
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
return {
|
|
@@ -38,19 +39,18 @@ function toVersionConfig(config) {
|
|
|
38
39
|
releaseType: bp.releaseType
|
|
39
40
|
})),
|
|
40
41
|
defaultReleaseType: config.defaultReleaseType,
|
|
41
|
-
skipHooks: config.skipHooks,
|
|
42
42
|
mismatchStrategy: config.mismatchStrategy,
|
|
43
43
|
versionPrefix: config.versionPrefix ?? "",
|
|
44
44
|
prereleaseIdentifier: config.prereleaseIdentifier,
|
|
45
|
-
baseBranch:
|
|
45
|
+
baseBranch: gitConfig?.branch,
|
|
46
46
|
cargo: config.cargo
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/config.ts
|
|
51
51
|
function loadConfig(options) {
|
|
52
|
-
const
|
|
53
|
-
return toVersionConfig(
|
|
52
|
+
const fullConfig = loadReleaseKitConfig(options);
|
|
53
|
+
return toVersionConfig(fullConfig.version, fullConfig.git);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// src/errors/versionError.ts
|
|
@@ -206,22 +206,6 @@ import semver3 from "semver";
|
|
|
206
206
|
// src/git/repository.ts
|
|
207
207
|
import { existsSync, statSync } from "fs";
|
|
208
208
|
import { join } from "path";
|
|
209
|
-
function isGitRepository(directory) {
|
|
210
|
-
const gitDir = join(directory, ".git");
|
|
211
|
-
if (!existsSync(gitDir)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
const stats = statSync(gitDir);
|
|
215
|
-
if (!stats.isDirectory()) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
try {
|
|
219
|
-
execSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd: directory });
|
|
220
|
-
return true;
|
|
221
|
-
} catch (_error) {
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
209
|
function getCurrentBranch() {
|
|
226
210
|
const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
227
211
|
return result.toString().trim();
|
|
@@ -275,8 +259,8 @@ To fix this:
|
|
|
275
259
|
let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
|
|
276
260
|
if (additionalContext) {
|
|
277
261
|
for (const [key, value] of Object.entries(additionalContext)) {
|
|
278
|
-
const placeholder = `\${${key}}`;
|
|
279
|
-
result = result.replace(new RegExp(placeholder
|
|
262
|
+
const placeholder = `${key ? `\${${key}}` : ""}`;
|
|
263
|
+
result = result.replace(new RegExp(escapeRegExp(placeholder), "g"), value);
|
|
280
264
|
}
|
|
281
265
|
}
|
|
282
266
|
return result;
|
|
@@ -590,13 +574,13 @@ import { parseCargoToml as parseCargoToml2 } from "@releasekit/config";
|
|
|
590
574
|
import semver2 from "semver";
|
|
591
575
|
|
|
592
576
|
// src/git/tagVerification.ts
|
|
593
|
-
function verifyTag(tagName,
|
|
577
|
+
function verifyTag(tagName, cwd3) {
|
|
594
578
|
if (!tagName || tagName.trim() === "") {
|
|
595
579
|
return { exists: false, reachable: false, error: "Empty tag name" };
|
|
596
580
|
}
|
|
597
581
|
try {
|
|
598
582
|
execSync("git", ["rev-parse", "--verify", tagName], {
|
|
599
|
-
cwd:
|
|
583
|
+
cwd: cwd3,
|
|
600
584
|
stdio: "ignore"
|
|
601
585
|
});
|
|
602
586
|
return { exists: true, reachable: true };
|
|
@@ -693,11 +677,11 @@ var VersionMismatchError = class extends Error {
|
|
|
693
677
|
this.name = "VersionMismatchError";
|
|
694
678
|
}
|
|
695
679
|
};
|
|
696
|
-
async function getBestVersionSource(tagName, packageVersion,
|
|
680
|
+
async function getBestVersionSource(tagName, packageVersion, cwd3, mismatchStrategy = "error", strictReachable = false) {
|
|
697
681
|
if (!tagName?.trim()) {
|
|
698
682
|
return packageVersion ? { source: "package", version: packageVersion, reason: "No git tag provided" } : { source: "initial", version: "0.1.0", reason: "No git tag or package version available" };
|
|
699
683
|
}
|
|
700
|
-
const verification = verifyTag(tagName,
|
|
684
|
+
const verification = verifyTag(tagName, cwd3);
|
|
701
685
|
if (!verification.exists || !verification.reachable) {
|
|
702
686
|
if (strictReachable) {
|
|
703
687
|
throw new Error(
|
|
@@ -964,18 +948,87 @@ async function calculateVersion(config, options) {
|
|
|
964
948
|
// src/package/packageProcessor.ts
|
|
965
949
|
import * as fs5 from "fs";
|
|
966
950
|
import path4 from "path";
|
|
967
|
-
import { exit } from "process";
|
|
968
951
|
|
|
969
952
|
// src/changelog/commitParser.ts
|
|
970
953
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
971
954
|
var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
|
|
955
|
+
function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
|
|
956
|
+
try {
|
|
957
|
+
const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
958
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
959
|
+
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
960
|
+
return commits.map((commit) => {
|
|
961
|
+
const [hash, ...messageParts] = commit.split("|||");
|
|
962
|
+
const message = messageParts.join("|||").trim();
|
|
963
|
+
const entry = parseCommitMessage(message);
|
|
964
|
+
if (entry && hash) {
|
|
965
|
+
return { hash: hash.trim(), entry };
|
|
966
|
+
}
|
|
967
|
+
return null;
|
|
968
|
+
}).filter((item) => item !== null);
|
|
969
|
+
} catch (error) {
|
|
970
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
971
|
+
log(`Error extracting all commits with hash: ${errorMessage}`, "error");
|
|
972
|
+
return [];
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
|
|
976
|
+
try {
|
|
977
|
+
const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
|
|
978
|
+
cwd: projectDir,
|
|
979
|
+
encoding: "utf8"
|
|
980
|
+
}).toString().trim();
|
|
981
|
+
if (!output) {
|
|
982
|
+
return false;
|
|
983
|
+
}
|
|
984
|
+
const changedFiles = output.split("\n");
|
|
985
|
+
return changedFiles.some((file) => {
|
|
986
|
+
return packageDirs.some((pkgDir) => {
|
|
987
|
+
if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
|
|
988
|
+
return false;
|
|
989
|
+
}
|
|
990
|
+
const normalizedFile = file.replace(/\\/g, "/");
|
|
991
|
+
const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
992
|
+
return normalizedFile.startsWith(normalizedPkgDir);
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
} catch (error) {
|
|
996
|
+
log(
|
|
997
|
+
`Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
|
|
998
|
+
"debug"
|
|
999
|
+
);
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
|
|
1004
|
+
try {
|
|
1005
|
+
const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
|
|
1006
|
+
const repoLevelCommits = allCommits.filter((commit) => {
|
|
1007
|
+
const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
|
|
1008
|
+
return !touchesPackage;
|
|
1009
|
+
});
|
|
1010
|
+
if (repoLevelCommits.length > 0) {
|
|
1011
|
+
log(
|
|
1012
|
+
`Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
|
|
1013
|
+
"debug"
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
return repoLevelCommits.map((c) => c.entry);
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
1019
|
+
return [];
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
972
1022
|
function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
|
|
1023
|
+
return extractCommitsFromGitLog(projectDir, revisionRange, true);
|
|
1024
|
+
}
|
|
1025
|
+
function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
|
|
973
1026
|
try {
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
).toString();
|
|
1027
|
+
const args = ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
1028
|
+
if (filterToPath) {
|
|
1029
|
+
args.push("--", ".");
|
|
1030
|
+
}
|
|
1031
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
979
1032
|
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
980
1033
|
return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
|
|
981
1034
|
} catch (error) {
|
|
@@ -1068,168 +1121,6 @@ function extractIssueIds(body) {
|
|
|
1068
1121
|
return issueIds;
|
|
1069
1122
|
}
|
|
1070
1123
|
|
|
1071
|
-
// src/git/commands.ts
|
|
1072
|
-
import { cwd as cwd2 } from "process";
|
|
1073
|
-
|
|
1074
|
-
// src/errors/gitError.ts
|
|
1075
|
-
var GitError = class extends BaseVersionError {
|
|
1076
|
-
};
|
|
1077
|
-
function createGitError(code, details) {
|
|
1078
|
-
const messages = {
|
|
1079
|
-
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: "Not a git repository",
|
|
1080
|
-
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: "Failed to create new version",
|
|
1081
|
-
["NO_FILES" /* NO_FILES */]: "No files specified for commit",
|
|
1082
|
-
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: "Commit message is required",
|
|
1083
|
-
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed",
|
|
1084
|
-
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: "Git tag already exists"
|
|
1085
|
-
};
|
|
1086
|
-
const suggestions = {
|
|
1087
|
-
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: [
|
|
1088
|
-
"Initialize git repository with: git init",
|
|
1089
|
-
"Ensure you are in the correct directory"
|
|
1090
|
-
],
|
|
1091
|
-
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: [
|
|
1092
|
-
"Delete the existing tag: git tag -d <tag-name>",
|
|
1093
|
-
"Use a different version by incrementing manually",
|
|
1094
|
-
"Check if this version was already released"
|
|
1095
|
-
],
|
|
1096
|
-
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: void 0,
|
|
1097
|
-
["NO_FILES" /* NO_FILES */]: void 0,
|
|
1098
|
-
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: void 0,
|
|
1099
|
-
["GIT_ERROR" /* GIT_ERROR */]: void 0
|
|
1100
|
-
};
|
|
1101
|
-
const baseMessage = messages[code];
|
|
1102
|
-
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
1103
|
-
return new GitError(fullMessage, code, suggestions[code]);
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
// src/git/commands.ts
|
|
1107
|
-
async function gitAdd(files) {
|
|
1108
|
-
return execAsync("git", ["add", ...files]);
|
|
1109
|
-
}
|
|
1110
|
-
async function gitCommit(options) {
|
|
1111
|
-
const args = ["commit"];
|
|
1112
|
-
if (options.amend) {
|
|
1113
|
-
args.push("--amend");
|
|
1114
|
-
}
|
|
1115
|
-
if (options.author) {
|
|
1116
|
-
args.push("--author", options.author);
|
|
1117
|
-
}
|
|
1118
|
-
if (options.date) {
|
|
1119
|
-
args.push("--date", options.date);
|
|
1120
|
-
}
|
|
1121
|
-
if (options.skipHooks) {
|
|
1122
|
-
args.push("--no-verify");
|
|
1123
|
-
}
|
|
1124
|
-
args.push("-m", options.message);
|
|
1125
|
-
return execAsync("git", args);
|
|
1126
|
-
}
|
|
1127
|
-
async function createGitTag(options) {
|
|
1128
|
-
const { tag, message = "" } = options;
|
|
1129
|
-
const args = ["tag", "-a", "-m", message, tag];
|
|
1130
|
-
try {
|
|
1131
|
-
return await execAsync("git", args);
|
|
1132
|
-
} catch (error) {
|
|
1133
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1134
|
-
if (errorMessage.includes("already exists")) {
|
|
1135
|
-
throw createGitError(
|
|
1136
|
-
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
1137
|
-
`Tag '${tag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
1138
|
-
);
|
|
1139
|
-
}
|
|
1140
|
-
throw createGitError("GIT_ERROR" /* GIT_ERROR */, errorMessage);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
async function gitProcess(options) {
|
|
1144
|
-
const { files, nextTag, commitMessage, skipHooks, dryRun } = options;
|
|
1145
|
-
if (!isGitRepository(cwd2())) {
|
|
1146
|
-
throw createGitError("NOT_GIT_REPO" /* NOT_GIT_REPO */);
|
|
1147
|
-
}
|
|
1148
|
-
try {
|
|
1149
|
-
if (!dryRun) {
|
|
1150
|
-
await gitAdd(files);
|
|
1151
|
-
await gitCommit({
|
|
1152
|
-
message: commitMessage,
|
|
1153
|
-
skipHooks
|
|
1154
|
-
});
|
|
1155
|
-
if (nextTag) {
|
|
1156
|
-
const tagMessage = `New Version ${nextTag} generated at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
1157
|
-
await createGitTag({
|
|
1158
|
-
tag: nextTag,
|
|
1159
|
-
message: tagMessage
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
} else {
|
|
1163
|
-
log("[DRY RUN] Would add files:", "info");
|
|
1164
|
-
for (const file of files) {
|
|
1165
|
-
log(` - ${file}`, "info");
|
|
1166
|
-
}
|
|
1167
|
-
log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
|
|
1168
|
-
if (nextTag) {
|
|
1169
|
-
log(`[DRY RUN] Would create tag: ${nextTag}`, "info");
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
} catch (err) {
|
|
1173
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1174
|
-
if (errorMessage.includes("already exists") && nextTag) {
|
|
1175
|
-
log(`Tag '${nextTag}' already exists in the repository.`, "error");
|
|
1176
|
-
throw createGitError(
|
|
1177
|
-
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
1178
|
-
`Tag '${nextTag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
log(`Git process error: ${errorMessage}`, "error");
|
|
1182
|
-
if (err instanceof Error && err.stack) {
|
|
1183
|
-
console.error("Git process stack trace:");
|
|
1184
|
-
console.error(err.stack);
|
|
1185
|
-
}
|
|
1186
|
-
throw createGitError("GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */, errorMessage);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, dryRun) {
|
|
1190
|
-
try {
|
|
1191
|
-
if (!files || files.length === 0) {
|
|
1192
|
-
throw createGitError("NO_FILES" /* NO_FILES */);
|
|
1193
|
-
}
|
|
1194
|
-
if (!commitMessage) {
|
|
1195
|
-
throw createGitError("NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */);
|
|
1196
|
-
}
|
|
1197
|
-
setCommitMessage(commitMessage);
|
|
1198
|
-
if (nextTag) {
|
|
1199
|
-
addTag(nextTag);
|
|
1200
|
-
}
|
|
1201
|
-
await gitProcess({
|
|
1202
|
-
files,
|
|
1203
|
-
nextTag,
|
|
1204
|
-
commitMessage,
|
|
1205
|
-
skipHooks,
|
|
1206
|
-
dryRun
|
|
1207
|
-
});
|
|
1208
|
-
if (!dryRun) {
|
|
1209
|
-
log(`Created tag: ${nextTag}`, "success");
|
|
1210
|
-
}
|
|
1211
|
-
} catch (error) {
|
|
1212
|
-
if (error instanceof GitError) {
|
|
1213
|
-
throw error;
|
|
1214
|
-
}
|
|
1215
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1216
|
-
log(`Failed to create git commit and tag: ${errorMessage}`, "error");
|
|
1217
|
-
if (error instanceof Error) {
|
|
1218
|
-
console.error("Git operation error details:");
|
|
1219
|
-
console.error(error.stack || error.message);
|
|
1220
|
-
if (errorMessage.includes("Command failed:")) {
|
|
1221
|
-
const cmdOutput = errorMessage.split("Command failed:")[1];
|
|
1222
|
-
if (cmdOutput) {
|
|
1223
|
-
console.error("Git command output:", cmdOutput.trim());
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
} else {
|
|
1227
|
-
console.error("Unknown git error:", error);
|
|
1228
|
-
}
|
|
1229
|
-
throw new GitError(`Git operation failed: ${errorMessage}`, "GIT_ERROR" /* GIT_ERROR */);
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
1124
|
// src/utils/packageMatching.ts
|
|
1234
1125
|
import micromatch from "micromatch";
|
|
1235
1126
|
function matchesPackageTarget(packageName, target) {
|
|
@@ -1301,7 +1192,6 @@ var PackageProcessor = class {
|
|
|
1301
1192
|
tagTemplate;
|
|
1302
1193
|
commitMessageTemplate;
|
|
1303
1194
|
dryRun;
|
|
1304
|
-
skipHooks;
|
|
1305
1195
|
getLatestTag;
|
|
1306
1196
|
config;
|
|
1307
1197
|
// Config for version calculation
|
|
@@ -1312,7 +1202,6 @@ var PackageProcessor = class {
|
|
|
1312
1202
|
this.tagTemplate = options.tagTemplate;
|
|
1313
1203
|
this.commitMessageTemplate = options.commitMessageTemplate || "";
|
|
1314
1204
|
this.dryRun = options.dryRun || false;
|
|
1315
|
-
this.skipHooks = options.skipHooks || false;
|
|
1316
1205
|
this.getLatestTag = options.getLatestTag;
|
|
1317
1206
|
this.config = options.config;
|
|
1318
1207
|
this.fullConfig = options.fullConfig;
|
|
@@ -1415,6 +1304,19 @@ var PackageProcessor = class {
|
|
|
1415
1304
|
revisionRange = "HEAD";
|
|
1416
1305
|
}
|
|
1417
1306
|
changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
|
|
1307
|
+
const allPackageDirs = packages.map((p) => p.dir);
|
|
1308
|
+
const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
|
|
1309
|
+
const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
|
|
1310
|
+
const repoLevelEntries = extractRepoLevelChangelogEntries(
|
|
1311
|
+
pkgPath,
|
|
1312
|
+
revisionRange,
|
|
1313
|
+
allPackageDirs,
|
|
1314
|
+
sharedPackageDirs
|
|
1315
|
+
);
|
|
1316
|
+
if (repoLevelEntries.length > 0) {
|
|
1317
|
+
log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
|
|
1318
|
+
changelogEntries = [...repoLevelEntries, ...changelogEntries];
|
|
1319
|
+
}
|
|
1418
1320
|
if (changelogEntries.length === 0) {
|
|
1419
1321
|
changelogEntries = [
|
|
1420
1322
|
{
|
|
@@ -1502,19 +1404,12 @@ var PackageProcessor = class {
|
|
|
1502
1404
|
this.tagTemplate,
|
|
1503
1405
|
this.fullConfig.packageSpecificTags
|
|
1504
1406
|
);
|
|
1505
|
-
const tagMessage = `chore(release): ${name} ${nextVersion}`;
|
|
1506
1407
|
addTag(packageTag);
|
|
1507
1408
|
tags.push(packageTag);
|
|
1508
|
-
if (
|
|
1509
|
-
try {
|
|
1510
|
-
await createGitTag({ tag: packageTag, message: tagMessage });
|
|
1511
|
-
log(`Created tag: ${packageTag}`, "success");
|
|
1512
|
-
} catch (tagError) {
|
|
1513
|
-
log(`Failed to create tag ${packageTag} for ${name}: ${tagError.message}`, "error");
|
|
1514
|
-
log(tagError.stack || "No stack trace available", "error");
|
|
1515
|
-
}
|
|
1516
|
-
} else {
|
|
1409
|
+
if (this.dryRun) {
|
|
1517
1410
|
log(`[DRY RUN] Would create tag: ${packageTag}`, "info");
|
|
1411
|
+
} else {
|
|
1412
|
+
log(`Version ${nextVersion} prepared (tag: ${packageTag})`, "success");
|
|
1518
1413
|
}
|
|
1519
1414
|
updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
|
|
1520
1415
|
}
|
|
@@ -1522,34 +1417,15 @@ var PackageProcessor = class {
|
|
|
1522
1417
|
log("No packages required a version update.", "info");
|
|
1523
1418
|
return { updatedPackages: [], tags };
|
|
1524
1419
|
}
|
|
1525
|
-
const filesToCommit = [];
|
|
1526
|
-
for (const info of updatedPackagesInfo) {
|
|
1527
|
-
const packageJsonPath = path4.join(info.path, "package.json");
|
|
1528
|
-
if (fs5.existsSync(packageJsonPath)) {
|
|
1529
|
-
filesToCommit.push(packageJsonPath);
|
|
1530
|
-
}
|
|
1531
|
-
const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
|
|
1532
|
-
if (cargoEnabled) {
|
|
1533
|
-
const cargoPaths = this.fullConfig.cargo?.paths;
|
|
1534
|
-
if (cargoPaths && cargoPaths.length > 0) {
|
|
1535
|
-
for (const cargoPath of cargoPaths) {
|
|
1536
|
-
const resolvedCargoPath = path4.resolve(info.path, cargoPath, "Cargo.toml");
|
|
1537
|
-
if (fs5.existsSync(resolvedCargoPath)) {
|
|
1538
|
-
filesToCommit.push(resolvedCargoPath);
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
} else {
|
|
1542
|
-
const cargoTomlPath = path4.join(info.path, "Cargo.toml");
|
|
1543
|
-
if (fs5.existsSync(cargoTomlPath)) {
|
|
1544
|
-
filesToCommit.push(cargoTomlPath);
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
1420
|
const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
|
|
1550
1421
|
const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
|
|
1551
1422
|
let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
|
|
1552
|
-
const
|
|
1423
|
+
const MAX_COMMIT_MSG_LENGTH = 1e4;
|
|
1424
|
+
if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
|
|
1425
|
+
log("Commit message template too long, truncating", "warning");
|
|
1426
|
+
commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
|
|
1427
|
+
}
|
|
1428
|
+
const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
|
|
1553
1429
|
if (updatedPackagesInfo.length === 1 && placeholderRegex.test(commitMessage)) {
|
|
1554
1430
|
const packageName = updatedPackagesInfo[0].name;
|
|
1555
1431
|
commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
|
|
@@ -1557,21 +1433,7 @@ var PackageProcessor = class {
|
|
|
1557
1433
|
commitMessage = `chore(release): ${packageNames} ${representativeVersion}`;
|
|
1558
1434
|
}
|
|
1559
1435
|
setCommitMessage(commitMessage);
|
|
1560
|
-
if (
|
|
1561
|
-
try {
|
|
1562
|
-
await gitAdd(filesToCommit);
|
|
1563
|
-
await gitCommit({ message: commitMessage, skipHooks: this.skipHooks });
|
|
1564
|
-
log(`Created commit for targeted release: ${packageNames}`, "success");
|
|
1565
|
-
} catch (commitError) {
|
|
1566
|
-
log("Failed to create commit for targeted release.", "error");
|
|
1567
|
-
console.error(commitError);
|
|
1568
|
-
exit(1);
|
|
1569
|
-
}
|
|
1570
|
-
} else {
|
|
1571
|
-
log("[DRY RUN] Would add files:", "info");
|
|
1572
|
-
for (const file of filesToCommit) {
|
|
1573
|
-
log(` - ${file}`, "info");
|
|
1574
|
-
}
|
|
1436
|
+
if (this.dryRun) {
|
|
1575
1437
|
log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
|
|
1576
1438
|
}
|
|
1577
1439
|
return {
|
|
@@ -1624,7 +1486,6 @@ function createSyncStrategy(config) {
|
|
|
1624
1486
|
commitMessage = `chore(release): v\${version}`,
|
|
1625
1487
|
prereleaseIdentifier,
|
|
1626
1488
|
dryRun,
|
|
1627
|
-
skipHooks,
|
|
1628
1489
|
mainPackage
|
|
1629
1490
|
} = config;
|
|
1630
1491
|
const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
|
|
@@ -1774,7 +1635,13 @@ function createSyncStrategy(config) {
|
|
|
1774
1635
|
config.packageSpecificTags || false
|
|
1775
1636
|
);
|
|
1776
1637
|
const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, commitPackageName, void 0);
|
|
1777
|
-
|
|
1638
|
+
addTag(nextTag);
|
|
1639
|
+
setCommitMessage(formattedCommitMessage);
|
|
1640
|
+
if (!dryRun) {
|
|
1641
|
+
log(`Version ${nextVersion} prepared (tag: ${nextTag})`, "success");
|
|
1642
|
+
} else {
|
|
1643
|
+
log(`Would create tag: ${nextTag}`, "info");
|
|
1644
|
+
}
|
|
1778
1645
|
} catch (error) {
|
|
1779
1646
|
if (BaseVersionError.isVersionError(error)) {
|
|
1780
1647
|
log(`Synced Strategy failed: ${error.message} (${error.code})`, "error");
|
|
@@ -1789,14 +1656,7 @@ function createSyncStrategy(config) {
|
|
|
1789
1656
|
function createSingleStrategy(config) {
|
|
1790
1657
|
return async (packages) => {
|
|
1791
1658
|
try {
|
|
1792
|
-
const {
|
|
1793
|
-
mainPackage,
|
|
1794
|
-
versionPrefix,
|
|
1795
|
-
tagTemplate,
|
|
1796
|
-
commitMessage = `chore(release): \${version}`,
|
|
1797
|
-
dryRun,
|
|
1798
|
-
skipHooks
|
|
1799
|
-
} = config;
|
|
1659
|
+
const { mainPackage, versionPrefix, tagTemplate, commitMessage = `chore(release): \${version}`, dryRun } = config;
|
|
1800
1660
|
let packageName;
|
|
1801
1661
|
if (mainPackage) {
|
|
1802
1662
|
packageName = mainPackage;
|
|
@@ -1916,9 +1776,10 @@ function createSingleStrategy(config) {
|
|
|
1916
1776
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
1917
1777
|
const tagName = formatTag(nextVersion, formattedPrefix, packageName, tagTemplate, config.packageSpecificTags);
|
|
1918
1778
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
1779
|
+
addTag(tagName);
|
|
1780
|
+
setCommitMessage(commitMsg);
|
|
1919
1781
|
if (!dryRun) {
|
|
1920
|
-
|
|
1921
|
-
log(`Created tag: ${tagName}`, "success");
|
|
1782
|
+
log(`Version ${nextVersion} prepared (tag: ${tagName})`, "success");
|
|
1922
1783
|
} else {
|
|
1923
1784
|
log(`Would create tag: ${tagName}`, "info");
|
|
1924
1785
|
}
|
|
@@ -1943,7 +1804,6 @@ function createAsyncStrategy(config) {
|
|
|
1943
1804
|
tagTemplate: config.tagTemplate,
|
|
1944
1805
|
commitMessageTemplate: config.commitMessage || "",
|
|
1945
1806
|
dryRun: config.dryRun || false,
|
|
1946
|
-
skipHooks: config.skipHooks || false,
|
|
1947
1807
|
getLatestTag: dependencies.getLatestTag,
|
|
1948
1808
|
fullConfig: config,
|
|
1949
1809
|
// Extract common version configuration properties
|
|
@@ -2006,9 +1866,13 @@ function createStrategyMap(config) {
|
|
|
2006
1866
|
}
|
|
2007
1867
|
|
|
2008
1868
|
// src/core/versionEngine.ts
|
|
2009
|
-
import { cwd as
|
|
1869
|
+
import { cwd as cwd2 } from "process";
|
|
2010
1870
|
import { getPackagesSync } from "@manypkg/get-packages";
|
|
2011
1871
|
|
|
1872
|
+
// src/errors/gitError.ts
|
|
1873
|
+
var GitError = class extends BaseVersionError {
|
|
1874
|
+
};
|
|
1875
|
+
|
|
2012
1876
|
// src/utils/packageFiltering.ts
|
|
2013
1877
|
import path6 from "path";
|
|
2014
1878
|
import micromatch2 from "micromatch";
|
|
@@ -2114,13 +1978,13 @@ var VersionEngine = class {
|
|
|
2114
1978
|
if (this.workspaceCache) {
|
|
2115
1979
|
return this.workspaceCache;
|
|
2116
1980
|
}
|
|
2117
|
-
const pkgsResult = getPackagesSync(
|
|
1981
|
+
const pkgsResult = getPackagesSync(cwd2());
|
|
2118
1982
|
if (!pkgsResult || !pkgsResult.packages) {
|
|
2119
1983
|
throw createVersionError("PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */);
|
|
2120
1984
|
}
|
|
2121
1985
|
if (!pkgsResult.root) {
|
|
2122
1986
|
log("Root path is undefined in packages result, setting to current working directory", "warning");
|
|
2123
|
-
pkgsResult.root =
|
|
1987
|
+
pkgsResult.root = cwd2();
|
|
2124
1988
|
}
|
|
2125
1989
|
if (this.config.packages && this.config.packages.length > 0) {
|
|
2126
1990
|
const originalCount = pkgsResult.packages.length;
|