@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/dist/index.cjs
CHANGED
|
@@ -79,7 +79,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
79
79
|
var import_config = require("@releasekit/config");
|
|
80
80
|
|
|
81
81
|
// src/types.ts
|
|
82
|
-
function toVersionConfig(config) {
|
|
82
|
+
function toVersionConfig(config, gitConfig) {
|
|
83
83
|
if (!config) {
|
|
84
84
|
return {
|
|
85
85
|
tagTemplate: "v{version}",
|
|
@@ -88,7 +88,8 @@ function toVersionConfig(config) {
|
|
|
88
88
|
sync: true,
|
|
89
89
|
packages: [],
|
|
90
90
|
updateInternalDependencies: "minor",
|
|
91
|
-
versionPrefix: ""
|
|
91
|
+
versionPrefix: "",
|
|
92
|
+
baseBranch: gitConfig?.branch
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
return {
|
|
@@ -107,19 +108,18 @@ function toVersionConfig(config) {
|
|
|
107
108
|
releaseType: bp.releaseType
|
|
108
109
|
})),
|
|
109
110
|
defaultReleaseType: config.defaultReleaseType,
|
|
110
|
-
skipHooks: config.skipHooks,
|
|
111
111
|
mismatchStrategy: config.mismatchStrategy,
|
|
112
112
|
versionPrefix: config.versionPrefix ?? "",
|
|
113
113
|
prereleaseIdentifier: config.prereleaseIdentifier,
|
|
114
|
-
baseBranch:
|
|
114
|
+
baseBranch: gitConfig?.branch,
|
|
115
115
|
cargo: config.cargo
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// src/config.ts
|
|
120
120
|
function loadConfig(options) {
|
|
121
|
-
const
|
|
122
|
-
return toVersionConfig(
|
|
121
|
+
const fullConfig = (0, import_config.loadConfig)(options);
|
|
122
|
+
return toVersionConfig(fullConfig.version, fullConfig.git);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// src/core/versionCalculator.ts
|
|
@@ -131,22 +131,6 @@ var import_semver3 = __toESM(require("semver"), 1);
|
|
|
131
131
|
var import_node_fs = require("fs");
|
|
132
132
|
var import_node_path = require("path");
|
|
133
133
|
init_commandExecutor();
|
|
134
|
-
function isGitRepository(directory) {
|
|
135
|
-
const gitDir = (0, import_node_path.join)(directory, ".git");
|
|
136
|
-
if (!(0, import_node_fs.existsSync)(gitDir)) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
const stats = (0, import_node_fs.statSync)(gitDir);
|
|
140
|
-
if (!stats.isDirectory()) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
execSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd: directory });
|
|
145
|
-
return true;
|
|
146
|
-
} catch (_error) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
134
|
function getCurrentBranch() {
|
|
151
135
|
const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
152
136
|
return result.toString().trim();
|
|
@@ -285,8 +269,8 @@ To fix this:
|
|
|
285
269
|
let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
|
|
286
270
|
if (additionalContext) {
|
|
287
271
|
for (const [key, value] of Object.entries(additionalContext)) {
|
|
288
|
-
const placeholder = `\${${key}}`;
|
|
289
|
-
result = result.replace(new RegExp(placeholder
|
|
272
|
+
const placeholder = `${key ? `\${${key}}` : ""}`;
|
|
273
|
+
result = result.replace(new RegExp(escapeRegExp(placeholder), "g"), value);
|
|
290
274
|
}
|
|
291
275
|
}
|
|
292
276
|
return result;
|
|
@@ -602,13 +586,13 @@ var import_semver2 = __toESM(require("semver"), 1);
|
|
|
602
586
|
|
|
603
587
|
// src/git/tagVerification.ts
|
|
604
588
|
init_commandExecutor();
|
|
605
|
-
function verifyTag(tagName,
|
|
589
|
+
function verifyTag(tagName, cwd3) {
|
|
606
590
|
if (!tagName || tagName.trim() === "") {
|
|
607
591
|
return { exists: false, reachable: false, error: "Empty tag name" };
|
|
608
592
|
}
|
|
609
593
|
try {
|
|
610
594
|
execSync("git", ["rev-parse", "--verify", tagName], {
|
|
611
|
-
cwd:
|
|
595
|
+
cwd: cwd3,
|
|
612
596
|
stdio: "ignore"
|
|
613
597
|
});
|
|
614
598
|
return { exists: true, reachable: true };
|
|
@@ -705,11 +689,11 @@ var VersionMismatchError = class extends Error {
|
|
|
705
689
|
this.name = "VersionMismatchError";
|
|
706
690
|
}
|
|
707
691
|
};
|
|
708
|
-
async function getBestVersionSource(tagName, packageVersion,
|
|
692
|
+
async function getBestVersionSource(tagName, packageVersion, cwd3, mismatchStrategy = "error", strictReachable = false) {
|
|
709
693
|
if (!tagName?.trim()) {
|
|
710
694
|
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" };
|
|
711
695
|
}
|
|
712
|
-
const verification = verifyTag(tagName,
|
|
696
|
+
const verification = verifyTag(tagName, cwd3);
|
|
713
697
|
if (!verification.exists || !verification.reachable) {
|
|
714
698
|
if (strictReachable) {
|
|
715
699
|
throw new Error(
|
|
@@ -974,7 +958,7 @@ async function calculateVersion(config, options) {
|
|
|
974
958
|
}
|
|
975
959
|
|
|
976
960
|
// src/core/versionEngine.ts
|
|
977
|
-
var
|
|
961
|
+
var import_node_process2 = require("process");
|
|
978
962
|
var import_get_packages = require("@manypkg/get-packages");
|
|
979
963
|
|
|
980
964
|
// src/errors/baseError.ts
|
|
@@ -995,34 +979,6 @@ var BaseVersionError = class _BaseVersionError extends import_core.ReleaseKitErr
|
|
|
995
979
|
// src/errors/gitError.ts
|
|
996
980
|
var GitError = class extends BaseVersionError {
|
|
997
981
|
};
|
|
998
|
-
function createGitError(code, details) {
|
|
999
|
-
const messages = {
|
|
1000
|
-
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: "Not a git repository",
|
|
1001
|
-
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: "Failed to create new version",
|
|
1002
|
-
["NO_FILES" /* NO_FILES */]: "No files specified for commit",
|
|
1003
|
-
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: "Commit message is required",
|
|
1004
|
-
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed",
|
|
1005
|
-
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: "Git tag already exists"
|
|
1006
|
-
};
|
|
1007
|
-
const suggestions = {
|
|
1008
|
-
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: [
|
|
1009
|
-
"Initialize git repository with: git init",
|
|
1010
|
-
"Ensure you are in the correct directory"
|
|
1011
|
-
],
|
|
1012
|
-
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: [
|
|
1013
|
-
"Delete the existing tag: git tag -d <tag-name>",
|
|
1014
|
-
"Use a different version by incrementing manually",
|
|
1015
|
-
"Check if this version was already released"
|
|
1016
|
-
],
|
|
1017
|
-
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: void 0,
|
|
1018
|
-
["NO_FILES" /* NO_FILES */]: void 0,
|
|
1019
|
-
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: void 0,
|
|
1020
|
-
["GIT_ERROR" /* GIT_ERROR */]: void 0
|
|
1021
|
-
};
|
|
1022
|
-
const baseMessage = messages[code];
|
|
1023
|
-
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
1024
|
-
return new GitError(fullMessage, code, suggestions[code]);
|
|
1025
|
-
}
|
|
1026
982
|
|
|
1027
983
|
// src/errors/versionError.ts
|
|
1028
984
|
var VersionError = class extends BaseVersionError {
|
|
@@ -1168,13 +1124,83 @@ var path6 = __toESM(require("path"), 1);
|
|
|
1168
1124
|
init_commandExecutor();
|
|
1169
1125
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
1170
1126
|
var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
|
|
1127
|
+
function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
|
|
1128
|
+
try {
|
|
1129
|
+
const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
1130
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
1131
|
+
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
1132
|
+
return commits.map((commit) => {
|
|
1133
|
+
const [hash, ...messageParts] = commit.split("|||");
|
|
1134
|
+
const message = messageParts.join("|||").trim();
|
|
1135
|
+
const entry = parseCommitMessage(message);
|
|
1136
|
+
if (entry && hash) {
|
|
1137
|
+
return { hash: hash.trim(), entry };
|
|
1138
|
+
}
|
|
1139
|
+
return null;
|
|
1140
|
+
}).filter((item) => item !== null);
|
|
1141
|
+
} catch (error) {
|
|
1142
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1143
|
+
log(`Error extracting all commits with hash: ${errorMessage}`, "error");
|
|
1144
|
+
return [];
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
|
|
1148
|
+
try {
|
|
1149
|
+
const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
|
|
1150
|
+
cwd: projectDir,
|
|
1151
|
+
encoding: "utf8"
|
|
1152
|
+
}).toString().trim();
|
|
1153
|
+
if (!output) {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
const changedFiles = output.split("\n");
|
|
1157
|
+
return changedFiles.some((file) => {
|
|
1158
|
+
return packageDirs.some((pkgDir) => {
|
|
1159
|
+
if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
const normalizedFile = file.replace(/\\/g, "/");
|
|
1163
|
+
const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1164
|
+
return normalizedFile.startsWith(normalizedPkgDir);
|
|
1165
|
+
});
|
|
1166
|
+
});
|
|
1167
|
+
} catch (error) {
|
|
1168
|
+
log(
|
|
1169
|
+
`Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
|
|
1170
|
+
"debug"
|
|
1171
|
+
);
|
|
1172
|
+
return false;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
|
|
1176
|
+
try {
|
|
1177
|
+
const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
|
|
1178
|
+
const repoLevelCommits = allCommits.filter((commit) => {
|
|
1179
|
+
const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
|
|
1180
|
+
return !touchesPackage;
|
|
1181
|
+
});
|
|
1182
|
+
if (repoLevelCommits.length > 0) {
|
|
1183
|
+
log(
|
|
1184
|
+
`Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
|
|
1185
|
+
"debug"
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
return repoLevelCommits.map((c) => c.entry);
|
|
1189
|
+
} catch (error) {
|
|
1190
|
+
log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
1191
|
+
return [];
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1171
1194
|
function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
|
|
1195
|
+
return extractCommitsFromGitLog(projectDir, revisionRange, true);
|
|
1196
|
+
}
|
|
1197
|
+
function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
|
|
1172
1198
|
try {
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
).toString();
|
|
1199
|
+
const args = ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
1200
|
+
if (filterToPath) {
|
|
1201
|
+
args.push("--", ".");
|
|
1202
|
+
}
|
|
1203
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
1178
1204
|
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
1179
1205
|
return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
|
|
1180
1206
|
} catch (error) {
|
|
@@ -1270,135 +1296,6 @@ function extractIssueIds(body) {
|
|
|
1270
1296
|
// src/core/versionStrategies.ts
|
|
1271
1297
|
init_commandExecutor();
|
|
1272
1298
|
|
|
1273
|
-
// src/git/commands.ts
|
|
1274
|
-
var import_node_process2 = require("process");
|
|
1275
|
-
init_commandExecutor();
|
|
1276
|
-
async function gitAdd(files) {
|
|
1277
|
-
return execAsync("git", ["add", ...files]);
|
|
1278
|
-
}
|
|
1279
|
-
async function gitCommit(options) {
|
|
1280
|
-
const args = ["commit"];
|
|
1281
|
-
if (options.amend) {
|
|
1282
|
-
args.push("--amend");
|
|
1283
|
-
}
|
|
1284
|
-
if (options.author) {
|
|
1285
|
-
args.push("--author", options.author);
|
|
1286
|
-
}
|
|
1287
|
-
if (options.date) {
|
|
1288
|
-
args.push("--date", options.date);
|
|
1289
|
-
}
|
|
1290
|
-
if (options.skipHooks) {
|
|
1291
|
-
args.push("--no-verify");
|
|
1292
|
-
}
|
|
1293
|
-
args.push("-m", options.message);
|
|
1294
|
-
return execAsync("git", args);
|
|
1295
|
-
}
|
|
1296
|
-
async function createGitTag(options) {
|
|
1297
|
-
const { tag, message = "" } = options;
|
|
1298
|
-
const args = ["tag", "-a", "-m", message, tag];
|
|
1299
|
-
try {
|
|
1300
|
-
return await execAsync("git", args);
|
|
1301
|
-
} catch (error) {
|
|
1302
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1303
|
-
if (errorMessage.includes("already exists")) {
|
|
1304
|
-
throw createGitError(
|
|
1305
|
-
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
1306
|
-
`Tag '${tag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
1307
|
-
);
|
|
1308
|
-
}
|
|
1309
|
-
throw createGitError("GIT_ERROR" /* GIT_ERROR */, errorMessage);
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
async function gitProcess(options) {
|
|
1313
|
-
const { files, nextTag, commitMessage, skipHooks, dryRun } = options;
|
|
1314
|
-
if (!isGitRepository((0, import_node_process2.cwd)())) {
|
|
1315
|
-
throw createGitError("NOT_GIT_REPO" /* NOT_GIT_REPO */);
|
|
1316
|
-
}
|
|
1317
|
-
try {
|
|
1318
|
-
if (!dryRun) {
|
|
1319
|
-
await gitAdd(files);
|
|
1320
|
-
await gitCommit({
|
|
1321
|
-
message: commitMessage,
|
|
1322
|
-
skipHooks
|
|
1323
|
-
});
|
|
1324
|
-
if (nextTag) {
|
|
1325
|
-
const tagMessage = `New Version ${nextTag} generated at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
1326
|
-
await createGitTag({
|
|
1327
|
-
tag: nextTag,
|
|
1328
|
-
message: tagMessage
|
|
1329
|
-
});
|
|
1330
|
-
}
|
|
1331
|
-
} else {
|
|
1332
|
-
log("[DRY RUN] Would add files:", "info");
|
|
1333
|
-
for (const file of files) {
|
|
1334
|
-
log(` - ${file}`, "info");
|
|
1335
|
-
}
|
|
1336
|
-
log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
|
|
1337
|
-
if (nextTag) {
|
|
1338
|
-
log(`[DRY RUN] Would create tag: ${nextTag}`, "info");
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
} catch (err) {
|
|
1342
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1343
|
-
if (errorMessage.includes("already exists") && nextTag) {
|
|
1344
|
-
log(`Tag '${nextTag}' already exists in the repository.`, "error");
|
|
1345
|
-
throw createGitError(
|
|
1346
|
-
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
1347
|
-
`Tag '${nextTag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
1348
|
-
);
|
|
1349
|
-
}
|
|
1350
|
-
log(`Git process error: ${errorMessage}`, "error");
|
|
1351
|
-
if (err instanceof Error && err.stack) {
|
|
1352
|
-
console.error("Git process stack trace:");
|
|
1353
|
-
console.error(err.stack);
|
|
1354
|
-
}
|
|
1355
|
-
throw createGitError("GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */, errorMessage);
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, dryRun) {
|
|
1359
|
-
try {
|
|
1360
|
-
if (!files || files.length === 0) {
|
|
1361
|
-
throw createGitError("NO_FILES" /* NO_FILES */);
|
|
1362
|
-
}
|
|
1363
|
-
if (!commitMessage) {
|
|
1364
|
-
throw createGitError("NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */);
|
|
1365
|
-
}
|
|
1366
|
-
setCommitMessage(commitMessage);
|
|
1367
|
-
if (nextTag) {
|
|
1368
|
-
addTag(nextTag);
|
|
1369
|
-
}
|
|
1370
|
-
await gitProcess({
|
|
1371
|
-
files,
|
|
1372
|
-
nextTag,
|
|
1373
|
-
commitMessage,
|
|
1374
|
-
skipHooks,
|
|
1375
|
-
dryRun
|
|
1376
|
-
});
|
|
1377
|
-
if (!dryRun) {
|
|
1378
|
-
log(`Created tag: ${nextTag}`, "success");
|
|
1379
|
-
}
|
|
1380
|
-
} catch (error) {
|
|
1381
|
-
if (error instanceof GitError) {
|
|
1382
|
-
throw error;
|
|
1383
|
-
}
|
|
1384
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1385
|
-
log(`Failed to create git commit and tag: ${errorMessage}`, "error");
|
|
1386
|
-
if (error instanceof Error) {
|
|
1387
|
-
console.error("Git operation error details:");
|
|
1388
|
-
console.error(error.stack || error.message);
|
|
1389
|
-
if (errorMessage.includes("Command failed:")) {
|
|
1390
|
-
const cmdOutput = errorMessage.split("Command failed:")[1];
|
|
1391
|
-
if (cmdOutput) {
|
|
1392
|
-
console.error("Git command output:", cmdOutput.trim());
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
} else {
|
|
1396
|
-
console.error("Unknown git error:", error);
|
|
1397
|
-
}
|
|
1398
|
-
throw new GitError(`Git operation failed: ${errorMessage}`, "GIT_ERROR" /* GIT_ERROR */);
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
1299
|
// src/package/packageManagement.ts
|
|
1403
1300
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
1404
1301
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
@@ -1433,7 +1330,6 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
|
|
|
1433
1330
|
// src/package/packageProcessor.ts
|
|
1434
1331
|
var fs5 = __toESM(require("fs"), 1);
|
|
1435
1332
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
1436
|
-
var import_node_process3 = require("process");
|
|
1437
1333
|
|
|
1438
1334
|
// src/utils/packageMatching.ts
|
|
1439
1335
|
var import_micromatch2 = __toESM(require("micromatch"), 1);
|
|
@@ -1475,7 +1371,6 @@ var PackageProcessor = class {
|
|
|
1475
1371
|
tagTemplate;
|
|
1476
1372
|
commitMessageTemplate;
|
|
1477
1373
|
dryRun;
|
|
1478
|
-
skipHooks;
|
|
1479
1374
|
getLatestTag;
|
|
1480
1375
|
config;
|
|
1481
1376
|
// Config for version calculation
|
|
@@ -1486,7 +1381,6 @@ var PackageProcessor = class {
|
|
|
1486
1381
|
this.tagTemplate = options.tagTemplate;
|
|
1487
1382
|
this.commitMessageTemplate = options.commitMessageTemplate || "";
|
|
1488
1383
|
this.dryRun = options.dryRun || false;
|
|
1489
|
-
this.skipHooks = options.skipHooks || false;
|
|
1490
1384
|
this.getLatestTag = options.getLatestTag;
|
|
1491
1385
|
this.config = options.config;
|
|
1492
1386
|
this.fullConfig = options.fullConfig;
|
|
@@ -1589,6 +1483,19 @@ var PackageProcessor = class {
|
|
|
1589
1483
|
revisionRange = "HEAD";
|
|
1590
1484
|
}
|
|
1591
1485
|
changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
|
|
1486
|
+
const allPackageDirs = packages.map((p) => p.dir);
|
|
1487
|
+
const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
|
|
1488
|
+
const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
|
|
1489
|
+
const repoLevelEntries = extractRepoLevelChangelogEntries(
|
|
1490
|
+
pkgPath,
|
|
1491
|
+
revisionRange,
|
|
1492
|
+
allPackageDirs,
|
|
1493
|
+
sharedPackageDirs
|
|
1494
|
+
);
|
|
1495
|
+
if (repoLevelEntries.length > 0) {
|
|
1496
|
+
log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
|
|
1497
|
+
changelogEntries = [...repoLevelEntries, ...changelogEntries];
|
|
1498
|
+
}
|
|
1592
1499
|
if (changelogEntries.length === 0) {
|
|
1593
1500
|
changelogEntries = [
|
|
1594
1501
|
{
|
|
@@ -1676,19 +1583,12 @@ var PackageProcessor = class {
|
|
|
1676
1583
|
this.tagTemplate,
|
|
1677
1584
|
this.fullConfig.packageSpecificTags
|
|
1678
1585
|
);
|
|
1679
|
-
const tagMessage = `chore(release): ${name} ${nextVersion}`;
|
|
1680
1586
|
addTag(packageTag);
|
|
1681
1587
|
tags.push(packageTag);
|
|
1682
|
-
if (
|
|
1683
|
-
try {
|
|
1684
|
-
await createGitTag({ tag: packageTag, message: tagMessage });
|
|
1685
|
-
log(`Created tag: ${packageTag}`, "success");
|
|
1686
|
-
} catch (tagError) {
|
|
1687
|
-
log(`Failed to create tag ${packageTag} for ${name}: ${tagError.message}`, "error");
|
|
1688
|
-
log(tagError.stack || "No stack trace available", "error");
|
|
1689
|
-
}
|
|
1690
|
-
} else {
|
|
1588
|
+
if (this.dryRun) {
|
|
1691
1589
|
log(`[DRY RUN] Would create tag: ${packageTag}`, "info");
|
|
1590
|
+
} else {
|
|
1591
|
+
log(`Version ${nextVersion} prepared (tag: ${packageTag})`, "success");
|
|
1692
1592
|
}
|
|
1693
1593
|
updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
|
|
1694
1594
|
}
|
|
@@ -1696,34 +1596,15 @@ var PackageProcessor = class {
|
|
|
1696
1596
|
log("No packages required a version update.", "info");
|
|
1697
1597
|
return { updatedPackages: [], tags };
|
|
1698
1598
|
}
|
|
1699
|
-
const filesToCommit = [];
|
|
1700
|
-
for (const info of updatedPackagesInfo) {
|
|
1701
|
-
const packageJsonPath = import_node_path6.default.join(info.path, "package.json");
|
|
1702
|
-
if (fs5.existsSync(packageJsonPath)) {
|
|
1703
|
-
filesToCommit.push(packageJsonPath);
|
|
1704
|
-
}
|
|
1705
|
-
const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
|
|
1706
|
-
if (cargoEnabled) {
|
|
1707
|
-
const cargoPaths = this.fullConfig.cargo?.paths;
|
|
1708
|
-
if (cargoPaths && cargoPaths.length > 0) {
|
|
1709
|
-
for (const cargoPath of cargoPaths) {
|
|
1710
|
-
const resolvedCargoPath = import_node_path6.default.resolve(info.path, cargoPath, "Cargo.toml");
|
|
1711
|
-
if (fs5.existsSync(resolvedCargoPath)) {
|
|
1712
|
-
filesToCommit.push(resolvedCargoPath);
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
} else {
|
|
1716
|
-
const cargoTomlPath = import_node_path6.default.join(info.path, "Cargo.toml");
|
|
1717
|
-
if (fs5.existsSync(cargoTomlPath)) {
|
|
1718
|
-
filesToCommit.push(cargoTomlPath);
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
1599
|
const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
|
|
1724
1600
|
const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
|
|
1725
1601
|
let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
|
|
1726
|
-
const
|
|
1602
|
+
const MAX_COMMIT_MSG_LENGTH = 1e4;
|
|
1603
|
+
if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
|
|
1604
|
+
log("Commit message template too long, truncating", "warning");
|
|
1605
|
+
commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
|
|
1606
|
+
}
|
|
1607
|
+
const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
|
|
1727
1608
|
if (updatedPackagesInfo.length === 1 && placeholderRegex.test(commitMessage)) {
|
|
1728
1609
|
const packageName = updatedPackagesInfo[0].name;
|
|
1729
1610
|
commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
|
|
@@ -1731,21 +1612,7 @@ var PackageProcessor = class {
|
|
|
1731
1612
|
commitMessage = `chore(release): ${packageNames} ${representativeVersion}`;
|
|
1732
1613
|
}
|
|
1733
1614
|
setCommitMessage(commitMessage);
|
|
1734
|
-
if (
|
|
1735
|
-
try {
|
|
1736
|
-
await gitAdd(filesToCommit);
|
|
1737
|
-
await gitCommit({ message: commitMessage, skipHooks: this.skipHooks });
|
|
1738
|
-
log(`Created commit for targeted release: ${packageNames}`, "success");
|
|
1739
|
-
} catch (commitError) {
|
|
1740
|
-
log("Failed to create commit for targeted release.", "error");
|
|
1741
|
-
console.error(commitError);
|
|
1742
|
-
(0, import_node_process3.exit)(1);
|
|
1743
|
-
}
|
|
1744
|
-
} else {
|
|
1745
|
-
log("[DRY RUN] Would add files:", "info");
|
|
1746
|
-
for (const file of filesToCommit) {
|
|
1747
|
-
log(` - ${file}`, "info");
|
|
1748
|
-
}
|
|
1615
|
+
if (this.dryRun) {
|
|
1749
1616
|
log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
|
|
1750
1617
|
}
|
|
1751
1618
|
return {
|
|
@@ -1796,7 +1663,6 @@ function createSyncStrategy(config) {
|
|
|
1796
1663
|
commitMessage = `chore(release): v\${version}`,
|
|
1797
1664
|
prereleaseIdentifier,
|
|
1798
1665
|
dryRun,
|
|
1799
|
-
skipHooks,
|
|
1800
1666
|
mainPackage
|
|
1801
1667
|
} = config;
|
|
1802
1668
|
const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
|
|
@@ -1946,7 +1812,13 @@ function createSyncStrategy(config) {
|
|
|
1946
1812
|
config.packageSpecificTags || false
|
|
1947
1813
|
);
|
|
1948
1814
|
const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, commitPackageName, void 0);
|
|
1949
|
-
|
|
1815
|
+
addTag(nextTag);
|
|
1816
|
+
setCommitMessage(formattedCommitMessage);
|
|
1817
|
+
if (!dryRun) {
|
|
1818
|
+
log(`Version ${nextVersion} prepared (tag: ${nextTag})`, "success");
|
|
1819
|
+
} else {
|
|
1820
|
+
log(`Would create tag: ${nextTag}`, "info");
|
|
1821
|
+
}
|
|
1950
1822
|
} catch (error) {
|
|
1951
1823
|
if (BaseVersionError.isVersionError(error)) {
|
|
1952
1824
|
log(`Synced Strategy failed: ${error.message} (${error.code})`, "error");
|
|
@@ -1961,14 +1833,7 @@ function createSyncStrategy(config) {
|
|
|
1961
1833
|
function createSingleStrategy(config) {
|
|
1962
1834
|
return async (packages) => {
|
|
1963
1835
|
try {
|
|
1964
|
-
const {
|
|
1965
|
-
mainPackage,
|
|
1966
|
-
versionPrefix,
|
|
1967
|
-
tagTemplate,
|
|
1968
|
-
commitMessage = `chore(release): \${version}`,
|
|
1969
|
-
dryRun,
|
|
1970
|
-
skipHooks
|
|
1971
|
-
} = config;
|
|
1836
|
+
const { mainPackage, versionPrefix, tagTemplate, commitMessage = `chore(release): \${version}`, dryRun } = config;
|
|
1972
1837
|
let packageName;
|
|
1973
1838
|
if (mainPackage) {
|
|
1974
1839
|
packageName = mainPackage;
|
|
@@ -2088,9 +1953,10 @@ function createSingleStrategy(config) {
|
|
|
2088
1953
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
2089
1954
|
const tagName = formatTag(nextVersion, formattedPrefix, packageName, tagTemplate, config.packageSpecificTags);
|
|
2090
1955
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
1956
|
+
addTag(tagName);
|
|
1957
|
+
setCommitMessage(commitMsg);
|
|
2091
1958
|
if (!dryRun) {
|
|
2092
|
-
|
|
2093
|
-
log(`Created tag: ${tagName}`, "success");
|
|
1959
|
+
log(`Version ${nextVersion} prepared (tag: ${tagName})`, "success");
|
|
2094
1960
|
} else {
|
|
2095
1961
|
log(`Would create tag: ${tagName}`, "info");
|
|
2096
1962
|
}
|
|
@@ -2115,7 +1981,6 @@ function createAsyncStrategy(config) {
|
|
|
2115
1981
|
tagTemplate: config.tagTemplate,
|
|
2116
1982
|
commitMessageTemplate: config.commitMessage || "",
|
|
2117
1983
|
dryRun: config.dryRun || false,
|
|
2118
|
-
skipHooks: config.skipHooks || false,
|
|
2119
1984
|
getLatestTag: dependencies.getLatestTag,
|
|
2120
1985
|
fullConfig: config,
|
|
2121
1986
|
// Extract common version configuration properties
|
|
@@ -2203,13 +2068,13 @@ var VersionEngine = class {
|
|
|
2203
2068
|
if (this.workspaceCache) {
|
|
2204
2069
|
return this.workspaceCache;
|
|
2205
2070
|
}
|
|
2206
|
-
const pkgsResult = (0, import_get_packages.getPackagesSync)((0,
|
|
2071
|
+
const pkgsResult = (0, import_get_packages.getPackagesSync)((0, import_node_process2.cwd)());
|
|
2207
2072
|
if (!pkgsResult || !pkgsResult.packages) {
|
|
2208
2073
|
throw createVersionError("PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */);
|
|
2209
2074
|
}
|
|
2210
2075
|
if (!pkgsResult.root) {
|
|
2211
2076
|
log("Root path is undefined in packages result, setting to current working directory", "warning");
|
|
2212
|
-
pkgsResult.root = (0,
|
|
2077
|
+
pkgsResult.root = (0, import_node_process2.cwd)();
|
|
2213
2078
|
}
|
|
2214
2079
|
if (this.config.packages && this.config.packages.length > 0) {
|
|
2215
2080
|
const originalCount = pkgsResult.packages.length;
|
package/dist/index.d.cts
CHANGED
|
@@ -26,7 +26,6 @@ interface Config extends VersionConfigBase {
|
|
|
26
26
|
versionStrategy?: 'branchPattern' | 'commitMessage';
|
|
27
27
|
branchPatterns?: BranchPattern[];
|
|
28
28
|
defaultReleaseType?: ReleaseType;
|
|
29
|
-
skipHooks?: boolean;
|
|
30
29
|
dryRun?: boolean;
|
|
31
30
|
latestTag?: string;
|
|
32
31
|
isPrerelease?: boolean;
|
|
@@ -151,7 +150,6 @@ interface PackageProcessorOptions {
|
|
|
151
150
|
tagTemplate?: string;
|
|
152
151
|
commitMessageTemplate?: string;
|
|
153
152
|
dryRun?: boolean;
|
|
154
|
-
skipHooks?: boolean;
|
|
155
153
|
getLatestTag: () => Promise<string | null>;
|
|
156
154
|
config: Omit<VersionConfigBase, 'versionPrefix' | 'path' | 'name'>;
|
|
157
155
|
fullConfig: Config;
|
|
@@ -171,7 +169,6 @@ declare class PackageProcessor {
|
|
|
171
169
|
private tagTemplate?;
|
|
172
170
|
private commitMessageTemplate;
|
|
173
171
|
private dryRun;
|
|
174
|
-
private skipHooks;
|
|
175
172
|
private getLatestTag;
|
|
176
173
|
private config;
|
|
177
174
|
private fullConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ interface Config extends VersionConfigBase {
|
|
|
26
26
|
versionStrategy?: 'branchPattern' | 'commitMessage';
|
|
27
27
|
branchPatterns?: BranchPattern[];
|
|
28
28
|
defaultReleaseType?: ReleaseType;
|
|
29
|
-
skipHooks?: boolean;
|
|
30
29
|
dryRun?: boolean;
|
|
31
30
|
latestTag?: string;
|
|
32
31
|
isPrerelease?: boolean;
|
|
@@ -151,7 +150,6 @@ interface PackageProcessorOptions {
|
|
|
151
150
|
tagTemplate?: string;
|
|
152
151
|
commitMessageTemplate?: string;
|
|
153
152
|
dryRun?: boolean;
|
|
154
|
-
skipHooks?: boolean;
|
|
155
153
|
getLatestTag: () => Promise<string | null>;
|
|
156
154
|
config: Omit<VersionConfigBase, 'versionPrefix' | 'path' | 'name'>;
|
|
157
155
|
fullConfig: Config;
|
|
@@ -171,7 +169,6 @@ declare class PackageProcessor {
|
|
|
171
169
|
private tagTemplate?;
|
|
172
170
|
private commitMessageTemplate;
|
|
173
171
|
private dryRun;
|
|
174
|
-
private skipHooks;
|
|
175
172
|
private getLatestTag;
|
|
176
173
|
private config;
|
|
177
174
|
private fullConfig;
|