@williamthorsen/release-kit 6.0.0 → 8.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 +18 -0
- package/README.md +5 -3
- package/dist/esm/assertCleanWorkingTree.js +9 -14
- package/dist/esm/bin/release-kit.js +200 -199
- package/dist/esm/buildChangelogEntries.d.ts +2 -2
- package/dist/esm/buildChangelogEntries.js +142 -149
- package/dist/esm/buildDependencyGraph.d.ts +1 -1
- package/dist/esm/buildDependencyGraph.js +60 -59
- package/dist/esm/buildEmptyReleaseEntry.d.ts +1 -1
- package/dist/esm/buildEmptyReleaseEntry.js +12 -15
- package/dist/esm/buildReleaseSummary.d.ts +1 -1
- package/dist/esm/buildReleaseSummary.js +23 -26
- package/dist/esm/buildSyntheticChangelogEntry.d.ts +1 -1
- package/dist/esm/buildSyntheticChangelogEntry.js +9 -12
- package/dist/esm/bumpAllVersions.d.ts +1 -1
- package/dist/esm/bumpAllVersions.js +51 -52
- package/dist/esm/bumpVersion.d.ts +1 -1
- package/dist/esm/bumpVersion.js +25 -28
- package/dist/esm/changelogJsonFile.d.ts +1 -1
- package/dist/esm/changelogJsonFile.js +59 -62
- package/dist/esm/changelogJsonUtils.d.ts +1 -1
- package/dist/esm/changelogJsonUtils.js +35 -32
- package/dist/esm/changelogOverrides.d.ts +1 -1
- package/dist/esm/changelogOverrides.js +374 -377
- package/dist/esm/checkWorkTypesDrift.js +104 -102
- package/dist/esm/collectPolicyViolations.d.ts +2 -2
- package/dist/esm/collectPolicyViolations.js +11 -14
- package/dist/esm/commitCommand.js +48 -46
- package/dist/esm/compareVersions.js +20 -23
- package/dist/esm/createGithubRelease.js +56 -59
- package/dist/esm/createGithubReleaseCommand.js +21 -23
- package/dist/esm/createTags.js +57 -56
- package/dist/esm/decideRelease.d.ts +2 -2
- package/dist/esm/decideRelease.js +27 -41
- package/dist/esm/defaults.d.ts +3 -3
- package/dist/esm/defaults.js +36 -48
- package/dist/esm/deleteFileIfExists.js +10 -12
- package/dist/esm/deriveWorkspaceConfig.d.ts +1 -1
- package/dist/esm/deriveWorkspaceConfig.js +34 -36
- package/dist/esm/detectPackageManager.js +35 -37
- package/dist/esm/detectUndeclaredTagPrefixes.js +41 -40
- package/dist/esm/determineBumpFromCommits.d.ts +2 -2
- package/dist/esm/determineBumpFromCommits.js +25 -29
- package/dist/esm/determineBumpType.d.ts +1 -1
- package/dist/esm/determineBumpType.js +31 -32
- package/dist/esm/discoverWorkspaces.js +38 -40
- package/dist/esm/format.js +6 -11
- package/dist/esm/generateChangelogs.d.ts +1 -1
- package/dist/esm/generateChangelogs.js +13 -17
- package/dist/esm/getCommitsSinceTarget.d.ts +1 -1
- package/dist/esm/getCommitsSinceTarget.js +54 -55
- package/dist/esm/hasPrettierConfig.js +33 -35
- package/dist/esm/help/prepareHelp.js +4 -8
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +2 -8
- package/dist/esm/init/checks.js +28 -32
- package/dist/esm/init/detectRepoType.js +12 -15
- package/dist/esm/init/initCommand.js +60 -54
- package/dist/esm/init/parseJsonRecord.js +9 -11
- package/dist/esm/init/scaffold.d.ts +1 -1
- package/dist/esm/init/scaffold.js +32 -38
- package/dist/esm/init/templates.d.ts +1 -1
- package/dist/esm/init/templates.js +16 -22
- package/dist/esm/injectReleaseNotesIntoReadme.js +42 -49
- package/dist/esm/injectSection.js +17 -27
- package/dist/esm/loadConfig.d.ts +1 -1
- package/dist/esm/loadConfig.js +206 -225
- package/dist/esm/parseCommitMessage.d.ts +1 -1
- package/dist/esm/parseCommitMessage.js +72 -76
- package/dist/esm/parseRequestedTags.js +6 -9
- package/dist/esm/prepareCommand.d.ts +1 -1
- package/dist/esm/prepareCommand.js +225 -235
- package/dist/esm/previewTagPrefixes.d.ts +1 -1
- package/dist/esm/previewTagPrefixes.js +101 -96
- package/dist/esm/propagateBumps.d.ts +2 -2
- package/dist/esm/propagateBumps.js +48 -50
- package/dist/esm/publish.d.ts +2 -2
- package/dist/esm/publish.js +22 -28
- package/dist/esm/publishCommand.js +75 -80
- package/dist/esm/pushCommand.js +33 -34
- package/dist/esm/pushRelease.d.ts +1 -1
- package/dist/esm/pushRelease.js +21 -24
- package/dist/esm/readCurrentVersion.js +13 -17
- package/dist/esm/releasePrepare.d.ts +1 -1
- package/dist/esm/releasePrepare.js +213 -231
- package/dist/esm/releasePrepareMono.d.ts +2 -2
- package/dist/esm/releasePrepareMono.js +434 -494
- package/dist/esm/releasePrepareProject.d.ts +2 -2
- package/dist/esm/releasePrepareProject.js +143 -153
- package/dist/esm/renderChangelogMarkdown.d.ts +1 -1
- package/dist/esm/renderChangelogMarkdown.js +20 -24
- package/dist/esm/renderReleaseNotes.d.ts +1 -1
- package/dist/esm/renderReleaseNotes.js +50 -55
- package/dist/esm/reportPrepare.d.ts +1 -1
- package/dist/esm/reportPrepare.js +230 -231
- package/dist/esm/resolveCliffConfigPath.js +18 -23
- package/dist/esm/resolveCommandTags.d.ts +1 -1
- package/dist/esm/resolveCommandTags.js +47 -45
- package/dist/esm/resolveReleaseNotesConfig.d.ts +1 -1
- package/dist/esm/resolveReleaseNotesConfig.js +39 -43
- package/dist/esm/resolveReleaseTags.d.ts +1 -1
- package/dist/esm/resolveReleaseTags.js +39 -40
- package/dist/esm/runGitCliff.js +27 -30
- package/dist/esm/showTagPrefixesCommand.js +48 -70
- package/dist/esm/stripEmojiPrefix.js +2 -5
- package/dist/esm/stripScope.js +18 -21
- package/dist/esm/sync-labels/generateCommand.d.ts +1 -1
- package/dist/esm/sync-labels/generateCommand.js +51 -53
- package/dist/esm/sync-labels/initCommand.js +46 -48
- package/dist/esm/sync-labels/loadSyncLabelsConfig.d.ts +1 -1
- package/dist/esm/sync-labels/loadSyncLabelsConfig.js +46 -52
- package/dist/esm/sync-labels/presets.d.ts +1 -1
- package/dist/esm/sync-labels/presets.js +40 -43
- package/dist/esm/sync-labels/resolveLabels.d.ts +1 -1
- package/dist/esm/sync-labels/resolveLabels.js +28 -35
- package/dist/esm/sync-labels/syncCommand.js +30 -31
- package/dist/esm/sync-labels/templates.d.ts +1 -1
- package/dist/esm/sync-labels/templates.js +23 -26
- package/dist/esm/sync-labels/types.js +1 -0
- package/dist/esm/syncWorkTypes.js +83 -84
- package/dist/esm/tagCommand.js +12 -14
- package/dist/esm/typeGuards.js +4 -8
- package/dist/esm/types.js +66 -60
- package/dist/esm/validateConfig.d.ts +1 -1
- package/dist/esm/validateConfig.js +109 -115
- package/dist/esm/validateOnlyExcludesStrandedDependents.d.ts +2 -2
- package/dist/esm/validateOnlyExcludesStrandedDependents.js +97 -91
- package/dist/esm/validateOverridesCommand.d.ts +2 -2
- package/dist/esm/validateOverridesCommand.js +110 -111
- package/dist/esm/workTypesData.js +57 -60
- package/dist/esm/workTypesUtils.js +16 -21
- package/dist/esm/writeReleaseNotesPreviews.js +55 -57
- package/package.json +3 -2
- package/dist/esm/.cache +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReleasePrepareOptions } from './releasePrepare.
|
|
2
|
-
import type { ChangelogOverride, MonorepoReleaseConfig, ProjectPrepareResult } from './types.
|
|
1
|
+
import type { ReleasePrepareOptions } from './releasePrepare.js';
|
|
2
|
+
import type { ChangelogOverride, MonorepoReleaseConfig, ProjectPrepareResult } from './types.js';
|
|
3
3
|
export interface ReleasePrepareProjectArgs {
|
|
4
4
|
config: MonorepoReleaseConfig;
|
|
5
5
|
options: ReleasePrepareOptions;
|
|
@@ -11,167 +11,157 @@ import { getCommitsSinceTarget } from "./getCommitsSinceTarget.js";
|
|
|
11
11
|
import { writeChangelogMarkdown } from "./renderChangelogMarkdown.js";
|
|
12
12
|
import { deriveSectionOrder } from "./resolveReleaseNotesConfig.js";
|
|
13
13
|
import { writeReleaseNotesPreviews } from "./writeReleaseNotesPreviews.js";
|
|
14
|
-
const ROOT_PACKAGE_FILE =
|
|
15
|
-
const ROOT_CHANGELOG_PATH =
|
|
16
|
-
function releasePrepareProject(args) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
const workTypes = config.workTypes ?? { ...DEFAULT_WORK_TYPES };
|
|
25
|
-
const versionPatterns = config.versionPatterns ?? { ...DEFAULT_VERSION_PATTERNS };
|
|
26
|
-
const breakingPolicies = config.breakingPolicies ?? DEFAULT_BREAKING_POLICIES;
|
|
27
|
-
const contributingPaths = config.workspaces.flatMap((workspace) => workspace.paths);
|
|
28
|
-
const { tag, commits } = getCommitsSinceTarget([project.tagPrefix], contributingPaths);
|
|
29
|
-
const since = tag === void 0 ? "(no previous release found)" : `since ${tag}`;
|
|
30
|
-
const collector = createPolicyViolationCollector();
|
|
31
|
-
const decision = decideRelease({
|
|
32
|
-
commits,
|
|
33
|
-
force,
|
|
34
|
-
bumpOverride,
|
|
35
|
-
workTypes,
|
|
36
|
-
versionPatterns,
|
|
37
|
-
scopeAliases: config.scopeAliases,
|
|
38
|
-
breakingPolicies,
|
|
39
|
-
onPolicyViolation: collector.onPolicyViolation,
|
|
40
|
-
skipReasons: {
|
|
41
|
-
noCommits: `No commits ${since}. Pass --force to release at patch. Skipping.`,
|
|
42
|
-
noBumpWorthy: `No bump-worthy commits ${since}. Pass --force to release at patch (or --force --bump=X for a different level). Skipping.`
|
|
14
|
+
const ROOT_PACKAGE_FILE = './package.json';
|
|
15
|
+
const ROOT_CHANGELOG_PATH = '.';
|
|
16
|
+
export function releasePrepareProject(args) {
|
|
17
|
+
const { config, options, modifiedFiles, tags } = args;
|
|
18
|
+
const { rootOverrides, overrideWarnings, globalMatchedRootKeys } = resolveOptionalOverrideArgs(args);
|
|
19
|
+
const { dryRun, bumpOverride, withReleaseNotes, force } = options;
|
|
20
|
+
const project = config.project;
|
|
21
|
+
if (project === undefined) {
|
|
22
|
+
throw new Error('releasePrepareProject called without a configured project block');
|
|
43
23
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
const workTypes = config.workTypes ?? { ...DEFAULT_WORK_TYPES };
|
|
25
|
+
const versionPatterns = config.versionPatterns ?? { ...DEFAULT_VERSION_PATTERNS };
|
|
26
|
+
const breakingPolicies = config.breakingPolicies ?? DEFAULT_BREAKING_POLICIES;
|
|
27
|
+
const contributingPaths = config.workspaces.flatMap((workspace) => workspace.paths);
|
|
28
|
+
const { tag, commits } = getCommitsSinceTarget([project.tagPrefix], contributingPaths);
|
|
29
|
+
const since = tag === undefined ? '(no previous release found)' : `since ${tag}`;
|
|
30
|
+
const collector = createPolicyViolationCollector();
|
|
31
|
+
const decision = decideRelease({
|
|
32
|
+
commits,
|
|
33
|
+
force,
|
|
34
|
+
bumpOverride,
|
|
35
|
+
workTypes,
|
|
36
|
+
versionPatterns,
|
|
37
|
+
scopeAliases: config.scopeAliases,
|
|
38
|
+
breakingPolicies,
|
|
39
|
+
onPolicyViolation: collector.onPolicyViolation,
|
|
40
|
+
skipReasons: {
|
|
41
|
+
noCommits: `No commits ${since}. Pass --force to release at patch. Skipping.`,
|
|
42
|
+
noBumpWorthy: `No bump-worthy commits ${since}. Pass --force to release at patch (or --force --bump=X for a different level). Skipping.`,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const policyViolations = collector.violations.length > 0 ? collector.violations : undefined;
|
|
46
|
+
if (decision.outcome === 'skip') {
|
|
47
|
+
const skipped = {
|
|
48
|
+
status: 'skipped',
|
|
49
|
+
commitCount: commits.length,
|
|
50
|
+
parsedCommitCount: decision.parsedCommitCount,
|
|
51
|
+
skipReason: decision.skipReason,
|
|
52
|
+
};
|
|
53
|
+
if (tag !== undefined) {
|
|
54
|
+
skipped.previousTag = tag;
|
|
55
|
+
}
|
|
56
|
+
if (decision.unparseableCommits !== undefined) {
|
|
57
|
+
skipped.unparseableCommits = decision.unparseableCommits;
|
|
58
|
+
}
|
|
59
|
+
if (policyViolations !== undefined) {
|
|
60
|
+
skipped.policyViolations = policyViolations;
|
|
61
|
+
}
|
|
62
|
+
return skipped;
|
|
63
|
+
}
|
|
64
|
+
const { releaseType, parsedCommitCount, unparseableCommits } = decision;
|
|
65
|
+
const bump = bumpAllVersions([ROOT_PACKAGE_FILE], releaseType, dryRun);
|
|
66
|
+
const newTag = `${project.tagPrefix}${bump.newVersion}`;
|
|
67
|
+
const { changelogFiles, changelogJsonFiles } = writeProjectChangelogs({
|
|
68
|
+
config,
|
|
69
|
+
project,
|
|
70
|
+
commits,
|
|
71
|
+
contributingPaths,
|
|
72
|
+
newTag,
|
|
73
|
+
newVersion: bump.newVersion,
|
|
74
|
+
dryRun,
|
|
75
|
+
rootOverrides,
|
|
76
|
+
overrideWarnings,
|
|
77
|
+
globalMatchedRootKeys,
|
|
78
|
+
});
|
|
79
|
+
const firstChangelogJsonPath = changelogJsonFiles[0];
|
|
80
|
+
if (withReleaseNotes === true && config.changelogJson.enabled && firstChangelogJsonPath !== undefined) {
|
|
81
|
+
const sectionOrder = deriveSectionOrder(workTypes);
|
|
82
|
+
writeReleaseNotesPreviews({
|
|
83
|
+
workspacePath: ROOT_CHANGELOG_PATH,
|
|
84
|
+
tag: newTag,
|
|
85
|
+
changelogJsonPath: firstChangelogJsonPath,
|
|
86
|
+
sectionOrder,
|
|
87
|
+
dryRun,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
tags.push(newTag);
|
|
91
|
+
modifiedFiles.push(ROOT_PACKAGE_FILE, ...changelogFiles, ...changelogJsonFiles);
|
|
92
|
+
const result = {
|
|
93
|
+
status: 'released',
|
|
94
|
+
commitCount: commits.length,
|
|
95
|
+
parsedCommitCount,
|
|
96
|
+
releaseType,
|
|
97
|
+
currentVersion: bump.currentVersion,
|
|
98
|
+
newVersion: bump.newVersion,
|
|
99
|
+
tag: newTag,
|
|
100
|
+
bumpedFiles: bump.files,
|
|
101
|
+
changelogFiles,
|
|
102
|
+
commits,
|
|
52
103
|
};
|
|
53
|
-
if (tag !==
|
|
54
|
-
|
|
104
|
+
if (tag !== undefined) {
|
|
105
|
+
result.previousTag = tag;
|
|
55
106
|
}
|
|
56
|
-
if (
|
|
57
|
-
|
|
107
|
+
if (unparseableCommits !== undefined) {
|
|
108
|
+
result.unparseableCommits = unparseableCommits;
|
|
58
109
|
}
|
|
59
|
-
if (policyViolations !==
|
|
60
|
-
|
|
110
|
+
if (policyViolations !== undefined) {
|
|
111
|
+
result.policyViolations = policyViolations;
|
|
61
112
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const newTag = `${project.tagPrefix}${bump.newVersion}`;
|
|
67
|
-
const { changelogFiles, changelogJsonFiles } = writeProjectChangelogs({
|
|
68
|
-
config,
|
|
69
|
-
project,
|
|
70
|
-
commits,
|
|
71
|
-
contributingPaths,
|
|
72
|
-
newTag,
|
|
73
|
-
newVersion: bump.newVersion,
|
|
74
|
-
dryRun,
|
|
75
|
-
rootOverrides,
|
|
76
|
-
overrideWarnings,
|
|
77
|
-
globalMatchedRootKeys
|
|
78
|
-
});
|
|
79
|
-
const firstChangelogJsonPath = changelogJsonFiles[0];
|
|
80
|
-
if (withReleaseNotes === true && config.changelogJson.enabled && firstChangelogJsonPath !== void 0) {
|
|
81
|
-
const sectionOrder = deriveSectionOrder(workTypes);
|
|
82
|
-
writeReleaseNotesPreviews({
|
|
83
|
-
workspacePath: ROOT_CHANGELOG_PATH,
|
|
84
|
-
tag: newTag,
|
|
85
|
-
changelogJsonPath: firstChangelogJsonPath,
|
|
86
|
-
sectionOrder,
|
|
87
|
-
dryRun
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
tags.push(newTag);
|
|
91
|
-
modifiedFiles.push(ROOT_PACKAGE_FILE, ...changelogFiles, ...changelogJsonFiles);
|
|
92
|
-
const result = {
|
|
93
|
-
status: "released",
|
|
94
|
-
commitCount: commits.length,
|
|
95
|
-
parsedCommitCount,
|
|
96
|
-
releaseType,
|
|
97
|
-
currentVersion: bump.currentVersion,
|
|
98
|
-
newVersion: bump.newVersion,
|
|
99
|
-
tag: newTag,
|
|
100
|
-
bumpedFiles: bump.files,
|
|
101
|
-
changelogFiles,
|
|
102
|
-
commits
|
|
103
|
-
};
|
|
104
|
-
if (tag !== void 0) {
|
|
105
|
-
result.previousTag = tag;
|
|
106
|
-
}
|
|
107
|
-
if (unparseableCommits !== void 0) {
|
|
108
|
-
result.unparseableCommits = unparseableCommits;
|
|
109
|
-
}
|
|
110
|
-
if (policyViolations !== void 0) {
|
|
111
|
-
result.policyViolations = policyViolations;
|
|
112
|
-
}
|
|
113
|
-
if (bumpOverride !== void 0) {
|
|
114
|
-
result.bumpOverride = bumpOverride;
|
|
115
|
-
}
|
|
116
|
-
return result;
|
|
113
|
+
if (bumpOverride !== undefined) {
|
|
114
|
+
result.bumpOverride = bumpOverride;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
117
|
}
|
|
118
118
|
function resolveOptionalOverrideArgs(args) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
return {
|
|
120
|
+
rootOverrides: args.rootOverrides ?? new Map(),
|
|
121
|
+
overrideWarnings: args.overrideWarnings ?? [],
|
|
122
|
+
globalMatchedRootKeys: args.globalMatchedRootKeys ?? new Set(),
|
|
123
|
+
};
|
|
124
124
|
}
|
|
125
125
|
function writeProjectChangelogs(args) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
126
|
+
const { config, project, commits, contributingPaths, newTag, newVersion, dryRun, rootOverrides, overrideWarnings, globalMatchedRootKeys, } = args;
|
|
127
|
+
const isEmptyRange = commits.length === 0;
|
|
128
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
129
|
+
const tagPattern = buildTagPattern([project.tagPrefix]);
|
|
130
|
+
const newEntries = isEmptyRange
|
|
131
|
+
? [buildEmptyReleaseEntry(newVersion, today)]
|
|
132
|
+
: buildChangelogEntries(config, newTag, { tagPattern, includePaths: contributingPaths });
|
|
133
|
+
const applied = applyChangelogOverrides(newEntries, rootOverrides);
|
|
134
|
+
if (applied.errors.length > 0) {
|
|
135
|
+
throw new Error(`Changelog override application failed:\n - ${applied.errors.join('\n - ')}`);
|
|
136
|
+
}
|
|
137
|
+
overrideWarnings.push(...applied.warnings);
|
|
138
|
+
for (const matched of applied.matchedKeys) {
|
|
139
|
+
globalMatchedRootKeys.add(matched);
|
|
140
|
+
}
|
|
141
|
+
const changelogJsonPath = resolveChangelogJsonPath(config, ROOT_CHANGELOG_PATH);
|
|
142
|
+
const sectionOrder = deriveSectionOrder(config.workTypes ?? { ...DEFAULT_WORK_TYPES });
|
|
143
|
+
const renderEntries = isEmptyRange
|
|
144
|
+
? mergeChangelogEntriesWithDisk(changelogJsonPath, applied.entries)
|
|
145
|
+
: applied.entries;
|
|
146
|
+
if (config.changelogJson.enabled && !dryRun) {
|
|
147
|
+
if (isEmptyRange) {
|
|
148
|
+
writeChangelogJson(changelogJsonPath, renderEntries);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
writeChangelogJson(changelogJsonPath, applied.entries);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const changelogFiles = [
|
|
155
|
+
writeChangelogMarkdown({
|
|
156
|
+
changelogPath: ROOT_CHANGELOG_PATH,
|
|
157
|
+
entries: renderEntries,
|
|
158
|
+
sectionOrder,
|
|
159
|
+
dryRun,
|
|
160
|
+
}),
|
|
161
|
+
];
|
|
162
|
+
const changelogJsonFiles = [];
|
|
163
|
+
if (config.changelogJson.enabled) {
|
|
164
|
+
changelogJsonFiles.push(changelogJsonPath);
|
|
159
165
|
}
|
|
160
|
-
|
|
161
|
-
const changelogFiles = [
|
|
162
|
-
writeChangelogMarkdown({
|
|
163
|
-
changelogPath: ROOT_CHANGELOG_PATH,
|
|
164
|
-
entries: renderEntries,
|
|
165
|
-
sectionOrder,
|
|
166
|
-
dryRun
|
|
167
|
-
})
|
|
168
|
-
];
|
|
169
|
-
const changelogJsonFiles = [];
|
|
170
|
-
if (config.changelogJson.enabled) {
|
|
171
|
-
changelogJsonFiles.push(changelogJsonPath);
|
|
172
|
-
}
|
|
173
|
-
return { changelogFiles, changelogJsonFiles };
|
|
166
|
+
return { changelogFiles, changelogJsonFiles };
|
|
174
167
|
}
|
|
175
|
-
export {
|
|
176
|
-
releasePrepareProject
|
|
177
|
-
};
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from
|
|
2
|
-
import { dirname, join as joinPath } from
|
|
1
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join as joinPath } from 'node:path';
|
|
3
3
|
import { renderReleaseNotesMulti } from "./renderReleaseNotes.js";
|
|
4
4
|
const CHANGELOG_HEADER = `# Changelog
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.`;
|
|
7
7
|
const CHANGELOG_FOOTER = `<!-- Generated by release-kit. Do not edit this file. Use .meta/changelog-overrides.json to override entries. -->`;
|
|
8
|
-
function renderChangelogMarkdown(entries, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export function renderChangelogMarkdown(entries, options) {
|
|
9
|
+
const body = renderReleaseNotesMulti(entries, options);
|
|
10
|
+
const trimmedBody = body.trimEnd();
|
|
11
|
+
const parts = [CHANGELOG_HEADER];
|
|
12
|
+
if (trimmedBody.length > 0) {
|
|
13
|
+
parts.push(trimmedBody);
|
|
14
|
+
}
|
|
15
|
+
parts.push(CHANGELOG_FOOTER);
|
|
16
|
+
return parts.join('\n\n') + '\n';
|
|
17
17
|
}
|
|
18
|
-
function writeChangelogMarkdown(params) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export function writeChangelogMarkdown(params) {
|
|
19
|
+
const { changelogPath, entries, sectionOrder, dryRun = false } = params;
|
|
20
|
+
const filePath = joinPath(changelogPath, 'CHANGELOG.md');
|
|
21
|
+
if (dryRun) {
|
|
22
|
+
return filePath;
|
|
23
|
+
}
|
|
24
|
+
const rendered = renderChangelogMarkdown(entries, sectionOrder !== undefined ? { sectionOrder } : undefined);
|
|
25
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
26
|
+
writeFileSync(filePath, rendered, 'utf8');
|
|
22
27
|
return filePath;
|
|
23
|
-
}
|
|
24
|
-
const rendered = renderChangelogMarkdown(entries, sectionOrder !== void 0 ? { sectionOrder } : void 0);
|
|
25
|
-
mkdirSync(dirname(filePath), { recursive: true });
|
|
26
|
-
writeFileSync(filePath, rendered, "utf8");
|
|
27
|
-
return filePath;
|
|
28
28
|
}
|
|
29
|
-
export {
|
|
30
|
-
renderChangelogMarkdown,
|
|
31
|
-
writeChangelogMarkdown
|
|
32
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangelogAudience, ChangelogEntry, ChangelogSection } from './types.
|
|
1
|
+
import type { ChangelogAudience, ChangelogEntry, ChangelogSection } from './types.js';
|
|
2
2
|
export interface RenderOptions {
|
|
3
3
|
filter?: (section: ChangelogSection) => boolean;
|
|
4
4
|
includeHeading?: boolean;
|
|
@@ -1,73 +1,68 @@
|
|
|
1
1
|
import { WORK_TYPES_DATA } from "./workTypesData.js";
|
|
2
2
|
function getBreakingPrefix() {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const { emoji, label } = WORK_TYPES_DATA.markers.breaking;
|
|
4
|
+
return `${emoji} **${label}:** `;
|
|
5
5
|
}
|
|
6
6
|
function allSections() {
|
|
7
|
-
|
|
7
|
+
return true;
|
|
8
8
|
}
|
|
9
9
|
function publicSections(section) {
|
|
10
|
-
|
|
10
|
+
return section.audience === 'all';
|
|
11
11
|
}
|
|
12
|
-
function matchesAudience(audience) {
|
|
13
|
-
|
|
12
|
+
export function matchesAudience(audience) {
|
|
13
|
+
return audience === 'dev' ? allSections : publicSections;
|
|
14
14
|
}
|
|
15
|
-
function renderReleaseNotesSingle(entry, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
const lines = [];
|
|
25
|
-
if (includeHeading) {
|
|
26
|
-
lines.push(`## ${entry.version} \u2014 ${entry.date}`);
|
|
27
|
-
}
|
|
28
|
-
for (const section of sections) {
|
|
29
|
-
if (lines.length > 0) {
|
|
30
|
-
lines.push("");
|
|
15
|
+
export function renderReleaseNotesSingle(entry, options) {
|
|
16
|
+
const filter = options?.filter;
|
|
17
|
+
const includeHeading = options?.includeHeading ?? true;
|
|
18
|
+
const sectionOrder = options?.sectionOrder;
|
|
19
|
+
const filtered = filter !== undefined ? entry.sections.filter(filter) : entry.sections;
|
|
20
|
+
const sections = sectionOrder !== undefined ? sortSectionsByOrder(filtered, sectionOrder) : filtered;
|
|
21
|
+
if (sections.length === 0) {
|
|
22
|
+
return '';
|
|
31
23
|
}
|
|
32
|
-
lines
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
lines.
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
const lines = [];
|
|
25
|
+
if (includeHeading) {
|
|
26
|
+
lines.push(`## ${entry.version} — ${entry.date}`);
|
|
27
|
+
}
|
|
28
|
+
for (const section of sections) {
|
|
29
|
+
if (lines.length > 0) {
|
|
30
|
+
lines.push('');
|
|
31
|
+
}
|
|
32
|
+
lines.push(`### ${section.title}`, '');
|
|
33
|
+
for (const [index, item] of section.items.entries()) {
|
|
34
|
+
const prefix = item.breaking === true ? getBreakingPrefix() : '';
|
|
35
|
+
lines.push(`- ${prefix}${item.description}`);
|
|
36
|
+
if (item.body !== undefined && item.body.length > 0) {
|
|
37
|
+
lines.push('', ...indentBodyLines(item.body));
|
|
38
|
+
if (index < section.items.length - 1) {
|
|
39
|
+
lines.push('');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
|
-
}
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
return lines.join("\n") + "\n";
|
|
44
|
+
return lines.join('\n') + '\n';
|
|
45
45
|
}
|
|
46
46
|
function sortSectionsByOrder(sections, order) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
const indexed = sections.map((section, index) => ({ section, index }));
|
|
52
|
-
indexed.sort((a, b) => {
|
|
53
|
-
const priorityA = priority.get(a.section.title) ?? Number.POSITIVE_INFINITY;
|
|
54
|
-
const priorityB = priority.get(b.section.title) ?? Number.POSITIVE_INFINITY;
|
|
55
|
-
if (priorityA !== priorityB) {
|
|
56
|
-
return priorityA - priorityB;
|
|
47
|
+
const priority = new Map();
|
|
48
|
+
for (const [index, title] of order.entries()) {
|
|
49
|
+
priority.set(title, index);
|
|
57
50
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
const indexed = sections.map((section, index) => ({ section, index }));
|
|
52
|
+
indexed.sort((a, b) => {
|
|
53
|
+
const priorityA = priority.get(a.section.title) ?? Number.POSITIVE_INFINITY;
|
|
54
|
+
const priorityB = priority.get(b.section.title) ?? Number.POSITIVE_INFINITY;
|
|
55
|
+
if (priorityA !== priorityB) {
|
|
56
|
+
return priorityA - priorityB;
|
|
57
|
+
}
|
|
58
|
+
return a.index - b.index;
|
|
59
|
+
});
|
|
60
|
+
return indexed.map(({ section }) => section);
|
|
61
61
|
}
|
|
62
62
|
function indentBodyLines(body) {
|
|
63
|
-
|
|
63
|
+
return body.split('\n').map((line) => (line.length === 0 ? '' : ` ${line}`));
|
|
64
64
|
}
|
|
65
|
-
function renderReleaseNotesMulti(entries, options) {
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
export function renderReleaseNotesMulti(entries, options) {
|
|
66
|
+
const parts = entries.map((entry) => renderReleaseNotesSingle(entry, options)).filter((part) => part.length > 0);
|
|
67
|
+
return parts.join('\n');
|
|
68
68
|
}
|
|
69
|
-
export {
|
|
70
|
-
matchesAudience,
|
|
71
|
-
renderReleaseNotesMulti,
|
|
72
|
-
renderReleaseNotesSingle
|
|
73
|
-
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PrepareResult } from './types.
|
|
1
|
+
import type { PrepareResult } from './types.js';
|
|
2
2
|
export declare function reportPrepare(result: PrepareResult): string;
|