Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

60
tools/lint-md/lint-md.mjs Normal file
View File

@ -0,0 +1,60 @@
import fs from 'node:fs';
import { parseArgs } from 'node:util';
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import presetLintNode from 'remark-preset-lint-node';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';
const { values: { format }, positionals: paths } = parseArgs({
options: {
format: { type: 'boolean', default: false },
},
allowPositionals: true,
});
if (!paths.length) {
console.error('Usage: lint-md.mjs [--format] <path> [<path> ...]');
process.exit(1);
}
const linter = unified()
.use(remarkParse)
.use(presetLintNode)
.use(remarkStringify);
paths.forEach(async (path) => {
const file = await read(path);
// We need to calculate `fileContents` before running `linter.process(files)`
// because `linter.process(files)` mutates `file` and returns it as `result`.
// So we won't be able to use `file` after that to see if its contents have
// changed as they will have been altered to the changed version.
const fileContents = file.toString();
const result = await linter.process(file);
const isDifferent = fileContents !== result.toString();
if (path.startsWith('doc/api/')) {
if (!fileContents.includes('introduced_in')) {
console.error(`${path} is missing an 'introduced_in' version. Please add one.`);
process.exitCode = 1;
}
}
if (format) {
if (isDifferent) {
fs.writeFileSync(path, result.toString());
}
} else {
if (isDifferent) {
process.exitCode = 1;
const cmd = process.platform === 'win32' ? 'vcbuild' : 'make';
console.error(`${path} is not formatted. Please run '${cmd} format-md'.`);
}
if (result.messages.length) {
process.exitCode = 1;
console.error(reporter(result));
}
}
});

View File

@ -0,0 +1,42 @@
#!/usr/bin/env node
import fs from 'node:fs';
import { createInterface } from 'node:readline';
const dataFolder = new URL('../../doc/changelogs/', import.meta.url);
const result = [];
async function getVersionsFromFile(file) {
const input = fs.createReadStream(file);
let toc = false;
for await (const line of createInterface({
input,
crlfDelay: Infinity,
})) {
if (toc === false && line === '<table>') {
toc = true;
} else if (toc && line[0] !== '<') {
input.close();
return;
} else if (toc && line.startsWith('<a')) {
result.push(line.slice(line.indexOf('>') + 1, -'</a><br/>'.length));
} else if (toc && line.startsWith('<b><a')) {
result.push(line.slice(line.indexOf('>', 3) + 1, -'</a></b><br/>'.length));
}
}
}
const filesToCheck = [];
const dir = await fs.promises.opendir(dataFolder);
for await (const dirent of dir) {
if (dirent.isFile()) {
filesToCheck.push(
getVersionsFromFile(new URL(dirent.name, dataFolder)),
);
}
}
await Promise.all(filesToCheck);
console.log(`NODE_RELEASED_VERSIONS=${result.join(',')}`);

2554
tools/lint-md/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"name": "lint-md",
"description": "markdown linting",
"version": "1.0.0",
"dependencies": {
"remark-parse": "^11.0.0",
"remark-preset-lint-node": "^5.1.2",
"remark-stringify": "^11.0.0",
"to-vfile": "^8.0.0",
"unified": "^11.0.5",
"vfile-reporter": "^8.1.1"
}
}