@releasekit/version 0.2.0-next.9 → 0.2.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 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 { loadVersionConfig } from "@releasekit/config";
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,9 @@ function toVersionConfig(config) {
19
19
  sync: true,
20
20
  packages: [],
21
21
  updateInternalDependencies: "minor",
22
- versionPrefix: ""
22
+ versionPrefix: "",
23
+ baseBranch: gitConfig?.branch,
24
+ skipHooks: gitConfig?.skipHooks
23
25
  };
24
26
  }
25
27
  return {
@@ -38,19 +40,19 @@ function toVersionConfig(config) {
38
40
  releaseType: bp.releaseType
39
41
  })),
40
42
  defaultReleaseType: config.defaultReleaseType,
41
- skipHooks: config.skipHooks,
43
+ skipHooks: gitConfig?.skipHooks,
42
44
  mismatchStrategy: config.mismatchStrategy,
43
45
  versionPrefix: config.versionPrefix ?? "",
44
46
  prereleaseIdentifier: config.prereleaseIdentifier,
45
- baseBranch: config.baseBranch,
47
+ baseBranch: gitConfig?.branch,
46
48
  cargo: config.cargo
47
49
  };
48
50
  }
49
51
 
50
52
  // src/config.ts
51
53
  function loadConfig(options) {
52
- const versionConfig = loadVersionConfig(options);
53
- return toVersionConfig(versionConfig);
54
+ const fullConfig = loadReleaseKitConfig(options);
55
+ return toVersionConfig(fullConfig.version, fullConfig.git);
54
56
  }
55
57
 
56
58
  // src/errors/versionError.ts
@@ -275,8 +277,8 @@ To fix this:
275
277
  let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
276
278
  if (additionalContext) {
277
279
  for (const [key, value] of Object.entries(additionalContext)) {
278
- const placeholder = `\${${key}}`;
279
- result = result.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), value);
280
+ const placeholder = `${key ? `\${${key}}` : ""}`;
281
+ result = result.replace(new RegExp(escapeRegExp(placeholder), "g"), value);
280
282
  }
281
283
  }
282
284
  return result;
@@ -969,13 +971,83 @@ import { exit } from "process";
969
971
  // src/changelog/commitParser.ts
970
972
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
971
973
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
974
+ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
975
+ try {
976
+ const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
977
+ const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
978
+ const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
979
+ return commits.map((commit) => {
980
+ const [hash, ...messageParts] = commit.split("|||");
981
+ const message = messageParts.join("|||").trim();
982
+ const entry = parseCommitMessage(message);
983
+ if (entry && hash) {
984
+ return { hash: hash.trim(), entry };
985
+ }
986
+ return null;
987
+ }).filter((item) => item !== null);
988
+ } catch (error) {
989
+ const errorMessage = error instanceof Error ? error.message : String(error);
990
+ log(`Error extracting all commits with hash: ${errorMessage}`, "error");
991
+ return [];
992
+ }
993
+ }
994
+ function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
995
+ try {
996
+ const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
997
+ cwd: projectDir,
998
+ encoding: "utf8"
999
+ }).toString().trim();
1000
+ if (!output) {
1001
+ return false;
1002
+ }
1003
+ const changedFiles = output.split("\n");
1004
+ return changedFiles.some((file) => {
1005
+ return packageDirs.some((pkgDir) => {
1006
+ if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
1007
+ return false;
1008
+ }
1009
+ const normalizedFile = file.replace(/\\/g, "/");
1010
+ const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
1011
+ return normalizedFile.startsWith(normalizedPkgDir);
1012
+ });
1013
+ });
1014
+ } catch (error) {
1015
+ log(
1016
+ `Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
1017
+ "debug"
1018
+ );
1019
+ return false;
1020
+ }
1021
+ }
1022
+ function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
1023
+ try {
1024
+ const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
1025
+ const repoLevelCommits = allCommits.filter((commit) => {
1026
+ const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
1027
+ return !touchesPackage;
1028
+ });
1029
+ if (repoLevelCommits.length > 0) {
1030
+ log(
1031
+ `Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
1032
+ "debug"
1033
+ );
1034
+ }
1035
+ return repoLevelCommits.map((c) => c.entry);
1036
+ } catch (error) {
1037
+ log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
1038
+ return [];
1039
+ }
1040
+ }
972
1041
  function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
1042
+ return extractCommitsFromGitLog(projectDir, revisionRange, true);
1043
+ }
1044
+ function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
973
1045
  try {
974
- const output = execSync(
975
- "git",
976
- ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges", "--", "."],
977
- { cwd: projectDir, encoding: "utf8" }
978
- ).toString();
1046
+ const args = ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges"];
1047
+ if (filterToPath) {
1048
+ args.push("--", ".");
1049
+ }
1050
+ const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
979
1051
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
980
1052
  return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
981
1053
  } catch (error) {
@@ -1415,6 +1487,19 @@ var PackageProcessor = class {
1415
1487
  revisionRange = "HEAD";
1416
1488
  }
1417
1489
  changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
1490
+ const allPackageDirs = packages.map((p) => p.dir);
1491
+ const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
1492
+ const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
1493
+ const repoLevelEntries = extractRepoLevelChangelogEntries(
1494
+ pkgPath,
1495
+ revisionRange,
1496
+ allPackageDirs,
1497
+ sharedPackageDirs
1498
+ );
1499
+ if (repoLevelEntries.length > 0) {
1500
+ log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
1501
+ changelogEntries = [...repoLevelEntries, ...changelogEntries];
1502
+ }
1418
1503
  if (changelogEntries.length === 0) {
1419
1504
  changelogEntries = [
1420
1505
  {
@@ -1549,7 +1634,12 @@ var PackageProcessor = class {
1549
1634
  const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
1550
1635
  const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
1551
1636
  let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
1552
- const placeholderRegex = /\$\{[^}]+\}/;
1637
+ const MAX_COMMIT_MSG_LENGTH = 1e4;
1638
+ if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
1639
+ log("Commit message template too long, truncating", "warning");
1640
+ commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
1641
+ }
1642
+ const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
1553
1643
  if (updatedPackagesInfo.length === 1 && placeholderRegex.test(commitMessage)) {
1554
1644
  const packageName = updatedPackagesInfo[0].name;
1555
1645
  commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
package/dist/cli.cjs CHANGED
@@ -98,7 +98,7 @@ var import_commander = require("commander");
98
98
  var import_config = require("@releasekit/config");
99
99
 
100
100
  // src/types.ts
101
- function toVersionConfig(config) {
101
+ function toVersionConfig(config, gitConfig) {
102
102
  if (!config) {
103
103
  return {
104
104
  tagTemplate: "v{version}",
@@ -107,7 +107,9 @@ function toVersionConfig(config) {
107
107
  sync: true,
108
108
  packages: [],
109
109
  updateInternalDependencies: "minor",
110
- versionPrefix: ""
110
+ versionPrefix: "",
111
+ baseBranch: gitConfig?.branch,
112
+ skipHooks: gitConfig?.skipHooks
111
113
  };
112
114
  }
113
115
  return {
@@ -126,19 +128,19 @@ function toVersionConfig(config) {
126
128
  releaseType: bp.releaseType
127
129
  })),
128
130
  defaultReleaseType: config.defaultReleaseType,
129
- skipHooks: config.skipHooks,
131
+ skipHooks: gitConfig?.skipHooks,
130
132
  mismatchStrategy: config.mismatchStrategy,
131
133
  versionPrefix: config.versionPrefix ?? "",
132
134
  prereleaseIdentifier: config.prereleaseIdentifier,
133
- baseBranch: config.baseBranch,
135
+ baseBranch: gitConfig?.branch,
134
136
  cargo: config.cargo
135
137
  };
136
138
  }
137
139
 
138
140
  // src/config.ts
139
141
  function loadConfig(options) {
140
- const versionConfig = (0, import_config.loadVersionConfig)(options);
141
- return toVersionConfig(versionConfig);
142
+ const fullConfig = (0, import_config.loadConfig)(options);
143
+ return toVersionConfig(fullConfig.version, fullConfig.git);
142
144
  }
143
145
 
144
146
  // src/core/versionEngine.ts
@@ -401,13 +403,83 @@ var path6 = __toESM(require("path"), 1);
401
403
  init_commandExecutor();
402
404
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
403
405
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
406
+ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
407
+ try {
408
+ const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
409
+ const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
410
+ const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
411
+ return commits.map((commit) => {
412
+ const [hash, ...messageParts] = commit.split("|||");
413
+ const message = messageParts.join("|||").trim();
414
+ const entry = parseCommitMessage(message);
415
+ if (entry && hash) {
416
+ return { hash: hash.trim(), entry };
417
+ }
418
+ return null;
419
+ }).filter((item) => item !== null);
420
+ } catch (error) {
421
+ const errorMessage = error instanceof Error ? error.message : String(error);
422
+ log(`Error extracting all commits with hash: ${errorMessage}`, "error");
423
+ return [];
424
+ }
425
+ }
426
+ function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
427
+ try {
428
+ const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
429
+ cwd: projectDir,
430
+ encoding: "utf8"
431
+ }).toString().trim();
432
+ if (!output) {
433
+ return false;
434
+ }
435
+ const changedFiles = output.split("\n");
436
+ return changedFiles.some((file) => {
437
+ return packageDirs.some((pkgDir) => {
438
+ if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
439
+ return false;
440
+ }
441
+ const normalizedFile = file.replace(/\\/g, "/");
442
+ const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
443
+ return normalizedFile.startsWith(normalizedPkgDir);
444
+ });
445
+ });
446
+ } catch (error) {
447
+ log(
448
+ `Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
449
+ "debug"
450
+ );
451
+ return false;
452
+ }
453
+ }
454
+ function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
455
+ try {
456
+ const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
457
+ const repoLevelCommits = allCommits.filter((commit) => {
458
+ const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
459
+ return !touchesPackage;
460
+ });
461
+ if (repoLevelCommits.length > 0) {
462
+ log(
463
+ `Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
464
+ "debug"
465
+ );
466
+ }
467
+ return repoLevelCommits.map((c) => c.entry);
468
+ } catch (error) {
469
+ log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
470
+ return [];
471
+ }
472
+ }
404
473
  function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
474
+ return extractCommitsFromGitLog(projectDir, revisionRange, true);
475
+ }
476
+ function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
405
477
  try {
406
- const output = execSync(
407
- "git",
408
- ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges", "--", "."],
409
- { cwd: projectDir, encoding: "utf8" }
410
- ).toString();
478
+ const args = ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges"];
479
+ if (filterToPath) {
480
+ args.push("--", ".");
481
+ }
482
+ const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
411
483
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
412
484
  return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
413
485
  } catch (error) {
@@ -708,8 +780,8 @@ To fix this:
708
780
  let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
709
781
  if (additionalContext) {
710
782
  for (const [key, value] of Object.entries(additionalContext)) {
711
- const placeholder = `\${${key}}`;
712
- result = result.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), value);
783
+ const placeholder = `${key ? `\${${key}}` : ""}`;
784
+ result = result.replace(new RegExp(escapeRegExp(placeholder), "g"), value);
713
785
  }
714
786
  }
715
787
  return result;
@@ -1591,6 +1663,19 @@ var PackageProcessor = class {
1591
1663
  revisionRange = "HEAD";
1592
1664
  }
1593
1665
  changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
1666
+ const allPackageDirs = packages.map((p) => p.dir);
1667
+ const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
1668
+ const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
1669
+ const repoLevelEntries = extractRepoLevelChangelogEntries(
1670
+ pkgPath,
1671
+ revisionRange,
1672
+ allPackageDirs,
1673
+ sharedPackageDirs
1674
+ );
1675
+ if (repoLevelEntries.length > 0) {
1676
+ log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
1677
+ changelogEntries = [...repoLevelEntries, ...changelogEntries];
1678
+ }
1594
1679
  if (changelogEntries.length === 0) {
1595
1680
  changelogEntries = [
1596
1681
  {
@@ -1725,7 +1810,12 @@ var PackageProcessor = class {
1725
1810
  const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
1726
1811
  const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
1727
1812
  let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
1728
- const placeholderRegex = /\$\{[^}]+\}/;
1813
+ const MAX_COMMIT_MSG_LENGTH = 1e4;
1814
+ if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
1815
+ log("Commit message template too long, truncating", "warning");
1816
+ commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
1817
+ }
1818
+ const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
1729
1819
  if (updatedPackagesInfo.length === 1 && placeholderRegex.test(commitMessage)) {
1730
1820
  const packageName = updatedPackagesInfo[0].name;
1731
1821
  commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  log,
7
7
  printJsonOutput
8
- } from "./chunk-7F6RMN2K.js";
8
+ } from "./chunk-GH75HGCN.js";
9
9
  import "./chunk-GQLJ7JQY.js";
10
10
  import "./chunk-LMPZV35Z.js";
11
11
 
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,9 @@ function toVersionConfig(config) {
88
88
  sync: true,
89
89
  packages: [],
90
90
  updateInternalDependencies: "minor",
91
- versionPrefix: ""
91
+ versionPrefix: "",
92
+ baseBranch: gitConfig?.branch,
93
+ skipHooks: gitConfig?.skipHooks
92
94
  };
93
95
  }
94
96
  return {
@@ -107,19 +109,19 @@ function toVersionConfig(config) {
107
109
  releaseType: bp.releaseType
108
110
  })),
109
111
  defaultReleaseType: config.defaultReleaseType,
110
- skipHooks: config.skipHooks,
112
+ skipHooks: gitConfig?.skipHooks,
111
113
  mismatchStrategy: config.mismatchStrategy,
112
114
  versionPrefix: config.versionPrefix ?? "",
113
115
  prereleaseIdentifier: config.prereleaseIdentifier,
114
- baseBranch: config.baseBranch,
116
+ baseBranch: gitConfig?.branch,
115
117
  cargo: config.cargo
116
118
  };
117
119
  }
118
120
 
119
121
  // src/config.ts
120
122
  function loadConfig(options) {
121
- const versionConfig = (0, import_config.loadVersionConfig)(options);
122
- return toVersionConfig(versionConfig);
123
+ const fullConfig = (0, import_config.loadConfig)(options);
124
+ return toVersionConfig(fullConfig.version, fullConfig.git);
123
125
  }
124
126
 
125
127
  // src/core/versionCalculator.ts
@@ -285,8 +287,8 @@ To fix this:
285
287
  let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
286
288
  if (additionalContext) {
287
289
  for (const [key, value] of Object.entries(additionalContext)) {
288
- const placeholder = `\${${key}}`;
289
- result = result.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), value);
290
+ const placeholder = `${key ? `\${${key}}` : ""}`;
291
+ result = result.replace(new RegExp(escapeRegExp(placeholder), "g"), value);
290
292
  }
291
293
  }
292
294
  return result;
@@ -1168,13 +1170,83 @@ var path6 = __toESM(require("path"), 1);
1168
1170
  init_commandExecutor();
1169
1171
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
1170
1172
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
1173
+ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
1174
+ try {
1175
+ const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
1176
+ const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1177
+ const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1178
+ return commits.map((commit) => {
1179
+ const [hash, ...messageParts] = commit.split("|||");
1180
+ const message = messageParts.join("|||").trim();
1181
+ const entry = parseCommitMessage(message);
1182
+ if (entry && hash) {
1183
+ return { hash: hash.trim(), entry };
1184
+ }
1185
+ return null;
1186
+ }).filter((item) => item !== null);
1187
+ } catch (error) {
1188
+ const errorMessage = error instanceof Error ? error.message : String(error);
1189
+ log(`Error extracting all commits with hash: ${errorMessage}`, "error");
1190
+ return [];
1191
+ }
1192
+ }
1193
+ function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
1194
+ try {
1195
+ const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
1196
+ cwd: projectDir,
1197
+ encoding: "utf8"
1198
+ }).toString().trim();
1199
+ if (!output) {
1200
+ return false;
1201
+ }
1202
+ const changedFiles = output.split("\n");
1203
+ return changedFiles.some((file) => {
1204
+ return packageDirs.some((pkgDir) => {
1205
+ if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
1206
+ return false;
1207
+ }
1208
+ const normalizedFile = file.replace(/\\/g, "/");
1209
+ const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
1210
+ return normalizedFile.startsWith(normalizedPkgDir);
1211
+ });
1212
+ });
1213
+ } catch (error) {
1214
+ log(
1215
+ `Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
1216
+ "debug"
1217
+ );
1218
+ return false;
1219
+ }
1220
+ }
1221
+ function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
1222
+ try {
1223
+ const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
1224
+ const repoLevelCommits = allCommits.filter((commit) => {
1225
+ const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
1226
+ return !touchesPackage;
1227
+ });
1228
+ if (repoLevelCommits.length > 0) {
1229
+ log(
1230
+ `Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
1231
+ "debug"
1232
+ );
1233
+ }
1234
+ return repoLevelCommits.map((c) => c.entry);
1235
+ } catch (error) {
1236
+ log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
1237
+ return [];
1238
+ }
1239
+ }
1171
1240
  function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
1241
+ return extractCommitsFromGitLog(projectDir, revisionRange, true);
1242
+ }
1243
+ function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
1172
1244
  try {
1173
- const output = execSync(
1174
- "git",
1175
- ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges", "--", "."],
1176
- { cwd: projectDir, encoding: "utf8" }
1177
- ).toString();
1245
+ const args = ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges"];
1246
+ if (filterToPath) {
1247
+ args.push("--", ".");
1248
+ }
1249
+ const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1178
1250
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1179
1251
  return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
1180
1252
  } catch (error) {
@@ -1589,6 +1661,19 @@ var PackageProcessor = class {
1589
1661
  revisionRange = "HEAD";
1590
1662
  }
1591
1663
  changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
1664
+ const allPackageDirs = packages.map((p) => p.dir);
1665
+ const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
1666
+ const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
1667
+ const repoLevelEntries = extractRepoLevelChangelogEntries(
1668
+ pkgPath,
1669
+ revisionRange,
1670
+ allPackageDirs,
1671
+ sharedPackageDirs
1672
+ );
1673
+ if (repoLevelEntries.length > 0) {
1674
+ log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
1675
+ changelogEntries = [...repoLevelEntries, ...changelogEntries];
1676
+ }
1592
1677
  if (changelogEntries.length === 0) {
1593
1678
  changelogEntries = [
1594
1679
  {
@@ -1723,7 +1808,12 @@ var PackageProcessor = class {
1723
1808
  const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
1724
1809
  const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
1725
1810
  let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
1726
- const placeholderRegex = /\$\{[^}]+\}/;
1811
+ const MAX_COMMIT_MSG_LENGTH = 1e4;
1812
+ if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
1813
+ log("Commit message template too long, truncating", "warning");
1814
+ commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
1815
+ }
1816
+ const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
1727
1817
  if (updatedPackagesInfo.length === 1 && placeholderRegex.test(commitMessage)) {
1728
1818
  const packageName = updatedPackagesInfo[0].name;
1729
1819
  commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  enableJsonOutput,
11
11
  getJsonData,
12
12
  loadConfig
13
- } from "./chunk-7F6RMN2K.js";
13
+ } from "./chunk-GH75HGCN.js";
14
14
  import {
15
15
  BaseVersionError
16
16
  } from "./chunk-GQLJ7JQY.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@releasekit/version",
3
- "version": "0.2.0-next.9",
3
+ "version": "0.2.0",
4
4
  "description": "Semantic versioning based on Git history and conventional commits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -21,17 +21,12 @@
21
21
  "bin": {
22
22
  "releasekit-version": "dist/cli.js"
23
23
  },
24
- "scripts": {
25
- "build": "tsup src/index.ts src/cli.ts --format esm,cjs --dts",
26
- "dev": "tsup src/index.ts src/cli.ts --format esm,cjs --watch --dts",
27
- "clean": "rm -rf dist coverage .turbo",
28
- "test": "vitest run --dir test/unit",
29
- "test:unit": "vitest run --coverage --dir test/unit",
30
- "test:coverage": "vitest run --coverage --dir test/unit",
31
- "lint": "biome check .",
32
- "typecheck": "tsc --noEmit"
33
- },
34
- "keywords": ["version", "semver", "git", "package"],
24
+ "keywords": [
25
+ "version",
26
+ "semver",
27
+ "git",
28
+ "package"
29
+ ],
35
30
  "author": {
36
31
  "name": "Sam Maister",
37
32
  "email": "goosewobbler@protonmail.com"
@@ -42,39 +37,53 @@
42
37
  "directory": "packages/version"
43
38
  },
44
39
  "license": "MIT",
45
- "files": ["dist", "docs", "version.schema.json"],
40
+ "files": [
41
+ "dist",
42
+ "docs",
43
+ "version.schema.json"
44
+ ],
46
45
  "publishConfig": {
47
46
  "access": "public"
48
47
  },
49
48
  "dependencies": {
50
49
  "@manypkg/get-packages": "^3.1.0",
51
- "@releasekit/config": "workspace:*",
52
- "@releasekit/core": "workspace:*",
53
50
  "@types/micromatch": "^4.0.10",
54
- "chalk": "catalog:",
55
- "commander": "catalog:",
56
- "conventional-changelog-angular": "^8.1.0",
51
+ "chalk": "^5.6.2",
52
+ "commander": "^14.0.3",
53
+ "conventional-changelog-angular": "^8.3.0",
57
54
  "conventional-changelog-conventional-commits": "npm:conventional-changelog-conventionalcommits@^9.0.0",
58
- "conventional-changelog-conventionalcommits": "^9.1.0",
55
+ "conventional-changelog-conventionalcommits": "^9.3.0",
59
56
  "conventional-commits-filter": "^5.0.0",
60
57
  "conventional-recommended-bump": "^11.2.0",
61
- "figlet": "^1.10.0",
62
- "git-semver-tags": "^8.0.0",
58
+ "figlet": "^1.11.0",
59
+ "git-semver-tags": "^8.0.1",
63
60
  "micromatch": "^4.0.8",
64
- "semver": "catalog:",
65
- "smol-toml": "catalog:"
61
+ "semver": "^7.7.4",
62
+ "smol-toml": "^1.6.0",
63
+ "@releasekit/config": "0.1.0",
64
+ "@releasekit/core": "0.1.0"
66
65
  },
67
66
  "devDependencies": {
68
- "@biomejs/biome": "catalog:",
67
+ "@biomejs/biome": "^2.4.6",
69
68
  "@types/figlet": "^1.5.5",
70
- "@types/node": "catalog:",
71
- "@types/semver": "catalog:",
72
- "@vitest/coverage-v8": "catalog:",
73
- "tsup": "catalog:",
74
- "typescript": "catalog:",
75
- "vitest": "catalog:"
69
+ "@types/node": "^22.19.15",
70
+ "@types/semver": "^7.7.1",
71
+ "@vitest/coverage-v8": "^4.1.0",
72
+ "tsup": "^8.5.1",
73
+ "typescript": "^5.9.3",
74
+ "vitest": "^4.1.0"
76
75
  },
77
76
  "engines": {
78
77
  "node": ">=20"
78
+ },
79
+ "scripts": {
80
+ "build": "tsup src/index.ts src/cli.ts --format esm,cjs --dts",
81
+ "dev": "tsup src/index.ts src/cli.ts --format esm,cjs --watch --dts",
82
+ "clean": "rm -rf dist coverage .turbo",
83
+ "test": "vitest run --dir test/unit",
84
+ "test:unit": "vitest run --coverage --dir test/unit",
85
+ "test:coverage": "vitest run --coverage --dir test/unit",
86
+ "lint": "biome check .",
87
+ "typecheck": "tsc --noEmit"
79
88
  }
80
- }
89
+ }