versionary 0.1.0 → 0.3.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 +217 -8
- package/dist/app/release/pr.d.ts +18 -0
- package/dist/app/release/pr.js +209 -0
- package/dist/app/release/recovery.d.ts +17 -0
- package/dist/app/release/recovery.js +101 -0
- package/dist/app/release/release.d.ts +1 -0
- package/dist/app/release/release.js +90 -0
- package/dist/app/release/state.d.ts +10 -0
- package/dist/app/release/state.js +59 -0
- package/dist/app/release/verify.d.ts +2 -0
- package/dist/app/release/verify.js +5 -0
- package/dist/cli/index.js +51 -8
- package/dist/config/load-config.js +8 -12
- package/dist/config/schema.d.ts +25 -85
- package/dist/config/schema.js +20 -81
- package/dist/domain/release/changelog.d.ts +12 -0
- package/dist/domain/release/changelog.js +123 -0
- package/dist/domain/release/plan.d.ts +21 -0
- package/dist/domain/release/plan.js +114 -0
- package/dist/domain/release/semver.d.ts +15 -0
- package/dist/domain/release/semver.js +111 -0
- package/dist/domain/strategy/node.d.ts +2 -0
- package/dist/domain/strategy/node.js +37 -0
- package/dist/domain/strategy/resolve.d.ts +3 -0
- package/dist/domain/strategy/resolve.js +11 -0
- package/dist/domain/strategy/simple.d.ts +2 -0
- package/dist/domain/strategy/simple.js +28 -0
- package/dist/domain/strategy/types.d.ts +7 -0
- package/dist/domain/strategy/types.js +2 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +10 -1
- package/dist/infra/git/commits.d.ts +65 -0
- package/dist/infra/git/commits.js +436 -0
- package/dist/infra/git/repo-url.d.ts +1 -0
- package/dist/infra/git/repo-url.js +27 -0
- package/dist/infra/scm/github/plugin.d.ts +1 -0
- package/dist/infra/scm/github/plugin.js +5 -0
- package/dist/infra/scm/runtime.d.ts +2 -0
- package/dist/infra/scm/runtime.js +24 -0
- package/dist/infra/scm/types.d.ts +1 -0
- package/dist/infra/scm/types.js +2 -0
- package/dist/plugins/capabilities.d.ts +3 -0
- package/dist/plugins/capabilities.js +10 -0
- package/dist/plugins/runtime.d.ts +1 -0
- package/dist/plugins/runtime.js +5 -0
- package/dist/scm/github-plugin.d.ts +2 -0
- package/dist/scm/github-plugin.js +207 -0
- package/dist/strategies/node.d.ts +1 -0
- package/dist/strategies/node.js +5 -0
- package/dist/strategies/resolve.d.ts +1 -0
- package/dist/strategies/resolve.js +5 -0
- package/dist/strategies/simple.d.ts +1 -0
- package/dist/strategies/simple.js +5 -0
- package/dist/strategies/types.d.ts +1 -0
- package/dist/strategies/types.js +2 -0
- package/dist/types/config.d.ts +20 -66
- package/dist/types/plugins.d.ts +37 -0
- package/dist/types/plugins.js +2 -0
- package/dist/verify/verify-project.js +13 -13
- package/package.json +15 -14
- package/dist/simple/changelog.d.ts +0 -3
- package/dist/simple/changelog.js +0 -32
- package/dist/simple/git.d.ts +0 -7
- package/dist/simple/git.js +0 -61
- package/dist/simple/plan.d.ts +0 -12
- package/dist/simple/plan.js +0 -37
- package/dist/simple/pr.d.ts +0 -5
- package/dist/simple/pr.js +0 -45
- package/dist/simple/semver.d.ts +0 -8
- package/dist/simple/semver.js +0 -25
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ReleaseTargetState {
|
|
2
|
+
path: string;
|
|
3
|
+
version: string;
|
|
4
|
+
tag: string;
|
|
5
|
+
notes?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getBaselineStatePath(cwd: string): string;
|
|
8
|
+
export declare function readBaselineSha(cwd?: string): string | null;
|
|
9
|
+
export declare function readReleaseTargets(cwd?: string): ReleaseTargetState[];
|
|
10
|
+
export declare function writeBaselineSha(cwd?: string, sha?: string, releaseTargets?: ReleaseTargetState[]): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getBaselineStatePath = getBaselineStatePath;
|
|
7
|
+
exports.readBaselineSha = readBaselineSha;
|
|
8
|
+
exports.readReleaseTargets = readReleaseTargets;
|
|
9
|
+
exports.writeBaselineSha = writeBaselineSha;
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const load_config_js_1 = require("../../config/load-config.js");
|
|
14
|
+
function getBaselineStatePath(cwd) {
|
|
15
|
+
const loaded = (0, load_config_js_1.loadConfig)(cwd);
|
|
16
|
+
const configured = loaded.config["baseline-file"];
|
|
17
|
+
if (configured) {
|
|
18
|
+
return node_path_1.default.join(cwd, configured);
|
|
19
|
+
}
|
|
20
|
+
const preferred = node_path_1.default.join(cwd, ".versionary-manifest.json");
|
|
21
|
+
if (node_fs_1.default.existsSync(preferred)) {
|
|
22
|
+
return preferred;
|
|
23
|
+
}
|
|
24
|
+
const legacy = node_path_1.default.join(cwd, "versionary.versions.json");
|
|
25
|
+
if (node_fs_1.default.existsSync(legacy)) {
|
|
26
|
+
return legacy;
|
|
27
|
+
}
|
|
28
|
+
return preferred;
|
|
29
|
+
}
|
|
30
|
+
function readBaselineSha(cwd = process.cwd()) {
|
|
31
|
+
const filePath = getBaselineStatePath(cwd);
|
|
32
|
+
if (!node_fs_1.default.existsSync(filePath)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const parsed = JSON.parse(node_fs_1.default.readFileSync(filePath, "utf8"));
|
|
36
|
+
return parsed.baselineSha ?? null;
|
|
37
|
+
}
|
|
38
|
+
function readReleaseTargets(cwd = process.cwd()) {
|
|
39
|
+
const filePath = getBaselineStatePath(cwd);
|
|
40
|
+
if (!node_fs_1.default.existsSync(filePath)) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const parsed = JSON.parse(node_fs_1.default.readFileSync(filePath, "utf8"));
|
|
44
|
+
return parsed.releaseTargets ?? [];
|
|
45
|
+
}
|
|
46
|
+
function writeBaselineSha(cwd = process.cwd(), sha, releaseTargets = []) {
|
|
47
|
+
const baselineSha = sha ??
|
|
48
|
+
(0, node_child_process_1.execFileSync)("git", ["rev-parse", "HEAD"], {
|
|
49
|
+
cwd,
|
|
50
|
+
encoding: "utf8",
|
|
51
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
52
|
+
}).trim();
|
|
53
|
+
const filePath = getBaselineStatePath(cwd);
|
|
54
|
+
const next = {
|
|
55
|
+
baselineSha,
|
|
56
|
+
releaseTargets,
|
|
57
|
+
};
|
|
58
|
+
node_fs_1.default.writeFileSync(filePath, `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
|
59
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyProject = void 0;
|
|
4
|
+
var verify_project_js_1 = require("../../verify/verify-project.js");
|
|
5
|
+
Object.defineProperty(exports, "verifyProject", { enumerable: true, get: function () { return verify_project_js_1.verifyProject; } });
|
package/dist/cli/index.js
CHANGED
|
@@ -4,22 +4,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
7
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const pr_js_1 = require("../app/release/pr.js");
|
|
11
|
+
const release_js_1 = require("../app/release/release.js");
|
|
12
|
+
const verify_js_1 = require("../app/release/verify.js");
|
|
13
|
+
const changelog_js_1 = require("../domain/release/changelog.js");
|
|
14
|
+
const plan_js_1 = require("../domain/release/plan.js");
|
|
13
15
|
function printVerifyResult() {
|
|
14
|
-
const result = (0,
|
|
16
|
+
const result = (0, verify_js_1.verifyProject)();
|
|
15
17
|
for (const check of result.checks) {
|
|
16
18
|
const status = check.ok ? "OK" : "FAIL";
|
|
17
19
|
console.log(`[${status}] ${check.name} - ${check.details}`);
|
|
18
20
|
}
|
|
19
21
|
return result.ok ? 0 : 1;
|
|
20
22
|
}
|
|
21
|
-
function main() {
|
|
23
|
+
async function main() {
|
|
22
24
|
const [, , command, ...args] = process.argv;
|
|
25
|
+
if (!command || command === "run") {
|
|
26
|
+
const subject = (0, node_child_process_1.execFileSync)("git", ["log", "-1", "--pretty=%s"], {
|
|
27
|
+
encoding: "utf8",
|
|
28
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
29
|
+
}).trim();
|
|
30
|
+
if ((0, pr_js_1.isReleaseCommitMessage)(subject)) {
|
|
31
|
+
const message = await (0, release_js_1.runSimpleRelease)(process.cwd());
|
|
32
|
+
console.log(message);
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
const plan = (0, plan_js_1.createSimplePlan)();
|
|
36
|
+
if (!plan.nextVersion) {
|
|
37
|
+
console.log("No releasable commits found. Nothing to do.");
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
const pr = (0, pr_js_1.prepareSimpleReleasePr)();
|
|
41
|
+
(0, pr_js_1.pushReleaseBranch)(process.cwd(), pr.branch);
|
|
42
|
+
const reviewResult = await (0, pr_js_1.openOrUpdateSimpleReviewRequest)(process.cwd(), pr.branch, pr.title, pr.version, pr.previousVersion, pr.commits, pr.plan);
|
|
43
|
+
console.log(`Prepared release PR branch ${pr.branch}`);
|
|
44
|
+
console.log(`Title: ${pr.title}`);
|
|
45
|
+
console.log(reviewResult);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
23
48
|
if (command === "verify") {
|
|
24
49
|
return printVerifyResult();
|
|
25
50
|
}
|
|
@@ -41,7 +66,9 @@ function main() {
|
|
|
41
66
|
return 0;
|
|
42
67
|
}
|
|
43
68
|
const changelogPath = node_path_1.default.join(process.cwd(), plan.changelogFile);
|
|
44
|
-
const existing = node_fs_1.default.existsSync(changelogPath)
|
|
69
|
+
const existing = node_fs_1.default.existsSync(changelogPath)
|
|
70
|
+
? node_fs_1.default.readFileSync(changelogPath, "utf8")
|
|
71
|
+
: "";
|
|
45
72
|
const heading = "# Changelog\n\n";
|
|
46
73
|
const body = existing.replace(/^# Changelog\s*/u, "");
|
|
47
74
|
node_fs_1.default.writeFileSync(changelogPath, `${heading}${section}\n${body}`.trimEnd() + "\n", "utf8");
|
|
@@ -50,16 +77,32 @@ function main() {
|
|
|
50
77
|
}
|
|
51
78
|
if (command === "pr") {
|
|
52
79
|
const pr = (0, pr_js_1.prepareSimpleReleasePr)();
|
|
80
|
+
(0, pr_js_1.pushReleaseBranch)(process.cwd(), pr.branch);
|
|
81
|
+
const reviewResult = await (0, pr_js_1.openOrUpdateSimpleReviewRequest)(process.cwd(), pr.branch, pr.title, pr.version, pr.previousVersion, pr.commits, pr.plan);
|
|
53
82
|
console.log(`Prepared release PR branch ${pr.branch}`);
|
|
54
83
|
console.log(`Title: ${pr.title}`);
|
|
84
|
+
console.log(reviewResult);
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
if (command === "release") {
|
|
88
|
+
const message = await (0, release_js_1.runSimpleRelease)(process.cwd());
|
|
89
|
+
console.log(message);
|
|
55
90
|
return 0;
|
|
56
91
|
}
|
|
57
92
|
console.log("Usage: versionary <command>");
|
|
58
93
|
console.log("Commands:");
|
|
94
|
+
console.log(" run Auto-dispatch release PR/update or release publish by context");
|
|
59
95
|
console.log(" verify Validate config and basic repository shape");
|
|
60
96
|
console.log(" plan Print release plan (simple mode)");
|
|
61
97
|
console.log(" changelog [--write] Print or write changelog section");
|
|
62
98
|
console.log(" pr Prepare release PR commit and branch");
|
|
99
|
+
console.log(" release Publish release metadata for release commit context");
|
|
63
100
|
return 1;
|
|
64
101
|
}
|
|
65
|
-
|
|
102
|
+
main()
|
|
103
|
+
.then((code) => process.exit(code))
|
|
104
|
+
.catch((error) => {
|
|
105
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
106
|
+
console.error(message);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
});
|
|
@@ -7,27 +7,20 @@ exports.findConfigFile = findConfigFile;
|
|
|
7
7
|
exports.loadConfig = loadConfig;
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const toml_1 = require("@iarna/toml");
|
|
11
10
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
12
11
|
const schema_js_1 = require("./schema.js");
|
|
13
12
|
const SUPPORTED_FILES = [
|
|
14
13
|
{ file: "versionary.jsonc", format: "jsonc" },
|
|
15
14
|
{ file: "versionary.json", format: "json" },
|
|
16
|
-
{ file: "versionary.toml", format: "toml" },
|
|
17
|
-
{ file: "versionary.js", format: "js" },
|
|
18
|
-
{ file: "versionary.config.jsonc", format: "jsonc" },
|
|
19
|
-
{ file: "versionary.config.json", format: "json" },
|
|
20
|
-
{ file: "versionary.config.toml", format: "toml" },
|
|
21
|
-
{ file: "versionary.config.js", format: "js" },
|
|
22
15
|
];
|
|
23
16
|
function parseConfig(raw, format) {
|
|
24
17
|
if (format === "json" || format === "jsonc") {
|
|
25
18
|
return (0, jsonc_parser_1.parse)(raw);
|
|
26
19
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
throw new Error("Unsupported config format. Use versionary.jsonc or versionary.json.");
|
|
21
|
+
}
|
|
22
|
+
function isRecord(value) {
|
|
23
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
31
24
|
}
|
|
32
25
|
function findConfigFile(cwd) {
|
|
33
26
|
for (const candidate of SUPPORTED_FILES) {
|
|
@@ -41,10 +34,13 @@ function findConfigFile(cwd) {
|
|
|
41
34
|
function loadConfig(cwd = process.cwd()) {
|
|
42
35
|
const found = findConfigFile(cwd);
|
|
43
36
|
if (!found) {
|
|
44
|
-
throw new Error("No Versionary config found. Create versionary.jsonc (preferred)
|
|
37
|
+
throw new Error("No Versionary config found. Create versionary.jsonc (preferred) or versionary.json.");
|
|
45
38
|
}
|
|
46
39
|
const raw = node_fs_1.default.readFileSync(found.path, "utf8");
|
|
47
40
|
const parsed = parseConfig(raw, found.format);
|
|
41
|
+
if (!isRecord(parsed)) {
|
|
42
|
+
throw new Error("Invalid config: expected an object at the root.");
|
|
43
|
+
}
|
|
48
44
|
const validated = schema_js_1.configSchema.parse(parsed);
|
|
49
45
|
return {
|
|
50
46
|
path: found.path,
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -1,99 +1,39 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const configSchema: z.ZodObject<{
|
|
3
3
|
version: z.ZodLiteral<1>;
|
|
4
|
-
mode: z.ZodOptional<z.ZodEnum<{
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
"review-mode": z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
direct: "direct";
|
|
6
|
+
review: "review";
|
|
7
7
|
}>>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, z.core.$strip>>;
|
|
28
|
-
commitConventions: z.ZodOptional<z.ZodObject<{
|
|
29
|
-
preset: z.ZodDefault<z.ZodEnum<{
|
|
30
|
-
conventional: "conventional";
|
|
31
|
-
angular: "angular";
|
|
32
|
-
custom: "custom";
|
|
33
|
-
}>>;
|
|
34
|
-
}, z.core.$strip>>;
|
|
35
|
-
}, z.core.$strip>>;
|
|
36
|
-
packages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
|
-
path: z.ZodString;
|
|
38
|
-
strategy: z.ZodOptional<z.ZodString>;
|
|
39
|
-
packageName: z.ZodOptional<z.ZodString>;
|
|
40
|
-
excludePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
-
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
42
|
-
file: z.ZodString;
|
|
43
|
-
format: z.ZodEnum<{
|
|
8
|
+
"version-file": z.ZodOptional<z.ZodString>;
|
|
9
|
+
"changelog-file": z.ZodOptional<z.ZodString>;
|
|
10
|
+
"release-branch": z.ZodOptional<z.ZodString>;
|
|
11
|
+
"baseline-file": z.ZodOptional<z.ZodString>;
|
|
12
|
+
"bootstrap-sha": z.ZodOptional<z.ZodString>;
|
|
13
|
+
"monorepo-mode": z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
independent: "independent";
|
|
15
|
+
fixed: "fixed";
|
|
16
|
+
}>>;
|
|
17
|
+
"bump-minor-pre-major": z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
"allow-stable-major": z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
"include-commit-authors": z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
"release-type": z.ZodOptional<z.ZodString>;
|
|
21
|
+
packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
22
|
+
"release-type": z.ZodOptional<z.ZodString>;
|
|
23
|
+
"package-name": z.ZodOptional<z.ZodString>;
|
|
24
|
+
"exclude-paths": z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
"extra-files": z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
26
|
+
type: z.ZodEnum<{
|
|
44
27
|
json: "json";
|
|
45
28
|
toml: "toml";
|
|
46
29
|
yaml: "yaml";
|
|
47
30
|
regex: "regex";
|
|
48
31
|
}>;
|
|
49
|
-
path: z.
|
|
32
|
+
path: z.ZodString;
|
|
33
|
+
jsonpath: z.ZodOptional<z.ZodString>;
|
|
50
34
|
pattern: z.ZodOptional<z.ZodString>;
|
|
51
35
|
}, z.core.$strip>>>;
|
|
52
36
|
}, z.core.$strip>>>;
|
|
53
|
-
|
|
54
|
-
extends: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
55
|
-
name: z.ZodString;
|
|
56
|
-
}, z.core.$strip>>>;
|
|
57
|
-
globalOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
|
-
execution: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
59
|
-
step: z.ZodEnum<{
|
|
60
|
-
verifyConditions: "verifyConditions";
|
|
61
|
-
analyzeCommits: "analyzeCommits";
|
|
62
|
-
resolveReverts: "resolveReverts";
|
|
63
|
-
verifyRelease: "verifyRelease";
|
|
64
|
-
generateNotes: "generateNotes";
|
|
65
|
-
updateArtifacts: "updateArtifacts";
|
|
66
|
-
preparePr: "preparePr";
|
|
67
|
-
publish: "publish";
|
|
68
|
-
postRelease: "postRelease";
|
|
69
|
-
success: "success";
|
|
70
|
-
fail: "fail";
|
|
71
|
-
}>;
|
|
72
|
-
lifecycle: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
73
|
-
plan: "plan";
|
|
74
|
-
pr: "pr";
|
|
75
|
-
release: "release";
|
|
76
|
-
}>>>;
|
|
77
|
-
merge: z.ZodOptional<z.ZodEnum<{
|
|
78
|
-
highest: "highest";
|
|
79
|
-
concat: "concat";
|
|
80
|
-
override: "override";
|
|
81
|
-
reduce: "reduce";
|
|
82
|
-
}>>;
|
|
83
|
-
}, z.core.$strip>>>;
|
|
84
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
85
|
-
name: z.ZodString;
|
|
86
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
87
|
-
}, z.core.$strip>>>;
|
|
88
|
-
}, z.core.$strip>>;
|
|
89
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
-
name: z.ZodString;
|
|
91
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
92
|
-
}, z.core.$strip>>>;
|
|
93
|
-
simple: z.ZodOptional<z.ZodObject<{
|
|
94
|
-
versionFile: z.ZodOptional<z.ZodString>;
|
|
95
|
-
changelogFile: z.ZodOptional<z.ZodString>;
|
|
96
|
-
releaseBranchPrefix: z.ZodOptional<z.ZodString>;
|
|
97
|
-
}, z.core.$strip>>;
|
|
37
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
38
|
}, z.core.$strip>;
|
|
99
39
|
export type ConfigSchema = z.infer<typeof configSchema>;
|
package/dist/config/schema.js
CHANGED
|
@@ -3,91 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.configSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const artifactRuleSchema = zod_1.z.object({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type: zod_1.z.enum(["json", "toml", "yaml", "regex"]),
|
|
7
|
+
path: zod_1.z.string().min(1),
|
|
8
|
+
jsonpath: zod_1.z.string().optional(),
|
|
9
9
|
pattern: zod_1.z.string().optional(),
|
|
10
10
|
});
|
|
11
11
|
const packageSchema = zod_1.z.object({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
artifacts: zod_1.z.array(artifactRuleSchema).optional(),
|
|
17
|
-
});
|
|
18
|
-
const pluginSchema = zod_1.z.object({
|
|
19
|
-
name: zod_1.z.string().min(1),
|
|
20
|
-
options: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
21
|
-
});
|
|
22
|
-
const pluginExecutionSchema = zod_1.z.object({
|
|
23
|
-
step: zod_1.z.enum([
|
|
24
|
-
"verifyConditions",
|
|
25
|
-
"analyzeCommits",
|
|
26
|
-
"resolveReverts",
|
|
27
|
-
"verifyRelease",
|
|
28
|
-
"generateNotes",
|
|
29
|
-
"updateArtifacts",
|
|
30
|
-
"preparePr",
|
|
31
|
-
"publish",
|
|
32
|
-
"postRelease",
|
|
33
|
-
"success",
|
|
34
|
-
"fail",
|
|
35
|
-
]),
|
|
36
|
-
lifecycle: zod_1.z.array(zod_1.z.enum(["plan", "pr", "release"])).optional(),
|
|
37
|
-
merge: zod_1.z.enum(["highest", "concat", "override", "reduce"]).optional(),
|
|
38
|
-
});
|
|
39
|
-
const pluginConfigSchema = zod_1.z.object({
|
|
40
|
-
extends: zod_1.z.array(zod_1.z.object({ name: zod_1.z.string().min(1) })).optional(),
|
|
41
|
-
globalOptions: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
42
|
-
execution: zod_1.z.array(pluginExecutionSchema).optional(),
|
|
43
|
-
plugins: zod_1.z.array(pluginSchema).optional(),
|
|
12
|
+
"release-type": zod_1.z.string().optional(),
|
|
13
|
+
"package-name": zod_1.z.string().optional(),
|
|
14
|
+
"exclude-paths": zod_1.z.array(zod_1.z.string()).optional(),
|
|
15
|
+
"extra-files": zod_1.z.array(artifactRuleSchema).optional(),
|
|
44
16
|
});
|
|
45
17
|
exports.configSchema = zod_1.z.object({
|
|
46
18
|
version: zod_1.z.literal(1),
|
|
47
|
-
mode: zod_1.z.enum(["
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
mode: zod_1.z.enum(["independent", "fixed"]).default("independent"),
|
|
61
|
-
})
|
|
62
|
-
.optional(),
|
|
63
|
-
defaults: zod_1.z
|
|
64
|
-
.object({
|
|
65
|
-
strategy: zod_1.z.string().optional(),
|
|
66
|
-
versioning: zod_1.z
|
|
67
|
-
.object({
|
|
68
|
-
bumpMinorPreMajor: zod_1.z.boolean().optional(),
|
|
69
|
-
})
|
|
70
|
-
.optional(),
|
|
71
|
-
changelog: zod_1.z
|
|
72
|
-
.object({
|
|
73
|
-
includeAuthors: zod_1.z.boolean().optional(),
|
|
74
|
-
})
|
|
75
|
-
.optional(),
|
|
76
|
-
commitConventions: zod_1.z
|
|
77
|
-
.object({
|
|
78
|
-
preset: zod_1.z.enum(["conventional", "angular", "custom"]).default("conventional"),
|
|
79
|
-
})
|
|
80
|
-
.optional(),
|
|
81
|
-
})
|
|
82
|
-
.optional(),
|
|
83
|
-
packages: zod_1.z.array(packageSchema).optional(),
|
|
84
|
-
pluginConfig: pluginConfigSchema.optional(),
|
|
85
|
-
plugins: zod_1.z.array(pluginSchema).optional(),
|
|
86
|
-
simple: zod_1.z
|
|
87
|
-
.object({
|
|
88
|
-
versionFile: zod_1.z.string().optional(),
|
|
89
|
-
changelogFile: zod_1.z.string().optional(),
|
|
90
|
-
releaseBranchPrefix: zod_1.z.string().optional(),
|
|
91
|
-
})
|
|
92
|
-
.optional(),
|
|
19
|
+
"review-mode": zod_1.z.enum(["direct", "review"]).optional(),
|
|
20
|
+
"version-file": zod_1.z.string().optional(),
|
|
21
|
+
"changelog-file": zod_1.z.string().optional(),
|
|
22
|
+
"release-branch": zod_1.z.string().optional(),
|
|
23
|
+
"baseline-file": zod_1.z.string().optional(),
|
|
24
|
+
"bootstrap-sha": zod_1.z.string().optional(),
|
|
25
|
+
"monorepo-mode": zod_1.z.enum(["independent", "fixed"]).optional(),
|
|
26
|
+
"bump-minor-pre-major": zod_1.z.boolean().optional(),
|
|
27
|
+
"allow-stable-major": zod_1.z.boolean().optional(),
|
|
28
|
+
"include-commit-authors": zod_1.z.boolean().optional(),
|
|
29
|
+
"release-type": zod_1.z.string().optional(),
|
|
30
|
+
packages: zod_1.z.record(zod_1.z.string().min(1), packageSchema).optional(),
|
|
31
|
+
plugins: zod_1.z.array(zod_1.z.string().min(1)).optional(),
|
|
93
32
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ParsedCommit } from "../../infra/git/commits.js";
|
|
2
|
+
import type { SimplePlan } from "./plan.js";
|
|
3
|
+
export declare function renderSimpleReleaseNotes(input: {
|
|
4
|
+
currentVersion: string;
|
|
5
|
+
nextVersion: string;
|
|
6
|
+
commits: ParsedCommit[];
|
|
7
|
+
cwd?: string;
|
|
8
|
+
}, options?: {
|
|
9
|
+
includeFooter?: boolean;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function renderSimpleChangelog(plan: SimplePlan): string;
|
|
12
|
+
export declare function prependChangelog(cwd: string, changelogFile: string, section: string): void;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderSimpleReleaseNotes = renderSimpleReleaseNotes;
|
|
7
|
+
exports.renderSimpleChangelog = renderSimpleChangelog;
|
|
8
|
+
exports.prependChangelog = prependChangelog;
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const commits_js_1 = require("../../infra/git/commits.js");
|
|
12
|
+
const repo_url_js_1 = require("../../infra/git/repo-url.js");
|
|
13
|
+
function formatDate() {
|
|
14
|
+
return new Date().toISOString().slice(0, 10);
|
|
15
|
+
}
|
|
16
|
+
function formatCommitMessage(subject) {
|
|
17
|
+
const conventional = subject.match(/^[a-z]+(?:\(([^)]+)\))?!?:\s+(.+)$/iu);
|
|
18
|
+
if (!conventional) {
|
|
19
|
+
return { label: "", message: subject };
|
|
20
|
+
}
|
|
21
|
+
const scope = conventional[1]?.trim();
|
|
22
|
+
const message = conventional[2]?.trim() ?? subject;
|
|
23
|
+
const label = scope ? `**${scope}:** ` : "";
|
|
24
|
+
return { label, message };
|
|
25
|
+
}
|
|
26
|
+
function formatCommitReferences(commit, repoBaseUrl) {
|
|
27
|
+
const references = commit.references ?? [];
|
|
28
|
+
if (references.length === 0) {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
return references
|
|
32
|
+
.map((reference) => {
|
|
33
|
+
const issue = reference.issue;
|
|
34
|
+
if (!issue) {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
const action = (reference.action?.trim() || "refs").toLowerCase();
|
|
38
|
+
if (!repoBaseUrl) {
|
|
39
|
+
return `${action} #${issue}`;
|
|
40
|
+
}
|
|
41
|
+
return `${action} [#${issue}](${repoBaseUrl}/issues/${issue})`;
|
|
42
|
+
})
|
|
43
|
+
.filter((entry) => entry.length > 0)
|
|
44
|
+
.join(", ");
|
|
45
|
+
}
|
|
46
|
+
function groupCommitLines(commits, repoUrl) {
|
|
47
|
+
const breaking = [];
|
|
48
|
+
const features = [];
|
|
49
|
+
const fixes = [];
|
|
50
|
+
for (const commit of commits) {
|
|
51
|
+
const type = (0, commits_js_1.inferReleaseTypeFromParsedCommit)(commit);
|
|
52
|
+
if (!type) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const { label, message } = formatCommitMessage(commit.subject);
|
|
56
|
+
const short = commit.hash.slice(0, 7);
|
|
57
|
+
const hashLabel = repoUrl
|
|
58
|
+
? `[\`${short}\`](${repoUrl}/commit/${commit.hash})`
|
|
59
|
+
: `\`${short}\``;
|
|
60
|
+
const references = formatCommitReferences(commit, repoUrl);
|
|
61
|
+
const referencesSuffix = references ? `, ${references}` : "";
|
|
62
|
+
const line = `- ${label}${message} (${hashLabel})${referencesSuffix}`;
|
|
63
|
+
const commitType = (commit.type ?? "").toLowerCase();
|
|
64
|
+
const isBreaking = type === "major";
|
|
65
|
+
if (isBreaking) {
|
|
66
|
+
breaking.push(line);
|
|
67
|
+
}
|
|
68
|
+
if (commitType === "feat" || (!isBreaking && type === "minor")) {
|
|
69
|
+
features.push(line);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (commitType === "fix" ||
|
|
73
|
+
commitType === "perf" ||
|
|
74
|
+
(!isBreaking && type === "patch")) {
|
|
75
|
+
fixes.push(line);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { breaking, features, fixes };
|
|
79
|
+
}
|
|
80
|
+
function renderSimpleReleaseNotes(input, options = {}) {
|
|
81
|
+
const repoUrl = (0, repo_url_js_1.resolveRepositoryWebBaseUrl)(input.cwd ?? process.cwd());
|
|
82
|
+
const header = repoUrl
|
|
83
|
+
? `## [${input.nextVersion}](${repoUrl}/compare/v${input.currentVersion}...v${input.nextVersion}) (${formatDate()})`
|
|
84
|
+
: `## ${input.nextVersion} (${formatDate()})`;
|
|
85
|
+
const grouped = groupCommitLines(input.commits, repoUrl);
|
|
86
|
+
const sections = [];
|
|
87
|
+
if (grouped.breaking.length > 0) {
|
|
88
|
+
sections.push("### Breaking changes", ...grouped.breaking, "");
|
|
89
|
+
}
|
|
90
|
+
if (grouped.features.length > 0) {
|
|
91
|
+
sections.push("### Features", ...grouped.features, "");
|
|
92
|
+
}
|
|
93
|
+
if (grouped.fixes.length > 0) {
|
|
94
|
+
sections.push("### Bug Fixes", ...grouped.fixes, "");
|
|
95
|
+
}
|
|
96
|
+
const lines = [header, "", ...sections];
|
|
97
|
+
if (options.includeFooter) {
|
|
98
|
+
lines.push("This PR was generated by Versionary.");
|
|
99
|
+
}
|
|
100
|
+
return lines.join("\n");
|
|
101
|
+
}
|
|
102
|
+
function renderSimpleChangelog(plan) {
|
|
103
|
+
if (!plan.nextVersion) {
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
106
|
+
return renderSimpleReleaseNotes({
|
|
107
|
+
currentVersion: plan.currentVersion,
|
|
108
|
+
nextVersion: plan.nextVersion,
|
|
109
|
+
commits: plan.commits,
|
|
110
|
+
cwd: process.cwd(),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function prependChangelog(cwd, changelogFile, section) {
|
|
114
|
+
const changelogPath = node_path_1.default.join(cwd, changelogFile);
|
|
115
|
+
const existing = node_fs_1.default.existsSync(changelogPath)
|
|
116
|
+
? node_fs_1.default.readFileSync(changelogPath, "utf8")
|
|
117
|
+
: "";
|
|
118
|
+
const heading = existing.startsWith("# Changelog") ? "" : "# Changelog\n\n";
|
|
119
|
+
const separator = existing.length > 0 ? "\n" : "";
|
|
120
|
+
const next = `${heading}${section}${separator}${existing.replace(/^# Changelog\s*/u, "")}`.trimEnd() +
|
|
121
|
+
"\n";
|
|
122
|
+
node_fs_1.default.writeFileSync(changelogPath, next, "utf8");
|
|
123
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ParsedCommit } from "../../infra/git/commits.js";
|
|
2
|
+
import { type ReleaseType } from "./semver.js";
|
|
3
|
+
export interface SimplePlan {
|
|
4
|
+
mode: "simple";
|
|
5
|
+
releaseType: ReleaseType;
|
|
6
|
+
currentVersion: string;
|
|
7
|
+
nextVersion: string | null;
|
|
8
|
+
versionFile: string;
|
|
9
|
+
changelogFile: string;
|
|
10
|
+
releaseBranchPrefix: string;
|
|
11
|
+
baselineSha: string | null;
|
|
12
|
+
commits: ParsedCommit[];
|
|
13
|
+
packages?: Array<{
|
|
14
|
+
path: string;
|
|
15
|
+
releaseType: ReleaseType;
|
|
16
|
+
currentVersion: string;
|
|
17
|
+
nextVersion: string | null;
|
|
18
|
+
commits: ParsedCommit[];
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export declare function createSimplePlan(cwd?: string): SimplePlan;
|