@releasekit/version 0.2.0-next.10 → 0.2.0-next.11

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.
@@ -969,9 +969,9 @@ import { exit } from "process";
969
969
  // src/changelog/commitParser.ts
970
970
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
971
971
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
972
- function extractChangelogEntriesWithHash(projectDir, revisionRange) {
972
+ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
973
973
  try {
974
- const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges", "--", "."];
974
+ const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
975
975
  const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
976
976
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
977
977
  return commits.map((commit) => {
@@ -985,27 +985,54 @@ function extractChangelogEntriesWithHash(projectDir, revisionRange) {
985
985
  }).filter((item) => item !== null);
986
986
  } catch (error) {
987
987
  const errorMessage = error instanceof Error ? error.message : String(error);
988
- log(`Error extracting commits with hash: ${errorMessage}`, "error");
988
+ log(`Error extracting all commits with hash: ${errorMessage}`, "error");
989
989
  return [];
990
990
  }
991
991
  }
992
- function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
992
+ function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
993
993
  try {
994
- const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
995
- const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
996
- const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
997
- return commits.map((commit) => {
998
- const [hash, ...messageParts] = commit.split("|||");
999
- const message = messageParts.join("|||").trim();
1000
- const entry = parseCommitMessage(message);
1001
- if (entry && hash) {
1002
- return { hash: hash.trim(), entry };
1003
- }
1004
- return null;
1005
- }).filter((item) => item !== null);
994
+ const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
995
+ cwd: projectDir,
996
+ encoding: "utf8"
997
+ }).toString().trim();
998
+ if (!output) {
999
+ return false;
1000
+ }
1001
+ const changedFiles = output.split("\n");
1002
+ return changedFiles.some((file) => {
1003
+ return packageDirs.some((pkgDir) => {
1004
+ if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
1005
+ return false;
1006
+ }
1007
+ const normalizedFile = file.replace(/\\/g, "/");
1008
+ const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
1009
+ return normalizedFile.startsWith(normalizedPkgDir);
1010
+ });
1011
+ });
1006
1012
  } catch (error) {
1007
- const errorMessage = error instanceof Error ? error.message : String(error);
1008
- log(`Error extracting all commits with hash: ${errorMessage}`, "error");
1013
+ log(
1014
+ `Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
1015
+ "debug"
1016
+ );
1017
+ return false;
1018
+ }
1019
+ }
1020
+ function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
1021
+ try {
1022
+ const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
1023
+ const repoLevelCommits = allCommits.filter((commit) => {
1024
+ const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
1025
+ return !touchesPackage;
1026
+ });
1027
+ if (repoLevelCommits.length > 0) {
1028
+ log(
1029
+ `Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
1030
+ "debug"
1031
+ );
1032
+ }
1033
+ return repoLevelCommits.map((c) => c.entry);
1034
+ } catch (error) {
1035
+ log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
1009
1036
  return [];
1010
1037
  }
1011
1038
  }
@@ -1458,13 +1485,18 @@ var PackageProcessor = class {
1458
1485
  revisionRange = "HEAD";
1459
1486
  }
1460
1487
  changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
1461
- const allCommitsWithHash = extractAllChangelogEntriesWithHash(pkgPath, revisionRange);
1462
- const packageCommitsWithHash = extractChangelogEntriesWithHash(pkgPath, revisionRange);
1463
- const packageCommitHashes = new Set(packageCommitsWithHash.map((c) => c.hash));
1464
- const globalCommits = allCommitsWithHash.filter((c) => !packageCommitHashes.has(c.hash)).map((c) => c.entry);
1465
- if (globalCommits.length > 0) {
1466
- log(`Adding ${globalCommits.length} global commit(s) to ${name} changelog`, "debug");
1467
- changelogEntries = [...globalCommits, ...changelogEntries];
1488
+ const allPackageDirs = packages.map((p) => p.dir);
1489
+ const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
1490
+ const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
1491
+ const repoLevelEntries = extractRepoLevelChangelogEntries(
1492
+ pkgPath,
1493
+ revisionRange,
1494
+ allPackageDirs,
1495
+ sharedPackageDirs
1496
+ );
1497
+ if (repoLevelEntries.length > 0) {
1498
+ log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
1499
+ changelogEntries = [...repoLevelEntries, ...changelogEntries];
1468
1500
  }
1469
1501
  if (changelogEntries.length === 0) {
1470
1502
  changelogEntries = [
package/dist/cli.cjs CHANGED
@@ -401,9 +401,9 @@ var path6 = __toESM(require("path"), 1);
401
401
  init_commandExecutor();
402
402
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
403
403
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
404
- function extractChangelogEntriesWithHash(projectDir, revisionRange) {
404
+ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
405
405
  try {
406
- const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges", "--", "."];
406
+ const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
407
407
  const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
408
408
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
409
409
  return commits.map((commit) => {
@@ -417,27 +417,54 @@ function extractChangelogEntriesWithHash(projectDir, revisionRange) {
417
417
  }).filter((item) => item !== null);
418
418
  } catch (error) {
419
419
  const errorMessage = error instanceof Error ? error.message : String(error);
420
- log(`Error extracting commits with hash: ${errorMessage}`, "error");
420
+ log(`Error extracting all commits with hash: ${errorMessage}`, "error");
421
421
  return [];
422
422
  }
423
423
  }
424
- function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
424
+ function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
425
425
  try {
426
- const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
427
- const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
428
- const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
429
- return commits.map((commit) => {
430
- const [hash, ...messageParts] = commit.split("|||");
431
- const message = messageParts.join("|||").trim();
432
- const entry = parseCommitMessage(message);
433
- if (entry && hash) {
434
- return { hash: hash.trim(), entry };
435
- }
436
- return null;
437
- }).filter((item) => item !== null);
426
+ const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
427
+ cwd: projectDir,
428
+ encoding: "utf8"
429
+ }).toString().trim();
430
+ if (!output) {
431
+ return false;
432
+ }
433
+ const changedFiles = output.split("\n");
434
+ return changedFiles.some((file) => {
435
+ return packageDirs.some((pkgDir) => {
436
+ if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
437
+ return false;
438
+ }
439
+ const normalizedFile = file.replace(/\\/g, "/");
440
+ const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
441
+ return normalizedFile.startsWith(normalizedPkgDir);
442
+ });
443
+ });
438
444
  } catch (error) {
439
- const errorMessage = error instanceof Error ? error.message : String(error);
440
- log(`Error extracting all commits with hash: ${errorMessage}`, "error");
445
+ log(
446
+ `Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
447
+ "debug"
448
+ );
449
+ return false;
450
+ }
451
+ }
452
+ function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
453
+ try {
454
+ const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
455
+ const repoLevelCommits = allCommits.filter((commit) => {
456
+ const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
457
+ return !touchesPackage;
458
+ });
459
+ if (repoLevelCommits.length > 0) {
460
+ log(
461
+ `Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
462
+ "debug"
463
+ );
464
+ }
465
+ return repoLevelCommits.map((c) => c.entry);
466
+ } catch (error) {
467
+ log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
441
468
  return [];
442
469
  }
443
470
  }
@@ -1634,13 +1661,18 @@ var PackageProcessor = class {
1634
1661
  revisionRange = "HEAD";
1635
1662
  }
1636
1663
  changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
1637
- const allCommitsWithHash = extractAllChangelogEntriesWithHash(pkgPath, revisionRange);
1638
- const packageCommitsWithHash = extractChangelogEntriesWithHash(pkgPath, revisionRange);
1639
- const packageCommitHashes = new Set(packageCommitsWithHash.map((c) => c.hash));
1640
- const globalCommits = allCommitsWithHash.filter((c) => !packageCommitHashes.has(c.hash)).map((c) => c.entry);
1641
- if (globalCommits.length > 0) {
1642
- log(`Adding ${globalCommits.length} global commit(s) to ${name} changelog`, "debug");
1643
- changelogEntries = [...globalCommits, ...changelogEntries];
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];
1644
1676
  }
1645
1677
  if (changelogEntries.length === 0) {
1646
1678
  changelogEntries = [
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  log,
7
7
  printJsonOutput
8
- } from "./chunk-DXDB5P7S.js";
8
+ } from "./chunk-25A2IEAC.js";
9
9
  import "./chunk-GQLJ7JQY.js";
10
10
  import "./chunk-LMPZV35Z.js";
11
11
 
package/dist/index.cjs CHANGED
@@ -1168,9 +1168,9 @@ var path6 = __toESM(require("path"), 1);
1168
1168
  init_commandExecutor();
1169
1169
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
1170
1170
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
1171
- function extractChangelogEntriesWithHash(projectDir, revisionRange) {
1171
+ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
1172
1172
  try {
1173
- const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges", "--", "."];
1173
+ const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
1174
1174
  const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1175
1175
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1176
1176
  return commits.map((commit) => {
@@ -1184,27 +1184,54 @@ function extractChangelogEntriesWithHash(projectDir, revisionRange) {
1184
1184
  }).filter((item) => item !== null);
1185
1185
  } catch (error) {
1186
1186
  const errorMessage = error instanceof Error ? error.message : String(error);
1187
- log(`Error extracting commits with hash: ${errorMessage}`, "error");
1187
+ log(`Error extracting all commits with hash: ${errorMessage}`, "error");
1188
1188
  return [];
1189
1189
  }
1190
1190
  }
1191
- function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
1191
+ function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
1192
1192
  try {
1193
- const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
1194
- const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1195
- const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1196
- return commits.map((commit) => {
1197
- const [hash, ...messageParts] = commit.split("|||");
1198
- const message = messageParts.join("|||").trim();
1199
- const entry = parseCommitMessage(message);
1200
- if (entry && hash) {
1201
- return { hash: hash.trim(), entry };
1202
- }
1203
- return null;
1204
- }).filter((item) => item !== null);
1193
+ const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
1194
+ cwd: projectDir,
1195
+ encoding: "utf8"
1196
+ }).toString().trim();
1197
+ if (!output) {
1198
+ return false;
1199
+ }
1200
+ const changedFiles = output.split("\n");
1201
+ return changedFiles.some((file) => {
1202
+ return packageDirs.some((pkgDir) => {
1203
+ if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
1204
+ return false;
1205
+ }
1206
+ const normalizedFile = file.replace(/\\/g, "/");
1207
+ const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
1208
+ return normalizedFile.startsWith(normalizedPkgDir);
1209
+ });
1210
+ });
1205
1211
  } catch (error) {
1206
- const errorMessage = error instanceof Error ? error.message : String(error);
1207
- log(`Error extracting all commits with hash: ${errorMessage}`, "error");
1212
+ log(
1213
+ `Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
1214
+ "debug"
1215
+ );
1216
+ return false;
1217
+ }
1218
+ }
1219
+ function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
1220
+ try {
1221
+ const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
1222
+ const repoLevelCommits = allCommits.filter((commit) => {
1223
+ const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
1224
+ return !touchesPackage;
1225
+ });
1226
+ if (repoLevelCommits.length > 0) {
1227
+ log(
1228
+ `Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
1229
+ "debug"
1230
+ );
1231
+ }
1232
+ return repoLevelCommits.map((c) => c.entry);
1233
+ } catch (error) {
1234
+ log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
1208
1235
  return [];
1209
1236
  }
1210
1237
  }
@@ -1632,13 +1659,18 @@ var PackageProcessor = class {
1632
1659
  revisionRange = "HEAD";
1633
1660
  }
1634
1661
  changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
1635
- const allCommitsWithHash = extractAllChangelogEntriesWithHash(pkgPath, revisionRange);
1636
- const packageCommitsWithHash = extractChangelogEntriesWithHash(pkgPath, revisionRange);
1637
- const packageCommitHashes = new Set(packageCommitsWithHash.map((c) => c.hash));
1638
- const globalCommits = allCommitsWithHash.filter((c) => !packageCommitHashes.has(c.hash)).map((c) => c.entry);
1639
- if (globalCommits.length > 0) {
1640
- log(`Adding ${globalCommits.length} global commit(s) to ${name} changelog`, "debug");
1641
- changelogEntries = [...globalCommits, ...changelogEntries];
1662
+ const allPackageDirs = packages.map((p) => p.dir);
1663
+ const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
1664
+ const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
1665
+ const repoLevelEntries = extractRepoLevelChangelogEntries(
1666
+ pkgPath,
1667
+ revisionRange,
1668
+ allPackageDirs,
1669
+ sharedPackageDirs
1670
+ );
1671
+ if (repoLevelEntries.length > 0) {
1672
+ log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
1673
+ changelogEntries = [...repoLevelEntries, ...changelogEntries];
1642
1674
  }
1643
1675
  if (changelogEntries.length === 0) {
1644
1676
  changelogEntries = [
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  enableJsonOutput,
11
11
  getJsonData,
12
12
  loadConfig
13
- } from "./chunk-DXDB5P7S.js";
13
+ } from "./chunk-25A2IEAC.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.10",
3
+ "version": "0.2.0-next.11",
4
4
  "description": "Semantic versioning based on Git history and conventional commits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",