@releasekit/version 0.3.0-next.4 → 0.3.1
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 +5 -3
- package/dist/baseError-FARJUY5U.js +6 -0
- package/dist/chunk-2MN2VLZF.js +85 -0
- package/dist/{chunk-ZEXPJ53Z.js → chunk-V6S7BEBD.js} +523 -133
- package/dist/cli.d.ts +5 -2
- package/dist/cli.js +22 -23
- package/dist/index.d.ts +9 -208
- package/dist/index.js +4 -2
- package/docs/CI_CD_INTEGRATION.md +13 -13
- package/docs/versioning.md +14 -14
- package/package.json +14 -12
- package/version.schema.json +1 -1
- package/dist/baseError-ZCZHF6A2.js +0 -7
- package/dist/chunk-GQLJ7JQY.js +0 -18
- package/dist/cli.cjs +0 -2230
- package/dist/cli.d.cts +0 -4
- package/dist/index.cjs +0 -2150
- package/dist/index.d.cts +0 -208
package/dist/cli.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { Command } from 'commander';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
declare function createVersionCommand(): Command;
|
|
5
|
+
declare function createVersionProgram(): Command;
|
|
6
|
+
|
|
7
|
+
export { createVersionCommand, createVersionProgram };
|
package/dist/cli.js
CHANGED
|
@@ -5,28 +5,18 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
log,
|
|
7
7
|
printJsonOutput
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import
|
|
8
|
+
} from "./chunk-V6S7BEBD.js";
|
|
9
|
+
import {
|
|
10
|
+
readPackageVersion
|
|
11
|
+
} from "./chunk-2MN2VLZF.js";
|
|
10
12
|
import "./chunk-LMPZV35Z.js";
|
|
11
13
|
|
|
12
14
|
// src/cli.ts
|
|
13
15
|
import * as fs from "fs";
|
|
14
|
-
import
|
|
16
|
+
import { fileURLToPath } from "url";
|
|
15
17
|
import { Command } from "commander";
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
const packageJsonPath = path.resolve(path.dirname(import.meta.url.replace("file:", "")), "../package.json");
|
|
19
|
-
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
|
|
20
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
21
|
-
return packageJson.version || "0.0.0";
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.error("Failed to read package version:", error);
|
|
24
|
-
return "0.0.0";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function main() {
|
|
28
|
-
const program = new Command();
|
|
29
|
-
program.name("releasekit-version").description("Version a package or packages based on conventional commits").version(getPackageVersion()).command("version", { isDefault: true }).description("Version a package or packages based on configuration").option("-c, --config <path>", "Path to config file (defaults to releasekit.config.json in current directory)").option("-d, --dry-run", "Dry run (no changes made)", false).option("-b, --bump <type>", "Specify bump type (patch|minor|major)").option("-p, --prerelease [identifier]", "Create prerelease version").option("-s, --sync", "Use synchronized versioning across all packages").option("-j, --json", "Output results as JSON", false).option("-t, --target <packages>", "Comma-delimited list of package names to target").option("--project-dir <path>", "Project directory to run commands in", process.cwd()).action(async (options) => {
|
|
18
|
+
function createVersionCommand() {
|
|
19
|
+
return new Command("version").description("Version a package or packages based on configuration").option("-c, --config <path>", "Path to config file (defaults to releasekit.config.json in current directory)").option("-d, --dry-run", "Dry run (no changes made)", false).option("-b, --bump <type>", "Specify bump type (patch|minor|major)").option("-p, --prerelease [identifier]", "Create prerelease version").option("-s, --sync", "Use synchronized versioning across all packages").option("-j, --json", "Output results as JSON", false).option("-t, --target <packages>", "Comma-delimited list of package names to target").option("--project-dir <path>", "Project directory to run commands in", process.cwd()).action(async (options) => {
|
|
30
20
|
if (options.json) {
|
|
31
21
|
enableJsonOutput(options.dryRun);
|
|
32
22
|
}
|
|
@@ -86,7 +76,7 @@ async function main() {
|
|
|
86
76
|
log("Versioning process completed.", "success");
|
|
87
77
|
printJsonOutput();
|
|
88
78
|
} catch (error) {
|
|
89
|
-
const { BaseVersionError } = await import("./baseError-
|
|
79
|
+
const { BaseVersionError } = await import("./baseError-FARJUY5U.js");
|
|
90
80
|
if (BaseVersionError.isVersionError(error)) {
|
|
91
81
|
error.logError();
|
|
92
82
|
} else {
|
|
@@ -95,12 +85,21 @@ async function main() {
|
|
|
95
85
|
process.exit(1);
|
|
96
86
|
}
|
|
97
87
|
});
|
|
98
|
-
program.parse();
|
|
99
88
|
}
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
var isMain = (() => {
|
|
90
|
+
try {
|
|
91
|
+
return process.argv[1] ? fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url) : false;
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
96
|
+
function createVersionProgram() {
|
|
97
|
+
return new Command().name("releasekit-version").description("Version a package or packages based on conventional commits").version(readPackageVersion(import.meta.url)).addCommand(createVersionCommand(), { isDefault: true });
|
|
98
|
+
}
|
|
99
|
+
if (isMain) {
|
|
100
|
+
createVersionProgram().parse();
|
|
102
101
|
}
|
|
103
|
-
main();
|
|
104
102
|
export {
|
|
105
|
-
|
|
103
|
+
createVersionCommand,
|
|
104
|
+
createVersionProgram
|
|
106
105
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,208 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
branchPattern?: string[];
|
|
11
|
-
baseBranch?: string;
|
|
12
|
-
path?: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
strictReachable?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface Config extends VersionConfigBase {
|
|
17
|
-
tagTemplate: string;
|
|
18
|
-
packageSpecificTags?: boolean;
|
|
19
|
-
preset: string;
|
|
20
|
-
sync: boolean;
|
|
21
|
-
packages: string[];
|
|
22
|
-
mainPackage?: string;
|
|
23
|
-
updateInternalDependencies: 'major' | 'minor' | 'patch' | 'no-internal-update';
|
|
24
|
-
skip?: string[];
|
|
25
|
-
commitMessage?: string;
|
|
26
|
-
versionStrategy?: 'branchPattern' | 'commitMessage';
|
|
27
|
-
branchPatterns?: BranchPattern[];
|
|
28
|
-
defaultReleaseType?: ReleaseType;
|
|
29
|
-
dryRun?: boolean;
|
|
30
|
-
latestTag?: string;
|
|
31
|
-
isPrerelease?: boolean;
|
|
32
|
-
mismatchStrategy?: 'error' | 'warn' | 'ignore' | 'prefer-package' | 'prefer-git';
|
|
33
|
-
strictReachable?: boolean;
|
|
34
|
-
cargo?: {
|
|
35
|
-
enabled?: boolean;
|
|
36
|
-
paths?: string[];
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
interface BranchPattern {
|
|
40
|
-
pattern: string;
|
|
41
|
-
releaseType: ReleaseType;
|
|
42
|
-
}
|
|
43
|
-
interface VersionOptions extends VersionConfigBase {
|
|
44
|
-
latestTag: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare function loadConfig(options?: LoadOptions): Config;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Version calculation logic
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Calculates the next version number based on the current version and options
|
|
55
|
-
*/
|
|
56
|
-
declare function calculateVersion(config: Config, options: VersionOptions): Promise<string>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Strategy functions for versioning using the higher-order function pattern
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Available strategy types
|
|
64
|
-
*/
|
|
65
|
-
type StrategyType = 'sync' | 'single' | 'async';
|
|
66
|
-
/**
|
|
67
|
-
* Strategy function type
|
|
68
|
-
*/
|
|
69
|
-
type StrategyFunction = (packages: PackagesWithRoot, targets?: string[]) => Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Create a sync versioning strategy function
|
|
72
|
-
*/
|
|
73
|
-
declare function createSyncStrategy(config: Config): StrategyFunction;
|
|
74
|
-
/**
|
|
75
|
-
* Create a single package versioning strategy function
|
|
76
|
-
*/
|
|
77
|
-
declare function createSingleStrategy(config: Config): StrategyFunction;
|
|
78
|
-
/**
|
|
79
|
-
* Create an async package versioning strategy function
|
|
80
|
-
*/
|
|
81
|
-
declare function createAsyncStrategy(config: Config): StrategyFunction;
|
|
82
|
-
|
|
83
|
-
interface PackagesWithRoot extends Packages {
|
|
84
|
-
root: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Main versioning engine that uses functional strategies
|
|
88
|
-
*/
|
|
89
|
-
declare class VersionEngine {
|
|
90
|
-
private config;
|
|
91
|
-
private workspaceCache;
|
|
92
|
-
private strategies;
|
|
93
|
-
private currentStrategy;
|
|
94
|
-
constructor(config: Config, _jsonMode?: boolean);
|
|
95
|
-
/**
|
|
96
|
-
* Get workspace packages information - with caching for performance
|
|
97
|
-
*/
|
|
98
|
-
getWorkspacePackages(): Promise<PackagesWithRoot>;
|
|
99
|
-
/**
|
|
100
|
-
* Run the current strategy
|
|
101
|
-
* @param packages Workspace packages to process
|
|
102
|
-
* @param targets Optional package targets to process (only used by async strategy)
|
|
103
|
-
*/
|
|
104
|
-
run(packages: PackagesWithRoot, targets?: string[]): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* Change the current strategy
|
|
107
|
-
* @param strategyType The strategy type to use: 'sync', 'single', or 'async'
|
|
108
|
-
*/
|
|
109
|
-
setStrategy(strategyType: StrategyType): void;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Version-specific base error that bridges the factory pattern
|
|
114
|
-
* used by @releasekit/version with the abstract ReleaseKitError base.
|
|
115
|
-
*/
|
|
116
|
-
declare class BaseVersionError extends ReleaseKitError {
|
|
117
|
-
readonly code: string;
|
|
118
|
-
readonly suggestions: string[];
|
|
119
|
-
constructor(message: string, code: string, suggestions?: string[]);
|
|
120
|
-
static isVersionError(error: unknown): error is BaseVersionError;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Custom error class for versioning operations
|
|
125
|
-
*/
|
|
126
|
-
declare class VersionError extends BaseVersionError {
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Error codes for versioning operations
|
|
130
|
-
*/
|
|
131
|
-
declare enum VersionErrorCode {
|
|
132
|
-
CONFIG_REQUIRED = "CONFIG_REQUIRED",
|
|
133
|
-
PACKAGES_NOT_FOUND = "PACKAGES_NOT_FOUND",
|
|
134
|
-
WORKSPACE_ERROR = "WORKSPACE_ERROR",
|
|
135
|
-
INVALID_CONFIG = "INVALID_CONFIG",
|
|
136
|
-
PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND",
|
|
137
|
-
VERSION_CALCULATION_ERROR = "VERSION_CALCULATION_ERROR"
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Creates a VersionError with standard error message for common failure scenarios
|
|
141
|
-
* @param code Error code
|
|
142
|
-
* @param details Additional error details
|
|
143
|
-
* @returns VersionError instance
|
|
144
|
-
*/
|
|
145
|
-
declare function createVersionError(code: VersionErrorCode, details?: string): VersionError;
|
|
146
|
-
|
|
147
|
-
interface PackageProcessorOptions {
|
|
148
|
-
skip?: string[];
|
|
149
|
-
versionPrefix?: string;
|
|
150
|
-
tagTemplate?: string;
|
|
151
|
-
commitMessageTemplate?: string;
|
|
152
|
-
dryRun?: boolean;
|
|
153
|
-
getLatestTag: () => Promise<string | null>;
|
|
154
|
-
config: Omit<VersionConfigBase, 'versionPrefix' | 'path' | 'name'>;
|
|
155
|
-
fullConfig: Config;
|
|
156
|
-
}
|
|
157
|
-
interface ProcessResult {
|
|
158
|
-
updatedPackages: Array<{
|
|
159
|
-
name: string;
|
|
160
|
-
version: string;
|
|
161
|
-
path: string;
|
|
162
|
-
}>;
|
|
163
|
-
commitMessage?: string;
|
|
164
|
-
tags: string[];
|
|
165
|
-
}
|
|
166
|
-
declare class PackageProcessor {
|
|
167
|
-
private skip;
|
|
168
|
-
private versionPrefix;
|
|
169
|
-
private tagTemplate?;
|
|
170
|
-
private commitMessageTemplate;
|
|
171
|
-
private dryRun;
|
|
172
|
-
private getLatestTag;
|
|
173
|
-
private config;
|
|
174
|
-
private fullConfig;
|
|
175
|
-
constructor(options: PackageProcessorOptions);
|
|
176
|
-
/**
|
|
177
|
-
* Process packages based on skip list only (targeting handled at discovery time)
|
|
178
|
-
*/
|
|
179
|
-
processPackages(packages: Package[]): Promise<ProcessResult>;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* JSON Output service for releasekit-version
|
|
184
|
-
* Centralizes all JSON output handling
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
interface JsonOutputData {
|
|
188
|
-
dryRun: boolean;
|
|
189
|
-
updates: Array<{
|
|
190
|
-
packageName: string;
|
|
191
|
-
newVersion: string;
|
|
192
|
-
filePath: string;
|
|
193
|
-
}>;
|
|
194
|
-
changelogs: VersionPackageChangelog[];
|
|
195
|
-
commitMessage?: string;
|
|
196
|
-
tags: string[];
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Enable JSON output mode
|
|
200
|
-
* @param dryRun Whether this is a dry run
|
|
201
|
-
*/
|
|
202
|
-
declare function enableJsonOutput(dryRun?: boolean): void;
|
|
203
|
-
/**
|
|
204
|
-
* Get the current JSON output data (for testing)
|
|
205
|
-
*/
|
|
206
|
-
declare function getJsonData(): JsonOutputData;
|
|
207
|
-
|
|
208
|
-
export { BaseVersionError, type Config, type JsonOutputData, PackageProcessor, type VersionConfigBase, VersionEngine, VersionErrorCode, calculateVersion, createAsyncStrategy, createSingleStrategy, createSyncStrategy, createVersionError, enableJsonOutput, getJsonData, loadConfig };
|
|
1
|
+
export { loadConfig } from './config.ts';
|
|
2
|
+
export { calculateVersion } from './core/versionCalculator.ts';
|
|
3
|
+
export { VersionEngine } from './core/versionEngine.ts';
|
|
4
|
+
export { createAsyncStrategy, createSingleStrategy, createSyncStrategy } from './core/versionStrategies.ts';
|
|
5
|
+
export { BaseVersionError } from './errors/baseError.ts';
|
|
6
|
+
export { VersionErrorCode, createVersionError } from './errors/versionError.ts';
|
|
7
|
+
export { PackageProcessor } from './package/packageProcessor.ts';
|
|
8
|
+
export { Config, VersionConfigBase } from './types.ts';
|
|
9
|
+
export { JsonOutputData, enableJsonOutput, flushPendingWrites, getJsonData } from './utils/jsonOutput.ts';
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
createSyncStrategy,
|
|
9
9
|
createVersionError,
|
|
10
10
|
enableJsonOutput,
|
|
11
|
+
flushPendingWrites,
|
|
11
12
|
getJsonData,
|
|
12
13
|
loadConfig
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-V6S7BEBD.js";
|
|
14
15
|
import {
|
|
15
16
|
BaseVersionError
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-2MN2VLZF.js";
|
|
17
18
|
import "./chunk-LMPZV35Z.js";
|
|
18
19
|
export {
|
|
19
20
|
BaseVersionError,
|
|
@@ -26,6 +27,7 @@ export {
|
|
|
26
27
|
createSyncStrategy,
|
|
27
28
|
createVersionError,
|
|
28
29
|
enableJsonOutput,
|
|
30
|
+
flushPendingWrites,
|
|
29
31
|
getJsonData,
|
|
30
32
|
loadConfig
|
|
31
33
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# CI/CD Integration
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
`releasekit-version` is designed to work seamlessly in CI/CD pipelines, making it easy to automate versioning as part of your release workflow.
|
|
4
4
|
|
|
5
5
|
## JSON Output Mode
|
|
6
6
|
|
|
7
|
-
For programmatic consumption in CI/CD scripts, `
|
|
7
|
+
For programmatic consumption in CI/CD scripts, `releasekit-version` provides a structured JSON output option:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
# Output results in JSON format
|
|
11
|
-
npx
|
|
11
|
+
npx releasekit-version --json
|
|
12
12
|
|
|
13
13
|
# Combine with dry-run for planning
|
|
14
|
-
npx
|
|
14
|
+
npx releasekit-version --dry-run --json
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
This will suppress all normal console output and instead output a single JSON object containing:
|
|
@@ -39,7 +39,7 @@ This will suppress all normal console output and instead output a single JSON ob
|
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
],
|
|
42
|
-
"commitMessage": "chore
|
|
42
|
+
"commitMessage": "chore: release my-package v1.2.3", // The commit message that was used
|
|
43
43
|
"tags": [ // Array of tags that were created
|
|
44
44
|
"v1.2.3" // or package-specific tags in targeted mode
|
|
45
45
|
]
|
|
@@ -58,7 +58,7 @@ The structured JSON output provides several advantages for CI/CD integration:
|
|
|
58
58
|
|
|
59
59
|
## Sample CI/CD Integration Patterns
|
|
60
60
|
|
|
61
|
-
Here are some common ways to incorporate `
|
|
61
|
+
Here are some common ways to incorporate `releasekit-version` into your CI/CD pipeline:
|
|
62
62
|
|
|
63
63
|
### GitHub Actions Workflow Example
|
|
64
64
|
|
|
@@ -77,12 +77,12 @@ jobs:
|
|
|
77
77
|
new_version: ${{ steps.version.outputs.new_version }}
|
|
78
78
|
|
|
79
79
|
steps:
|
|
80
|
-
- uses: actions/checkout@
|
|
80
|
+
- uses: actions/checkout@v6
|
|
81
81
|
with:
|
|
82
82
|
fetch-depth: 0 # Important for git history
|
|
83
83
|
|
|
84
84
|
- name: Setup Node.js
|
|
85
|
-
uses: actions/setup-node@
|
|
85
|
+
uses: actions/setup-node@v6
|
|
86
86
|
with:
|
|
87
87
|
node-version: '18'
|
|
88
88
|
|
|
@@ -93,7 +93,7 @@ jobs:
|
|
|
93
93
|
id: version
|
|
94
94
|
run: |
|
|
95
95
|
# Run in JSON mode for parsing
|
|
96
|
-
VERSION_OUTPUT=$(npx
|
|
96
|
+
VERSION_OUTPUT=$(npx releasekit-version --json)
|
|
97
97
|
echo "Version output: $VERSION_OUTPUT"
|
|
98
98
|
|
|
99
99
|
# Use jq to parse the JSON output
|
|
@@ -127,7 +127,7 @@ determine_version:
|
|
|
127
127
|
script:
|
|
128
128
|
- npm ci
|
|
129
129
|
- |
|
|
130
|
-
VERSION_OUTPUT=$(npx
|
|
130
|
+
VERSION_OUTPUT=$(npx releasekit-version --json)
|
|
131
131
|
echo "VERSION_OUTPUT=$VERSION_OUTPUT" >> version.env
|
|
132
132
|
|
|
133
133
|
# Parse values for use in later stages
|
|
@@ -153,7 +153,7 @@ publish:
|
|
|
153
153
|
|
|
154
154
|
## Working with Tags in CI
|
|
155
155
|
|
|
156
|
-
When using the targeted mode with `-t` flag, `
|
|
156
|
+
When using the targeted mode with `-t` flag, `releasekit-version` creates package-specific tags (e.g., `@scope/package-a@1.2.0`) but not a global tag. If your release process needs a global tag, you can add a step to your CI/CD pipeline:
|
|
157
157
|
|
|
158
158
|
```bash
|
|
159
159
|
# Create a global tag based on the representative version
|
|
@@ -164,7 +164,7 @@ git push origin "v$NEW_VERSION"
|
|
|
164
164
|
|
|
165
165
|
## Environment Variables
|
|
166
166
|
|
|
167
|
-
`
|
|
167
|
+
`releasekit-version` respects the following environment variables:
|
|
168
168
|
|
|
169
169
|
- `NO_COLOR=1`: Disables colored output in logs (automatically detected in CI environments)
|
|
170
170
|
- `CI=true`: Most CI environments set this automatically, which helps the tool adjust its output behaviour
|
|
@@ -175,7 +175,7 @@ If you want to prevent additional CI runs when version commits are made, you can
|
|
|
175
175
|
|
|
176
176
|
```json
|
|
177
177
|
{
|
|
178
|
-
"commitMessage": "chore
|
|
178
|
+
"commitMessage": "chore: release ${packageName} v${version} [skip ci]",
|
|
179
179
|
// other configuration options...
|
|
180
180
|
}
|
|
181
181
|
```
|
package/docs/versioning.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Versioning Strategies and Concepts
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
`releasekit-version` offers flexible ways to determine the next version for your project based on its history and your configuration.
|
|
4
4
|
|
|
5
5
|
## How the Next Version is Calculated
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ There are two primary methods the tool uses to decide the version bump (e.g., pa
|
|
|
8
8
|
|
|
9
9
|
### 1. Conventional Commits (`versionStrategy: "conventional"`)
|
|
10
10
|
|
|
11
|
-
This is the default strategy. `
|
|
11
|
+
This is the default strategy. `releasekit-version` analyzes Git commit messages since the last Git tag that follows semver patterns. It uses the [conventional-commits](https://www.conventionalcommits.org/) specification to determine the bump:
|
|
12
12
|
|
|
13
13
|
- **Patch Bump (e.g., 1.2.3 -> 1.2.4):** Triggered by `fix:` commit types.
|
|
14
14
|
- **Minor Bump (e.g., 1.2.3 -> 1.3.0):** Triggered by `feat:` commit types.
|
|
@@ -67,7 +67,7 @@ This allows you to enforce version bumps based on your branching workflow (e.g.,
|
|
|
67
67
|
|
|
68
68
|
## Package Type Support
|
|
69
69
|
|
|
70
|
-
`
|
|
70
|
+
`releasekit-version` supports both JavaScript/TypeScript projects using `package.json` and Rust projects using `Cargo.toml`:
|
|
71
71
|
|
|
72
72
|
### JavaScript/TypeScript Projects
|
|
73
73
|
|
|
@@ -79,7 +79,7 @@ For Rust projects, the tool looks for and updates the `package.version` field in
|
|
|
79
79
|
|
|
80
80
|
### Mixed Projects with Both Manifests
|
|
81
81
|
|
|
82
|
-
When both `package.json` and `Cargo.toml` exist in the same directory, `
|
|
82
|
+
When both `package.json` and `Cargo.toml` exist in the same directory, `releasekit-version` will:
|
|
83
83
|
|
|
84
84
|
1. Update both manifest files independently with the same calculated version
|
|
85
85
|
2. First check `package.json` for the current version (when no tags exist)
|
|
@@ -89,7 +89,7 @@ This allows you to maintain consistent versioning across JavaScript and Rust com
|
|
|
89
89
|
|
|
90
90
|
## Version Source Selection
|
|
91
91
|
|
|
92
|
-
`
|
|
92
|
+
`releasekit-version` uses a smart version source selection strategy to determine the base version for calculating the next version:
|
|
93
93
|
|
|
94
94
|
1. First, it checks for Git tags:
|
|
95
95
|
- In normal mode: Uses the latest reachable tag, falling back to unreachable tags if needed
|
|
@@ -273,7 +273,7 @@ This configuration will process all packages in the `@mycompany` scope except fo
|
|
|
273
273
|
|
|
274
274
|
## Tag Templates and Configuration
|
|
275
275
|
|
|
276
|
-
`
|
|
276
|
+
`releasekit-version` provides flexible configuration for how Git tags are formatted, allowing you to customize the tag structure for both single package repositories and monorepos.
|
|
277
277
|
|
|
278
278
|
### Tag Template Configuration
|
|
279
279
|
|
|
@@ -355,7 +355,7 @@ This would produce package tags like `@scope/package-name-v1.2.3` instead of `@s
|
|
|
355
355
|
|
|
356
356
|
## Troubleshooting Template Configuration
|
|
357
357
|
|
|
358
|
-
`
|
|
358
|
+
`releasekit-version` provides helpful warnings when template configurations don't match your project setup. Here are common issues and their solutions:
|
|
359
359
|
|
|
360
360
|
### Template Contains ${packageName} but No Package Name Available
|
|
361
361
|
|
|
@@ -430,7 +430,7 @@ For global commit messages, use templates without `${packageName}`:
|
|
|
430
430
|
|
|
431
431
|
## Monorepo Versioning Modes
|
|
432
432
|
|
|
433
|
-
While primarily used for single packages now, `
|
|
433
|
+
While primarily used for single packages now, `releasekit-version` retains options for monorepo workflows, controlled mainly by the `sync` flag in `version.config.json`.
|
|
434
434
|
|
|
435
435
|
### Sync Mode (`sync: true`)
|
|
436
436
|
|
|
@@ -457,13 +457,13 @@ This is the default if the `sync` flag is present and true.
|
|
|
457
457
|
- It calculates an appropriate version bump **independently for each targeted package** based on its commit history.
|
|
458
458
|
- The `package.json` file of each successfully updated targeted package is modified.
|
|
459
459
|
- An **individual Git tag** (e.g., `packageName@1.2.3`) is created **for each successfully updated package** immediately after its version is bumped.
|
|
460
|
-
- Finally, a **single commit** is created including all the updated `package.json` files, using a summary commit message (e.g., `chore
|
|
461
|
-
- **Important:** Only package-specific tags are created. The global tag (e.g., `v1.2.3`) is **not** automatically generated in this mode. If your release process (like GitHub Releases) depends on a global tag, you'll need to create it manually in your CI/CD script *after* `
|
|
460
|
+
- Finally, a **single commit** is created including all the updated `package.json` files, using a summary commit message (e.g., `chore: release pkg-a, pkg-b v1.2.3 [skip ci]`).
|
|
461
|
+
- **Important:** Only package-specific tags are created. The global tag (e.g., `v1.2.3`) is **not** automatically generated in this mode. If your release process (like GitHub Releases) depends on a global tag, you'll need to create it manually in your CI/CD script *after* `releasekit-version` completes.
|
|
462
462
|
- **Use Case:** Releasing specific packages independently while still tagging each released package individually.
|
|
463
463
|
|
|
464
464
|
## Prerelease Handling
|
|
465
465
|
|
|
466
|
-
`
|
|
466
|
+
`releasekit-version` provides flexible handling for prerelease versions, allowing both creation of prereleases and promotion to stable releases.
|
|
467
467
|
|
|
468
468
|
### Creating Prereleases
|
|
469
469
|
|
|
@@ -471,7 +471,7 @@ Use the `--prerelease` flag with an identifier to create a prerelease version:
|
|
|
471
471
|
|
|
472
472
|
```bash
|
|
473
473
|
# Create a beta prerelease
|
|
474
|
-
npx
|
|
474
|
+
npx releasekit-version --bump minor --prerelease beta
|
|
475
475
|
# Result: 1.0.0 -> 1.1.0-beta.0
|
|
476
476
|
```
|
|
477
477
|
|
|
@@ -485,11 +485,11 @@ You can also set a default prerelease identifier in your `version.config.json`:
|
|
|
485
485
|
|
|
486
486
|
### Promoting Prereleases to Stable Releases
|
|
487
487
|
|
|
488
|
-
When using standard bump types (`major`, `minor`, `patch`) with the `--bump` flag on a prerelease version, `
|
|
488
|
+
When using standard bump types (`major`, `minor`, `patch`) with the `--bump` flag on a prerelease version, `releasekit-version` will automatically clean the prerelease identifier:
|
|
489
489
|
|
|
490
490
|
```bash
|
|
491
491
|
# Starting from version 1.0.0-beta.1
|
|
492
|
-
npx
|
|
492
|
+
npx releasekit-version --bump major
|
|
493
493
|
# Result: 1.0.0-beta.1 -> 2.0.0 (not 2.0.0-beta.0)
|
|
494
494
|
```
|
|
495
495
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@releasekit/version",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Semantic versioning based on Git history and conventional commits",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
6
|
"module": "./dist/index.js",
|
|
8
7
|
"types": "./dist/index.d.ts",
|
|
9
8
|
"exports": {
|
|
@@ -11,10 +10,12 @@
|
|
|
11
10
|
"import": {
|
|
12
11
|
"types": "./dist/index.d.ts",
|
|
13
12
|
"default": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"./cli": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/cli.d.ts",
|
|
18
|
+
"default": "./dist/cli.js"
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
},
|
|
@@ -59,9 +60,8 @@
|
|
|
59
60
|
"git-semver-tags": "^8.0.1",
|
|
60
61
|
"micromatch": "^4.0.8",
|
|
61
62
|
"semver": "^7.7.4",
|
|
62
|
-
"smol-toml": "^1.6.
|
|
63
|
-
"
|
|
64
|
-
"@releasekit/core": "0.1.0"
|
|
63
|
+
"smol-toml": "^1.6.1",
|
|
64
|
+
"zod": "^4.3.6"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@biomejs/biome": "^2.4.6",
|
|
@@ -71,14 +71,16 @@
|
|
|
71
71
|
"@vitest/coverage-v8": "^4.1.0",
|
|
72
72
|
"tsup": "^8.5.1",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
|
-
"vitest": "^4.1.0"
|
|
74
|
+
"vitest": "^4.1.0",
|
|
75
|
+
"@releasekit/config": "0.0.0",
|
|
76
|
+
"@releasekit/core": "0.0.0"
|
|
75
77
|
},
|
|
76
78
|
"engines": {
|
|
77
79
|
"node": ">=20"
|
|
78
80
|
},
|
|
79
81
|
"scripts": {
|
|
80
|
-
"build": "tsup
|
|
81
|
-
"dev": "tsup
|
|
82
|
+
"build": "tsup",
|
|
83
|
+
"dev": "tsup --watch",
|
|
82
84
|
"clean": "rm -rf dist coverage .turbo",
|
|
83
85
|
"test": "vitest run --dir test/unit",
|
|
84
86
|
"test:unit": "vitest run --coverage --dir test/unit",
|
package/version.schema.json
CHANGED
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"commitMessage": {
|
|
94
94
|
"type": "string",
|
|
95
95
|
"minLength": 1,
|
|
96
|
-
"default": "chore
|
|
96
|
+
"default": "chore: release ${packageName} v${version}",
|
|
97
97
|
"description": "Template for commit messages. Available variables: ${version}, ${packageName}, ${scope}"
|
|
98
98
|
},
|
|
99
99
|
"prereleaseIdentifier": {
|
package/dist/chunk-GQLJ7JQY.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/errors/baseError.ts
|
|
2
|
-
import { ReleaseKitError } from "@releasekit/core";
|
|
3
|
-
var BaseVersionError = class _BaseVersionError extends ReleaseKitError {
|
|
4
|
-
code;
|
|
5
|
-
suggestions;
|
|
6
|
-
constructor(message, code, suggestions) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.code = code;
|
|
9
|
-
this.suggestions = suggestions ?? [];
|
|
10
|
-
}
|
|
11
|
-
static isVersionError(error) {
|
|
12
|
-
return error instanceof _BaseVersionError;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
BaseVersionError
|
|
18
|
-
};
|