versionary 1.6.1 → 1.7.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/dist/cli/index.js +46 -0
- package/dist/config/commit-overrides.d.ts +4 -0
- package/dist/config/commit-overrides.js +47 -0
- package/dist/config/load-config.js +11 -0
- package/dist/config/schema.d.ts +7 -0
- package/dist/config/schema.js +22 -0
- package/dist/git/commit-overrides.d.ts +16 -0
- package/dist/git/commit-overrides.js +65 -0
- package/dist/index.d.ts +1 -1
- package/dist/release/plan.d.ts +6 -2
- package/dist/release/plan.js +21 -6
- package/dist/release/pr.js +11 -1
- package/dist/types/config.d.ts +10 -0
- package/package.json +3 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
import { writeCommitOverride } from "../config/commit-overrides.js";
|
|
3
6
|
import { loadConfig } from "../config/load-config.js";
|
|
7
|
+
import { resolveCommitSha } from "../git/commit-overrides.js";
|
|
4
8
|
import { prependChangelog, renderReleasePlanChangelog, } from "../release/changelog.js";
|
|
5
9
|
import { runDirectRelease } from "../release/direct.js";
|
|
6
10
|
import { createReleasePlan } from "../release/plan.js";
|
|
@@ -8,6 +12,43 @@ import { closeStaleReviewRequestIfExists, isReleaseCommitMessage, openOrUpdateRe
|
|
|
8
12
|
import { runRelease, runReleaseDetailed } from "../release/release.js";
|
|
9
13
|
import { hasFullyUntaggedPendingRelease, hasReleaseStateChangeAtHead, readPendingReleaseTargets, } from "../release/state.js";
|
|
10
14
|
import { verifyProject } from "../release/verify-project.js";
|
|
15
|
+
function recordCommitOverride(command, args) {
|
|
16
|
+
const { values, positionals } = parseArgs({
|
|
17
|
+
args,
|
|
18
|
+
allowPositionals: true,
|
|
19
|
+
options: {
|
|
20
|
+
reason: { type: "string" },
|
|
21
|
+
...(command === "correct"
|
|
22
|
+
? { message: { type: "string" } }
|
|
23
|
+
: {}),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
if (positionals.length !== 1 || (command === "correct" && !values.message)) {
|
|
27
|
+
throw new Error(`Usage: versionary ${command} <sha>${command === "correct" ? ' --message "<commit message>"' : ""} [--reason "<reason>"]`);
|
|
28
|
+
}
|
|
29
|
+
const reason = values.reason?.trim();
|
|
30
|
+
if (values.reason !== undefined && !reason) {
|
|
31
|
+
throw new Error("The exclusion or correction reason must not be empty.");
|
|
32
|
+
}
|
|
33
|
+
const cwd = process.cwd();
|
|
34
|
+
const loaded = loadConfig(cwd);
|
|
35
|
+
const hash = resolveCommitSha(cwd, positionals[0]);
|
|
36
|
+
const override = {
|
|
37
|
+
...(command === "exclude"
|
|
38
|
+
? { skip: true }
|
|
39
|
+
: { message: values.message }),
|
|
40
|
+
...(reason ? { reason } : {}),
|
|
41
|
+
};
|
|
42
|
+
const plan = createReleasePlan(cwd, {
|
|
43
|
+
commitOverrides: { ...loaded.config["commit-overrides"], [hash]: override },
|
|
44
|
+
});
|
|
45
|
+
if (!plan.commitOverrides?.find((entry) => entry.hash === hash)?.packages.length) {
|
|
46
|
+
throw new Error(`Commit ${hash} is outside every configured package's unreleased commit window.`);
|
|
47
|
+
}
|
|
48
|
+
writeCommitOverride(loaded, hash, override);
|
|
49
|
+
console.log(`${command === "exclude" ? "Excluded" : "Corrected"} ${hash} in ${path.basename(loaded.path)}. Commit the configuration change to share it with CI.`);
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
11
52
|
/**
|
|
12
53
|
* What a dry run would actually release. `plan.nextVersion` is the repository
|
|
13
54
|
* aggregate, which in a monorepo names no real release, so prefer the
|
|
@@ -401,6 +442,9 @@ async function main() {
|
|
|
401
442
|
if (command === "verify") {
|
|
402
443
|
return printVerifyResult();
|
|
403
444
|
}
|
|
445
|
+
if (command === "exclude" || command === "correct") {
|
|
446
|
+
return recordCommitOverride(command, args);
|
|
447
|
+
}
|
|
404
448
|
if (command === "plan") {
|
|
405
449
|
const plan = createReleasePlan();
|
|
406
450
|
console.log(JSON.stringify(plan, null, 2));
|
|
@@ -492,6 +536,8 @@ async function main() {
|
|
|
492
536
|
console.log(" run [--json] [--dry-run] Auto-dispatch release PR/update or release publish by context");
|
|
493
537
|
console.log(" verify Validate config and basic repository shape");
|
|
494
538
|
console.log(" plan Print release plan");
|
|
539
|
+
console.log(' exclude <sha> [--reason "..."] Exclude a commit from release analysis and notes');
|
|
540
|
+
console.log(' correct <sha> --message "..." [--reason "..."] Correct a commit for release analysis and notes');
|
|
495
541
|
console.log(" changelog [--write] Print or write changelog section");
|
|
496
542
|
console.log(" pr [--dry-run] Prepare release PR commit and branch");
|
|
497
543
|
console.log(" release [--dry-run] Publish release metadata for release commit context");
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReleasePlan } from "../release/plan.js";
|
|
2
|
+
import type { LoadedConfig, VersionaryCommitOverride } from "../types/config.js";
|
|
3
|
+
export declare function writeCommitOverride(loaded: LoadedConfig, hash: string, override: VersionaryCommitOverride): void;
|
|
4
|
+
export declare function pruneCommitOverrides(cwd: string, plan: ReleasePlan): string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { applyEdits, modify, parse } from "jsonc-parser";
|
|
4
|
+
import { loadConfig } from "./load-config.js";
|
|
5
|
+
function updateCommitOverrides(loaded, updates) {
|
|
6
|
+
let raw = fs.readFileSync(loaded.path, "utf8");
|
|
7
|
+
const errors = [];
|
|
8
|
+
parse(raw, errors, { allowTrailingComma: true });
|
|
9
|
+
if (errors.length > 0) {
|
|
10
|
+
throw new Error(`Cannot edit malformed configuration at ${loaded.path}.`);
|
|
11
|
+
}
|
|
12
|
+
const indent = raw.match(/\n([\t ]+)"/u)?.[1] ?? " ";
|
|
13
|
+
const options = {
|
|
14
|
+
formattingOptions: {
|
|
15
|
+
insertSpaces: !indent.includes("\t"),
|
|
16
|
+
tabSize: indent.length,
|
|
17
|
+
eol: raw.includes("\r\n") ? "\r\n" : "\n",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const remaining = { ...loaded.config["commit-overrides"] };
|
|
21
|
+
for (const [hash, override] of updates) {
|
|
22
|
+
if (override === undefined) {
|
|
23
|
+
delete remaining[hash];
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
remaining[hash] = override;
|
|
27
|
+
}
|
|
28
|
+
raw = applyEdits(raw, modify(raw, ["commit-overrides", hash], override, options));
|
|
29
|
+
}
|
|
30
|
+
if (Object.keys(remaining).length === 0) {
|
|
31
|
+
raw = applyEdits(raw, modify(raw, ["commit-overrides"], undefined, options));
|
|
32
|
+
}
|
|
33
|
+
fs.writeFileSync(loaded.path, raw, "utf8");
|
|
34
|
+
}
|
|
35
|
+
export function writeCommitOverride(loaded, hash, override) {
|
|
36
|
+
updateCommitOverrides(loaded, [[hash, override]]);
|
|
37
|
+
}
|
|
38
|
+
export function pruneCommitOverrides(cwd, plan) {
|
|
39
|
+
// A shared override stays active until every affected package advances past it.
|
|
40
|
+
const consumed = (plan.commitOverrides ?? []).filter((entry) => entry.packages.length === 0);
|
|
41
|
+
if (consumed.length === 0) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const loaded = loadConfig(cwd);
|
|
45
|
+
updateCommitOverrides(loaded, consumed.map(({ hash }) => [hash, undefined]));
|
|
46
|
+
return [path.relative(cwd, loaded.path)];
|
|
47
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parse as parseJsonc } from "jsonc-parser";
|
|
4
|
+
import { parseCommitOverrideMessage } from "../git/commit-overrides.js";
|
|
4
5
|
import { listKnownReleaseTypes, resolveVersionStrategy, } from "../strategy/resolve.js";
|
|
5
6
|
import { configSchema } from "./schema.js";
|
|
6
7
|
const SUPPORTED_FILES = [
|
|
@@ -110,6 +111,16 @@ export function loadConfig(cwd = process.cwd()) {
|
|
|
110
111
|
warnForDeprecatedConfig(found.path);
|
|
111
112
|
}
|
|
112
113
|
validateReleaseTypes(normalized.config);
|
|
114
|
+
for (const [hash, override] of Object.entries(normalized.config["commit-overrides"] ?? {})) {
|
|
115
|
+
if (override.message !== undefined) {
|
|
116
|
+
try {
|
|
117
|
+
parseCommitOverrideMessage(override.message);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new Error(`Invalid commit-overrides["${hash}"]: ${error.message}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
113
124
|
return {
|
|
114
125
|
path: found.path,
|
|
115
126
|
format: found.format,
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -32,6 +32,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
32
32
|
"include-commit-authors": z.ZodOptional<z.ZodBoolean>;
|
|
33
33
|
"exclude-paths": z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
34
|
"release-type": z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
35
|
+
"commit-overrides": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
skip: z.ZodLiteral<true>;
|
|
37
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
message: z.ZodString;
|
|
40
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strict>]>>>;
|
|
35
42
|
packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
36
43
|
"release-type": z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
37
44
|
"package-name": z.ZodOptional<z.ZodString>;
|
package/dist/config/schema.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
const commitOverrideSchema = z.union([
|
|
3
|
+
z
|
|
4
|
+
.object({
|
|
5
|
+
skip: z.literal(true),
|
|
6
|
+
reason: z.string().trim().min(1).optional(),
|
|
7
|
+
})
|
|
8
|
+
.strict(),
|
|
9
|
+
z
|
|
10
|
+
.object({
|
|
11
|
+
message: z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.describe("Complete replacement Conventional Commit message, including any body and footers."),
|
|
15
|
+
reason: z.string().trim().min(1).optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict(),
|
|
18
|
+
]);
|
|
2
19
|
const artifactRuleSchema = z
|
|
3
20
|
.object({
|
|
4
21
|
type: z.enum(["json", "toml", "yaml", "nix", "regex"]),
|
|
@@ -112,6 +129,11 @@ export const configSchema = z
|
|
|
112
129
|
"release-type": z
|
|
113
130
|
.union([z.string().min(1), z.array(z.string().min(1)).min(1)])
|
|
114
131
|
.optional(),
|
|
132
|
+
"commit-overrides": z
|
|
133
|
+
.record(z
|
|
134
|
+
.string()
|
|
135
|
+
.regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u, "Expected a full, lowercase commit SHA."), commitOverrideSchema)
|
|
136
|
+
.optional(),
|
|
115
137
|
packages: z.record(z.string().min(1), packageSchema).optional(),
|
|
116
138
|
})
|
|
117
139
|
.strict()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VersionaryCommitOverride } from "../types/config.js";
|
|
2
|
+
import { type ParsedCommit } from "./commits.js";
|
|
3
|
+
export interface CommitOverrideReport {
|
|
4
|
+
hash: string;
|
|
5
|
+
originalMessage: string;
|
|
6
|
+
override: VersionaryCommitOverride;
|
|
7
|
+
packages: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface ResolvedCommitOverride {
|
|
10
|
+
report: CommitOverrideReport;
|
|
11
|
+
replacement?: ParsedCommit;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseCommitOverrideMessage(message: string): ParsedCommit;
|
|
14
|
+
export declare function resolveCommitSha(cwd: string, sha: string): string;
|
|
15
|
+
export declare function resolveCommitOverrides(cwd: string, overrides: Record<string, VersionaryCommitOverride>): Map<string, ResolvedCommitOverride>;
|
|
16
|
+
export declare function applyCommitOverrides(commits: ParsedCommit[], overrides: ReadonlyMap<string, ResolvedCommitOverride>): ParsedCommit[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { parseConventionalCommitMessageDetailed, } from "./commits.js";
|
|
3
|
+
export function parseCommitOverrideMessage(message) {
|
|
4
|
+
const [header, ...body] = message.trim().replace(/\r\n/gu, "\n").split("\n");
|
|
5
|
+
const parsed = parseConventionalCommitMessageDetailed(header, body.join("\n"));
|
|
6
|
+
if (!parsed.isConventional || parsed.diagnostics?.length) {
|
|
7
|
+
throw new Error(`Invalid commit override message: ${parsed.diagnostics?.[0]?.message ?? "expected a Conventional Commit message."}`);
|
|
8
|
+
}
|
|
9
|
+
return parsed;
|
|
10
|
+
}
|
|
11
|
+
export function resolveCommitSha(cwd, sha) {
|
|
12
|
+
if (!/^[a-f0-9]{4,64}$/iu.test(sha)) {
|
|
13
|
+
throw new Error("Expected a commit SHA (at least four hexadecimal characters).");
|
|
14
|
+
}
|
|
15
|
+
let hash;
|
|
16
|
+
try {
|
|
17
|
+
hash = execFileSync("git", ["rev-parse", "--verify", "--end-of-options", `${sha}^{commit}`], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error(`Commit SHA "${sha}" is unknown or ambiguous. Use a longer SHA and ensure the commit history is available locally.`);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
execFileSync("git", ["merge-base", "--is-ancestor", hash, "HEAD"], {
|
|
24
|
+
cwd,
|
|
25
|
+
stdio: "ignore",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
throw new Error(`Commit ${hash} is not an ancestor of HEAD.`);
|
|
30
|
+
}
|
|
31
|
+
return hash;
|
|
32
|
+
}
|
|
33
|
+
export function resolveCommitOverrides(cwd, overrides) {
|
|
34
|
+
return new Map(Object.entries(overrides).map(([sha, override]) => {
|
|
35
|
+
const hash = resolveCommitSha(cwd, sha);
|
|
36
|
+
const originalMessage = execFileSync("git", ["show", "-s", "--format=%B", hash], {
|
|
37
|
+
cwd,
|
|
38
|
+
encoding: "utf8",
|
|
39
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
40
|
+
}).trim();
|
|
41
|
+
return [
|
|
42
|
+
hash,
|
|
43
|
+
{
|
|
44
|
+
report: { hash, originalMessage, override, packages: [] },
|
|
45
|
+
...(override.message === undefined
|
|
46
|
+
? {}
|
|
47
|
+
: {
|
|
48
|
+
replacement: {
|
|
49
|
+
...parseCommitOverrideMessage(override.message),
|
|
50
|
+
hash,
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
export function applyCommitOverrides(commits, overrides) {
|
|
58
|
+
return commits.flatMap((commit) => {
|
|
59
|
+
const resolved = overrides.get(commit.hash);
|
|
60
|
+
if (resolved?.report.override.skip) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return [resolved?.replacement ?? commit];
|
|
64
|
+
});
|
|
65
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export { getScmClient } from "./scm/client.js";
|
|
|
5
5
|
export { createGitHubPlugin } from "./scm/github-plugin.js";
|
|
6
6
|
export type { ScmClient, ScmClientContext, ScmListReviewRequestsInput, ScmProvider, ScmReleaseMetadataInput, ScmReleaseMetadataResult, ScmReleaseReferenceCommentsInput, ScmReleaseReferenceCommentsResult, ScmReviewRequestInput, ScmReviewRequestResult, ScmReviewRequestSummary, } from "./scm/types.js";
|
|
7
7
|
export { resolveVersionStrategy } from "./strategy/resolve.js";
|
|
8
|
-
export type { VersionaryArtifactRule, VersionaryConfig, VersionaryPackage, } from "./types/config.js";
|
|
8
|
+
export type { VersionaryArtifactRule, VersionaryCommitOverride, VersionaryConfig, VersionaryPackage, } from "./types/config.js";
|
|
9
9
|
export type { VersionaryPluginCapability, VersionaryPluginContext, VersionaryPluginRuntime, VersionaryScmListReviewRequestsInput, VersionaryScmReleaseMetadataInput, VersionaryScmReleaseMetadataResult, VersionaryScmReleaseReferenceCommentsInput, VersionaryScmReleaseReferenceCommentsResult, VersionaryScmReviewRequestInput, VersionaryScmReviewRequestResult, VersionaryScmReviewRequestSummary, } from "./types/plugins.js";
|
package/dist/release/plan.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type CommitOverrideReport } from "../git/commit-overrides.js";
|
|
1
2
|
import { type ParsedCommit } from "../git/commits.js";
|
|
2
|
-
import type { VersionaryChangelogFormat, VersionaryConfig } from "../types/config.js";
|
|
3
|
+
import type { VersionaryChangelogFormat, VersionaryCommitOverride, VersionaryConfig } from "../types/config.js";
|
|
3
4
|
import { type ReleaseType } from "./semver.js";
|
|
4
5
|
type BumpReason = "direct" | "dependency-propagation" | "stale-dependency" | "follows" | "release-as";
|
|
5
6
|
export interface ReleasePlan {
|
|
@@ -14,6 +15,7 @@ export interface ReleasePlan {
|
|
|
14
15
|
releaseBranchPrefix: string;
|
|
15
16
|
baselineSha: string | null;
|
|
16
17
|
commits: ParsedCommit[];
|
|
18
|
+
commitOverrides?: CommitOverrideReport[];
|
|
17
19
|
packages?: Array<{
|
|
18
20
|
path: string;
|
|
19
21
|
releaseType: ReleaseType;
|
|
@@ -33,7 +35,9 @@ export declare function getChangelogDefaults(config: {
|
|
|
33
35
|
changelogFile: string;
|
|
34
36
|
changelogFormat: VersionaryChangelogFormat;
|
|
35
37
|
};
|
|
36
|
-
export declare function createReleasePlan(cwd?: string
|
|
38
|
+
export declare function createReleasePlan(cwd?: string, options?: {
|
|
39
|
+
commitOverrides?: Record<string, VersionaryCommitOverride>;
|
|
40
|
+
}): ReleasePlan;
|
|
37
41
|
/**
|
|
38
42
|
* The root package's own release, as distinct from the plan-level aggregate.
|
|
39
43
|
*
|
package/dist/release/plan.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { loadConfig } from "../config/load-config.js";
|
|
4
|
+
import { applyCommitOverrides, resolveCommitOverrides, } from "../git/commit-overrides.js";
|
|
4
5
|
import { analyzeParsedCommits, applyRevertSuppression, getParsedCommitsForPath, getParsedCommitsSinceLastTag, } from "../git/commits.js";
|
|
5
6
|
import { resolvePackageStrategyContext } from "../strategy/package-context.js";
|
|
6
7
|
import { resolveVersionStrategy } from "../strategy/resolve.js";
|
|
@@ -38,8 +39,12 @@ function getNormalizedPackages(config) {
|
|
|
38
39
|
}
|
|
39
40
|
return [{ path: ".", config: {}, implicitRoot: true }, ...configured];
|
|
40
41
|
}
|
|
41
|
-
export function createReleasePlan(cwd = process.cwd()) {
|
|
42
|
+
export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
42
43
|
const loaded = loadConfig(cwd);
|
|
44
|
+
const overrides = resolveCommitOverrides(cwd, options.commitOverrides ?? loaded.config["commit-overrides"] ?? {});
|
|
45
|
+
const originalCommits = new Map();
|
|
46
|
+
// Keep the original revert relationships even when either commit is excluded.
|
|
47
|
+
const effectiveCommits = (commits) => applyCommitOverrides(applyRevertSuppression(commits), overrides);
|
|
43
48
|
const strategy = resolveVersionStrategy(loaded.config);
|
|
44
49
|
const configuredPackageCount = Object.keys(loaded.config.packages ?? {}).length;
|
|
45
50
|
const hasPackages = configuredPackageCount > 0;
|
|
@@ -82,9 +87,13 @@ export function createReleasePlan(cwd = process.cwd()) {
|
|
|
82
87
|
? baselineSha
|
|
83
88
|
: (releaseTargetByPath.get(pkg.path)?.tag ?? baselineSha), pkg.path, excludePaths);
|
|
84
89
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
for (const commit of parsedCommits) {
|
|
91
|
+
originalCommits.set(commit.hash, commit);
|
|
92
|
+
overrides.get(commit.hash)?.report.packages.push(pkg.path);
|
|
93
|
+
}
|
|
94
|
+
parsedCommits = effectiveCommits(parsedCommits);
|
|
95
|
+
const commits = parsedCommits;
|
|
96
|
+
const analyzedType = analyzeParsedCommits(commits);
|
|
88
97
|
const override = resolveReleaseAsOverride(commits, packageCurrentVersion);
|
|
89
98
|
let releaseType;
|
|
90
99
|
let nextVersion;
|
|
@@ -405,6 +414,9 @@ export function createReleasePlan(cwd = process.cwd()) {
|
|
|
405
414
|
});
|
|
406
415
|
const visiblePackages = adjustedPackages.filter((pkgPlan) => !pkgPlan.implicitRoot || hasExplicitRootPackage);
|
|
407
416
|
const rootPackagePlan = adjustedPackages.find((pkgPlan) => pkgPlan.path === ".");
|
|
417
|
+
const overrideReport = overrides.size > 0
|
|
418
|
+
? { commitOverrides: [...overrides.values()].map(({ report }) => report) }
|
|
419
|
+
: {};
|
|
408
420
|
if (!rootPackagePlan) {
|
|
409
421
|
throw new Error('Internal error: normalized package list must always include root path ".".');
|
|
410
422
|
}
|
|
@@ -421,11 +433,12 @@ export function createReleasePlan(cwd = process.cwd()) {
|
|
|
421
433
|
releaseBranchPrefix,
|
|
422
434
|
baselineSha,
|
|
423
435
|
commits: rootPackagePlan.commits,
|
|
436
|
+
...overrideReport,
|
|
424
437
|
};
|
|
425
438
|
}
|
|
426
439
|
const rootOverridden = rootPackagePlan.bumpReason === "release-as";
|
|
427
440
|
if (monorepoMode === "fixed") {
|
|
428
|
-
const analyzedFixedType = analyzeParsedCommits(
|
|
441
|
+
const analyzedFixedType = analyzeParsedCommits(effectiveCommits([...originalCommits.values()]));
|
|
429
442
|
const fixedBaseVersion = rootPackagePlan.currentVersion;
|
|
430
443
|
// A `Release-As:` footer on the shared (root) version pins every package.
|
|
431
444
|
const fixedType = rootOverridden
|
|
@@ -457,12 +470,13 @@ export function createReleasePlan(cwd = process.cwd()) {
|
|
|
457
470
|
releaseBranchPrefix,
|
|
458
471
|
baselineSha,
|
|
459
472
|
commits: adjusted.flatMap((pkgPlan) => pkgPlan.commits),
|
|
473
|
+
...overrideReport,
|
|
460
474
|
packages: adjusted
|
|
461
475
|
.filter((pkgPlan) => !pkgPlan.implicitRoot || hasExplicitRootPackage)
|
|
462
476
|
.map(({ implicitRoot: _implicitRoot, ...pkgPlan }) => pkgPlan),
|
|
463
477
|
};
|
|
464
478
|
}
|
|
465
|
-
const analyzedOverallType = analyzeParsedCommits(
|
|
479
|
+
const analyzedOverallType = analyzeParsedCommits(effectiveCommits([...originalCommits.values()]));
|
|
466
480
|
const overallBaseVersion = rootPackagePlan.currentVersion;
|
|
467
481
|
// A root-level `Release-As:` footer drives the aggregate version too, keeping
|
|
468
482
|
// the top-level plan consistent with the pinned root package.
|
|
@@ -488,6 +502,7 @@ export function createReleasePlan(cwd = process.cwd()) {
|
|
|
488
502
|
releaseBranchPrefix,
|
|
489
503
|
baselineSha,
|
|
490
504
|
commits: adjustedPackages.flatMap((pkgPlan) => pkgPlan.commits),
|
|
505
|
+
...overrideReport,
|
|
491
506
|
packages: visiblePackages.map(({ implicitRoot: _implicitRoot, ...pkgPlan }) => pkgPlan),
|
|
492
507
|
};
|
|
493
508
|
}
|
package/dist/release/pr.js
CHANGED
|
@@ -2,6 +2,7 @@ import { execFileSync } from "node:child_process";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { pruneCommitOverrides } from "../config/commit-overrides.js";
|
|
5
6
|
import { loadConfig } from "../config/load-config.js";
|
|
6
7
|
import { ensureGitIdentity } from "../git/identity.js";
|
|
7
8
|
import { redactCredentials } from "../git/redact.js";
|
|
@@ -478,11 +479,13 @@ export function prepareReleasePr(cwd = process.cwd(), options = {}) {
|
|
|
478
479
|
cwd,
|
|
479
480
|
stdio: ["ignore", "pipe", "ignore"],
|
|
480
481
|
});
|
|
482
|
+
const updatedConfigFiles = pruneCommitOverrides(cwd, plan);
|
|
481
483
|
const filesToAdd = [
|
|
482
484
|
...new Set([
|
|
483
485
|
...updatedVersionFiles,
|
|
484
486
|
...updatedArtifactFiles,
|
|
485
487
|
...updatedChangelogFiles,
|
|
488
|
+
...updatedConfigFiles,
|
|
486
489
|
]),
|
|
487
490
|
];
|
|
488
491
|
execFileSync("git", ["add", ...filesToAdd], {
|
|
@@ -626,6 +629,9 @@ function materializeCandidateChanges(cwd, plan, options) {
|
|
|
626
629
|
updatedChangelogFiles.push(packageChangelogPath);
|
|
627
630
|
}
|
|
628
631
|
const targets = buildReleaseTargets(cwd, plan, loaded.config);
|
|
632
|
+
const updatedConfigFiles = options.pruneOverrides
|
|
633
|
+
? pruneCommitOverrides(cwd, plan)
|
|
634
|
+
: [];
|
|
629
635
|
const stateFiles = options.writePackageState && options.branch
|
|
630
636
|
? writePackageReleaseState(cwd, options.baselineSha, targets, options.branch)
|
|
631
637
|
: [];
|
|
@@ -635,6 +641,7 @@ function materializeCandidateChanges(cwd, plan, options) {
|
|
|
635
641
|
...updatedVersionFiles,
|
|
636
642
|
...updatedArtifactFiles,
|
|
637
643
|
...updatedChangelogFiles,
|
|
644
|
+
...updatedConfigFiles,
|
|
638
645
|
...stateFiles,
|
|
639
646
|
]),
|
|
640
647
|
].sort((a, b) => a.localeCompare(b)),
|
|
@@ -678,6 +685,8 @@ export function prepareSeparateReleasePrs(cwd = process.cwd(), options = {}) {
|
|
|
678
685
|
if (initialCohorts.length === 0) {
|
|
679
686
|
return [];
|
|
680
687
|
}
|
|
688
|
+
// One candidate owns shared config cleanup so cleanup alone cannot couple PRs.
|
|
689
|
+
const cleanupOwner = initialCohorts[0]?.[0];
|
|
681
690
|
buildReleaseTargets(cwd, plan, loaded.config);
|
|
682
691
|
ensureCleanWorktree(cwd, options.logger);
|
|
683
692
|
const baselineSha = execFileSync("git", ["rev-parse", "HEAD"], {
|
|
@@ -694,7 +703,7 @@ export function prepareSeparateReleasePrs(cwd = process.cwd(), options = {}) {
|
|
|
694
703
|
try {
|
|
695
704
|
const cohorts = stabilizeReleaseCohorts(initialCohorts, (packagePaths) => {
|
|
696
705
|
resetTemporaryWorktree(worktree, baselineSha);
|
|
697
|
-
return materializeCandidateChanges(worktree, scopeReleasePlan(plan, packagePaths), { baselineSha }).files;
|
|
706
|
+
return materializeCandidateChanges(worktree, scopeReleasePlan(plan, packagePaths), { baselineSha, pruneOverrides: packagePaths.includes(cleanupOwner) }).files;
|
|
698
707
|
});
|
|
699
708
|
const prepared = [];
|
|
700
709
|
for (const packagePaths of cohorts) {
|
|
@@ -718,6 +727,7 @@ export function prepareSeparateReleasePrs(cwd = process.cwd(), options = {}) {
|
|
|
718
727
|
baselineSha,
|
|
719
728
|
branch,
|
|
720
729
|
writePackageState: true,
|
|
730
|
+
pruneOverrides: packagePaths.includes(cleanupOwner),
|
|
721
731
|
});
|
|
722
732
|
const title = formatReleaseCommitTitle(materialized.targets);
|
|
723
733
|
if (!options["dry-run"]) {
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export type ConfigFileFormat = "jsonc" | "json" | "toml" | "js";
|
|
2
2
|
export type VersionaryChangelogFormat = "markdown-changelog" | "r-news";
|
|
3
3
|
export type ReleaseReferenceCommentsMode = "off" | "best-effort" | "strict";
|
|
4
|
+
export type VersionaryCommitOverride = ({
|
|
5
|
+
skip: true;
|
|
6
|
+
message?: never;
|
|
7
|
+
} | {
|
|
8
|
+
message: string;
|
|
9
|
+
skip?: never;
|
|
10
|
+
}) & {
|
|
11
|
+
reason?: string;
|
|
12
|
+
};
|
|
4
13
|
export interface VersionaryArtifactRule {
|
|
5
14
|
type: "json" | "toml" | "yaml" | "nix" | "regex";
|
|
6
15
|
path: string;
|
|
@@ -42,6 +51,7 @@ export interface VersionaryConfig {
|
|
|
42
51
|
"allow-stable-major"?: boolean;
|
|
43
52
|
"include-commit-authors"?: boolean;
|
|
44
53
|
"exclude-paths"?: string[];
|
|
54
|
+
"commit-overrides"?: Record<string, VersionaryCommitOverride>;
|
|
45
55
|
"release-type"?: string | string[];
|
|
46
56
|
packages?: Record<string, VersionaryPackage>;
|
|
47
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versionary",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Automatic release framework based on conventional commits and semantic versioning",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"releasing",
|
|
@@ -51,6 +51,8 @@
|
|
|
51
51
|
"verify": "tsx src/cli/index.ts verify",
|
|
52
52
|
"run": "tsx src/cli/index.ts run",
|
|
53
53
|
"plan": "tsx src/cli/index.ts plan",
|
|
54
|
+
"exclude": "tsx src/cli/index.ts exclude",
|
|
55
|
+
"correct": "tsx src/cli/index.ts correct",
|
|
54
56
|
"changelog": "tsx src/cli/index.ts changelog",
|
|
55
57
|
"pr": "tsx src/cli/index.ts pr",
|
|
56
58
|
"release": "tsx src/cli/index.ts release",
|