@releasekit/version 0.3.0 → 0.4.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/README.md CHANGED
@@ -133,10 +133,19 @@ Configure via `releasekit.config.json`:
133
133
  | `cargo.enabled` | Update Cargo.toml files | `true` |
134
134
  | `cargo.paths` | Directories containing Cargo.toml | auto-detect |
135
135
 
136
+ ## Using in CI
137
+
138
+ A few things to keep in mind when running `releasekit-version` in a pipeline:
139
+
140
+ - **Always pass `fetch-depth: 0`** on checkout — the tool reads git history to determine the version bump and will produce incorrect results on a shallow clone.
141
+ - **Use `--json`** for reliable downstream parsing. Text output format can change; the JSON schema is stable.
142
+ - **`NO_COLOR=1`** disables ANSI colour codes in log output. Most CI environments set `CI=true` automatically, which the tool detects and adjusts for.
143
+
144
+ If you are running the full release pipeline (version + changelog + publish), use `@releasekit/release` instead of invoking `releasekit-version` directly. See the [CI setup guide](../release/docs/ci-setup.md).
145
+
136
146
  ## Documentation
137
147
 
138
148
  - [Versioning Strategies and Concepts](./docs/versioning.md)
139
- - [CI/CD Integration](./docs/CI_CD_INTEGRATION.md)
140
149
 
141
150
  ## Acknowledgements
142
151
 
@@ -0,0 +1,6 @@
1
+ import {
2
+ BaseVersionError
3
+ } from "./chunk-2MN2VLZF.js";
4
+ export {
5
+ BaseVersionError
6
+ };
@@ -0,0 +1,85 @@
1
+ // ../core/dist/index.js
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import { fileURLToPath } from "url";
5
+ import chalk from "chalk";
6
+ function readPackageVersion(importMetaUrl) {
7
+ try {
8
+ const dir = path.dirname(fileURLToPath(importMetaUrl));
9
+ const packageJsonPath = path.resolve(dir, "../package.json");
10
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
11
+ return packageJson.version ?? "0.0.0";
12
+ } catch {
13
+ return "0.0.0";
14
+ }
15
+ }
16
+ var LOG_LEVELS = {
17
+ error: 0,
18
+ warn: 1,
19
+ info: 2,
20
+ debug: 3,
21
+ trace: 4
22
+ };
23
+ var PREFIXES = {
24
+ error: "[ERROR]",
25
+ warn: "[WARN]",
26
+ info: "[INFO]",
27
+ debug: "[DEBUG]",
28
+ trace: "[TRACE]"
29
+ };
30
+ var COLORS = {
31
+ error: chalk.red,
32
+ warn: chalk.yellow,
33
+ info: chalk.blue,
34
+ debug: chalk.gray,
35
+ trace: chalk.dim
36
+ };
37
+ var currentLevel = "info";
38
+ var quietMode = false;
39
+ function shouldLog(level) {
40
+ if (quietMode && level !== "error") return false;
41
+ return LOG_LEVELS[level] <= LOG_LEVELS[currentLevel];
42
+ }
43
+ function log(message, level = "info") {
44
+ if (!shouldLog(level)) return;
45
+ const formatted = COLORS[level](`${PREFIXES[level]} ${message}`);
46
+ console.error(formatted);
47
+ }
48
+ var ReleaseKitError = class _ReleaseKitError extends Error {
49
+ constructor(message) {
50
+ super(message);
51
+ this.name = this.constructor.name;
52
+ }
53
+ logError() {
54
+ log(this.message, "error");
55
+ if (this.suggestions.length > 0) {
56
+ log("\nSuggested solutions:", "info");
57
+ for (const [i, suggestion] of this.suggestions.entries()) {
58
+ log(`${i + 1}. ${suggestion}`, "info");
59
+ }
60
+ }
61
+ }
62
+ static isReleaseKitError(error2) {
63
+ return error2 instanceof _ReleaseKitError;
64
+ }
65
+ };
66
+
67
+ // src/errors/baseError.ts
68
+ var BaseVersionError = class _BaseVersionError extends ReleaseKitError {
69
+ code;
70
+ suggestions;
71
+ constructor(message, code, suggestions) {
72
+ super(message);
73
+ this.code = code;
74
+ this.suggestions = suggestions ?? [];
75
+ }
76
+ static isVersionError(error) {
77
+ return error instanceof _BaseVersionError;
78
+ }
79
+ };
80
+
81
+ export {
82
+ readPackageVersion,
83
+ ReleaseKitError,
84
+ BaseVersionError
85
+ };
@@ -0,0 +1,20 @@
1
+ // src/git/commandExecutor.ts
2
+ import { execFile, execFileSync } from "child_process";
3
+ var execAsync = (file, args, options) => {
4
+ const defaultOptions = { maxBuffer: 1024 * 1024 * 10, ...options };
5
+ return new Promise((resolve, reject) => {
6
+ execFile(file, args, defaultOptions, (error, stdout, stderr) => {
7
+ if (error) {
8
+ reject(error);
9
+ } else {
10
+ resolve({ stdout: stdout.toString(), stderr: stderr.toString() });
11
+ }
12
+ });
13
+ });
14
+ };
15
+ var execSync = (file, args, options) => execFileSync(file, args, { maxBuffer: 1024 * 1024 * 10, ...options });
16
+
17
+ export {
18
+ execAsync,
19
+ execSync
20
+ };