@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.
- package/dist/bin/make-index.js +37 -74
- package/dist/bin/node-compat.d.ts +2 -0
- package/dist/bin/node-compat.js +337 -0
- package/dist/bin/zci.js +33 -44
- package/dist/bin/zenfs-test.js +45 -78
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/make_index.d.ts +20 -0
- package/dist/make_index.js +49 -0
- package/dist/node_compat/analysis.d.ts +53 -0
- package/dist/node_compat/analysis.js +60 -0
- package/dist/node_compat/changelog.d.ts +25 -0
- package/dist/node_compat/changelog.js +60 -0
- package/dist/node_compat/commits.d.ts +26 -0
- package/dist/node_compat/commits.js +66 -0
- package/dist/node_compat/config.d.ts +6 -0
- package/dist/node_compat/config.js +18 -0
- package/dist/node_compat/docs.d.ts +58 -0
- package/dist/node_compat/docs.js +213 -0
- package/dist/node_compat/git.d.ts +22 -0
- package/dist/node_compat/git.js +74 -0
- package/dist/node_compat/index.d.ts +10 -0
- package/dist/node_compat/index.js +11 -0
- package/dist/node_compat/node.d.ts +42 -0
- package/dist/node_compat/node.js +84 -0
- package/dist/node_compat/output.d.ts +29 -0
- package/dist/node_compat/output.js +95 -0
- package/dist/node_compat/pr.d.ts +59 -0
- package/dist/node_compat/pr.js +125 -0
- package/dist/node_compat/state.d.ts +18 -0
- package/dist/node_compat/state.js +12 -0
- package/dist/node_compat/versions.d.ts +5 -0
- package/dist/node_compat/versions.js +13 -0
- package/dist/node_compat/zenfs.d.ts +3 -0
- package/dist/node_compat/zenfs.js +108 -0
- package/package.json +7 -2
package/dist/bin/zenfs-test.js
CHANGED
|
@@ -1,86 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
3
|
+
import { Command, InvalidArgumentError, Option } from 'commander';
|
|
3
4
|
import { execFileSync } from 'node:child_process';
|
|
4
5
|
import { existsSync, globSync, mkdirSync, rmSync } from 'node:fs';
|
|
5
6
|
import { join, parse, basename } from 'node:path';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
8
|
+
import { styleText } from 'node:util';
|
|
9
|
+
function positiveInteger(value) {
|
|
10
|
+
const number = Number(value);
|
|
11
|
+
if (!Number.isSafeInteger(number) || number < 1)
|
|
12
|
+
throw new InvalidArgumentError('Not a positive integer.');
|
|
13
|
+
return number;
|
|
14
|
+
}
|
|
15
|
+
const cli = new Command('zenfs-test')
|
|
16
|
+
.description('Runs the ZenFS test suites')
|
|
17
|
+
.argument('[paths...]', 'The setup files to run tests on')
|
|
18
|
+
.optionsGroup('Behavior:')
|
|
19
|
+
.option('-a, --auto', 'Automatically detect setup files')
|
|
20
|
+
.option('-b, --build', 'Run the npm build script prior to running tests')
|
|
21
|
+
.option('-c, --common', 'Also run tests not specific to any backend')
|
|
22
|
+
.option('-e, --exit-on-fail', 'If any tests suites fail, exit immediately')
|
|
23
|
+
.option('-r, --runs <n>', 'Run tests n times and print average result', positiveInteger, 1)
|
|
24
|
+
.option('-t, --test <glob>', 'Which FS test suite(s) to run')
|
|
25
|
+
.option('-f, --force', 'Whether to use --test-force-exit')
|
|
26
|
+
.option('-I, --inspect', 'Use the inspector for debugging')
|
|
27
|
+
.option('-s, --skip <pattern...>', 'Skip tests with names matching the given pattern; can be passed multiple times', [])
|
|
28
|
+
.option('-d, --debug', 'Output debug messages from the test runner')
|
|
29
|
+
.optionsGroup('Output:')
|
|
30
|
+
.option('-v, --verbose', 'Output verbose messages')
|
|
31
|
+
.addOption(new Option('-q, --quiet', "Don't output normal messages").conflicts('verbose'))
|
|
32
|
+
.option('-l, --log <level>', 'Change the default log level for test output; can be a number or string')
|
|
33
|
+
.option('-N, --file-names', 'Use full file paths for tests from setup files instead of the base name')
|
|
34
|
+
.option('-C, --ci', 'Continuous integration (CI) mode, which reports to the GitHub Checks API; requires @octokit/action')
|
|
35
|
+
.optionsGroup('Coverage:')
|
|
36
|
+
.option('--coverage <dir>', 'Override the default coverage data directory', 'tests/.coverage')
|
|
37
|
+
.option('-p, --preserve', 'Do not delete or report coverage data')
|
|
38
|
+
.option('--report', 'Report coverage along with test results')
|
|
39
|
+
.option('--report-only', 'Only report coverage')
|
|
40
|
+
.option('--clean', 'Only clean up the coverage directory')
|
|
41
|
+
.option('--profile', 'Record performance profiles')
|
|
42
|
+
.parse();
|
|
43
|
+
const options = cli.opts();
|
|
44
|
+
const [positionals] = cli.processedArgs;
|
|
39
45
|
function debug(...args) {
|
|
40
46
|
if (options.debug || process.env.DEBUG)
|
|
41
47
|
console.debug(styleText('dim', '[debug]'), ...args.map(a => (typeof a === 'string' ? styleText('dim', a) : a)));
|
|
42
48
|
}
|
|
43
|
-
if (options.help) {
|
|
44
|
-
console.log(`zenfs-test [...options] <...paths>
|
|
45
|
-
|
|
46
|
-
Paths: The setup files to run tests on
|
|
47
|
-
|
|
48
|
-
Behavior:
|
|
49
|
-
-a, --auto Automatically detect setup files
|
|
50
|
-
-b, --build Run the npm build script prior to running tests
|
|
51
|
-
-c, --common Also run tests not specific to any backend
|
|
52
|
-
-e, --exit-on-fail If any tests suites fail, exit immediately
|
|
53
|
-
-r, --runs <n> Run tests n times and print average result
|
|
54
|
-
-t, --test <glob> Which FS test suite(s) to run
|
|
55
|
-
-f, --force Whether to use --test-force-exit
|
|
56
|
-
-I, --inspect Use the inspector for debugging
|
|
57
|
-
-s, --skip <pattern> Skip tests with names matching the given pattern. Can be specified multiple times.
|
|
58
|
-
-d, --debug Output debug messages from the test runner
|
|
59
|
-
|
|
60
|
-
Output:
|
|
61
|
-
-h, --help Outputs this help message
|
|
62
|
-
-v, --verbose Output verbose messages
|
|
63
|
-
-q, --quiet Don't output normal messages
|
|
64
|
-
-l, --logs <level> Change the default log level for test output. Level can be a number or string
|
|
65
|
-
-N, --file-names Use full file paths for tests from setup files instead of the base name
|
|
66
|
-
-C, --ci Continuous integration (CI) mode. This interacts with the Github
|
|
67
|
-
Checks API for better test status. Requires @octokit/action
|
|
68
|
-
|
|
69
|
-
Coverage:
|
|
70
|
-
--coverage <dir> Override the default coverage data directory
|
|
71
|
-
-p, --preserve Do not delete or report coverage data
|
|
72
|
-
--report Report coverage along with test results
|
|
73
|
-
--report-only ONLY report coverage
|
|
74
|
-
--clean ONLY clean up coverage directory
|
|
75
|
-
--profile Record performance profiles`);
|
|
76
|
-
process.exit();
|
|
77
|
-
}
|
|
78
|
-
if (options.quiet && options.verbose) {
|
|
79
|
-
console.error('ERROR: Can not specify --verbose and --quiet');
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
49
|
process.env.NODE_V8_COVERAGE = options.coverage;
|
|
83
|
-
process.env.ZENFS_LOG_LEVEL = options.log;
|
|
50
|
+
process.env.ZENFS_LOG_LEVEL = options.log ?? '';
|
|
84
51
|
if (options.verbose)
|
|
85
52
|
process.env.VERBOSE = '1';
|
|
86
53
|
if (options.clean) {
|
|
@@ -99,14 +66,14 @@ function report() {
|
|
|
99
66
|
rmSync(options.coverage, { recursive: true });
|
|
100
67
|
}
|
|
101
68
|
}
|
|
102
|
-
if (options
|
|
69
|
+
if (options.reportOnly) {
|
|
103
70
|
report();
|
|
104
71
|
process.exit();
|
|
105
72
|
}
|
|
106
|
-
const nRuns =
|
|
73
|
+
const nRuns = options.runs;
|
|
107
74
|
let ci;
|
|
108
75
|
if (options.ci) {
|
|
109
|
-
if (
|
|
76
|
+
if (nRuns != 1) {
|
|
110
77
|
console.error('Cannot use --ci with --runs');
|
|
111
78
|
process.exit(1);
|
|
112
79
|
}
|
|
@@ -206,7 +173,7 @@ async function runTests(config) {
|
|
|
206
173
|
console.error(`${styleText(['red', 'bold'], 'failed')}${identText} ${time()}`);
|
|
207
174
|
await ci?.completeCheck(statusName, 'failure');
|
|
208
175
|
process.exitCode = 1;
|
|
209
|
-
if (options
|
|
176
|
+
if (options.exitOnFail)
|
|
210
177
|
process.exit();
|
|
211
178
|
return;
|
|
212
179
|
}
|
|
@@ -230,12 +197,12 @@ for (const setupFile of positionals) {
|
|
|
230
197
|
continue;
|
|
231
198
|
}
|
|
232
199
|
process.env.SETUP = setupFile;
|
|
233
|
-
const name = options
|
|
200
|
+
const name = options.fileNames && !options.ci ? setupFile : parse(setupFile).name;
|
|
234
201
|
await runTests({
|
|
235
202
|
name,
|
|
236
203
|
args: [`${testsGlob.replaceAll("'", "\\'")}`, process.env.CMD || ''],
|
|
237
204
|
shouldSkip() {
|
|
238
|
-
return basename(setupFile).startsWith('_') && options.auto;
|
|
205
|
+
return basename(setupFile).startsWith('_') && !!options.auto;
|
|
239
206
|
},
|
|
240
207
|
});
|
|
241
208
|
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as makeIndex } from './make_index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as makeIndex } from './make_index.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IndexData } from '@zenfs/core';
|
|
2
|
+
import { type Stats } from 'node:fs';
|
|
3
|
+
export interface MakeIndexOptions {
|
|
4
|
+
/** Glob patterns of paths to leave out */
|
|
5
|
+
ignore?: string[];
|
|
6
|
+
/** Include entries from devices other than the one `root` is on */
|
|
7
|
+
xdev?: boolean;
|
|
8
|
+
/** Called with a message when an entry crosses a device boundary */
|
|
9
|
+
onWarning?(message: string): void;
|
|
10
|
+
/** Called when an entry can not be added. If not set, the error is thrown. */
|
|
11
|
+
onError?(path: string, error: Error): void;
|
|
12
|
+
/** Called for each entry added to the index */
|
|
13
|
+
onEntry?(path: string, stats: Stats): void;
|
|
14
|
+
/** Called for each path left out because it matches `ignore` */
|
|
15
|
+
onIgnore?(path: string): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates an index of the host file system at `root`, for use with backends like `Fetch`
|
|
19
|
+
*/
|
|
20
|
+
export default function makeIndex(root?: string, options?: MakeIndexOptions): IndexData;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { constants as c, lstatSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join, matchesGlob, relative } from 'node:path/posix';
|
|
3
|
+
const supportedTypes = new Set([c.S_IFBLK, c.S_IFCHR, c.S_IFIFO, c.S_IFSOCK, c.S_IFREG, c.S_IFDIR, c.S_IFLNK]);
|
|
4
|
+
/**
|
|
5
|
+
* Creates an index of the host file system at `root`, for use with backends like `Fetch`
|
|
6
|
+
*/
|
|
7
|
+
export default function makeIndex(root = '.', options = {}) {
|
|
8
|
+
const entries = new Map();
|
|
9
|
+
const seenDevs = new Set();
|
|
10
|
+
function computeEntries(path) {
|
|
11
|
+
try {
|
|
12
|
+
if (options.ignore?.some(pattern => matchesGlob(path, pattern))) {
|
|
13
|
+
options.onIgnore?.(path);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const stats = lstatSync(path);
|
|
17
|
+
if (!seenDevs.size)
|
|
18
|
+
seenDevs.add(stats.dev);
|
|
19
|
+
else if (!seenDevs.has(stats.dev))
|
|
20
|
+
if (options.xdev) {
|
|
21
|
+
options.onWarning?.(`--xdev: Adding entries from device ${stats.dev} (${path}). You may get duplicate inos which MUST be de-duplicated manually.`);
|
|
22
|
+
seenDevs.add(stats.dev);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
options.onWarning?.(`Ignoring ${path} because it crosses a device boundary`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!supportedTypes.has(stats.mode & c.S_IFMT))
|
|
29
|
+
throw new Error(`Unknown file type: 0o${(stats.mode & c.S_IFMT).toString(8)}`);
|
|
30
|
+
entries.set('/' + relative(root, path), stats);
|
|
31
|
+
options.onEntry?.(path, stats);
|
|
32
|
+
if (stats.isDirectory()) {
|
|
33
|
+
for (const file of readdirSync(path))
|
|
34
|
+
computeEntries(join(path, file));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
39
|
+
if (!options.onError)
|
|
40
|
+
throw error;
|
|
41
|
+
options.onError(path, error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
computeEntries(root);
|
|
45
|
+
return {
|
|
46
|
+
version: 1,
|
|
47
|
+
entries: Object.fromEntries(entries),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Api } from './docs.js';
|
|
2
|
+
import type { NodeRepository } from './node.js';
|
|
3
|
+
import type { PR } from './pr.js';
|
|
4
|
+
import type { MarkEntry, Marks } from './state.js';
|
|
5
|
+
/**
|
|
6
|
+
* `auto` means every API the PR added exists in ZenFS.
|
|
7
|
+
*/
|
|
8
|
+
export type Status = 'pending' | 'resolved' | 'ignored' | 'auto';
|
|
9
|
+
export interface ApiStatus {
|
|
10
|
+
api: Api;
|
|
11
|
+
present: boolean;
|
|
12
|
+
mark?: MarkEntry;
|
|
13
|
+
}
|
|
14
|
+
export interface PRStatus {
|
|
15
|
+
pr: PR;
|
|
16
|
+
status: Status;
|
|
17
|
+
mark?: MarkEntry;
|
|
18
|
+
/** Affected APIs that ZenFS lacks */
|
|
19
|
+
missing: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface PRFilter {
|
|
22
|
+
/** Include PRs released in this version or later */
|
|
23
|
+
since?: string;
|
|
24
|
+
/** Include unreleased PRs that landed on or after this ISO date */
|
|
25
|
+
landedSince?: string;
|
|
26
|
+
semver?: PR['semver'][];
|
|
27
|
+
status?: Status[];
|
|
28
|
+
/** Release lines the PR must have been released in */
|
|
29
|
+
lines?: number[];
|
|
30
|
+
/** Tags the PR must have; prefix with `!` to exclude */
|
|
31
|
+
tags?: string[];
|
|
32
|
+
/** Matched against the title and commit messages */
|
|
33
|
+
grep?: RegExp;
|
|
34
|
+
/** Only PRs not in any release */
|
|
35
|
+
unreleased?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Combines Node.js data, the ZenFS probe, and manual marks.
|
|
39
|
+
*/
|
|
40
|
+
export declare class Analysis {
|
|
41
|
+
readonly node: NodeRepository;
|
|
42
|
+
readonly apis: Map<string, ApiStatus>;
|
|
43
|
+
readonly prs: Map<number, PRStatus>;
|
|
44
|
+
constructor(node: NodeRepository, marks: Marks);
|
|
45
|
+
/**
|
|
46
|
+
* @param prs Defaults to every PR
|
|
47
|
+
*/
|
|
48
|
+
filterPRs(filter: PRFilter, prs?: Iterable<PRStatus>): PRStatus[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sorts newest first, by landing date on the tracked ref or by first release.
|
|
52
|
+
*/
|
|
53
|
+
export declare function byNewest(left: PRStatus, right: PRStatus): number;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { compareVersions } from './versions.js';
|
|
2
|
+
import * as zenfs from './zenfs.js';
|
|
3
|
+
/**
|
|
4
|
+
* Combines Node.js data, the ZenFS probe, and manual marks.
|
|
5
|
+
*/
|
|
6
|
+
export class Analysis {
|
|
7
|
+
node;
|
|
8
|
+
apis = new Map();
|
|
9
|
+
prs = new Map();
|
|
10
|
+
constructor(node, marks) {
|
|
11
|
+
this.node = node;
|
|
12
|
+
const snapshot = new Map(marks);
|
|
13
|
+
for (const api of node.apis.values()) {
|
|
14
|
+
this.apis.set(api.id, { api, present: zenfs.has(api), mark: snapshot.get(api.id) });
|
|
15
|
+
}
|
|
16
|
+
for (const pr of node.prs.values()) {
|
|
17
|
+
const mark = snapshot.get(pr.key);
|
|
18
|
+
const missing = [...pr.apis.added, ...pr.apis.changed].filter(id => {
|
|
19
|
+
const status = this.apis.get(id);
|
|
20
|
+
return status && !status.present && !status.mark;
|
|
21
|
+
});
|
|
22
|
+
const auto = pr.apis.added.length > 0 && pr.apis.added.every(id => this.apis.get(id)?.present);
|
|
23
|
+
this.prs.set(pr.number, { pr, mark, missing, status: mark?.status ?? (auto ? 'auto' : 'pending') });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @param prs Defaults to every PR
|
|
28
|
+
*/
|
|
29
|
+
filterPRs(filter, prs = this.prs.values()) {
|
|
30
|
+
const { since, landedSince, grep } = filter;
|
|
31
|
+
return [...prs].filter(({ pr, status }) => {
|
|
32
|
+
if (filter.unreleased && pr.releases.length)
|
|
33
|
+
return false;
|
|
34
|
+
if (since && pr.releases.length && !pr.releases.some(release => compareVersions(release.version, since) >= 0))
|
|
35
|
+
return false;
|
|
36
|
+
if (landedSince && !pr.releases.length && (pr.commits[0]?.date ?? '') < landedSince)
|
|
37
|
+
return false;
|
|
38
|
+
if (filter.semver && !filter.semver.includes(pr.semver))
|
|
39
|
+
return false;
|
|
40
|
+
if (filter.status && !filter.status.includes(status))
|
|
41
|
+
return false;
|
|
42
|
+
if (filter.lines && !filter.lines.every(line => pr.releases.some(release => release.line == line)))
|
|
43
|
+
return false;
|
|
44
|
+
const { tags } = pr;
|
|
45
|
+
for (const tag of filter.tags ?? []) {
|
|
46
|
+
if (tag.startsWith('!') ? tags.includes(tag.slice(1)) : !tags.includes(tag))
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (grep && !grep.test(pr.title) && !pr.commits.some(commit => grep.test(commit.body)))
|
|
50
|
+
return false;
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sorts newest first, by landing date on the tracked ref or by first release.
|
|
57
|
+
*/
|
|
58
|
+
export function byNewest(left, right) {
|
|
59
|
+
return right.pr.date.localeCompare(left.pr.date) || right.pr.number - left.pr.number;
|
|
60
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Repository } from './git.js';
|
|
2
|
+
export type Semver = 'major' | 'minor' | 'patch';
|
|
3
|
+
export interface Release {
|
|
4
|
+
version: string;
|
|
5
|
+
/** Major version */
|
|
6
|
+
line: number;
|
|
7
|
+
/** ISO date */
|
|
8
|
+
date: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Entry {
|
|
11
|
+
pr: number;
|
|
12
|
+
/** Abbreviated hash on the release branch */
|
|
13
|
+
commit: string;
|
|
14
|
+
subsystems: string[];
|
|
15
|
+
title: string;
|
|
16
|
+
author: string;
|
|
17
|
+
semver: Semver;
|
|
18
|
+
revert: boolean;
|
|
19
|
+
release: Release;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parses the commit lines of a changelog, including the duplicates listed under notable changes.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parse(text: string): Entry[];
|
|
25
|
+
export declare function read(repo: Repository): Entry[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { parseVersion } from './versions.js';
|
|
2
|
+
const releaseHeading = /^## (?<date>\d{4}-\d{2}-\d{2}), Version (?<version>\d+\.\d+\.\d+)/;
|
|
3
|
+
const changelogLine = /^\* \\\[\[`(?<commit>[0-9a-f]+)`\]\([^)]*\)\] - (?<rest>.+?)\s*\[#(?<pr>\d+)\]\(https:\/\/github\.com\/nodejs\/node\/pull\/\d+\)\s*$/;
|
|
4
|
+
/**
|
|
5
|
+
* Parses the commit lines of a changelog, including the duplicates listed under notable changes.
|
|
6
|
+
*/
|
|
7
|
+
export function parse(text) {
|
|
8
|
+
const entries = [];
|
|
9
|
+
let release;
|
|
10
|
+
for (const line of text.split('\n')) {
|
|
11
|
+
const heading = releaseHeading.exec(line);
|
|
12
|
+
if (heading?.groups) {
|
|
13
|
+
const { date, version } = heading.groups;
|
|
14
|
+
release = { version, line: parseVersion(version)[0], date };
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const match = release && changelogLine.exec(line);
|
|
18
|
+
if (!release || !match?.groups)
|
|
19
|
+
continue;
|
|
20
|
+
let rest = match.groups.rest;
|
|
21
|
+
let semver = 'patch';
|
|
22
|
+
for (let tag; (tag = /^\*\*\((?<tag>[^)]+)\)\*\*\s*/.exec(rest)); rest = rest.slice(tag[0].length)) {
|
|
23
|
+
if (tag.groups?.tag == 'SEMVER-MAJOR')
|
|
24
|
+
semver = 'major';
|
|
25
|
+
if (tag.groups?.tag == 'SEMVER-MINOR' && semver != 'major')
|
|
26
|
+
semver = 'minor';
|
|
27
|
+
}
|
|
28
|
+
const revert = /^_\*\*Revert\*\*_ "/.test(rest);
|
|
29
|
+
if (revert)
|
|
30
|
+
rest = rest.replace(/^_\*\*Revert\*\*_ "/, '');
|
|
31
|
+
const subject = /^\*\*(?<subsystems>[^*]+)\*\*: (?<text>.*)$/.exec(rest);
|
|
32
|
+
if (!subject?.groups)
|
|
33
|
+
continue;
|
|
34
|
+
let { text: title } = subject.groups;
|
|
35
|
+
let author = '';
|
|
36
|
+
const authorStart = title.lastIndexOf(' (');
|
|
37
|
+
if (authorStart != -1 && title.endsWith(')')) {
|
|
38
|
+
author = title.slice(authorStart + 2, -1);
|
|
39
|
+
title = title.slice(0, authorStart);
|
|
40
|
+
}
|
|
41
|
+
if (revert)
|
|
42
|
+
title = title.replace(/"$/, '');
|
|
43
|
+
entries.push({
|
|
44
|
+
pr: Number(match.groups.pr),
|
|
45
|
+
commit: match.groups.commit,
|
|
46
|
+
subsystems: subject.groups.subsystems.split(',').map(name => name.trim()),
|
|
47
|
+
title,
|
|
48
|
+
author,
|
|
49
|
+
semver,
|
|
50
|
+
revert,
|
|
51
|
+
release,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return entries;
|
|
55
|
+
}
|
|
56
|
+
export function read(repo) {
|
|
57
|
+
const listing = repo.git(['ls-tree', repo.ref, 'doc/changelogs/']);
|
|
58
|
+
const hashes = [...listing.matchAll(/^\S+ blob (\S+)\tdoc\/changelogs\/CHANGELOG_V\d+\.md$/gm)].map(match => match[1]);
|
|
59
|
+
return [...repo.readBlobs(hashes).values()].flatMap(parse);
|
|
60
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Repository } from './git.js';
|
|
2
|
+
export interface Subject {
|
|
3
|
+
revert: boolean;
|
|
4
|
+
subsystems: string[];
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseSubject(subject: string): Subject | undefined;
|
|
8
|
+
export declare function matchesSubsystem(subsystems: string[], wanted: string[]): boolean;
|
|
9
|
+
export interface Commit {
|
|
10
|
+
hash: string;
|
|
11
|
+
/** ISO date */
|
|
12
|
+
date: string;
|
|
13
|
+
author: string;
|
|
14
|
+
subject: string;
|
|
15
|
+
body: string;
|
|
16
|
+
files: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function readCommits(repo: Repository, subsystems: string[]): Commit[];
|
|
19
|
+
export interface ApiHistory {
|
|
20
|
+
added: string[];
|
|
21
|
+
removed: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Finds which APIs each commit added or removed by diffing the parsed docs before and after it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readApiHistory(repo: Repository, docs: string, hashes: Set<string>): Map<string, ApiHistory>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
2
|
+
import { Api } from './docs.js';
|
|
3
|
+
const subjectPattern = /^(?<revert>Revert ")?(?:\[v\d+\.x\]\s*)?(?<subsystems>[\w./-]+(?:,\s?[\w./-]+)*): (?<title>.+?)"?$/;
|
|
4
|
+
export function parseSubject(subject) {
|
|
5
|
+
const match = subjectPattern.exec(subject);
|
|
6
|
+
if (!match?.groups)
|
|
7
|
+
return;
|
|
8
|
+
const { revert, subsystems, title } = match.groups;
|
|
9
|
+
return { revert: !!revert, subsystems: subsystems.split(',').map(name => name.trim()), title };
|
|
10
|
+
}
|
|
11
|
+
export function matchesSubsystem(subsystems, wanted) {
|
|
12
|
+
return subsystems.some(name => wanted.some(want => name == want || name.startsWith(want + '/')));
|
|
13
|
+
}
|
|
14
|
+
export function readCommits(repo, subsystems) {
|
|
15
|
+
const commits = [];
|
|
16
|
+
for (const record of repo.git(['log', repo.ref, '--format=%x1e%H%x1f%cI%x1f%an%x1f%s%x1f%b']).split('\x1e')) {
|
|
17
|
+
if (!record)
|
|
18
|
+
continue;
|
|
19
|
+
const [hash, date, author, subject, body] = record.split('\x1f');
|
|
20
|
+
const parsed = parseSubject(subject);
|
|
21
|
+
if (!parsed || !matchesSubsystem(parsed.subsystems, subsystems))
|
|
22
|
+
continue;
|
|
23
|
+
commits.push({ hash, date, author, subject, body: body.trim(), files: [] });
|
|
24
|
+
}
|
|
25
|
+
if (!commits.length)
|
|
26
|
+
return commits;
|
|
27
|
+
const byHash = new Map(commits.map(commit => [commit.hash, commit]));
|
|
28
|
+
const hashes = commits.map(commit => commit.hash).join('\n');
|
|
29
|
+
for (const record of repo.git(['log', '--no-walk=unsorted', '--stdin', '--format=%x1e%H', '--name-only'], hashes).split('\x1e')) {
|
|
30
|
+
const [hash, ...files] = record.trim().split('\n');
|
|
31
|
+
const commit = byHash.get(hash);
|
|
32
|
+
if (commit)
|
|
33
|
+
commit.files = files.filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
return commits;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Finds which APIs each commit added or removed by diffing the parsed docs before and after it.
|
|
39
|
+
*/
|
|
40
|
+
export function readApiHistory(repo, docs, hashes) {
|
|
41
|
+
const changes = [];
|
|
42
|
+
for (const record of repo.git(['log', repo.ref, '--format=%x1e%H', '--raw', '--no-abbrev', '--', docs]).split('\x1e')) {
|
|
43
|
+
const [hash, raw] = record.split('\n').filter(Boolean);
|
|
44
|
+
if (!hashes.has(hash) || !raw)
|
|
45
|
+
continue;
|
|
46
|
+
const [, , before, after] = raw.split(/\s+/);
|
|
47
|
+
changes.push({ hash, before, after });
|
|
48
|
+
}
|
|
49
|
+
const blobs = repo.readBlobs([...new Set(changes.flatMap(change => [change.before, change.after]))]);
|
|
50
|
+
const parsed = new Map();
|
|
51
|
+
function idsOf(blob) {
|
|
52
|
+
let ids = parsed.get(blob);
|
|
53
|
+
if (!ids)
|
|
54
|
+
parsed.set(blob, (ids = new Set(Api.parse(blobs.get(blob) ?? '').keys())));
|
|
55
|
+
return ids;
|
|
56
|
+
}
|
|
57
|
+
const history = new Map();
|
|
58
|
+
for (const { hash, before, after } of changes) {
|
|
59
|
+
const old = idsOf(before), current = idsOf(after);
|
|
60
|
+
history.set(hash, {
|
|
61
|
+
added: [...current].filter(id => !old.has(id)),
|
|
62
|
+
removed: [...old].filter(id => !current.has(id)),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return history;
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
2
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { JSONFileMap } from 'utilium/fs';
|
|
6
|
+
export const configPath = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'zenfs', 'node-compat.json');
|
|
7
|
+
/**
|
|
8
|
+
* Path to the saved Node.js clone, if any.
|
|
9
|
+
*/
|
|
10
|
+
export function savedRepo() {
|
|
11
|
+
if (!existsSync(configPath))
|
|
12
|
+
return;
|
|
13
|
+
return new JSONFileMap(configPath, { overwrite_invalid: true }).get('repo');
|
|
14
|
+
}
|
|
15
|
+
export function saveRepo(path) {
|
|
16
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
17
|
+
new JSONFileMap(configPath, { overwrite_invalid: true }).set('repo', path);
|
|
18
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Repository } from './git.js';
|
|
2
|
+
export declare const fs = "doc/api/fs.md";
|
|
3
|
+
export interface ApiChange {
|
|
4
|
+
versions: string[];
|
|
5
|
+
pr?: number;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export type ApiKind = 'module' | 'class' | 'member' | 'constant';
|
|
9
|
+
export declare class Api {
|
|
10
|
+
/** `<owner>.<path>` for modules, classes, and constants; `<Class>#<member>` for members */
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly kind: ApiKind;
|
|
13
|
+
/** The object the API lives on: `fs`, `fsPromises`, or a class name */
|
|
14
|
+
readonly owner: string;
|
|
15
|
+
/** Property path from `owner` */
|
|
16
|
+
readonly path: (string | symbol)[];
|
|
17
|
+
/** Top-level docs section */
|
|
18
|
+
readonly section: string;
|
|
19
|
+
/** Headings from the docs, without backticks */
|
|
20
|
+
readonly signatures: string[];
|
|
21
|
+
readonly added: string[];
|
|
22
|
+
readonly deprecated: string[];
|
|
23
|
+
readonly removed: string[];
|
|
24
|
+
readonly changes: ApiChange[];
|
|
25
|
+
stability?: number;
|
|
26
|
+
constructor(
|
|
27
|
+
/** `<owner>.<path>` for modules, classes, and constants; `<Class>#<member>` for members */
|
|
28
|
+
id: string, kind: ApiKind,
|
|
29
|
+
/** The object the API lives on: `fs`, `fsPromises`, or a class name */
|
|
30
|
+
owner: string,
|
|
31
|
+
/** Property path from `owner` */
|
|
32
|
+
path: (string | symbol)[],
|
|
33
|
+
/** Top-level docs section */
|
|
34
|
+
section: string);
|
|
35
|
+
/**
|
|
36
|
+
* Adds metadata from a YAML doc comment, skipping duplicates.
|
|
37
|
+
*/
|
|
38
|
+
merge(yaml: Yaml): void;
|
|
39
|
+
toJSON(): this & {
|
|
40
|
+
path: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @param text Contents of the `fs` docs
|
|
44
|
+
*/
|
|
45
|
+
static parse(text: string): Map<string, Api>;
|
|
46
|
+
static read(repo: Repository, path?: string): Map<string, Api>;
|
|
47
|
+
}
|
|
48
|
+
export interface Yaml {
|
|
49
|
+
added: string[];
|
|
50
|
+
deprecated: string[];
|
|
51
|
+
removed: string[];
|
|
52
|
+
changes: ApiChange[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parses the subset of YAML used in `<!-- YAML -->` doc comments.
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseYaml(lines: string[]): Yaml;
|
|
58
|
+
export declare function formatPath(path: (string | symbol)[]): string;
|