@zenfs/devel 0.1.0 → 1.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.
@@ -0,0 +1,213 @@
1
+ export const fs = 'doc/api/fs.md';
2
+ export class Api {
3
+ id;
4
+ kind;
5
+ owner;
6
+ path;
7
+ section;
8
+ /** Headings from the docs, without backticks */
9
+ signatures = [];
10
+ added = [];
11
+ deprecated = [];
12
+ removed = [];
13
+ changes = [];
14
+ stability;
15
+ constructor(
16
+ /** `<owner>.<path>` for modules, classes, and constants; `<Class>#<member>` for members */
17
+ id, kind,
18
+ /** The object the API lives on: `fs`, `fsPromises`, or a class name */
19
+ owner,
20
+ /** Property path from `owner` */
21
+ path,
22
+ /** Top-level docs section */
23
+ section) {
24
+ this.id = id;
25
+ this.kind = kind;
26
+ this.owner = owner;
27
+ this.path = path;
28
+ this.section = section;
29
+ }
30
+ /**
31
+ * Adds metadata from a YAML doc comment, skipping duplicates.
32
+ */
33
+ merge(yaml) {
34
+ for (const key of ['added', 'deprecated', 'removed']) {
35
+ for (const version of yaml[key])
36
+ if (!this[key].includes(version))
37
+ this[key].push(version);
38
+ }
39
+ for (const change of yaml.changes) {
40
+ if (!this.changes.some(other => other.pr == change.pr && other.description == change.description))
41
+ this.changes.push(change);
42
+ }
43
+ }
44
+ toJSON() {
45
+ return { ...this, path: formatPath(this.path) };
46
+ }
47
+ /**
48
+ * @param text Contents of the `fs` docs
49
+ */
50
+ static parse(text) {
51
+ const apis = new Map();
52
+ const lines = text.split('\n');
53
+ let section = '';
54
+ let currentClass;
55
+ let classDepth = 0;
56
+ let current;
57
+ let inConstants = false;
58
+ function add(id, kind, owner, path, signature) {
59
+ let api = apis.get(id);
60
+ if (!api)
61
+ apis.set(id, (api = new Api(id, kind, owner, path, section)));
62
+ api.signatures.push(signature);
63
+ return api;
64
+ }
65
+ for (let i = 0; i < lines.length; i++) {
66
+ const line = lines[i];
67
+ if (line.startsWith('<!-- YAML') && current) {
68
+ const end = lines.indexOf('-->', i);
69
+ current.merge(parseYaml(lines.slice(i + 1, end)));
70
+ i = end;
71
+ continue;
72
+ }
73
+ const stability = /^> Stability: (\d)/.exec(line);
74
+ if (stability && current && current.stability === undefined) {
75
+ current.stability = Number(stability[1]);
76
+ continue;
77
+ }
78
+ const constant = inConstants && /^\s*<td><code>(\w+)<\/code><\/td>/.exec(line);
79
+ if (constant) {
80
+ add('fs.constants.' + constant[1], 'constant', 'fs', ['constants', constant[1]], constant[1]);
81
+ continue;
82
+ }
83
+ const heading = /^(#{2,5}) (.*)$/.exec(line);
84
+ if (!heading)
85
+ continue;
86
+ const [, hashes, title] = heading;
87
+ const depth = hashes.length;
88
+ current = undefined;
89
+ if (depth == 2)
90
+ section = title;
91
+ if (depth <= 4)
92
+ inConstants = title == 'FS constants';
93
+ if (depth <= classDepth)
94
+ currentClass = undefined;
95
+ const classHeading = /^Class:? `?((?:fs\.)?(\w+))`?$/.exec(title);
96
+ if (classHeading) {
97
+ currentClass = classHeading[2];
98
+ classDepth = depth;
99
+ current = add(classHeading[1], 'class', currentClass, [], title);
100
+ continue;
101
+ }
102
+ const code = /^`(.+)`$/.exec(title)?.[1] ?? (/^(new )?[\w$]+(\.[\w$]+|\[Symbol\.\w+\])*(\(.*)?$/.test(title) ? title : undefined);
103
+ if (!code)
104
+ continue;
105
+ const constructor = /^new (?:fs\.)?(\w+)\(/.exec(code);
106
+ if (constructor) {
107
+ current = add('fs.' + constructor[1], 'class', constructor[1], [], code);
108
+ continue;
109
+ }
110
+ const expression = /^[\w$.]+(?:\[Symbol\.\w+\])?/.exec(code)?.[0];
111
+ if (!expression)
112
+ continue;
113
+ const [prefix] = expression.split(/[.[]/);
114
+ if (prefix == 'fs' || prefix == 'fsPromises') {
115
+ const path = parsePath(expression.slice(prefix.length));
116
+ current = add(prefix + formatPath(['', ...path]), 'module', prefix, path, code);
117
+ continue;
118
+ }
119
+ const owner = prefix == 'watcher' ? currentClass : ownerPrefixes[prefix];
120
+ if (!owner)
121
+ continue;
122
+ const path = parsePath(expression.slice(prefix.length));
123
+ current = add(owner + '#' + formatPath(path), 'member', owner, path, code);
124
+ }
125
+ return apis;
126
+ }
127
+ static read(repo, path = fs) {
128
+ return this.parse(repo.show(path));
129
+ }
130
+ }
131
+ const versionListKeys = ['added', 'deprecated', 'removed'];
132
+ function isVersionListKey(key) {
133
+ return !!key && versionListKeys.includes(key);
134
+ }
135
+ /**
136
+ * Parses the subset of YAML used in `<!-- YAML -->` doc comments.
137
+ */
138
+ export function parseYaml(lines) {
139
+ const yaml = { added: [], deprecated: [], removed: [], changes: [] };
140
+ let key;
141
+ let change;
142
+ let field;
143
+ for (const line of lines) {
144
+ const top = /^([\w-]+):\s*(.*)$/.exec(line);
145
+ if (top) {
146
+ key = top[1];
147
+ if (top[2] && isVersionListKey(key))
148
+ yaml[key].push(top[2]);
149
+ continue;
150
+ }
151
+ if (key != 'changes') {
152
+ const item = /^\s*-\s+(\S+)/.exec(line);
153
+ if (item && isVersionListKey(key))
154
+ yaml[key].push(item[1]);
155
+ continue;
156
+ }
157
+ const entry = /^(\s*-\s+)?(version|pr-url|description):\s*(.*)$/.exec(line.trim().startsWith('-') ? line : line.trimStart());
158
+ if (entry) {
159
+ if (entry[1])
160
+ yaml.changes.push((change = { versions: [], description: '' }));
161
+ if (!change)
162
+ continue;
163
+ field = entry[2];
164
+ const value = entry[3].trim();
165
+ if (field == 'version' && value)
166
+ change.versions.push(value);
167
+ if (field == 'pr-url')
168
+ change.pr = Number(/\/pull\/(\d+)/.exec(value)?.[1]) || undefined;
169
+ if (field == 'description')
170
+ change.description = value;
171
+ continue;
172
+ }
173
+ if (!change)
174
+ continue;
175
+ const item = /^\s*-\s+(\S+)\s*$/.exec(line);
176
+ if (item && field == 'version') {
177
+ change.versions.push(item[1]);
178
+ continue;
179
+ }
180
+ if (field == 'description')
181
+ change.description += ' ' + line.trim();
182
+ }
183
+ return yaml;
184
+ }
185
+ const ownerPrefixes = {
186
+ fs: 'fs',
187
+ fsPromises: 'fsPromises',
188
+ filehandle: 'FileHandle',
189
+ dir: 'Dir',
190
+ dirent: 'Dirent',
191
+ stats: 'Stats',
192
+ statfs: 'StatFs',
193
+ readStream: 'ReadStream',
194
+ writeStream: 'WriteStream',
195
+ utf8Stream: 'Utf8Stream',
196
+ };
197
+ /**
198
+ * Converts the expression in a doc heading into a property path.
199
+ */
200
+ function parsePath(expression) {
201
+ return [...expression.matchAll(/\.?([\w$]+)|\[Symbol\.(\w+)\]/g)].map(match => (match[2] ? wellKnownSymbol(match[2]) : match[1]));
202
+ }
203
+ /**
204
+ * Looks up a well-known symbol case-insensitively, returning the name as a string if there is no such symbol.
205
+ */
206
+ function wellKnownSymbol(name) {
207
+ const key = Object.getOwnPropertyNames(Symbol).find(key => key.toLowerCase() == name.toLowerCase());
208
+ const symbol = key && Reflect.get(Symbol, key);
209
+ return typeof symbol == 'symbol' ? symbol : `[Symbol.${name}]`;
210
+ }
211
+ export function formatPath(path) {
212
+ return path.map((part, index) => (typeof part == 'symbol' ? `[${part.description}]` : index ? '.' + part : part)).join('');
213
+ }
@@ -0,0 +1,22 @@
1
+ export declare class Repository {
2
+ /** Defaults to the upstream of `main`, or `HEAD` if there is none */
3
+ readonly ref: string;
4
+ readonly path: string;
5
+ /** Resolved commit of `ref` */
6
+ readonly hash: string;
7
+ /** Commit date of `ref` */
8
+ readonly date: Date;
9
+ constructor(path: string,
10
+ /** Defaults to the upstream of `main`, or `HEAD` if there is none */
11
+ ref?: string);
12
+ private static defaultRef;
13
+ git(args: string[], input?: string): string;
14
+ /**
15
+ * Reads a file as of `ref`.
16
+ */
17
+ show(file: string): string;
18
+ /**
19
+ * Reads many blobs with a single `git cat-file` process.
20
+ */
21
+ readBlobs(hashes: string[]): Map<string, string>;
22
+ }
@@ -0,0 +1,74 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { execFileSync } from 'node:child_process';
3
+ import { resolve } from 'node:path';
4
+ function git(path, args, input) {
5
+ return execFileSync('git', ['-C', path, ...args], { encoding: 'utf8', maxBuffer: 1 << 30, input, stdio: ['pipe', 'pipe', 'pipe'] });
6
+ }
7
+ export class Repository {
8
+ ref;
9
+ path;
10
+ /** Resolved commit of `ref` */
11
+ hash;
12
+ /** Commit date of `ref` */
13
+ date;
14
+ constructor(path,
15
+ /** Defaults to the upstream of `main`, or `HEAD` if there is none */
16
+ ref = Repository.defaultRef(path)) {
17
+ this.ref = ref;
18
+ path = resolve(path);
19
+ this.path = path;
20
+ try {
21
+ git(path, ['rev-parse', '--git-dir']);
22
+ }
23
+ catch {
24
+ throw new Error(`Not a git repository: ${path}`);
25
+ }
26
+ try {
27
+ const [hash, date] = git(path, ['log', '-1', '--format=%H%x1f%cI', ref]).trim().split('\x1f');
28
+ this.hash = hash;
29
+ this.date = new Date(date);
30
+ }
31
+ catch {
32
+ throw new Error(`Unknown ref in ${path}: ${ref}`);
33
+ }
34
+ }
35
+ static defaultRef(path) {
36
+ try {
37
+ return git(path, ['rev-parse', '--abbrev-ref', 'main@{upstream}']).trim();
38
+ }
39
+ catch {
40
+ return 'HEAD';
41
+ }
42
+ }
43
+ git(args, input) {
44
+ return git(this.path, args, input);
45
+ }
46
+ /**
47
+ * Reads a file as of `ref`.
48
+ */
49
+ show(file) {
50
+ return this.git(['show', `${this.ref}:${file}`]);
51
+ }
52
+ /**
53
+ * Reads many blobs with a single `git cat-file` process.
54
+ */
55
+ readBlobs(hashes) {
56
+ const blobs = new Map();
57
+ if (!hashes.length)
58
+ return blobs;
59
+ const output = execFileSync('git', ['-C', this.path, 'cat-file', '--batch'], { input: hashes.join('\n') + '\n', maxBuffer: 1 << 30 });
60
+ let offset = 0;
61
+ while (offset < output.length) {
62
+ const headerEnd = output.indexOf(0x0a, offset);
63
+ const [hash, type, size] = output.subarray(offset, headerEnd).toString().split(' ');
64
+ if (type == 'missing') {
65
+ offset = headerEnd + 1;
66
+ continue;
67
+ }
68
+ const start = headerEnd + 1;
69
+ blobs.set(hash, output.subarray(start, start + Number(size)).toString());
70
+ offset = start + Number(size) + 1;
71
+ }
72
+ return blobs;
73
+ }
74
+ }
@@ -0,0 +1,10 @@
1
+ export * from './analysis.js';
2
+ export * as changelog from './changelog.js';
3
+ export * from './commits.js';
4
+ export * as docs from './docs.js';
5
+ export * from './git.js';
6
+ export * from './node.js';
7
+ export * from './pr.js';
8
+ export * from './state.js';
9
+ export * from './versions.js';
10
+ export * as zenfs from './zenfs.js';
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ export * from './analysis.js';
3
+ export * as changelog from './changelog.js';
4
+ export * from './commits.js';
5
+ export * as docs from './docs.js';
6
+ export * from './git.js';
7
+ export * from './node.js';
8
+ export * from './pr.js';
9
+ export * from './state.js';
10
+ export * from './versions.js';
11
+ export * as zenfs from './zenfs.js';
@@ -0,0 +1,42 @@
1
+ import * as changelog from './changelog.js';
2
+ import * as docs from './docs.js';
3
+ import { Repository } from './git.js';
4
+ import { PR } from './pr.js';
5
+ export interface NodeRepositoryInit {
6
+ /** Path to a Node.js clone */
7
+ repo: string;
8
+ /** Git ref to read history, changelogs, and docs from */
9
+ ref?: string;
10
+ subsystems?: string[];
11
+ /** Docs file within the Node.js repository */
12
+ docs?: string;
13
+ }
14
+ export interface Resolved {
15
+ /** Key for marks */
16
+ key: string;
17
+ pr?: PR;
18
+ api?: docs.Api;
19
+ }
20
+ export declare class NodeRepository extends Repository {
21
+ readonly prs: Map<number, PR>;
22
+ readonly apis: Map<string, docs.Api>;
23
+ /** Every release found in the changelogs, newest first */
24
+ readonly releases: changelog.Release[];
25
+ /**
26
+ * Loads PRs, releases, and the API surface from a local Node.js clone.
27
+ */
28
+ constructor({ subsystems, docs: docPath, ...options }: NodeRepositoryInit);
29
+ get latest(): changelog.Release | undefined;
30
+ /**
31
+ * Date of the first release at or after a version.
32
+ */
33
+ releaseDate(version: string): string | undefined;
34
+ /**
35
+ * Resolves a PR number, `#number`, PR URL, or case-insensitive API ID.
36
+ */
37
+ resolve(input: string): Resolved | undefined;
38
+ /**
39
+ * Like `resolve`, but API IDs may contain `*` wildcards.
40
+ */
41
+ resolveAll(input: string): Resolved[];
42
+ }
@@ -0,0 +1,84 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import * as changelog from './changelog.js';
3
+ import { matchesSubsystem, readApiHistory, readCommits } from './commits.js';
4
+ import * as docs from './docs.js';
5
+ import { Repository } from './git.js';
6
+ import { PR } from './pr.js';
7
+ import { compareVersions } from './versions.js';
8
+ export class NodeRepository extends Repository {
9
+ prs = new Map();
10
+ apis = new Map();
11
+ /** Every release found in the changelogs, newest first */
12
+ releases = [];
13
+ /**
14
+ * Loads PRs, releases, and the API surface from a local Node.js clone.
15
+ */
16
+ constructor({ subsystems = ['fs'], docs: docPath = docs.fs, ...options }) {
17
+ super(options.repo, options.ref);
18
+ const commits = readCommits(this, subsystems);
19
+ const history = readApiHistory(this, docPath, new Set(commits.map(commit => commit.hash)));
20
+ const getPR = (number) => {
21
+ let pr = this.prs.get(number);
22
+ if (!pr)
23
+ this.prs.set(number, (pr = new PR(number)));
24
+ return pr;
25
+ };
26
+ for (const commit of commits.toReversed()) {
27
+ const number = Number(/^PR-URL: https:\/\/github\.com\/nodejs\/node\/pull\/(\d+)/m.exec(commit.body)?.[1]);
28
+ if (number)
29
+ getPR(number).addCommit(commit, history.get(commit.hash));
30
+ }
31
+ const releases = new Map();
32
+ for (const entry of changelog.read(this)) {
33
+ releases.set(entry.release.version, entry.release);
34
+ if (matchesSubsystem(entry.subsystems, subsystems) || this.prs.has(entry.pr))
35
+ getPR(entry.pr).addRelease(entry);
36
+ }
37
+ for (const api of docs.Api.read(this, docPath).values()) {
38
+ this.apis.set(api.id, api);
39
+ for (const change of api.changes) {
40
+ const pr = change.pr && this.prs.get(change.pr);
41
+ if (pr && !pr.apis.changed.includes(api.id))
42
+ pr.apis.changed.push(api.id);
43
+ }
44
+ }
45
+ this.releases = [...releases.values()].sort((left, right) => compareVersions(right.version, left.version));
46
+ }
47
+ get latest() {
48
+ return this.releases[0];
49
+ }
50
+ /**
51
+ * Date of the first release at or after a version.
52
+ */
53
+ releaseDate(version) {
54
+ return this.releases.filter(release => compareVersions(release.version, version) >= 0).at(-1)?.date;
55
+ }
56
+ /**
57
+ * Resolves a PR number, `#number`, PR URL, or case-insensitive API ID.
58
+ */
59
+ resolve(input) {
60
+ const number = Number(/^(?:#|.*\/pull\/)?(\d+)\/?$/.exec(input.trim())?.[1]);
61
+ if (number) {
62
+ const pr = this.prs.get(number);
63
+ return pr && { key: pr.key, pr };
64
+ }
65
+ const name = input.trim().replace(/\(.*\)$/, '');
66
+ const api = this.apis.get(name) ?? [...this.apis.values()].find(api => api.id.toLowerCase() == name.toLowerCase());
67
+ return api && { key: api.id, api };
68
+ }
69
+ /**
70
+ * Like `resolve`, but API IDs may contain `*` wildcards.
71
+ */
72
+ resolveAll(input) {
73
+ if (!input.includes('*')) {
74
+ const resolved = this.resolve(input);
75
+ return resolved ? [resolved] : [];
76
+ }
77
+ const source = input
78
+ .trim()
79
+ .replace(/[.+?^${}()|[\]\\]/g, '\\$&')
80
+ .replaceAll('*', '.*');
81
+ const pattern = new RegExp(`^${source}$`, 'i');
82
+ return [...this.apis.values()].filter(api => pattern.test(api.id)).map(api => ({ key: api.id, api }));
83
+ }
84
+ }
@@ -0,0 +1,29 @@
1
+ import { type InspectColor } from 'node:util';
2
+ import type { PRStatus, Status } from './analysis.js';
3
+ import type { PR } from './pr.js';
4
+ import type { MarkEntry } from './state.js';
5
+ export declare function displayPath(path: string): string;
6
+ export declare const statusStyles: Record<Status, InspectColor>;
7
+ export declare const semverStyles: Record<PR['semver'], InspectColor>;
8
+ /**
9
+ * Creates an option parser for repeated, comma-separated values, optionally restricted to `choices`.
10
+ */
11
+ export declare function parseList<const T extends string = string>(choices?: readonly T[]): (value: string, previous: T[] | undefined) => T[];
12
+ export declare function parseIntegers(value: string, previous: number[] | undefined): number[];
13
+ export declare function parsePositiveInteger(value: string): number;
14
+ /**
15
+ * Compiles a case-insensitive pattern.
16
+ */
17
+ export declare function parseRegex(source: string): RegExp;
18
+ /**
19
+ * Pads text containing ANSI escapes to a visible width.
20
+ */
21
+ export declare function pad(text: string, width: number): string;
22
+ /**
23
+ * Shortens text to `width` when writing to a terminal.
24
+ */
25
+ export declare function truncate(text: string, width: number): string;
26
+ export declare function formatVersions(versions: string[]): string;
27
+ export declare function formatMark(mark: MarkEntry | undefined): string;
28
+ export declare function printFields(fields: [label: string, value: string][]): void;
29
+ export declare function printPRTable(rows: PRStatus[]): void;
@@ -0,0 +1,95 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { InvalidArgumentError } from 'commander';
3
+ import { homedir } from 'node:os';
4
+ import { relative } from 'node:path';
5
+ import { stripVTControlCharacters, styleText } from 'node:util';
6
+ export function displayPath(path) {
7
+ const fromCwd = relative(process.cwd(), path);
8
+ if (!fromCwd.startsWith('..'))
9
+ return fromCwd || '.';
10
+ return path.startsWith(homedir()) ? '~' + path.slice(homedir().length) : path;
11
+ }
12
+ export const statusStyles = { pending: 'yellow', auto: 'cyan', resolved: 'green', ignored: 'gray' };
13
+ export const semverStyles = { major: 'red', minor: 'magenta', patch: 'dim', unreleased: 'blue' };
14
+ /**
15
+ * Creates an option parser for repeated, comma-separated values, optionally restricted to `choices`.
16
+ */
17
+ export function parseList(choices) {
18
+ return (value, previous) => {
19
+ const values = value
20
+ .split(',')
21
+ .map(item => item.trim())
22
+ .filter(Boolean);
23
+ for (const item of values) {
24
+ if (choices && !choices.includes(item))
25
+ throw new InvalidArgumentError(`Expected ${choices.join(', ')}.`);
26
+ }
27
+ return [...(previous ?? []), ...values];
28
+ };
29
+ }
30
+ export function parseIntegers(value, previous) {
31
+ const numbers = parseList()(value, undefined).map(Number);
32
+ if (numbers.some(number => !Number.isSafeInteger(number)))
33
+ throw new InvalidArgumentError('Expected integers.');
34
+ return [...(previous ?? []), ...numbers];
35
+ }
36
+ export function parsePositiveInteger(value) {
37
+ const number = Number(value);
38
+ if (!Number.isSafeInteger(number) || number < 1)
39
+ throw new InvalidArgumentError('Expected a positive integer.');
40
+ return number;
41
+ }
42
+ /**
43
+ * Compiles a case-insensitive pattern.
44
+ */
45
+ export function parseRegex(source) {
46
+ try {
47
+ return new RegExp(source, 'i');
48
+ }
49
+ catch {
50
+ throw new InvalidArgumentError('Invalid regular expression.');
51
+ }
52
+ }
53
+ /**
54
+ * Pads text containing ANSI escapes to a visible width.
55
+ */
56
+ export function pad(text, width) {
57
+ return text + ' '.repeat(Math.max(0, width - stripVTControlCharacters(text).length));
58
+ }
59
+ /**
60
+ * Shortens text to `width` when writing to a terminal.
61
+ */
62
+ export function truncate(text, width) {
63
+ if (!process.stdout.isTTY || text.length <= width)
64
+ return text;
65
+ return text.slice(0, Math.max(0, width - 1)) + '…';
66
+ }
67
+ export function formatVersions(versions) {
68
+ return versions.join(', ') || styleText('blue', 'unreleased');
69
+ }
70
+ export function formatMark(mark) {
71
+ if (!mark)
72
+ return '';
73
+ return styleText(statusStyles[mark.status], mark.status) + styleText('dim', ` ${mark.date}`) + (mark.note ? ` — ${mark.note}` : '');
74
+ }
75
+ export function printFields(fields) {
76
+ for (const [label, value] of fields)
77
+ if (value)
78
+ console.log(styleText('bold', label.padEnd(10)), value);
79
+ }
80
+ export function printPRTable(rows) {
81
+ const versionWidth = Math.min(28, Math.max(10, ...rows.map(({ pr }) => formatVersions(pr.versions).length)));
82
+ const width = process.stdout.columns ?? Infinity;
83
+ for (const { pr, status, missing } of rows) {
84
+ const tags = pr.tags.length ? styleText('dim', ` [${pr.tags.join(', ')}]`) : '';
85
+ const extra = missing.length ? styleText('red', ` missing: ${missing.join(', ')}`) : '';
86
+ const prefix = [
87
+ pad(styleText('bold', '#' + pr.number), 7),
88
+ pad(styleText(semverStyles[pr.semver], pr.semver), 10),
89
+ pad(styleText(statusStyles[status], status), 8),
90
+ pad(truncate(formatVersions(pr.versions), versionWidth), versionWidth),
91
+ ].join(' ');
92
+ const fixed = 7 + 10 + 8 + versionWidth + 4;
93
+ console.log(prefix, truncate(pr.title, width - fixed) + tags + extra);
94
+ }
95
+ }
@@ -0,0 +1,59 @@
1
+ import type * as changelog from './changelog.js';
2
+ import { type ApiHistory, type Commit } from './commits.js';
3
+ export interface AffectedApis {
4
+ added: string[];
5
+ removed: string[];
6
+ changed: string[];
7
+ }
8
+ export declare class PR {
9
+ readonly number: number;
10
+ title: string;
11
+ subsystems: string[];
12
+ author: string;
13
+ semver: changelog.Semver | 'unreleased';
14
+ revert: boolean;
15
+ /** Commits on the tracked ref, oldest first */
16
+ readonly commits: Commit[];
17
+ /** Every release that lists the PR, ascending */
18
+ readonly releases: changelog.Release[];
19
+ /** Affected APIs, by ID */
20
+ readonly apis: AffectedApis;
21
+ constructor(number: number);
22
+ get url(): string;
23
+ /** Key for marks */
24
+ get key(): string;
25
+ /** Earliest version in each release line, ascending */
26
+ get versions(): string[];
27
+ /** Top-level directories touched */
28
+ get areas(): string[];
29
+ /** Heuristic labels derived from the title and touched areas */
30
+ get tags(): string[];
31
+ /** ISO date the PR landed on the tracked ref, or of its first release */
32
+ get date(): string;
33
+ /**
34
+ * Adds a commit in chronological order, along with the APIs it added or removed.
35
+ */
36
+ addCommit(commit: Commit, history?: ApiHistory): void;
37
+ addRelease(entry: changelog.Entry): void;
38
+ toJSON(): {
39
+ number: number;
40
+ url: string;
41
+ title: string;
42
+ subsystems: string[];
43
+ author: string;
44
+ semver: changelog.Semver | "unreleased";
45
+ revert: boolean;
46
+ commits: {
47
+ hash: string;
48
+ date: string;
49
+ author: string;
50
+ subject: string;
51
+ files: string[];
52
+ }[];
53
+ releases: changelog.Release[];
54
+ versions: string[];
55
+ areas: string[];
56
+ tags: string[];
57
+ apis: AffectedApis;
58
+ };
59
+ }