@williamthorsen/release-kit 2.3.2 → 4.0.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/CHANGELOG.md +54 -38
- package/README.md +29 -12
- package/cliff.toml.template +13 -12
- package/dist/esm/.cache +1 -1
- package/dist/esm/bin/release-kit.js +28 -0
- package/dist/esm/buildDependencyGraph.d.ts +7 -0
- package/dist/esm/buildDependencyGraph.js +59 -0
- package/dist/esm/buildReleaseSummary.d.ts +2 -0
- package/dist/esm/buildReleaseSummary.js +22 -0
- package/dist/esm/commitCommand.d.ts +1 -0
- package/dist/esm/commitCommand.js +55 -0
- package/dist/esm/createTags.js +12 -1
- package/dist/esm/determineBumpFromCommits.d.ts +1 -1
- package/dist/esm/determineBumpFromCommits.js +2 -2
- package/dist/esm/generateChangelogs.d.ts +2 -0
- package/dist/esm/generateChangelogs.js +9 -1
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +8 -1
- package/dist/esm/init/initCommand.js +4 -2
- package/dist/esm/init/scaffold.js +3 -2
- package/dist/esm/init/templates.d.ts +1 -0
- package/dist/esm/init/templates.js +24 -2
- package/dist/esm/loadConfig.js +6 -6
- package/dist/esm/parseCommitMessage.d.ts +1 -1
- package/dist/esm/parseCommitMessage.js +9 -7
- package/dist/esm/prepareCommand.d.ts +1 -0
- package/dist/esm/prepareCommand.js +20 -0
- package/dist/esm/propagateBumps.d.ts +8 -0
- package/dist/esm/propagateBumps.js +54 -0
- package/dist/esm/publish.d.ts +1 -0
- package/dist/esm/publish.js +6 -3
- package/dist/esm/publishCommand.js +3 -2
- package/dist/esm/releasePrepare.js +2 -1
- package/dist/esm/releasePrepareMono.js +237 -48
- package/dist/esm/reportPrepare.js +29 -3
- package/dist/esm/stripScope.d.ts +1 -0
- package/dist/esm/stripScope.js +24 -0
- package/dist/esm/sync-labels/templates.js +1 -1
- package/dist/esm/types.d.ts +11 -4
- package/dist/esm/validateConfig.js +6 -6
- package/dist/esm/writeSyntheticChangelog.d.ts +9 -0
- package/dist/esm/writeSyntheticChangelog.js +27 -0
- package/package.json +1 -1
|
@@ -54,18 +54,26 @@ ${sectionHeader(component.name)}`);
|
|
|
54
54
|
lines.push(` \u23ED\uFE0F ${component.skipReason ?? "Skipped"}`);
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
const { propagatedFrom } = component;
|
|
58
|
+
const isPropagatedOnly = propagatedFrom !== void 0 && component.commitCount === 0;
|
|
59
|
+
if (isPropagatedOnly) {
|
|
60
|
+
const depNames = propagatedFrom.map((p) => p.packageName).join(", ");
|
|
61
|
+
lines.push(dim(` 0 commits (bumped via dependency: ${depNames})`));
|
|
62
|
+
} else if (component.parsedCommitCount !== void 0) {
|
|
58
63
|
lines.push(dim(` Parsed ${component.parsedCommitCount} typed commits`));
|
|
59
64
|
}
|
|
60
65
|
formatUnparseableWarning(lines, component, " ");
|
|
61
|
-
if (component.parsedCommitCount === void 0 && component.releaseType !== void 0) {
|
|
66
|
+
if (component.parsedCommitCount === void 0 && component.releaseType !== void 0 && !isPropagatedOnly) {
|
|
62
67
|
lines.push(` Using bump override: ${component.releaseType}`);
|
|
63
68
|
}
|
|
64
69
|
if (component.releaseType !== void 0) {
|
|
65
70
|
lines.push(dim(` Bumping versions (${component.releaseType})...`));
|
|
66
71
|
}
|
|
67
72
|
if (component.currentVersion !== void 0 && component.newVersion !== void 0 && component.releaseType !== void 0) {
|
|
68
|
-
|
|
73
|
+
const suffix = isPropagatedOnly ? formatPropagationSuffix(propagatedFrom) : "";
|
|
74
|
+
lines.push(
|
|
75
|
+
` \u{1F4E6} ${component.currentVersion} \u2192 ${bold(component.newVersion)} (${component.releaseType}${suffix})`
|
|
76
|
+
);
|
|
69
77
|
}
|
|
70
78
|
formatBumpFiles(lines, component, result.dryRun, " ");
|
|
71
79
|
lines.push(dim(" Generating changelogs..."));
|
|
@@ -75,6 +83,7 @@ ${sectionHeader(component.name)}`);
|
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
85
|
formatFormatCommand(lines, result);
|
|
86
|
+
formatWarnings(lines, result);
|
|
78
87
|
if (result.tags.length > 0) {
|
|
79
88
|
lines.push(`
|
|
80
89
|
\u2705 Release preparation complete.`);
|
|
@@ -120,6 +129,23 @@ function formatUnparseableWarning(lines, component, indent = "") {
|
|
|
120
129
|
lines.push(`${indent} \xB7 ${shortHash} ${truncatedMessage}`);
|
|
121
130
|
}
|
|
122
131
|
}
|
|
132
|
+
function formatPropagationSuffix(propagatedFrom) {
|
|
133
|
+
if (propagatedFrom === void 0 || propagatedFrom.length === 0) {
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
const names = propagatedFrom.map((p) => p.packageName).join(", ");
|
|
137
|
+
return `, dependency: ${names}`;
|
|
138
|
+
}
|
|
139
|
+
function formatWarnings(lines, result) {
|
|
140
|
+
const { warnings } = result;
|
|
141
|
+
if (warnings === void 0 || warnings.length === 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
lines.push("");
|
|
145
|
+
for (const warning of warnings) {
|
|
146
|
+
lines.push(`\u26A0\uFE0F ${warning}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
123
149
|
function formatFormatCommand(lines, result) {
|
|
124
150
|
if (result.formatCommand === void 0) {
|
|
125
151
|
return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripScope(message: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { COMMIT_PREPROCESSOR_PATTERNS } from "./parseCommitMessage.js";
|
|
2
|
+
function stripScope(message) {
|
|
3
|
+
let ticketPrefix = "";
|
|
4
|
+
let remainder = message;
|
|
5
|
+
for (const pattern of COMMIT_PREPROCESSOR_PATTERNS) {
|
|
6
|
+
const match = remainder.match(pattern);
|
|
7
|
+
if (match) {
|
|
8
|
+
ticketPrefix += match[0];
|
|
9
|
+
remainder = remainder.slice(match[0].length);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const pipeMatch = remainder.match(/^[^|]+\|(.*)$/);
|
|
13
|
+
if (pipeMatch) {
|
|
14
|
+
return `${ticketPrefix}${pipeMatch[1]}`;
|
|
15
|
+
}
|
|
16
|
+
const parenMatch = remainder.match(/^(\w+)\([^)]+\)(.*)$/);
|
|
17
|
+
if (parenMatch) {
|
|
18
|
+
return `${ticketPrefix}${parenMatch[1]}${parenMatch[2]}`;
|
|
19
|
+
}
|
|
20
|
+
return message;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
stripScope
|
|
24
|
+
};
|
|
@@ -8,7 +8,7 @@ on:
|
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
sync:
|
|
11
|
-
uses: williamthorsen/node-monorepo-tools/.github/workflows/sync-labels.yaml@sync-labels-v1
|
|
11
|
+
uses: williamthorsen/node-monorepo-tools/.github/workflows/sync-labels.reusable.yaml@sync-labels-workflow-v1
|
|
12
12
|
`;
|
|
13
13
|
}
|
|
14
14
|
function buildScopeLabels(workspacePaths) {
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type ReleaseType = 'major' | 'minor' | 'patch';
|
|
2
|
+
export interface PropagationSource {
|
|
3
|
+
packageName: string;
|
|
4
|
+
newVersion: string;
|
|
5
|
+
}
|
|
2
6
|
export interface BumpResult {
|
|
3
7
|
currentVersion: string;
|
|
4
8
|
newVersion: string;
|
|
@@ -16,7 +20,9 @@ export interface ComponentPrepareResult {
|
|
|
16
20
|
tag?: string | undefined;
|
|
17
21
|
bumpedFiles: string[];
|
|
18
22
|
changelogFiles: string[];
|
|
23
|
+
commits?: Commit[] | undefined;
|
|
19
24
|
unparseableCommits?: Commit[] | undefined;
|
|
25
|
+
propagatedFrom?: PropagationSource[] | undefined;
|
|
20
26
|
skipReason?: string | undefined;
|
|
21
27
|
}
|
|
22
28
|
export interface PrepareResult {
|
|
@@ -28,6 +34,7 @@ export interface PrepareResult {
|
|
|
28
34
|
files: string[];
|
|
29
35
|
} | undefined;
|
|
30
36
|
dryRun: boolean;
|
|
37
|
+
warnings?: string[] | undefined;
|
|
31
38
|
}
|
|
32
39
|
export interface WorkTypeConfig {
|
|
33
40
|
header: string;
|
|
@@ -43,7 +50,7 @@ export interface ReleaseKitConfig {
|
|
|
43
50
|
workTypes?: Record<string, WorkTypeConfig>;
|
|
44
51
|
formatCommand?: string;
|
|
45
52
|
cliffConfigPath?: string;
|
|
46
|
-
|
|
53
|
+
scopeAliases?: Record<string, string>;
|
|
47
54
|
}
|
|
48
55
|
export interface ComponentOverride {
|
|
49
56
|
dir: string;
|
|
@@ -58,7 +65,7 @@ export interface ParsedCommit {
|
|
|
58
65
|
hash: string;
|
|
59
66
|
type: string;
|
|
60
67
|
description: string;
|
|
61
|
-
|
|
68
|
+
scope?: string;
|
|
62
69
|
breaking: boolean;
|
|
63
70
|
}
|
|
64
71
|
export interface ComponentConfig {
|
|
@@ -74,7 +81,7 @@ export interface MonorepoReleaseConfig {
|
|
|
74
81
|
versionPatterns?: VersionPatterns;
|
|
75
82
|
formatCommand?: string;
|
|
76
83
|
cliffConfigPath?: string;
|
|
77
|
-
|
|
84
|
+
scopeAliases?: Record<string, string>;
|
|
78
85
|
}
|
|
79
86
|
export interface ReleaseConfig {
|
|
80
87
|
tagPrefix: string;
|
|
@@ -84,5 +91,5 @@ export interface ReleaseConfig {
|
|
|
84
91
|
versionPatterns?: VersionPatterns;
|
|
85
92
|
formatCommand?: string;
|
|
86
93
|
cliffConfigPath?: string;
|
|
87
|
-
|
|
94
|
+
scopeAliases?: Record<string, string>;
|
|
88
95
|
}
|
|
@@ -11,7 +11,7 @@ function validateConfig(raw) {
|
|
|
11
11
|
"workTypes",
|
|
12
12
|
"formatCommand",
|
|
13
13
|
"cliffConfigPath",
|
|
14
|
-
"
|
|
14
|
+
"scopeAliases"
|
|
15
15
|
]);
|
|
16
16
|
for (const key of Object.keys(raw)) {
|
|
17
17
|
if (!knownFields.has(key)) {
|
|
@@ -23,7 +23,7 @@ function validateConfig(raw) {
|
|
|
23
23
|
validateWorkTypes(raw.workTypes, config, errors);
|
|
24
24
|
validateStringField("formatCommand", raw.formatCommand, config, errors);
|
|
25
25
|
validateStringField("cliffConfigPath", raw.cliffConfigPath, config, errors);
|
|
26
|
-
|
|
26
|
+
validateScopeAliases(raw.scopeAliases, config, errors);
|
|
27
27
|
return { config, errors };
|
|
28
28
|
}
|
|
29
29
|
function isStringArray(value) {
|
|
@@ -121,10 +121,10 @@ function validateStringField(fieldName, value, config, errors) {
|
|
|
121
121
|
}
|
|
122
122
|
config[fieldName] = value;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function validateScopeAliases(value, config, errors) {
|
|
125
125
|
if (value === void 0) return;
|
|
126
126
|
if (!isRecord(value)) {
|
|
127
|
-
errors.push("'
|
|
127
|
+
errors.push("'scopeAliases' must be a record (object)");
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
const aliases = {};
|
|
@@ -133,12 +133,12 @@ function validateWorkspaceAliases(value, config, errors) {
|
|
|
133
133
|
if (typeof v === "string") {
|
|
134
134
|
aliases[key] = v;
|
|
135
135
|
} else {
|
|
136
|
-
errors.push(`
|
|
136
|
+
errors.push(`scopeAliases.${key}: value must be a string`);
|
|
137
137
|
valid = false;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
if (valid) {
|
|
141
|
-
config.
|
|
141
|
+
config.scopeAliases = aliases;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
export {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PropagationSource } from './types.ts';
|
|
2
|
+
export interface WriteSyntheticChangelogParams {
|
|
3
|
+
changelogPath: string;
|
|
4
|
+
newVersion: string;
|
|
5
|
+
date: string;
|
|
6
|
+
propagatedFrom: PropagationSource[];
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function writeSyntheticChangelog(params: WriteSyntheticChangelogParams): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
function writeSyntheticChangelog(params) {
|
|
3
|
+
const { changelogPath, newVersion, date, propagatedFrom, dryRun } = params;
|
|
4
|
+
const filePath = `${changelogPath}/CHANGELOG.md`;
|
|
5
|
+
const bullets = propagatedFrom.map((dep) => `- Bumped \`${dep.packageName}\` to ${dep.newVersion}`).join("\n");
|
|
6
|
+
const section = `## ${newVersion} \u2014 ${date}
|
|
7
|
+
|
|
8
|
+
### Dependency updates
|
|
9
|
+
|
|
10
|
+
${bullets}
|
|
11
|
+
`;
|
|
12
|
+
if (dryRun) {
|
|
13
|
+
return filePath;
|
|
14
|
+
}
|
|
15
|
+
let existingContent = "";
|
|
16
|
+
if (existsSync(filePath)) {
|
|
17
|
+
existingContent = readFileSync(filePath, "utf8");
|
|
18
|
+
}
|
|
19
|
+
const newContent = existingContent.length > 0 ? `${section}
|
|
20
|
+
${existingContent}` : `${section}
|
|
21
|
+
`;
|
|
22
|
+
writeFileSync(filePath, newContent, "utf8");
|
|
23
|
+
return filePath;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
writeSyntheticChangelog
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@williamthorsen/release-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Version-bumping and changelog-generation toolkit for release workflows",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/williamthorsen/node-monorepo-tools/tree/main/packages/release-kit#readme",
|