@williamthorsen/release-kit 5.4.0 → 7.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 +32 -0
- package/README.md +12 -12
- package/dist/esm/.cache +1 -1
- package/dist/esm/assertCleanWorkingTree.js +9 -14
- package/dist/esm/bin/release-kit.js +202 -229
- 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 -99
- package/dist/esm/collectPolicyViolations.d.ts +2 -2
- package/dist/esm/collectPolicyViolations.js +11 -14
- package/dist/esm/commitCommand.js +48 -53
- package/dist/esm/compareVersions.js +20 -23
- package/dist/esm/createGithubRelease.js +56 -59
- package/dist/esm/createGithubReleaseCommand.js +21 -29
- 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.d.ts +2 -0
- package/dist/esm/help/prepareHelp.js +26 -0
- 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 +32 -1
- package/dist/esm/prepareCommand.js +225 -271
- 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 -86
- package/dist/esm/pushCommand.js +33 -40
- 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 -493
- 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 -44
- package/dist/esm/resolveReleaseNotesConfig.d.ts +1 -1
- package/dist/esm/resolveReleaseNotesConfig.js +39 -41
- 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 -52
- package/dist/esm/sync-labels/initCommand.js +46 -47
- 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 -30
- 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 -81
- package/dist/esm/tagCommand.js +12 -21
- 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 +111 -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 +2 -6
|
@@ -1,62 +1,61 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { bumpVersion } from "./bumpVersion.js";
|
|
3
3
|
function isPackageJson(value) {
|
|
4
|
-
|
|
4
|
+
return typeof value === 'object' && value !== null && 'version' in value && typeof value.version === 'string';
|
|
5
5
|
}
|
|
6
|
-
function bumpAllVersions(packageFiles, releaseType, dryRun) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
export function bumpAllVersions(packageFiles, releaseType, dryRun) {
|
|
7
|
+
const firstFile = packageFiles[0];
|
|
8
|
+
if (firstFile === undefined) {
|
|
9
|
+
throw new Error('No package files specified');
|
|
10
|
+
}
|
|
11
|
+
const firstPkg = readPackageJson(firstFile);
|
|
12
|
+
const currentVersion = firstPkg.version;
|
|
13
|
+
const newVersion = bumpVersion(currentVersion, releaseType);
|
|
14
|
+
writeVersionToAllFiles(packageFiles, firstFile, firstPkg, newVersion, dryRun);
|
|
15
|
+
return { currentVersion, newVersion, files: [...packageFiles] };
|
|
16
16
|
}
|
|
17
|
-
function setAllVersions(packageFiles, newVersion, dryRun) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
export function setAllVersions(packageFiles, newVersion, dryRun) {
|
|
18
|
+
const firstFile = packageFiles[0];
|
|
19
|
+
if (firstFile === undefined) {
|
|
20
|
+
throw new Error('No package files specified');
|
|
21
|
+
}
|
|
22
|
+
const firstPkg = readPackageJson(firstFile);
|
|
23
|
+
const currentVersion = firstPkg.version;
|
|
24
|
+
writeVersionToAllFiles(packageFiles, firstFile, firstPkg, newVersion, dryRun);
|
|
25
|
+
return { currentVersion, newVersion, files: [...packageFiles] };
|
|
26
26
|
}
|
|
27
27
|
function writeVersionToAllFiles(packageFiles, firstFile, firstPkg, newVersion, dryRun) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
for (const filePath of packageFiles) {
|
|
29
|
+
if (dryRun) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const pkg = filePath === firstFile ? firstPkg : readPackageJson(filePath);
|
|
33
|
+
pkg.version = newVersion;
|
|
34
|
+
try {
|
|
35
|
+
writeFileSync(filePath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Failed to write ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
|
-
}
|
|
40
41
|
}
|
|
41
42
|
function readPackageJson(filePath) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
let content;
|
|
44
|
+
try {
|
|
45
|
+
content = readFileSync(filePath, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new Error(`Failed to read ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
let parsed;
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(content);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new Error(`Failed to parse JSON in ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
56
|
+
}
|
|
57
|
+
if (!isPackageJson(parsed)) {
|
|
58
|
+
throw new Error(`No valid 'version' field found in ${filePath}`);
|
|
59
|
+
}
|
|
60
|
+
return parsed;
|
|
58
61
|
}
|
|
59
|
-
export {
|
|
60
|
-
bumpAllVersions,
|
|
61
|
-
setAllVersions
|
|
62
|
-
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ReleaseType } from './types.
|
|
1
|
+
import type { ReleaseType } from './types.js';
|
|
2
2
|
export declare function bumpVersion(version: string, releaseType: ReleaseType): string;
|
package/dist/esm/bumpVersion.js
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
function bumpVersion(version, releaseType) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
export function bumpVersion(version, releaseType) {
|
|
2
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
3
|
+
if (!match) {
|
|
4
|
+
throw new Error(`Invalid semver version: '${version}'`);
|
|
5
|
+
}
|
|
6
|
+
const major = match[1];
|
|
7
|
+
const minor = match[2];
|
|
8
|
+
const patch = match[3];
|
|
9
|
+
if (major === undefined || minor === undefined || patch === undefined) {
|
|
10
|
+
throw new Error(`Invalid semver version: '${version}'`);
|
|
11
|
+
}
|
|
12
|
+
const majorNum = Number.parseInt(major, 10);
|
|
13
|
+
const minorNum = Number.parseInt(minor, 10);
|
|
14
|
+
const patchNum = Number.parseInt(patch, 10);
|
|
15
|
+
switch (releaseType) {
|
|
16
|
+
case 'major':
|
|
17
|
+
if (majorNum === 0) {
|
|
18
|
+
return `0.${minorNum + 1}.0`;
|
|
19
|
+
}
|
|
20
|
+
return `${majorNum + 1}.0.0`;
|
|
21
|
+
case 'minor':
|
|
22
|
+
return `${majorNum}.${minorNum + 1}.0`;
|
|
23
|
+
case 'patch':
|
|
24
|
+
return `${majorNum}.${minorNum}.${patchNum + 1}`;
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
|
-
export {
|
|
28
|
-
bumpVersion
|
|
29
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangelogEntry, ReleaseConfig } from './types.
|
|
1
|
+
import type { ChangelogEntry, ReleaseConfig } from './types.js';
|
|
2
2
|
export declare function resolveChangelogJsonPath(config: Pick<ReleaseConfig, 'changelogJson'>, changelogPath: string): string;
|
|
3
3
|
export declare function writeChangelogJson(filePath: string, entries: ChangelogEntry[]): string;
|
|
4
4
|
export declare function upsertChangelogJson(filePath: string, entries: ChangelogEntry[]): string;
|
|
@@ -1,78 +1,75 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from
|
|
2
|
-
import { dirname, join } from
|
|
3
|
-
import stringify from
|
|
4
|
-
import semver from
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import stringify from 'json-stringify-pretty-compact';
|
|
4
|
+
import semver from 'semver';
|
|
5
5
|
import { isChangelogEntry } from "./changelogJsonUtils.js";
|
|
6
6
|
import { isUnknownArray } from "./typeGuards.js";
|
|
7
|
-
function resolveChangelogJsonPath(config, changelogPath) {
|
|
8
|
-
|
|
7
|
+
export function resolveChangelogJsonPath(config, changelogPath) {
|
|
8
|
+
return join(changelogPath, config.changelogJson.outputPath);
|
|
9
9
|
}
|
|
10
|
-
function writeChangelogJson(filePath, entries) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export function writeChangelogJson(filePath, entries) {
|
|
11
|
+
const sorted = sortNewestFirst(entries);
|
|
12
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
13
|
+
writeFileSync(filePath, stringify(sorted, { maxLength: 100 }) + '\n', 'utf8');
|
|
14
|
+
return filePath;
|
|
15
15
|
}
|
|
16
|
-
function upsertChangelogJson(filePath, entries) {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export function upsertChangelogJson(filePath, entries) {
|
|
17
|
+
upsertChangelogJsonAndReturn(filePath, entries);
|
|
18
|
+
return filePath;
|
|
19
19
|
}
|
|
20
|
-
function upsertChangelogJsonAndReturn(filePath, entries) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
export function upsertChangelogJsonAndReturn(filePath, entries) {
|
|
21
|
+
const existing = readExistingEntries(filePath);
|
|
22
|
+
const merged = mergeEntries(entries, existing);
|
|
23
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
24
|
+
writeFileSync(filePath, stringify(merged, { maxLength: 100 }) + '\n', 'utf8');
|
|
25
|
+
return merged;
|
|
26
26
|
}
|
|
27
|
-
function mergeChangelogEntriesWithDisk(filePath, entries) {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
export function mergeChangelogEntriesWithDisk(filePath, entries) {
|
|
28
|
+
const existing = readExistingEntries(filePath);
|
|
29
|
+
return mergeEntries(entries, existing);
|
|
30
30
|
}
|
|
31
31
|
function sortNewestFirst(entries) {
|
|
32
|
-
|
|
32
|
+
return [...entries].sort((a, b) => compareVersionsDescending(a.version, b.version));
|
|
33
33
|
}
|
|
34
34
|
function readExistingEntries(filePath) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (!existsSync(filePath)) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const content = readFileSync(filePath, 'utf8');
|
|
40
|
+
const parsed = JSON.parse(content);
|
|
41
|
+
if (!isUnknownArray(parsed)) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return parsed.filter(isChangelogEntry);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.warn(`Warning: could not parse existing ${filePath}: ${error instanceof Error ? error.message : String(error)}; treating as empty`);
|
|
48
|
+
return [];
|
|
43
49
|
}
|
|
44
|
-
return parsed.filter(isChangelogEntry);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.warn(
|
|
47
|
-
`Warning: could not parse existing ${filePath}: ${error instanceof Error ? error.message : String(error)}; treating as empty`
|
|
48
|
-
);
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
50
|
}
|
|
52
51
|
function mergeEntries(newEntries, existingEntries) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
const versionMap = new Map();
|
|
53
|
+
for (const entry of existingEntries) {
|
|
54
|
+
versionMap.set(entry.version, entry);
|
|
55
|
+
}
|
|
56
|
+
for (const entry of newEntries) {
|
|
57
|
+
versionMap.set(entry.version, entry);
|
|
58
|
+
}
|
|
59
|
+
return sortNewestFirst(versionMap.values());
|
|
61
60
|
}
|
|
62
61
|
function compareVersionsDescending(a, b) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
const aValid = semver.valid(a);
|
|
63
|
+
const bValid = semver.valid(b);
|
|
64
|
+
if (aValid && bValid)
|
|
65
|
+
return semver.rcompare(aValid, bValid);
|
|
66
|
+
if (aValid)
|
|
67
|
+
return -1;
|
|
68
|
+
if (bValid)
|
|
69
|
+
return 1;
|
|
70
|
+
if (a > b)
|
|
71
|
+
return -1;
|
|
72
|
+
if (a < b)
|
|
73
|
+
return 1;
|
|
74
|
+
return 0;
|
|
71
75
|
}
|
|
72
|
-
export {
|
|
73
|
-
mergeChangelogEntriesWithDisk,
|
|
74
|
-
resolveChangelogJsonPath,
|
|
75
|
-
upsertChangelogJson,
|
|
76
|
-
upsertChangelogJsonAndReturn,
|
|
77
|
-
writeChangelogJson
|
|
78
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangelogEntry, ChangelogItem } from './types.
|
|
1
|
+
import type { ChangelogEntry, ChangelogItem } from './types.js';
|
|
2
2
|
export declare function isChangelogItem(value: unknown): value is ChangelogItem;
|
|
3
3
|
export declare function isChangelogEntry(value: unknown): value is ChangelogEntry;
|
|
4
4
|
export declare function extractVersion(tag: string): string;
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { isRecord, isUnknownArray } from "./typeGuards.js";
|
|
3
|
-
function isChangelogItem(value) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export function isChangelogItem(value) {
|
|
4
|
+
if (!isRecord(value))
|
|
5
|
+
return false;
|
|
6
|
+
if (typeof value.description !== 'string')
|
|
7
|
+
return false;
|
|
8
|
+
if (value.body !== undefined && typeof value.body !== 'string')
|
|
9
|
+
return false;
|
|
10
|
+
if (value.breaking !== undefined && typeof value.breaking !== 'boolean')
|
|
11
|
+
return false;
|
|
12
|
+
if (value.hash !== undefined && typeof value.hash !== 'string')
|
|
13
|
+
return false;
|
|
14
|
+
return true;
|
|
10
15
|
}
|
|
11
|
-
function isChangelogEntry(value) {
|
|
12
|
-
|
|
16
|
+
export function isChangelogEntry(value) {
|
|
17
|
+
return (isRecord(value) &&
|
|
18
|
+
typeof value.version === 'string' &&
|
|
19
|
+
typeof value.date === 'string' &&
|
|
20
|
+
isUnknownArray(value.sections));
|
|
13
21
|
}
|
|
14
|
-
function extractVersion(tag) {
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
export function extractVersion(tag) {
|
|
23
|
+
const match = /(\d+\.\d+\.\d+.*)$/.exec(tag);
|
|
24
|
+
return match?.[1] ?? tag;
|
|
17
25
|
}
|
|
18
|
-
function readChangelogEntries(filePath) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
export function readChangelogEntries(filePath) {
|
|
27
|
+
if (!existsSync(filePath)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const content = readFileSync(filePath, 'utf8');
|
|
32
|
+
const parsed = JSON.parse(content);
|
|
33
|
+
if (!isUnknownArray(parsed)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return parsed.filter(isChangelogEntry);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
27
40
|
}
|
|
28
|
-
return parsed.filter(isChangelogEntry);
|
|
29
|
-
} catch {
|
|
30
|
-
return void 0;
|
|
31
|
-
}
|
|
32
41
|
}
|
|
33
|
-
export {
|
|
34
|
-
extractVersion,
|
|
35
|
-
isChangelogEntry,
|
|
36
|
-
isChangelogItem,
|
|
37
|
-
readChangelogEntries
|
|
38
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChangelogEntry, ChangelogOverride, WorkspaceConfig } from './types.
|
|
1
|
+
import type { ChangelogEntry, ChangelogOverride, WorkspaceConfig } from './types.js';
|
|
2
2
|
export type LoadChangelogOverridesResult = {
|
|
3
3
|
overrides: Map<string, ChangelogOverride>;
|
|
4
4
|
} | {
|