@releasekit/version 0.2.0-next.6 → 0.2.0-next.8

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.
@@ -698,12 +698,17 @@ var VersionMismatchError = class extends Error {
698
698
  this.name = "VersionMismatchError";
699
699
  }
700
700
  };
701
- async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error") {
701
+ async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error", strictReachable = false) {
702
702
  if (!tagName?.trim()) {
703
703
  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" };
704
704
  }
705
705
  const verification = verifyTag(tagName, cwd4);
706
706
  if (!verification.exists || !verification.reachable) {
707
+ if (strictReachable) {
708
+ throw new Error(
709
+ `Git tag '${tagName}' is not reachable from the current commit. The tag exists but cannot be reached from HEAD, which usually means you're on a different branch or the tag is orphaned. To allow fallback to package version, set strictReachable to false in your configuration.`
710
+ );
711
+ }
707
712
  if (packageVersion) {
708
713
  log(
709
714
  `Git tag '${tagName}' unreachable (${verification.error}), using package version: ${packageVersion}`,
@@ -809,7 +814,8 @@ async function calculateVersion(config, options) {
809
814
  prereleaseIdentifier: configPrereleaseIdentifier,
810
815
  branchPattern,
811
816
  baseBranch,
812
- mismatchStrategy
817
+ mismatchStrategy,
818
+ strictReachable
813
819
  } = config;
814
820
  const {
815
821
  latestTag,
@@ -854,7 +860,13 @@ async function calculateVersion(config, options) {
854
860
  const packageDir = pkgPath || cwd();
855
861
  const manifestResult = getVersionFromManifests(packageDir);
856
862
  const packageVersion = manifestResult.manifestFound && manifestResult.version ? manifestResult.version : void 0;
857
- versionSource = await getBestVersionSource(latestTag, packageVersion, packageDir, mismatchStrategy);
863
+ versionSource = await getBestVersionSource(
864
+ latestTag,
865
+ packageVersion,
866
+ packageDir,
867
+ mismatchStrategy,
868
+ strictReachable
869
+ );
858
870
  log(`Using version source: ${versionSource.source} (${versionSource.reason})`, "info");
859
871
  }
860
872
  const specifiedType = type;
@@ -1396,6 +1408,11 @@ var PackageProcessor = class {
1396
1408
  if (verification.exists && verification.reachable) {
1397
1409
  revisionRange = `${latestTag}..HEAD`;
1398
1410
  } else {
1411
+ if (this.config.strictReachable) {
1412
+ throw new Error(
1413
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1414
+ );
1415
+ }
1399
1416
  log(`Tag ${latestTag} is unreachable (${verification.error}), using all commits for changelog`, "debug");
1400
1417
  revisionRange = "HEAD";
1401
1418
  }
@@ -1713,6 +1730,11 @@ function createSyncStrategy(config) {
1713
1730
  });
1714
1731
  revisionRange = `${latestTag}..HEAD`;
1715
1732
  } catch {
1733
+ if (config.strictReachable) {
1734
+ throw new Error(
1735
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1736
+ );
1737
+ }
1716
1738
  log(`Tag ${latestTag} doesn't exist, using all commits for changelog`, "debug");
1717
1739
  revisionRange = "HEAD";
1718
1740
  }
@@ -1832,6 +1854,11 @@ function createSingleStrategy(config) {
1832
1854
  });
1833
1855
  revisionRange = `${latestTag}..HEAD`;
1834
1856
  } catch {
1857
+ if (config.strictReachable) {
1858
+ throw new Error(
1859
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1860
+ );
1861
+ }
1835
1862
  log(`Tag ${latestTag} doesn't exist, using all commits for changelog`, "debug");
1836
1863
  revisionRange = "HEAD";
1837
1864
  }
package/dist/cli.cjs CHANGED
@@ -1143,12 +1143,17 @@ var VersionMismatchError = class extends Error {
1143
1143
  this.name = "VersionMismatchError";
1144
1144
  }
1145
1145
  };
1146
- async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error") {
1146
+ async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error", strictReachable = false) {
1147
1147
  if (!tagName?.trim()) {
1148
1148
  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" };
1149
1149
  }
1150
1150
  const verification = verifyTag(tagName, cwd4);
1151
1151
  if (!verification.exists || !verification.reachable) {
1152
+ if (strictReachable) {
1153
+ throw new Error(
1154
+ `Git tag '${tagName}' is not reachable from the current commit. The tag exists but cannot be reached from HEAD, which usually means you're on a different branch or the tag is orphaned. To allow fallback to package version, set strictReachable to false in your configuration.`
1155
+ );
1156
+ }
1152
1157
  if (packageVersion) {
1153
1158
  log(
1154
1159
  `Git tag '${tagName}' unreachable (${verification.error}), using package version: ${packageVersion}`,
@@ -1254,7 +1259,8 @@ async function calculateVersion(config, options) {
1254
1259
  prereleaseIdentifier: configPrereleaseIdentifier,
1255
1260
  branchPattern,
1256
1261
  baseBranch,
1257
- mismatchStrategy
1262
+ mismatchStrategy,
1263
+ strictReachable
1258
1264
  } = config;
1259
1265
  const {
1260
1266
  latestTag,
@@ -1299,7 +1305,13 @@ async function calculateVersion(config, options) {
1299
1305
  const packageDir = pkgPath || (0, import_node_process2.cwd)();
1300
1306
  const manifestResult = getVersionFromManifests(packageDir);
1301
1307
  const packageVersion = manifestResult.manifestFound && manifestResult.version ? manifestResult.version : void 0;
1302
- versionSource = await getBestVersionSource(latestTag, packageVersion, packageDir, mismatchStrategy);
1308
+ versionSource = await getBestVersionSource(
1309
+ latestTag,
1310
+ packageVersion,
1311
+ packageDir,
1312
+ mismatchStrategy,
1313
+ strictReachable
1314
+ );
1303
1315
  log(`Using version source: ${versionSource.source} (${versionSource.reason})`, "info");
1304
1316
  }
1305
1317
  const specifiedType = type;
@@ -1541,6 +1553,11 @@ var PackageProcessor = class {
1541
1553
  if (verification.exists && verification.reachable) {
1542
1554
  revisionRange = `${latestTag}..HEAD`;
1543
1555
  } else {
1556
+ if (this.config.strictReachable) {
1557
+ throw new Error(
1558
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1559
+ );
1560
+ }
1544
1561
  log(`Tag ${latestTag} is unreachable (${verification.error}), using all commits for changelog`, "debug");
1545
1562
  revisionRange = "HEAD";
1546
1563
  }
@@ -1856,6 +1873,11 @@ function createSyncStrategy(config) {
1856
1873
  });
1857
1874
  revisionRange = `${latestTag}..HEAD`;
1858
1875
  } catch {
1876
+ if (config.strictReachable) {
1877
+ throw new Error(
1878
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1879
+ );
1880
+ }
1859
1881
  log(`Tag ${latestTag} doesn't exist, using all commits for changelog`, "debug");
1860
1882
  revisionRange = "HEAD";
1861
1883
  }
@@ -1975,6 +1997,11 @@ function createSingleStrategy(config) {
1975
1997
  });
1976
1998
  revisionRange = `${latestTag}..HEAD`;
1977
1999
  } catch {
2000
+ if (config.strictReachable) {
2001
+ throw new Error(
2002
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
2003
+ );
2004
+ }
1978
2005
  log(`Tag ${latestTag} doesn't exist, using all commits for changelog`, "debug");
1979
2006
  revisionRange = "HEAD";
1980
2007
  }
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  log,
7
7
  printJsonOutput
8
- } from "./chunk-OQ5Z3KXR.js";
8
+ } from "./chunk-ORO3VYQ7.js";
9
9
  import "./chunk-GQLJ7JQY.js";
10
10
 
11
11
  // src/cli.ts
package/dist/index.cjs CHANGED
@@ -681,12 +681,17 @@ var VersionMismatchError = class extends Error {
681
681
  this.name = "VersionMismatchError";
682
682
  }
683
683
  };
684
- async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error") {
684
+ async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error", strictReachable = false) {
685
685
  if (!tagName?.trim()) {
686
686
  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" };
687
687
  }
688
688
  const verification = verifyTag(tagName, cwd4);
689
689
  if (!verification.exists || !verification.reachable) {
690
+ if (strictReachable) {
691
+ throw new Error(
692
+ `Git tag '${tagName}' is not reachable from the current commit. The tag exists but cannot be reached from HEAD, which usually means you're on a different branch or the tag is orphaned. To allow fallback to package version, set strictReachable to false in your configuration.`
693
+ );
694
+ }
690
695
  if (packageVersion) {
691
696
  log(
692
697
  `Git tag '${tagName}' unreachable (${verification.error}), using package version: ${packageVersion}`,
@@ -792,7 +797,8 @@ async function calculateVersion(config, options) {
792
797
  prereleaseIdentifier: configPrereleaseIdentifier,
793
798
  branchPattern,
794
799
  baseBranch,
795
- mismatchStrategy
800
+ mismatchStrategy,
801
+ strictReachable
796
802
  } = config;
797
803
  const {
798
804
  latestTag,
@@ -837,7 +843,13 @@ async function calculateVersion(config, options) {
837
843
  const packageDir = pkgPath || (0, import_node_process.cwd)();
838
844
  const manifestResult = getVersionFromManifests(packageDir);
839
845
  const packageVersion = manifestResult.manifestFound && manifestResult.version ? manifestResult.version : void 0;
840
- versionSource = await getBestVersionSource(latestTag, packageVersion, packageDir, mismatchStrategy);
846
+ versionSource = await getBestVersionSource(
847
+ latestTag,
848
+ packageVersion,
849
+ packageDir,
850
+ mismatchStrategy,
851
+ strictReachable
852
+ );
841
853
  log(`Using version source: ${versionSource.source} (${versionSource.reason})`, "info");
842
854
  }
843
855
  const specifiedType = type;
@@ -1536,6 +1548,11 @@ var PackageProcessor = class {
1536
1548
  if (verification.exists && verification.reachable) {
1537
1549
  revisionRange = `${latestTag}..HEAD`;
1538
1550
  } else {
1551
+ if (this.config.strictReachable) {
1552
+ throw new Error(
1553
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1554
+ );
1555
+ }
1539
1556
  log(`Tag ${latestTag} is unreachable (${verification.error}), using all commits for changelog`, "debug");
1540
1557
  revisionRange = "HEAD";
1541
1558
  }
@@ -1851,6 +1868,11 @@ function createSyncStrategy(config) {
1851
1868
  });
1852
1869
  revisionRange = `${latestTag}..HEAD`;
1853
1870
  } catch {
1871
+ if (config.strictReachable) {
1872
+ throw new Error(
1873
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1874
+ );
1875
+ }
1854
1876
  log(`Tag ${latestTag} doesn't exist, using all commits for changelog`, "debug");
1855
1877
  revisionRange = "HEAD";
1856
1878
  }
@@ -1970,6 +1992,11 @@ function createSingleStrategy(config) {
1970
1992
  });
1971
1993
  revisionRange = `${latestTag}..HEAD`;
1972
1994
  } catch {
1995
+ if (config.strictReachable) {
1996
+ throw new Error(
1997
+ `Cannot generate changelog: tag '${latestTag}' is not reachable from the current commit. When strictReachable is enabled, all tags must be reachable. To allow fallback to all commits, set strictReachable to false.`
1998
+ );
1999
+ }
1973
2000
  log(`Tag ${latestTag} doesn't exist, using all commits for changelog`, "debug");
1974
2001
  revisionRange = "HEAD";
1975
2002
  }
package/dist/index.d.cts CHANGED
@@ -11,6 +11,7 @@ interface VersionConfigBase {
11
11
  baseBranch?: string;
12
12
  path?: string;
13
13
  name?: string;
14
+ strictReachable?: boolean;
14
15
  }
15
16
  interface Config extends VersionConfigBase {
16
17
  tagTemplate: string;
@@ -30,6 +31,7 @@ interface Config extends VersionConfigBase {
30
31
  latestTag?: string;
31
32
  isPrerelease?: boolean;
32
33
  mismatchStrategy?: 'error' | 'warn' | 'ignore' | 'prefer-package' | 'prefer-git';
34
+ strictReachable?: boolean;
33
35
  cargo?: {
34
36
  enabled?: boolean;
35
37
  paths?: string[];
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ interface VersionConfigBase {
11
11
  baseBranch?: string;
12
12
  path?: string;
13
13
  name?: string;
14
+ strictReachable?: boolean;
14
15
  }
15
16
  interface Config extends VersionConfigBase {
16
17
  tagTemplate: string;
@@ -30,6 +31,7 @@ interface Config extends VersionConfigBase {
30
31
  latestTag?: string;
31
32
  isPrerelease?: boolean;
32
33
  mismatchStrategy?: 'error' | 'warn' | 'ignore' | 'prefer-package' | 'prefer-git';
34
+ strictReachable?: boolean;
33
35
  cargo?: {
34
36
  enabled?: boolean;
35
37
  paths?: string[];
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  enableJsonOutput,
11
11
  getJsonData,
12
12
  loadConfig
13
- } from "./chunk-OQ5Z3KXR.js";
13
+ } from "./chunk-ORO3VYQ7.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.6",
3
+ "version": "0.2.0-next.8",
4
4
  "description": "Semantic versioning based on Git history and conventional commits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",