@releasekit/version 0.1.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/LICENCE.md +7 -0
- package/README.md +307 -0
- package/dist/baseError-IKMJCSYK.js +6 -0
- package/dist/baseError-ZCZHF6A2.js +7 -0
- package/dist/chunk-6CLV2DJG.js +2166 -0
- package/dist/chunk-7GDPUNML.js +128 -0
- package/dist/chunk-GLFC564Q.js +2174 -0
- package/dist/chunk-GQLJ7JQY.js +18 -0
- package/dist/chunk-KZDV4EBO.js +2170 -0
- package/dist/chunk-WEP3ACTS.js +2125 -0
- package/dist/cli.cjs +2313 -0
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +105 -0
- package/dist/index.cjs +2228 -0
- package/dist/index.d.cts +209 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +30 -0
- package/docs/CI_CD_INTEGRATION.md +197 -0
- package/docs/versioning.md +501 -0
- package/package.json +80 -0
- package/version.schema.json +148 -0
package/dist/cli.d.cts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
VersionEngine,
|
|
4
|
+
enableJsonOutput,
|
|
5
|
+
loadConfig,
|
|
6
|
+
log,
|
|
7
|
+
printJsonOutput
|
|
8
|
+
} from "./chunk-GLFC564Q.js";
|
|
9
|
+
import "./chunk-GQLJ7JQY.js";
|
|
10
|
+
|
|
11
|
+
// src/cli.ts
|
|
12
|
+
import * as fs from "fs";
|
|
13
|
+
import path from "path";
|
|
14
|
+
import { Command } from "commander";
|
|
15
|
+
function getPackageVersion() {
|
|
16
|
+
try {
|
|
17
|
+
const packageJsonPath = path.resolve(path.dirname(import.meta.url.replace("file:", "")), "../package.json");
|
|
18
|
+
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
|
|
19
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
20
|
+
return packageJson.version || "0.0.0";
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error("Failed to read package version:", error);
|
|
23
|
+
return "0.0.0";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function main() {
|
|
27
|
+
const program = new Command();
|
|
28
|
+
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) => {
|
|
29
|
+
if (options.json) {
|
|
30
|
+
enableJsonOutput(options.dryRun);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const originalCwd = process.cwd();
|
|
34
|
+
if (options.projectDir && options.projectDir !== originalCwd) {
|
|
35
|
+
try {
|
|
36
|
+
process.chdir(options.projectDir);
|
|
37
|
+
log(`Changed working directory to: ${options.projectDir}`, "debug");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Failed to change to directory "${options.projectDir}": ${error instanceof Error ? error.message : String(error)}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const config = loadConfig({ cwd: options.projectDir, configPath: options.config });
|
|
45
|
+
log(`Loaded configuration from ${options.config || "releasekit.config.json"}`, "info");
|
|
46
|
+
if (options.dryRun) config.dryRun = true;
|
|
47
|
+
if (options.sync) config.sync = true;
|
|
48
|
+
if (options.bump) config.type = options.bump;
|
|
49
|
+
if (options.prerelease) {
|
|
50
|
+
config.prereleaseIdentifier = options.prerelease === true ? "next" : options.prerelease;
|
|
51
|
+
config.isPrerelease = true;
|
|
52
|
+
}
|
|
53
|
+
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
54
|
+
if (cliTargets.length > 0) {
|
|
55
|
+
config.packages = cliTargets;
|
|
56
|
+
log(`CLI targets specified: ${cliTargets.join(", ")}`, "info");
|
|
57
|
+
}
|
|
58
|
+
const engine = new VersionEngine(config, !!options.json);
|
|
59
|
+
const pkgsResult = await engine.getWorkspacePackages();
|
|
60
|
+
const resolvedCount = pkgsResult.packages.length;
|
|
61
|
+
log(`Resolved ${resolvedCount} packages from workspace`, "debug");
|
|
62
|
+
log(`Config packages: ${JSON.stringify(config.packages)}`, "debug");
|
|
63
|
+
log(`Config sync: ${config.sync}`, "debug");
|
|
64
|
+
if (config.sync) {
|
|
65
|
+
log("Using sync versioning strategy.", "info");
|
|
66
|
+
engine.setStrategy("sync");
|
|
67
|
+
await engine.run(pkgsResult);
|
|
68
|
+
} else if (resolvedCount === 1) {
|
|
69
|
+
log("Using single package versioning strategy.", "info");
|
|
70
|
+
if (cliTargets.length > 0) {
|
|
71
|
+
log("--target flag is ignored for single package strategy.", "warning");
|
|
72
|
+
}
|
|
73
|
+
engine.setStrategy("single");
|
|
74
|
+
await engine.run(pkgsResult);
|
|
75
|
+
} else if (resolvedCount === 0) {
|
|
76
|
+
throw new Error("No packages found in workspace");
|
|
77
|
+
} else {
|
|
78
|
+
log("Using async versioning strategy.", "info");
|
|
79
|
+
if (cliTargets.length > 0) {
|
|
80
|
+
log(`Targeting specific packages: ${cliTargets.join(", ")}`, "info");
|
|
81
|
+
}
|
|
82
|
+
engine.setStrategy("async");
|
|
83
|
+
await engine.run(pkgsResult, cliTargets);
|
|
84
|
+
}
|
|
85
|
+
log("Versioning process completed.", "success");
|
|
86
|
+
printJsonOutput();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
const { BaseVersionError } = await import("./baseError-ZCZHF6A2.js");
|
|
89
|
+
if (BaseVersionError.isVersionError(error)) {
|
|
90
|
+
error.logError();
|
|
91
|
+
} else {
|
|
92
|
+
log(`Error: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
93
|
+
}
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
program.parse();
|
|
98
|
+
}
|
|
99
|
+
async function run() {
|
|
100
|
+
await main();
|
|
101
|
+
}
|
|
102
|
+
main();
|
|
103
|
+
export {
|
|
104
|
+
run
|
|
105
|
+
};
|