@releasekit/version 0.3.0 → 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/dist/baseError-FARJUY5U.js +6 -0
- package/dist/chunk-2MN2VLZF.js +85 -0
- package/dist/chunk-LMPZV35Z.js +20 -0
- package/dist/chunk-V6S7BEBD.js +2451 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +104 -0
- package/dist/commandExecutor-E44ID5U4.js +8 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +33 -0
- package/package.json +3 -3
package/dist/cli.d.ts
ADDED
package/dist/cli.js
CHANGED
|
@@ -1 +1,105 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
VersionEngine,
|
|
4
|
+
enableJsonOutput,
|
|
5
|
+
loadConfig,
|
|
6
|
+
log,
|
|
7
|
+
printJsonOutput
|
|
8
|
+
} from "./chunk-V6S7BEBD.js";
|
|
9
|
+
import {
|
|
10
|
+
readPackageVersion
|
|
11
|
+
} from "./chunk-2MN2VLZF.js";
|
|
12
|
+
import "./chunk-LMPZV35Z.js";
|
|
13
|
+
|
|
14
|
+
// src/cli.ts
|
|
15
|
+
import * as fs from "fs";
|
|
16
|
+
import { fileURLToPath } from "url";
|
|
17
|
+
import { Command } from "commander";
|
|
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) => {
|
|
20
|
+
if (options.json) {
|
|
21
|
+
enableJsonOutput(options.dryRun);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const originalCwd = process.cwd();
|
|
25
|
+
if (options.projectDir && options.projectDir !== originalCwd) {
|
|
26
|
+
try {
|
|
27
|
+
process.chdir(options.projectDir);
|
|
28
|
+
log(`Changed working directory to: ${options.projectDir}`, "debug");
|
|
29
|
+
} catch (error) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Failed to change to directory "${options.projectDir}": ${error instanceof Error ? error.message : String(error)}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const config = loadConfig({ cwd: options.projectDir, configPath: options.config });
|
|
36
|
+
log(`Loaded configuration from ${options.config || "releasekit.config.json"}`, "info");
|
|
37
|
+
if (options.dryRun) config.dryRun = true;
|
|
38
|
+
if (options.sync) config.sync = true;
|
|
39
|
+
if (options.bump) config.type = options.bump;
|
|
40
|
+
if (options.prerelease) {
|
|
41
|
+
config.prereleaseIdentifier = options.prerelease === true ? "next" : options.prerelease;
|
|
42
|
+
config.isPrerelease = true;
|
|
43
|
+
}
|
|
44
|
+
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
45
|
+
if (cliTargets.length > 0) {
|
|
46
|
+
config.packages = cliTargets;
|
|
47
|
+
log(`CLI targets specified: ${cliTargets.join(", ")}`, "info");
|
|
48
|
+
}
|
|
49
|
+
const engine = new VersionEngine(config, !!options.json);
|
|
50
|
+
const pkgsResult = await engine.getWorkspacePackages();
|
|
51
|
+
const resolvedCount = pkgsResult.packages.length;
|
|
52
|
+
log(`Resolved ${resolvedCount} packages from workspace`, "debug");
|
|
53
|
+
log(`Config packages: ${JSON.stringify(config.packages)}`, "debug");
|
|
54
|
+
log(`Config sync: ${config.sync}`, "debug");
|
|
55
|
+
if (config.sync) {
|
|
56
|
+
log("Using sync versioning strategy.", "info");
|
|
57
|
+
engine.setStrategy("sync");
|
|
58
|
+
await engine.run(pkgsResult);
|
|
59
|
+
} else if (resolvedCount === 1) {
|
|
60
|
+
log("Using single package versioning strategy.", "info");
|
|
61
|
+
if (cliTargets.length > 0) {
|
|
62
|
+
log("--target flag is ignored for single package strategy.", "warning");
|
|
63
|
+
}
|
|
64
|
+
engine.setStrategy("single");
|
|
65
|
+
await engine.run(pkgsResult);
|
|
66
|
+
} else if (resolvedCount === 0) {
|
|
67
|
+
throw new Error("No packages found in workspace");
|
|
68
|
+
} else {
|
|
69
|
+
log("Using async versioning strategy.", "info");
|
|
70
|
+
if (cliTargets.length > 0) {
|
|
71
|
+
log(`Targeting specific packages: ${cliTargets.join(", ")}`, "info");
|
|
72
|
+
}
|
|
73
|
+
engine.setStrategy("async");
|
|
74
|
+
await engine.run(pkgsResult, cliTargets);
|
|
75
|
+
}
|
|
76
|
+
log("Versioning process completed.", "success");
|
|
77
|
+
printJsonOutput();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
const { BaseVersionError } = await import("./baseError-FARJUY5U.js");
|
|
80
|
+
if (BaseVersionError.isVersionError(error)) {
|
|
81
|
+
error.logError();
|
|
82
|
+
} else {
|
|
83
|
+
log(`Error: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
84
|
+
}
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
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();
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
createVersionCommand,
|
|
104
|
+
createVersionProgram
|
|
105
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PackageProcessor,
|
|
3
|
+
VersionEngine,
|
|
4
|
+
VersionErrorCode,
|
|
5
|
+
calculateVersion,
|
|
6
|
+
createAsyncStrategy,
|
|
7
|
+
createSingleStrategy,
|
|
8
|
+
createSyncStrategy,
|
|
9
|
+
createVersionError,
|
|
10
|
+
enableJsonOutput,
|
|
11
|
+
flushPendingWrites,
|
|
12
|
+
getJsonData,
|
|
13
|
+
loadConfig
|
|
14
|
+
} from "./chunk-V6S7BEBD.js";
|
|
15
|
+
import {
|
|
16
|
+
BaseVersionError
|
|
17
|
+
} from "./chunk-2MN2VLZF.js";
|
|
18
|
+
import "./chunk-LMPZV35Z.js";
|
|
19
|
+
export {
|
|
20
|
+
BaseVersionError,
|
|
21
|
+
PackageProcessor,
|
|
22
|
+
VersionEngine,
|
|
23
|
+
VersionErrorCode,
|
|
24
|
+
calculateVersion,
|
|
25
|
+
createAsyncStrategy,
|
|
26
|
+
createSingleStrategy,
|
|
27
|
+
createSyncStrategy,
|
|
28
|
+
createVersionError,
|
|
29
|
+
enableJsonOutput,
|
|
30
|
+
flushPendingWrites,
|
|
31
|
+
getJsonData,
|
|
32
|
+
loadConfig
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
"module": "./dist/index.js",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"tsup": "^8.5.1",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
74
|
"vitest": "^4.1.0",
|
|
75
|
-
"@releasekit/
|
|
76
|
-
"@releasekit/
|
|
75
|
+
"@releasekit/config": "0.0.0",
|
|
76
|
+
"@releasekit/core": "0.0.0"
|
|
77
77
|
},
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=20"
|