@releasekit/version 0.2.0 → 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/dist/index.cjs CHANGED
@@ -89,8 +89,7 @@ function toVersionConfig(config, gitConfig) {
89
89
  packages: [],
90
90
  updateInternalDependencies: "minor",
91
91
  versionPrefix: "",
92
- baseBranch: gitConfig?.branch,
93
- skipHooks: gitConfig?.skipHooks
92
+ baseBranch: gitConfig?.branch
94
93
  };
95
94
  }
96
95
  return {
@@ -109,7 +108,6 @@ function toVersionConfig(config, gitConfig) {
109
108
  releaseType: bp.releaseType
110
109
  })),
111
110
  defaultReleaseType: config.defaultReleaseType,
112
- skipHooks: gitConfig?.skipHooks,
113
111
  mismatchStrategy: config.mismatchStrategy,
114
112
  versionPrefix: config.versionPrefix ?? "",
115
113
  prereleaseIdentifier: config.prereleaseIdentifier,
@@ -133,22 +131,6 @@ var import_semver3 = __toESM(require("semver"), 1);
133
131
  var import_node_fs = require("fs");
134
132
  var import_node_path = require("path");
135
133
  init_commandExecutor();
136
- function isGitRepository(directory) {
137
- const gitDir = (0, import_node_path.join)(directory, ".git");
138
- if (!(0, import_node_fs.existsSync)(gitDir)) {
139
- return false;
140
- }
141
- const stats = (0, import_node_fs.statSync)(gitDir);
142
- if (!stats.isDirectory()) {
143
- return false;
144
- }
145
- try {
146
- execSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd: directory });
147
- return true;
148
- } catch (_error) {
149
- return false;
150
- }
151
- }
152
134
  function getCurrentBranch() {
153
135
  const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
154
136
  return result.toString().trim();
@@ -604,13 +586,13 @@ var import_semver2 = __toESM(require("semver"), 1);
604
586
 
605
587
  // src/git/tagVerification.ts
606
588
  init_commandExecutor();
607
- function verifyTag(tagName, cwd4) {
589
+ function verifyTag(tagName, cwd3) {
608
590
  if (!tagName || tagName.trim() === "") {
609
591
  return { exists: false, reachable: false, error: "Empty tag name" };
610
592
  }
611
593
  try {
612
594
  execSync("git", ["rev-parse", "--verify", tagName], {
613
- cwd: cwd4,
595
+ cwd: cwd3,
614
596
  stdio: "ignore"
615
597
  });
616
598
  return { exists: true, reachable: true };
@@ -707,11 +689,11 @@ var VersionMismatchError = class extends Error {
707
689
  this.name = "VersionMismatchError";
708
690
  }
709
691
  };
710
- async function getBestVersionSource(tagName, packageVersion, cwd4, mismatchStrategy = "error", strictReachable = false) {
692
+ async function getBestVersionSource(tagName, packageVersion, cwd3, mismatchStrategy = "error", strictReachable = false) {
711
693
  if (!tagName?.trim()) {
712
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" };
713
695
  }
714
- const verification = verifyTag(tagName, cwd4);
696
+ const verification = verifyTag(tagName, cwd3);
715
697
  if (!verification.exists || !verification.reachable) {
716
698
  if (strictReachable) {
717
699
  throw new Error(
@@ -976,7 +958,7 @@ async function calculateVersion(config, options) {
976
958
  }
977
959
 
978
960
  // src/core/versionEngine.ts
979
- var import_node_process4 = require("process");
961
+ var import_node_process2 = require("process");
980
962
  var import_get_packages = require("@manypkg/get-packages");
981
963
 
982
964
  // src/errors/baseError.ts
@@ -997,34 +979,6 @@ var BaseVersionError = class _BaseVersionError extends import_core.ReleaseKitErr
997
979
  // src/errors/gitError.ts
998
980
  var GitError = class extends BaseVersionError {
999
981
  };
1000
- function createGitError(code, details) {
1001
- const messages = {
1002
- ["NOT_GIT_REPO" /* NOT_GIT_REPO */]: "Not a git repository",
1003
- ["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: "Failed to create new version",
1004
- ["NO_FILES" /* NO_FILES */]: "No files specified for commit",
1005
- ["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: "Commit message is required",
1006
- ["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed",
1007
- ["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: "Git tag already exists"
1008
- };
1009
- const suggestions = {
1010
- ["NOT_GIT_REPO" /* NOT_GIT_REPO */]: [
1011
- "Initialize git repository with: git init",
1012
- "Ensure you are in the correct directory"
1013
- ],
1014
- ["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: [
1015
- "Delete the existing tag: git tag -d <tag-name>",
1016
- "Use a different version by incrementing manually",
1017
- "Check if this version was already released"
1018
- ],
1019
- ["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: void 0,
1020
- ["NO_FILES" /* NO_FILES */]: void 0,
1021
- ["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: void 0,
1022
- ["GIT_ERROR" /* GIT_ERROR */]: void 0
1023
- };
1024
- const baseMessage = messages[code];
1025
- const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
1026
- return new GitError(fullMessage, code, suggestions[code]);
1027
- }
1028
982
 
1029
983
  // src/errors/versionError.ts
1030
984
  var VersionError = class extends BaseVersionError {
@@ -1342,135 +1296,6 @@ function extractIssueIds(body) {
1342
1296
  // src/core/versionStrategies.ts
1343
1297
  init_commandExecutor();
1344
1298
 
1345
- // src/git/commands.ts
1346
- var import_node_process2 = require("process");
1347
- init_commandExecutor();
1348
- async function gitAdd(files) {
1349
- return execAsync("git", ["add", ...files]);
1350
- }
1351
- async function gitCommit(options) {
1352
- const args = ["commit"];
1353
- if (options.amend) {
1354
- args.push("--amend");
1355
- }
1356
- if (options.author) {
1357
- args.push("--author", options.author);
1358
- }
1359
- if (options.date) {
1360
- args.push("--date", options.date);
1361
- }
1362
- if (options.skipHooks) {
1363
- args.push("--no-verify");
1364
- }
1365
- args.push("-m", options.message);
1366
- return execAsync("git", args);
1367
- }
1368
- async function createGitTag(options) {
1369
- const { tag, message = "" } = options;
1370
- const args = ["tag", "-a", "-m", message, tag];
1371
- try {
1372
- return await execAsync("git", args);
1373
- } catch (error) {
1374
- const errorMessage = error instanceof Error ? error.message : String(error);
1375
- if (errorMessage.includes("already exists")) {
1376
- throw createGitError(
1377
- "TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
1378
- `Tag '${tag}' already exists in the repository. Please use a different version or delete the existing tag first.`
1379
- );
1380
- }
1381
- throw createGitError("GIT_ERROR" /* GIT_ERROR */, errorMessage);
1382
- }
1383
- }
1384
- async function gitProcess(options) {
1385
- const { files, nextTag, commitMessage, skipHooks, dryRun } = options;
1386
- if (!isGitRepository((0, import_node_process2.cwd)())) {
1387
- throw createGitError("NOT_GIT_REPO" /* NOT_GIT_REPO */);
1388
- }
1389
- try {
1390
- if (!dryRun) {
1391
- await gitAdd(files);
1392
- await gitCommit({
1393
- message: commitMessage,
1394
- skipHooks
1395
- });
1396
- if (nextTag) {
1397
- const tagMessage = `New Version ${nextTag} generated at ${(/* @__PURE__ */ new Date()).toISOString()}`;
1398
- await createGitTag({
1399
- tag: nextTag,
1400
- message: tagMessage
1401
- });
1402
- }
1403
- } else {
1404
- log("[DRY RUN] Would add files:", "info");
1405
- for (const file of files) {
1406
- log(` - ${file}`, "info");
1407
- }
1408
- log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
1409
- if (nextTag) {
1410
- log(`[DRY RUN] Would create tag: ${nextTag}`, "info");
1411
- }
1412
- }
1413
- } catch (err) {
1414
- const errorMessage = err instanceof Error ? err.message : String(err);
1415
- if (errorMessage.includes("already exists") && nextTag) {
1416
- log(`Tag '${nextTag}' already exists in the repository.`, "error");
1417
- throw createGitError(
1418
- "TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
1419
- `Tag '${nextTag}' already exists in the repository. Please use a different version or delete the existing tag first.`
1420
- );
1421
- }
1422
- log(`Git process error: ${errorMessage}`, "error");
1423
- if (err instanceof Error && err.stack) {
1424
- console.error("Git process stack trace:");
1425
- console.error(err.stack);
1426
- }
1427
- throw createGitError("GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */, errorMessage);
1428
- }
1429
- }
1430
- async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, dryRun) {
1431
- try {
1432
- if (!files || files.length === 0) {
1433
- throw createGitError("NO_FILES" /* NO_FILES */);
1434
- }
1435
- if (!commitMessage) {
1436
- throw createGitError("NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */);
1437
- }
1438
- setCommitMessage(commitMessage);
1439
- if (nextTag) {
1440
- addTag(nextTag);
1441
- }
1442
- await gitProcess({
1443
- files,
1444
- nextTag,
1445
- commitMessage,
1446
- skipHooks,
1447
- dryRun
1448
- });
1449
- if (!dryRun) {
1450
- log(`Created tag: ${nextTag}`, "success");
1451
- }
1452
- } catch (error) {
1453
- if (error instanceof GitError) {
1454
- throw error;
1455
- }
1456
- const errorMessage = error instanceof Error ? error.message : String(error);
1457
- log(`Failed to create git commit and tag: ${errorMessage}`, "error");
1458
- if (error instanceof Error) {
1459
- console.error("Git operation error details:");
1460
- console.error(error.stack || error.message);
1461
- if (errorMessage.includes("Command failed:")) {
1462
- const cmdOutput = errorMessage.split("Command failed:")[1];
1463
- if (cmdOutput) {
1464
- console.error("Git command output:", cmdOutput.trim());
1465
- }
1466
- }
1467
- } else {
1468
- console.error("Unknown git error:", error);
1469
- }
1470
- throw new GitError(`Git operation failed: ${errorMessage}`, "GIT_ERROR" /* GIT_ERROR */);
1471
- }
1472
- }
1473
-
1474
1299
  // src/package/packageManagement.ts
1475
1300
  var import_node_fs5 = __toESM(require("fs"), 1);
1476
1301
  var import_node_path5 = __toESM(require("path"), 1);
@@ -1505,7 +1330,6 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
1505
1330
  // src/package/packageProcessor.ts
1506
1331
  var fs5 = __toESM(require("fs"), 1);
1507
1332
  var import_node_path6 = __toESM(require("path"), 1);
1508
- var import_node_process3 = require("process");
1509
1333
 
1510
1334
  // src/utils/packageMatching.ts
1511
1335
  var import_micromatch2 = __toESM(require("micromatch"), 1);
@@ -1547,7 +1371,6 @@ var PackageProcessor = class {
1547
1371
  tagTemplate;
1548
1372
  commitMessageTemplate;
1549
1373
  dryRun;
1550
- skipHooks;
1551
1374
  getLatestTag;
1552
1375
  config;
1553
1376
  // Config for version calculation
@@ -1558,7 +1381,6 @@ var PackageProcessor = class {
1558
1381
  this.tagTemplate = options.tagTemplate;
1559
1382
  this.commitMessageTemplate = options.commitMessageTemplate || "";
1560
1383
  this.dryRun = options.dryRun || false;
1561
- this.skipHooks = options.skipHooks || false;
1562
1384
  this.getLatestTag = options.getLatestTag;
1563
1385
  this.config = options.config;
1564
1386
  this.fullConfig = options.fullConfig;
@@ -1761,19 +1583,12 @@ var PackageProcessor = class {
1761
1583
  this.tagTemplate,
1762
1584
  this.fullConfig.packageSpecificTags
1763
1585
  );
1764
- const tagMessage = `chore(release): ${name} ${nextVersion}`;
1765
1586
  addTag(packageTag);
1766
1587
  tags.push(packageTag);
1767
- if (!this.dryRun) {
1768
- try {
1769
- await createGitTag({ tag: packageTag, message: tagMessage });
1770
- log(`Created tag: ${packageTag}`, "success");
1771
- } catch (tagError) {
1772
- log(`Failed to create tag ${packageTag} for ${name}: ${tagError.message}`, "error");
1773
- log(tagError.stack || "No stack trace available", "error");
1774
- }
1775
- } else {
1588
+ if (this.dryRun) {
1776
1589
  log(`[DRY RUN] Would create tag: ${packageTag}`, "info");
1590
+ } else {
1591
+ log(`Version ${nextVersion} prepared (tag: ${packageTag})`, "success");
1777
1592
  }
1778
1593
  updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
1779
1594
  }
@@ -1781,30 +1596,6 @@ var PackageProcessor = class {
1781
1596
  log("No packages required a version update.", "info");
1782
1597
  return { updatedPackages: [], tags };
1783
1598
  }
1784
- const filesToCommit = [];
1785
- for (const info of updatedPackagesInfo) {
1786
- const packageJsonPath = import_node_path6.default.join(info.path, "package.json");
1787
- if (fs5.existsSync(packageJsonPath)) {
1788
- filesToCommit.push(packageJsonPath);
1789
- }
1790
- const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
1791
- if (cargoEnabled) {
1792
- const cargoPaths = this.fullConfig.cargo?.paths;
1793
- if (cargoPaths && cargoPaths.length > 0) {
1794
- for (const cargoPath of cargoPaths) {
1795
- const resolvedCargoPath = import_node_path6.default.resolve(info.path, cargoPath, "Cargo.toml");
1796
- if (fs5.existsSync(resolvedCargoPath)) {
1797
- filesToCommit.push(resolvedCargoPath);
1798
- }
1799
- }
1800
- } else {
1801
- const cargoTomlPath = import_node_path6.default.join(info.path, "Cargo.toml");
1802
- if (fs5.existsSync(cargoTomlPath)) {
1803
- filesToCommit.push(cargoTomlPath);
1804
- }
1805
- }
1806
- }
1807
- }
1808
1599
  const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
1809
1600
  const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
1810
1601
  let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
@@ -1821,21 +1612,7 @@ var PackageProcessor = class {
1821
1612
  commitMessage = `chore(release): ${packageNames} ${representativeVersion}`;
1822
1613
  }
1823
1614
  setCommitMessage(commitMessage);
1824
- if (!this.dryRun) {
1825
- try {
1826
- await gitAdd(filesToCommit);
1827
- await gitCommit({ message: commitMessage, skipHooks: this.skipHooks });
1828
- log(`Created commit for targeted release: ${packageNames}`, "success");
1829
- } catch (commitError) {
1830
- log("Failed to create commit for targeted release.", "error");
1831
- console.error(commitError);
1832
- (0, import_node_process3.exit)(1);
1833
- }
1834
- } else {
1835
- log("[DRY RUN] Would add files:", "info");
1836
- for (const file of filesToCommit) {
1837
- log(` - ${file}`, "info");
1838
- }
1615
+ if (this.dryRun) {
1839
1616
  log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
1840
1617
  }
1841
1618
  return {
@@ -1886,7 +1663,6 @@ function createSyncStrategy(config) {
1886
1663
  commitMessage = `chore(release): v\${version}`,
1887
1664
  prereleaseIdentifier,
1888
1665
  dryRun,
1889
- skipHooks,
1890
1666
  mainPackage
1891
1667
  } = config;
1892
1668
  const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
@@ -2036,7 +1812,13 @@ function createSyncStrategy(config) {
2036
1812
  config.packageSpecificTags || false
2037
1813
  );
2038
1814
  const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, commitPackageName, void 0);
2039
- await createGitCommitAndTag(files, nextTag, formattedCommitMessage, skipHooks, dryRun);
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
+ }
2040
1822
  } catch (error) {
2041
1823
  if (BaseVersionError.isVersionError(error)) {
2042
1824
  log(`Synced Strategy failed: ${error.message} (${error.code})`, "error");
@@ -2051,14 +1833,7 @@ function createSyncStrategy(config) {
2051
1833
  function createSingleStrategy(config) {
2052
1834
  return async (packages) => {
2053
1835
  try {
2054
- const {
2055
- mainPackage,
2056
- versionPrefix,
2057
- tagTemplate,
2058
- commitMessage = `chore(release): \${version}`,
2059
- dryRun,
2060
- skipHooks
2061
- } = config;
1836
+ const { mainPackage, versionPrefix, tagTemplate, commitMessage = `chore(release): \${version}`, dryRun } = config;
2062
1837
  let packageName;
2063
1838
  if (mainPackage) {
2064
1839
  packageName = mainPackage;
@@ -2178,9 +1953,10 @@ function createSingleStrategy(config) {
2178
1953
  log(`Updated package ${packageName} to version ${nextVersion}`, "success");
2179
1954
  const tagName = formatTag(nextVersion, formattedPrefix, packageName, tagTemplate, config.packageSpecificTags);
2180
1955
  const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
1956
+ addTag(tagName);
1957
+ setCommitMessage(commitMsg);
2181
1958
  if (!dryRun) {
2182
- await createGitCommitAndTag(filesToCommit, tagName, commitMsg, skipHooks, dryRun);
2183
- log(`Created tag: ${tagName}`, "success");
1959
+ log(`Version ${nextVersion} prepared (tag: ${tagName})`, "success");
2184
1960
  } else {
2185
1961
  log(`Would create tag: ${tagName}`, "info");
2186
1962
  }
@@ -2205,7 +1981,6 @@ function createAsyncStrategy(config) {
2205
1981
  tagTemplate: config.tagTemplate,
2206
1982
  commitMessageTemplate: config.commitMessage || "",
2207
1983
  dryRun: config.dryRun || false,
2208
- skipHooks: config.skipHooks || false,
2209
1984
  getLatestTag: dependencies.getLatestTag,
2210
1985
  fullConfig: config,
2211
1986
  // Extract common version configuration properties
@@ -2293,13 +2068,13 @@ var VersionEngine = class {
2293
2068
  if (this.workspaceCache) {
2294
2069
  return this.workspaceCache;
2295
2070
  }
2296
- const pkgsResult = (0, import_get_packages.getPackagesSync)((0, import_node_process4.cwd)());
2071
+ const pkgsResult = (0, import_get_packages.getPackagesSync)((0, import_node_process2.cwd)());
2297
2072
  if (!pkgsResult || !pkgsResult.packages) {
2298
2073
  throw createVersionError("PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */);
2299
2074
  }
2300
2075
  if (!pkgsResult.root) {
2301
2076
  log("Root path is undefined in packages result, setting to current working directory", "warning");
2302
- pkgsResult.root = (0, import_node_process4.cwd)();
2077
+ pkgsResult.root = (0, import_node_process2.cwd)();
2303
2078
  }
2304
2079
  if (this.config.packages && this.config.packages.length > 0) {
2305
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;
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  enableJsonOutput,
11
11
  getJsonData,
12
12
  loadConfig
13
- } from "./chunk-GH75HGCN.js";
13
+ } from "./chunk-4OGOAITO.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",
3
+ "version": "0.3.0-next.0",
4
4
  "description": "Semantic versioning based on Git history and conventional commits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",