@mui/internal-code-infra 0.1.1-canary.37 → 0.1.1-canary.39
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/build/changelog/changelogChanges.d.mts +36 -0
- package/build/changelog/changelogGrouping.d.mts +52 -0
- package/build/changelog/changelogMarkdown.d.mts +69 -0
- package/build/changelog/changelogTags.d.mts +15 -0
- package/build/changelog/changelogTitle.d.mts +28 -0
- package/build/changelog/fetchChangelogData.d.mts +16 -0
- package/build/changelog/index.d.mts +24 -0
- package/build/changelog/octokit.d.mts +7 -0
- package/build/changelog/types.d.ts +158 -0
- package/package.json +19 -19
- package/src/changelog/changelogChanges.mjs +421 -0
- package/src/changelog/changelogGrouping.mjs +148 -0
- package/src/changelog/changelogMarkdown.mjs +110 -0
- package/src/changelog/changelogTags.mjs +34 -0
- package/src/changelog/changelogTitle.mjs +56 -0
- package/src/changelog/fetchChangelogData.mjs +171 -0
- package/src/changelog/fetchChangelogs.mjs +3 -30
- package/src/changelog/index.mjs +31 -0
- package/src/changelog/octokit.mjs +35 -0
- package/src/changelog/types.ts +167 -0
- package/build/brokenLinksChecker/__fixtures__/no-signal-forwarding.d.mts +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { $ } from 'execa';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The closest version tag behind a commit. Tags on the commit itself are the release being made, not
|
|
5
|
+
* the one before it.
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} options
|
|
8
|
+
* @param {string} options.cwd
|
|
9
|
+
* @param {string | null} options.remote - Remote to fetch the tags and the commit from
|
|
10
|
+
* @param {string} options.sha
|
|
11
|
+
* @returns {Promise<string>}
|
|
12
|
+
*/
|
|
13
|
+
export async function findPreviousVersionTag({ cwd, remote, sha }) {
|
|
14
|
+
const $$ = $({ cwd });
|
|
15
|
+
if (remote) {
|
|
16
|
+
// --force to update any existing tags that may have changed to avoid the clobering error.
|
|
17
|
+
const { exitCode } = await $$({ reject: false })`git cat-file -e ${sha}^{commit}`;
|
|
18
|
+
const missing = exitCode === 0 ? [] : [sha];
|
|
19
|
+
await $$`git fetch --tags --force ${remote} ${missing}`;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const { stdout: ownTags } = await $$`git tag --points-at ${sha}`;
|
|
23
|
+
const excludes = ownTags.split('\n').flatMap((tag) => (tag ? ['--exclude', tag] : []));
|
|
24
|
+
const { stdout } =
|
|
25
|
+
await $$`git describe --tags --abbrev=0 --match ${'v[0-9]*'} ${excludes} ${sha}`;
|
|
26
|
+
return stdout.trim();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`No version tag found behind ${sha}. A shallow clone is the usual cause: fetch the full ` +
|
|
30
|
+
'history, or pass the `lastRelease` ref.',
|
|
31
|
+
{ cause: error },
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./types.ts').ChangelogTitle} ChangelogTitle
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const PREFIX = /^\[([^[\]]+)\]\s*/;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Splits the leading `[prefixes]` off a title.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} title
|
|
11
|
+
* @returns {ChangelogTitle}
|
|
12
|
+
*/
|
|
13
|
+
export function parseTitle(title) {
|
|
14
|
+
const prefixes = [];
|
|
15
|
+
let text = title.trim();
|
|
16
|
+
for (let match = PREFIX.exec(text); match; match = PREFIX.exec(text)) {
|
|
17
|
+
prefixes.push(match[1].trim());
|
|
18
|
+
text = text.slice(match[0].length);
|
|
19
|
+
}
|
|
20
|
+
return { prefixes, text };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} prefix
|
|
25
|
+
*/
|
|
26
|
+
function normalizePrefix(prefix) {
|
|
27
|
+
return prefix.toLowerCase().replace(/[\s_-]/g, '');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The candidate that a prefix is a spelling of: case, spaces, hyphens and underscores don't matter.
|
|
32
|
+
*
|
|
33
|
+
* @template {string} Candidate
|
|
34
|
+
* @param {string} prefix
|
|
35
|
+
* @param {Iterable<Candidate>} candidates
|
|
36
|
+
* @returns {Candidate | undefined}
|
|
37
|
+
*/
|
|
38
|
+
export function matchPrefix(prefix, candidates) {
|
|
39
|
+
const normalized = normalizePrefix(prefix);
|
|
40
|
+
return Array.from(candidates).find((candidate) => normalizePrefix(candidate) === normalized);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Rewrites the prefixes of a title. Duplicates and prefixes that become empty are left out.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} title
|
|
47
|
+
* @param {(prefix: string) => string} rewrite
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
export function mapPrefixes(title, rewrite) {
|
|
51
|
+
const { prefixes, text } = parseTitle(title);
|
|
52
|
+
const rewritten = new Set(prefixes.map((prefix) => rewrite(prefix)).filter(Boolean));
|
|
53
|
+
return [Array.from(rewritten, (prefix) => `[${prefix}]`).join(''), text]
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.join(' ');
|
|
56
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
4
|
+
import { mapAsync } from 'es-toolkit/array';
|
|
5
|
+
import { $ } from 'execa';
|
|
6
|
+
import * as semver from 'semver';
|
|
7
|
+
|
|
8
|
+
import { getCurrentGitSha, getRepositoryInfo } from '../utils/git.mjs';
|
|
9
|
+
import { getWorkspacePackages } from '../utils/pnpm.mjs';
|
|
10
|
+
import { createOctokit } from './octokit.mjs';
|
|
11
|
+
import { fetchChangelogChanges } from './changelogChanges.mjs';
|
|
12
|
+
import { findPreviousVersionTag } from './changelogTags.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import('./types.ts').FetchChangelogDataOptions} FetchChangelogDataOptions
|
|
16
|
+
* @typedef {import('./types.ts').GitHubRepository} GitHubRepository
|
|
17
|
+
* @typedef {import('./types.ts').ChangelogData} ChangelogData
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Collects what happened in a release: its changes and its packages. Run inside a checkout of the
|
|
22
|
+
* repository, every option is optional.
|
|
23
|
+
*
|
|
24
|
+
* @param {FetchChangelogDataOptions} [options]
|
|
25
|
+
* @returns {Promise<ChangelogData>}
|
|
26
|
+
*/
|
|
27
|
+
export async function fetchChangelogData(options = {}) {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
try {
|
|
30
|
+
return await collectData(options, controller);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// Cancels what is still in flight. The first failure is the reason, not the cancellations
|
|
33
|
+
// that follow from it.
|
|
34
|
+
controller.abort(error);
|
|
35
|
+
throw controller.signal.reason;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {FetchChangelogDataOptions} options
|
|
41
|
+
* @param {AbortController} controller
|
|
42
|
+
* @returns {Promise<ChangelogData>}
|
|
43
|
+
*/
|
|
44
|
+
async function collectData(options, controller) {
|
|
45
|
+
const cwd = await fs.realpath(options.cwd ?? process.cwd());
|
|
46
|
+
const octokit = options.octokit ?? createOctokit();
|
|
47
|
+
const { signal } = controller;
|
|
48
|
+
|
|
49
|
+
const { repository, remote } = await resolveRepository(cwd, options);
|
|
50
|
+
const isLocalHead = (options.release ?? 'HEAD') === 'HEAD';
|
|
51
|
+
const releaseRef = isLocalHead
|
|
52
|
+
? await getCurrentGitSha(cwd)
|
|
53
|
+
: /** @type {string} */ (options.release);
|
|
54
|
+
const releaseCommit = await getCommit(octokit, repository, releaseRef, signal).catch((error) => {
|
|
55
|
+
if (isLocalHead && error.status === 422) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`HEAD (${releaseRef}) is not on GitHub in ${repository.owner}/${repository.repo}. ` +
|
|
58
|
+
'Push it, or pass a `release` ref that is already pushed.',
|
|
59
|
+
{ cause: error },
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
});
|
|
64
|
+
const releaseSha = releaseCommit.sha;
|
|
65
|
+
|
|
66
|
+
const previousRef =
|
|
67
|
+
options.lastRelease ?? (await findPreviousVersionTag({ cwd, remote, sha: releaseSha }));
|
|
68
|
+
const previousSha = (await getCommit(octokit, repository, previousRef, signal)).sha;
|
|
69
|
+
|
|
70
|
+
const changes = await fetchChangelogChanges({
|
|
71
|
+
octokit,
|
|
72
|
+
repository,
|
|
73
|
+
previousSha,
|
|
74
|
+
releaseSha,
|
|
75
|
+
includeDirectCommits: options.includeDirectCommits ?? false,
|
|
76
|
+
controller,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const packages = await readPackages(cwd, previousSha);
|
|
80
|
+
const taggedVersion = isLocalHead ? null : semver.valid(releaseRef);
|
|
81
|
+
const version =
|
|
82
|
+
options.version ?? taggedVersion ?? packages.find((pkg) => pkg.path === '.')?.version;
|
|
83
|
+
if (!version) {
|
|
84
|
+
throw new Error('The root package.json has no version. Pass the `version` of the release.');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const date =
|
|
88
|
+
options.date ?? (taggedVersion && releaseCommit.commit.committer?.date) ?? new Date();
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
repository,
|
|
92
|
+
previous: { ref: previousRef, sha: previousSha },
|
|
93
|
+
release: { ref: releaseRef, sha: releaseSha },
|
|
94
|
+
version,
|
|
95
|
+
date: new Date(date).toISOString(),
|
|
96
|
+
changes,
|
|
97
|
+
packages: packages.flatMap(({ name, ...pkg }) => (name === null ? [] : [{ name, ...pkg }])),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The packages as they are in the working tree, named or not, sorted by path.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} cwd
|
|
105
|
+
* @param {string} previousSha
|
|
106
|
+
*/
|
|
107
|
+
async function readPackages(cwd, previousSha) {
|
|
108
|
+
const workspaceDir = await findWorkspaceDir(cwd);
|
|
109
|
+
const root = workspaceDir ?? cwd;
|
|
110
|
+
const packages = await getWorkspacePackages({ cwd: root });
|
|
111
|
+
const $$ = $({ cwd: root, reject: false });
|
|
112
|
+
const { exitCode } = await $$`git cat-file -e ${previousSha}^{commit}`;
|
|
113
|
+
|
|
114
|
+
const described = await mapAsync(
|
|
115
|
+
// Without a workspace, pnpm lists the packages of all subdirectories.
|
|
116
|
+
packages.filter((pkg) => workspaceDir || pkg.path === root),
|
|
117
|
+
async (pkg) => {
|
|
118
|
+
const directory = path.relative(root, pkg.path).split(path.sep).join('/') || '.';
|
|
119
|
+
const version = pkg.version ?? null;
|
|
120
|
+
let changed = null;
|
|
121
|
+
if (exitCode === 0) {
|
|
122
|
+
const previous =
|
|
123
|
+
await $$`git show ${previousSha}:./${path.posix.join(directory, 'package.json')}`;
|
|
124
|
+
changed =
|
|
125
|
+
previous.exitCode !== 0 || (JSON.parse(previous.stdout).version ?? null) !== version;
|
|
126
|
+
}
|
|
127
|
+
return { name: pkg.name ?? null, version, private: pkg.isPrivate, path: directory, changed };
|
|
128
|
+
},
|
|
129
|
+
{ concurrency: 10 },
|
|
130
|
+
);
|
|
131
|
+
return described.sort((a, b) => (a.path < b.path ? -1 : 1));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The repository, and the remote of the checkout that points at it, if any.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} cwd
|
|
138
|
+
* @param {FetchChangelogDataOptions} options
|
|
139
|
+
* @returns {Promise<{ repository: GitHubRepository, remote: string | null }>}
|
|
140
|
+
*/
|
|
141
|
+
async function resolveRepository(cwd, options) {
|
|
142
|
+
const info = await getRepositoryInfo(cwd).catch((error) => {
|
|
143
|
+
if (options.repo) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
throw error;
|
|
147
|
+
});
|
|
148
|
+
const owner = options.org ?? 'mui';
|
|
149
|
+
const repo = options.repo ?? /** @type {NonNullable<typeof info>} */ (info).repo;
|
|
150
|
+
const isCheckout = info?.owner === owner && info.repo === repo;
|
|
151
|
+
return { repository: { owner, repo }, remote: isCheckout ? info.remoteName : null };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Resolving refs up front keeps a moving branch from shifting the range while it is paginated.
|
|
156
|
+
*
|
|
157
|
+
* @param {import('@octokit/rest').Octokit} octokit
|
|
158
|
+
* @param {GitHubRepository} repository
|
|
159
|
+
* @param {string} ref
|
|
160
|
+
* @param {AbortSignal} signal
|
|
161
|
+
*/
|
|
162
|
+
async function getCommit(octokit, repository, ref, signal) {
|
|
163
|
+
const { data } = await octokit.repos.getCommit({
|
|
164
|
+
...repository,
|
|
165
|
+
ref,
|
|
166
|
+
// Limits the file list, which can be large and isn't needed.
|
|
167
|
+
per_page: 1,
|
|
168
|
+
request: { signal },
|
|
169
|
+
});
|
|
170
|
+
return data;
|
|
171
|
+
}
|
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import { retry } from '@octokit/plugin-retry';
|
|
2
|
-
import { throttling } from '@octokit/plugin-throttling';
|
|
3
|
-
import { Octokit } from '@octokit/rest';
|
|
4
1
|
import { mapAsync } from 'es-toolkit/array';
|
|
5
2
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const ThrottledOctokit = Octokit.plugin(throttling, retry);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Waits out short rate limits. Longer ones fail with the original error.
|
|
12
|
-
*
|
|
13
|
-
* @param {number} retryAfter - Seconds until the request may be retried
|
|
14
|
-
* @param {unknown} options
|
|
15
|
-
* @param {unknown} octokit
|
|
16
|
-
* @param {number} retryCount
|
|
17
|
-
* @returns {boolean}
|
|
18
|
-
*/
|
|
19
|
-
function shouldRetryRateLimit(retryAfter, options, octokit, retryCount) {
|
|
20
|
-
return retryAfter <= 60 && retryCount < 3;
|
|
21
|
-
}
|
|
3
|
+
import { createOctokit } from './octokit.mjs';
|
|
22
4
|
|
|
23
5
|
/**
|
|
24
6
|
* @typedef {import('@octokit/rest').Octokit} OctokitType
|
|
@@ -45,16 +27,7 @@ function shouldRetryRateLimit(retryAfter, options, octokit, retryCount) {
|
|
|
45
27
|
* @returns {Promise<FetchedCommitDetails[]>}
|
|
46
28
|
*/
|
|
47
29
|
export async function fetchCommitsBetweenRefs(opts) {
|
|
48
|
-
const octokit =
|
|
49
|
-
'octokit' in opts && opts.octokit
|
|
50
|
-
? opts.octokit
|
|
51
|
-
: new ThrottledOctokit({
|
|
52
|
-
authStrategy: persistentAuthStrategy,
|
|
53
|
-
throttle: {
|
|
54
|
-
onRateLimit: shouldRetryRateLimit,
|
|
55
|
-
onSecondaryRateLimit: shouldRetryRateLimit,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
30
|
+
const octokit = 'octokit' in opts && opts.octokit ? opts.octokit : createOctokit();
|
|
58
31
|
|
|
59
32
|
return fetchCommitsRest({
|
|
60
33
|
octokit,
|
|
@@ -77,7 +50,7 @@ export async function fetchCommitsBetweenRefs(opts) {
|
|
|
77
50
|
*/
|
|
78
51
|
async function fetchCommitsRest({ octokit, repo, lastRelease, release, org = 'mui', onProgress }) {
|
|
79
52
|
/**
|
|
80
|
-
* @typedef {Awaited<ReturnType<
|
|
53
|
+
* @typedef {Awaited<ReturnType<OctokitType['repos']['compareCommits']>>['data']['commits']} Commits
|
|
81
54
|
*/
|
|
82
55
|
/**
|
|
83
56
|
* @type {Commits}
|
package/src/changelog/index.mjs
CHANGED
|
@@ -2,9 +2,40 @@
|
|
|
2
2
|
* Changelog generation utilities.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import('./types.ts').FetchChangelogDataOptions} FetchChangelogDataOptions
|
|
7
|
+
* @typedef {import('./types.ts').ChangelogData} ChangelogData
|
|
8
|
+
* @typedef {import('./types.ts').ChangelogChange} ChangelogChange
|
|
9
|
+
* @typedef {import('./types.ts').ChangelogAuthor} ChangelogAuthor
|
|
10
|
+
* @typedef {import('./types.ts').ChangelogPackage} ChangelogPackage
|
|
11
|
+
* @typedef {import('./types.ts').ChangelogTitle} ChangelogTitle
|
|
12
|
+
* @typedef {import('./types.ts').ChangelogCredits} ChangelogCredits
|
|
13
|
+
* @typedef {import('./types.ts').MarkdownBlock} MarkdownBlock
|
|
14
|
+
* @typedef {import('./types.ts').MarkdownInline} MarkdownInline
|
|
15
|
+
*/
|
|
16
|
+
|
|
5
17
|
export { generateChangelog } from './generateChangelog.mjs';
|
|
6
18
|
export * from './loadChangelogConfig.mjs';
|
|
7
19
|
export * from './fetchChangelogs.mjs';
|
|
20
|
+
export { fetchChangelogData } from './fetchChangelogData.mjs';
|
|
21
|
+
export {
|
|
22
|
+
creditAuthors,
|
|
23
|
+
groupBy,
|
|
24
|
+
labelValues,
|
|
25
|
+
readLabels,
|
|
26
|
+
sortByTitle,
|
|
27
|
+
} from './changelogGrouping.mjs';
|
|
28
|
+
export {
|
|
29
|
+
bulletList,
|
|
30
|
+
formatAuthor,
|
|
31
|
+
formatDate,
|
|
32
|
+
formatReference,
|
|
33
|
+
formatSubHeader,
|
|
34
|
+
joinBlocks,
|
|
35
|
+
joinWords,
|
|
36
|
+
section,
|
|
37
|
+
} from './changelogMarkdown.mjs';
|
|
38
|
+
export { mapPrefixes, matchPrefix, parseTitle } from './changelogTitle.mjs';
|
|
8
39
|
// Moved to the git utilities, where the rest of the local git plumbing lives. Re-exported because
|
|
9
40
|
// `@mui/internal-code-infra/changelog` is a published entry point and this was part of it.
|
|
10
41
|
export { findLatestTaggedVersion } from '../utils/git.mjs';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { retry } from '@octokit/plugin-retry';
|
|
2
|
+
import { throttling } from '@octokit/plugin-throttling';
|
|
3
|
+
import { Octokit } from '@octokit/rest';
|
|
4
|
+
|
|
5
|
+
import { persistentAuthStrategy } from '../utils/github.mjs';
|
|
6
|
+
|
|
7
|
+
const ThrottledOctokit = Octokit.plugin(throttling, retry);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Waits out short rate limits. Longer ones fail with the original error.
|
|
11
|
+
*
|
|
12
|
+
* @param {number} retryAfter - Seconds until the request may be retried
|
|
13
|
+
* @param {unknown} options
|
|
14
|
+
* @param {unknown} octokit
|
|
15
|
+
* @param {number} retryCount
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
function shouldRetryRateLimit(retryAfter, options, octokit, retryCount) {
|
|
19
|
+
return retryAfter <= 60 && retryCount < 3;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A client that authenticates as the developer running it.
|
|
24
|
+
*
|
|
25
|
+
* @returns {Octokit}
|
|
26
|
+
*/
|
|
27
|
+
export function createOctokit() {
|
|
28
|
+
return new ThrottledOctokit({
|
|
29
|
+
authStrategy: persistentAuthStrategy,
|
|
30
|
+
throttle: {
|
|
31
|
+
onRateLimit: shouldRetryRateLimit,
|
|
32
|
+
onSecondaryRateLimit: shouldRetryRateLimit,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
package/src/changelog/types.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { Octokit } from '@octokit/rest';
|
|
2
|
+
// eslint-disable-next-line import/extensions
|
|
3
|
+
import type { RepoInfo } from '../utils/git.mjs';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Commit details fetched from GitHub including PR information and labels.
|
|
3
7
|
*/
|
|
@@ -438,3 +442,166 @@ export interface GenerateChangelogResult {
|
|
|
438
442
|
all: string[];
|
|
439
443
|
};
|
|
440
444
|
}
|
|
445
|
+
|
|
446
|
+
export type GitHubRepository = Pick<RepoInfo, 'owner' | 'repo'>;
|
|
447
|
+
|
|
448
|
+
export interface ReleaseRef {
|
|
449
|
+
/**
|
|
450
|
+
* The ref as given. A local `HEAD` is replaced by its SHA.
|
|
451
|
+
*/
|
|
452
|
+
ref: string;
|
|
453
|
+
sha: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface ChangelogAuthor {
|
|
457
|
+
/**
|
|
458
|
+
* `null` for a commit author without a linked GitHub account.
|
|
459
|
+
*/
|
|
460
|
+
login: string | null;
|
|
461
|
+
/**
|
|
462
|
+
* Git author name. Only known for direct commits.
|
|
463
|
+
*/
|
|
464
|
+
name: string | null;
|
|
465
|
+
association: 'team' | 'community' | 'first-timer';
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* A merged pull request, or a commit that landed without one.
|
|
470
|
+
*/
|
|
471
|
+
export interface ChangelogChange {
|
|
472
|
+
/**
|
|
473
|
+
* Subject of the commit, without the references that the other fields already carry: the pull
|
|
474
|
+
* request it belongs to and, for a cherry-pick, the original pull request and its author.
|
|
475
|
+
*/
|
|
476
|
+
title: string;
|
|
477
|
+
/**
|
|
478
|
+
* Full commit message.
|
|
479
|
+
*/
|
|
480
|
+
message: string;
|
|
481
|
+
sha: string;
|
|
482
|
+
/**
|
|
483
|
+
* Page of the pull request, or of the commit when there is none.
|
|
484
|
+
*/
|
|
485
|
+
url: string;
|
|
486
|
+
labels: string[];
|
|
487
|
+
/**
|
|
488
|
+
* Whether the pull request has the `breaking` or the `breaking change` label.
|
|
489
|
+
*/
|
|
490
|
+
isBreakingChange: boolean;
|
|
491
|
+
pullRequest: { number: number; title: string; body: string } | null;
|
|
492
|
+
/**
|
|
493
|
+
* `null` when the GitHub account was deleted.
|
|
494
|
+
*/
|
|
495
|
+
author: ChangelogAuthor | null;
|
|
496
|
+
/**
|
|
497
|
+
* When the pull request was opened, or the commit authored. ISO 8601.
|
|
498
|
+
*/
|
|
499
|
+
createdAt: string | null;
|
|
500
|
+
/**
|
|
501
|
+
* When the pull request was merged, or the commit committed. ISO 8601.
|
|
502
|
+
*/
|
|
503
|
+
mergedAt: string | null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface ChangelogPackage {
|
|
507
|
+
name: string;
|
|
508
|
+
version: string | null;
|
|
509
|
+
/**
|
|
510
|
+
* Whether the package can't be published: marked as private, or without a version.
|
|
511
|
+
*/
|
|
512
|
+
private: boolean;
|
|
513
|
+
/**
|
|
514
|
+
* Directory relative to the workspace root, with `/` separators. `.` for the root package.
|
|
515
|
+
*/
|
|
516
|
+
path: string;
|
|
517
|
+
/**
|
|
518
|
+
* Whether the version differs from the previous release. `true` for a new package, `null` when the
|
|
519
|
+
* previous release isn't available locally.
|
|
520
|
+
*/
|
|
521
|
+
changed: boolean | null;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* What happened in a release, as JSON-serializable data.
|
|
526
|
+
*/
|
|
527
|
+
export interface ChangelogData {
|
|
528
|
+
repository: GitHubRepository;
|
|
529
|
+
previous: ReleaseRef;
|
|
530
|
+
release: ReleaseRef;
|
|
531
|
+
version: string;
|
|
532
|
+
/**
|
|
533
|
+
* ISO 8601.
|
|
534
|
+
*/
|
|
535
|
+
date: string;
|
|
536
|
+
/**
|
|
537
|
+
* Oldest first.
|
|
538
|
+
*/
|
|
539
|
+
changes: ChangelogChange[];
|
|
540
|
+
/**
|
|
541
|
+
* Named packages in the working tree, sorted by path. Without a workspace, only the root package.
|
|
542
|
+
*/
|
|
543
|
+
packages: ChangelogPackage[];
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export interface FetchChangelogDataOptions {
|
|
547
|
+
/**
|
|
548
|
+
* A directory of the released workspace.
|
|
549
|
+
* @default process.cwd()
|
|
550
|
+
*/
|
|
551
|
+
cwd?: string;
|
|
552
|
+
/**
|
|
553
|
+
* Repository name. Defaults to the one the checkout's remote points at.
|
|
554
|
+
*/
|
|
555
|
+
repo?: string;
|
|
556
|
+
/**
|
|
557
|
+
* @default 'mui'
|
|
558
|
+
*/
|
|
559
|
+
org?: string;
|
|
560
|
+
/**
|
|
561
|
+
* Ref of the previous release. Defaults to the closest version tag before `release`.
|
|
562
|
+
*/
|
|
563
|
+
lastRelease?: string;
|
|
564
|
+
/**
|
|
565
|
+
* Ref of the release.
|
|
566
|
+
* @default 'HEAD'
|
|
567
|
+
*/
|
|
568
|
+
release?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Defaults to the version `release` is a tag of, else the version of the root package.
|
|
571
|
+
*/
|
|
572
|
+
version?: string;
|
|
573
|
+
/**
|
|
574
|
+
* Defaults to the commit date when `release` is a version tag, else now.
|
|
575
|
+
*/
|
|
576
|
+
date?: Date | string;
|
|
577
|
+
/**
|
|
578
|
+
* Include commits that landed without a pull request.
|
|
579
|
+
* @default false
|
|
580
|
+
*/
|
|
581
|
+
includeDirectCommits?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* GitHub client. Defaults to one authenticated as the developer running it.
|
|
584
|
+
*/
|
|
585
|
+
octokit?: Octokit;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Title of a change, split into its leading `[prefixes]` and the rest.
|
|
590
|
+
*/
|
|
591
|
+
export interface ChangelogTitle {
|
|
592
|
+
prefixes: string[];
|
|
593
|
+
text: string;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Authors to credit, once each.
|
|
598
|
+
*/
|
|
599
|
+
export interface ChangelogCredits {
|
|
600
|
+
all: ChangelogAuthor[];
|
|
601
|
+
team: ChangelogAuthor[];
|
|
602
|
+
community: ChangelogAuthor[];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export type MarkdownInline = string | false | null | undefined;
|
|
606
|
+
|
|
607
|
+
export type MarkdownBlock = MarkdownInline | readonly MarkdownBlock[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|