From a1d0aef60ee9253b53486332710815731306c85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 8 Jun 2021 12:44:33 +0200 Subject: [PATCH] tools: update doctool dependencies, migrate to ESM - Migrated to ESM because some dependencies now require it. - Did not update `highlight.js` to v11 because it has many breaking changes. - Used non-deprecated `highlight.js` API. Refs: https://github.com/highlightjs/highlight.js/issues/2277 Fixes: https://github.com/nodejs/node/issues/38938 Co-authored-by: Antoine du Hamel PR-URL: https://github.com/nodejs/node/pull/38966 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: Anto Aravinth Reviewed-By: Antoine du Hamel --- Makefile | 36 +- doc/api/index.md | 2 +- test/common/index.mjs | 2 + .../{test-apilinks.js => test-apilinks.mjs} | 23 +- ...-doctool-html.js => test-doctool-html.mjs} | 24 +- ...-doctool-json.js => test-doctool-json.mjs} | 22 +- ...-versions.js => test-doctool-versions.mjs} | 19 +- ...=> test-local-md-file-reference-regex.mjs} | 7 +- .../{test-make-doc.js => test-make-doc.mjs} | 27 +- tools/doc/README.md | 2 +- .../doc/{addon-verify.js => addon-verify.mjs} | 59 +- tools/doc/{allhtml.js => allhtml.mjs} | 12 +- tools/doc/{alljson.js => alljson.mjs} | 12 +- tools/doc/{apilinks.js => apilinks.mjs} | 11 +- tools/doc/{checkLinks.js => checkLinks.mjs} | 16 +- tools/doc/{common.js => common.mjs} | 14 +- tools/doc/{generate.js => generate.mjs} | 31 +- tools/doc/{html.js => html.mjs} | 54 +- tools/doc/{json.js => json.mjs} | 13 +- tools/doc/{markdown.js => markdown.mjs} | 13 +- tools/doc/package-lock.json | 612 +++++++++++++----- tools/doc/package.json | 18 +- tools/doc/{stability.js => stability.mjs} | 34 +- tools/doc/{type-parser.js => type-parser.mjs} | 6 +- tools/doc/{versions.js => versions.mjs} | 12 +- vcbuild.bat | 4 +- 26 files changed, 658 insertions(+), 427 deletions(-) rename test/doctool/{test-apilinks.js => test-apilinks.mjs} (71%) rename test/doctool/{test-doctool-html.js => test-doctool-html.mjs} (90%) rename test/doctool/{test-doctool-json.js => test-doctool-json.mjs} (91%) rename test/doctool/{test-doctool-versions.js => test-doctool-versions.mjs} (86%) rename test/doctool/{test-local-md-file-reference-regex.js => test-local-md-file-reference-regex.mjs} (84%) rename test/doctool/{test-make-doc.js => test-make-doc.mjs} (75%) rename tools/doc/{addon-verify.js => addon-verify.mjs} (63%) rename tools/doc/{allhtml.js => allhtml.mjs} (90%) rename tools/doc/{alljson.js => alljson.mjs} (84%) rename tools/doc/{apilinks.js => apilinks.mjs} (97%) rename tools/doc/{checkLinks.js => checkLinks.mjs} (89%) rename tools/doc/{common.js => common.mjs} (77%) rename tools/doc/{generate.js => generate.mjs} (87%) rename tools/doc/{html.js => html.mjs} (94%) rename tools/doc/{json.js => json.mjs} (98%) rename tools/doc/{markdown.js => markdown.mjs} (67%) rename tools/doc/{stability.js => stability.mjs} (79%) rename tools/doc/{type-parser.js => type-parser.mjs} (99%) rename tools/doc/{versions.js => versions.mjs} (87%) diff --git a/Makefile b/Makefile index 97c9562a559115..58260979e11458 100644 --- a/Makefile +++ b/Makefile @@ -338,7 +338,7 @@ test-valgrind: all test-check-deopts: all $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) --check-deopts parallel sequential -DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.js doc/api/addons.md +DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.mjs doc/api/addons.md ifeq ($(OSTYPE),aix) DOCBUILDSTAMP_PREREQS := $(DOCBUILDSTAMP_PREREQS) out/$(BUILDTYPE)/node.exp @@ -589,12 +589,12 @@ test-doc: doc-only lint-md ## Builds, lints, and verifies the docs. else \ $(PYTHON) tools/test.py $(PARALLEL_ARGS) doctool; \ fi - $(NODE) tools/doc/checkLinks.js . + $(NODE) tools/doc/checkLinks.mjs . .PHONY: test-doc-ci test-doc-ci: doc-only $(PYTHON) tools/test.py --shell $(NODE) $(TEST_CI_ARGS) $(PARALLEL_ARGS) doctool - $(NODE) tools/doc/checkLinks.js . + $(NODE) tools/doc/checkLinks.mjs . test-known-issues: all $(PYTHON) tools/test.py $(PARALLEL_ARGS) known_issues @@ -736,33 +736,33 @@ run-npm-ci = $(PWD)/$(NPM) ci LINK_DATA = out/doc/apilinks.json VERSIONS_DATA = out/previous-doc-versions.json -gen-api = tools/doc/generate.js --node-version=$(FULLVERSION) \ +gen-api = tools/doc/generate.mjs --node-version=$(FULLVERSION) \ --apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \ --versions-file=$(VERSIONS_DATA) -gen-apilink = tools/doc/apilinks.js $(LINK_DATA) $(wildcard lib/*.js) +gen-apilink = tools/doc/apilinks.mjs $(LINK_DATA) $(wildcard lib/*.js) -$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.js | out/doc +$(LINK_DATA): $(wildcard lib/*.js) tools/doc/apilinks.mjs | out/doc $(call available-node, $(gen-apilink)) # Regenerate previous versions data if the current version changes -$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.js - $(call available-node, tools/doc/versions.js $@) +$(VERSIONS_DATA): CHANGELOG.md src/node_version.h tools/doc/versions.mjs + $(call available-node, tools/doc/versions.mjs $@) -out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.js \ - tools/doc/markdown.js tools/doc/html.js tools/doc/json.js \ - tools/doc/apilinks.js $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api +out/doc/api/%.json out/doc/api/%.html: doc/api/%.md tools/doc/generate.mjs \ + tools/doc/markdown.mjs tools/doc/html.mjs tools/doc/json.mjs \ + tools/doc/apilinks.mjs $(VERSIONS_DATA) | $(LINK_DATA) out/doc/api $(call available-node, $(gen-api)) -out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.js \ - tools/doc/apilinks.js | out/doc/api - $(call available-node, tools/doc/allhtml.js) +out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.mjs \ + tools/doc/apilinks.mjs | out/doc/api + $(call available-node, tools/doc/allhtml.mjs) -out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.js | out/doc/api - $(call available-node, tools/doc/alljson.js) +out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.mjs | out/doc/api + $(call available-node, tools/doc/alljson.mjs) .PHONY: out/doc/api/stability -out/doc/api/stability: out/doc/api/all.json tools/doc/stability.js | out/doc/api - $(call available-node, tools/doc/stability.js) +out/doc/api/stability: out/doc/api/all.json tools/doc/stability.mjs | out/doc/api + $(call available-node, tools/doc/stability.mjs) .PHONY: docopen docopen: out/doc/api/all.html diff --git a/doc/api/index.md b/doc/api/index.md index f45aa17ecc451a..71c415afaa673a 100644 --- a/doc/api/index.md +++ b/doc/api/index.md @@ -1,6 +1,6 @@ diff --git a/test/common/index.mjs b/test/common/index.mjs index 73049004759869..9700fe8039c771 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -30,6 +30,7 @@ const { allowGlobals, mustCall, mustCallAtLeast, + mustSucceed, hasMultiLocalhost, skipIfDumbTerminal, skipIfEslintMissing, @@ -75,6 +76,7 @@ export { allowGlobals, mustCall, mustCallAtLeast, + mustSucceed, hasMultiLocalhost, skipIfDumbTerminal, skipIfEslintMissing, diff --git a/test/doctool/test-apilinks.js b/test/doctool/test-apilinks.mjs similarity index 71% rename from test/doctool/test-apilinks.js rename to test/doctool/test-apilinks.mjs index 91de4b79f865f4..e3c334b19e7234 100644 --- a/test/doctool/test-apilinks.js +++ b/test/doctool/test-apilinks.mjs @@ -1,14 +1,15 @@ -'use strict'; - -require('../common'); -const fixtures = require('../common/fixtures'); -const tmpdir = require('../common/tmpdir'); -const fs = require('fs'); -const assert = require('assert'); -const path = require('path'); -const { execFileSync } = require('child_process'); - -const script = path.join(__dirname, '..', '..', 'tools', 'doc', 'apilinks.js'); +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import tmpdir from '../common/tmpdir.js'; + +import assert from 'assert'; +import { execFileSync } from 'child_process'; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const script = fileURLToPath( + new URL('../../tools/doc/apilinks.mjs', import.meta.url)); const apilinks = fixtures.path('apilinks'); tmpdir.refresh(); diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.mjs similarity index 90% rename from test/doctool/test-doctool-html.js rename to test/doctool/test-doctool-html.mjs index dd651a66c1e94f..bf3475c6a61d0f 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.mjs @@ -1,22 +1,14 @@ -'use strict'; +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; -const common = require('../common'); -// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree. -try { - require('../../tools/node_modules/eslint/node_modules/js-yaml'); -} catch { - common.skip('missing js-yaml (eslint not present)'); -} +import assert from 'assert'; +import { readFileSync } from 'fs'; +import { createRequire } from 'module'; -const assert = require('assert'); -const { readFileSync } = require('fs'); -const fixtures = require('../common/fixtures'); -const { replaceLinks } = require('../../tools/doc/markdown.js'); -const html = require('../../tools/doc/html.js'); -const path = require('path'); +import * as html from '../../tools/doc/html.mjs'; +import { replaceLinks } from '../../tools/doc/markdown.mjs'; -module.paths.unshift( - path.join(__dirname, '..', '..', 'tools', 'doc', 'node_modules')); +const require = createRequire(new URL('../../tools/doc/', import.meta.url)); const unified = require('unified'); const markdown = require('remark-parse'); const remark2rehype = require('remark-rehype'); diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.mjs similarity index 91% rename from test/doctool/test-doctool-json.js rename to test/doctool/test-doctool-json.mjs index 70e6aa50f0c568..d3badf84f553b2 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.mjs @@ -1,21 +1,13 @@ -'use strict'; +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; -const common = require('../common'); -// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree. -try { - require('../../tools/node_modules/eslint/node_modules/js-yaml'); -} catch { - common.skip('missing js-yaml (eslint not present)'); -} +import assert from 'assert'; +import fs from 'fs'; +import { createRequire } from 'module'; -const assert = require('assert'); -const fs = require('fs'); -const path = require('path'); -const fixtures = require('../common/fixtures'); -const json = require('../../tools/doc/json.js'); +import * as json from '../../tools/doc/json.mjs'; -module.paths.unshift( - path.join(__dirname, '..', '..', 'tools', 'doc', 'node_modules')); +const require = createRequire(new URL('../../tools/doc/', import.meta.url)); const unified = require('unified'); const markdown = require('remark-parse'); diff --git a/test/doctool/test-doctool-versions.js b/test/doctool/test-doctool-versions.mjs similarity index 86% rename from test/doctool/test-doctool-versions.js rename to test/doctool/test-doctool-versions.mjs index 5673cc79402df7..92dedab9cc49ea 100644 --- a/test/doctool/test-doctool-versions.js +++ b/test/doctool/test-doctool-versions.mjs @@ -1,15 +1,16 @@ -'use strict'; +import '../common/index.mjs'; +import tmpdir from '../common/tmpdir.js'; -require('../common'); -const assert = require('assert'); -const { spawnSync } = require('child_process'); -const fs = require('fs'); -const path = require('path'); -const tmpdir = require('../common/tmpdir'); -const util = require('util'); +import assert from 'assert'; +import { spawnSync } from 'child_process'; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import util from 'util'; const debuglog = util.debuglog('test'); -const versionsTool = path.resolve(__dirname, '../../tools/doc/versions.js'); +const versionsTool = fileURLToPath( + new URL('../../tools/doc/versions.mjs', import.meta.url)); // At the time of writing these are the minimum expected versions. // New versions of Node.js do not have to be explicitly added here. diff --git a/test/doctool/test-local-md-file-reference-regex.js b/test/doctool/test-local-md-file-reference-regex.mjs similarity index 84% rename from test/doctool/test-local-md-file-reference-regex.js rename to test/doctool/test-local-md-file-reference-regex.mjs index f0fa922d89c860..3cc312b8401022 100644 --- a/test/doctool/test-local-md-file-reference-regex.js +++ b/test/doctool/test-local-md-file-reference-regex.mjs @@ -1,9 +1,8 @@ -'use strict'; +import '../common/index.mjs'; -require('../common'); -const assert = require('assert'); +import assert from 'assert'; -const { referenceToLocalMdFile } = require('../../tools/doc/markdown.js'); +import { referenceToLocalMdFile } from '../../tools/doc/markdown.mjs'; { const shouldBeSpotted = [ diff --git a/test/doctool/test-make-doc.js b/test/doctool/test-make-doc.mjs similarity index 75% rename from test/doctool/test-make-doc.js rename to test/doctool/test-make-doc.mjs index 7f4f3ae6fbfdfa..06ec6e028bf4e8 100644 --- a/test/doctool/test-make-doc.js +++ b/test/doctool/test-make-doc.mjs @@ -1,5 +1,9 @@ -'use strict'; -const common = require('../common'); +import * as common from '../common/index.mjs'; + +import assert from 'assert'; +import fs from 'fs'; +import path from 'path'; + if (common.isWindows) { common.skip('`make doc` does not run on Windows'); } @@ -7,14 +11,10 @@ if (common.isWindows) { // This tests that `make doc` generates the documentation properly. // Note that for this test to pass, `make doc` must be run first. -const assert = require('assert'); -const fs = require('fs'); -const path = require('path'); - -const apiPath = path.resolve(__dirname, '..', '..', 'out', 'doc', 'api'); -const mdPath = path.resolve(__dirname, '..', '..', 'doc', 'api'); -const allMD = fs.readdirSync(mdPath); -const allDocs = fs.readdirSync(apiPath); +const apiURL = new URL('../../out/doc/api/', import.meta.url); +const mdURL = new URL('../../doc/api/', import.meta.url); +const allMD = fs.readdirSync(mdURL); +const allDocs = fs.readdirSync(apiURL); assert.ok(allDocs.includes('index.html')); const actualDocs = allDocs.filter( @@ -33,7 +33,7 @@ for (const name of actualDocs) { ); } -const toc = fs.readFileSync(path.resolve(apiPath, 'index.html'), 'utf8'); +const toc = fs.readFileSync(new URL('./index.html', apiURL), 'utf8'); const re = /href="([^/]+\.html)"/; const globalRe = new RegExp(re, 'g'); const links = toc.match(globalRe); @@ -56,8 +56,9 @@ for (const actualDoc of actualDocs) { assert.ok( expectedDocs.includes(actualDoc), `${actualDoc} does not match TOC`); - assert.ok( - fs.statSync(path.join(apiPath, actualDoc)).size !== 0, + assert.notStrictEqual( + fs.statSync(new URL(`./${actualDoc}`, apiURL)).size, + 0, `${actualDoc} is empty` ); } diff --git a/tools/doc/README.md b/tools/doc/README.md index f2f37faa653d4d..e2aedfb1b56622 100644 --- a/tools/doc/README.md +++ b/tools/doc/README.md @@ -78,7 +78,7 @@ added: v0.10.0 * Returns: {SomeClass | null} The next `SomeClass` in line. -`SomeClass` must be registered in `tools/doc/type-parser.js` +`SomeClass` must be registered in `tools/doc/type-parser.mjs` to be properly parsed in `{type}` fields. ### SomeClass.someProperty diff --git a/tools/doc/addon-verify.js b/tools/doc/addon-verify.mjs similarity index 63% rename from tools/doc/addon-verify.js rename to tools/doc/addon-verify.mjs index 8093439d6d925c..ee4d597693b8b3 100644 --- a/tools/doc/addon-verify.js +++ b/tools/doc/addon-verify.mjs @@ -1,23 +1,21 @@ -'use strict'; - // doc/api/addons.md has a bunch of code. Extract it for verification // that the C++ code compiles and the js code runs. // Add .gyp files which will be used to compile the C++ code. // Modify the require paths in the js code to pull from the build tree. // Triggered from the build-addons target in the Makefile and vcbuild.bat. -const { mkdir, writeFile } = require('fs'); -const { resolve } = require('path'); -const vfile = require('to-vfile'); -const unified = require('unified'); -const remarkParse = require('remark-parse'); -const gfm = require('remark-gfm'); +import { mkdir, writeFile } from 'fs/promises'; + +import gfm from 'remark-gfm'; +import remarkParse from 'remark-parse'; +import { toVFile } from 'to-vfile'; +import unified from 'unified'; -const rootDir = resolve(__dirname, '..', '..'); -const doc = resolve(rootDir, 'doc', 'api', 'addons.md'); -const verifyDir = resolve(rootDir, 'test', 'addons'); +const rootDir = new URL('../../', import.meta.url); +const doc = new URL('./doc/api/addons.md', rootDir); +const verifyDir = new URL('./test/addons/', rootDir); -const file = vfile.readSync(doc, 'utf8'); +const file = toVFile.readSync(doc, 'utf8'); const tree = unified().use(remarkParse).use(gfm).parse(file); const addons = {}; let id = 0; @@ -26,7 +24,7 @@ let currentHeader; const validNames = /^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/; tree.children.forEach((node) => { if (node.type === 'heading') { - currentHeader = file.contents.slice( + currentHeader = file.value.slice( node.children[0].position.start.offset, node.position.end.offset); addons[currentHeader] = { files: {} }; @@ -38,9 +36,10 @@ tree.children.forEach((node) => { } }); -Object.keys(addons).forEach((header) => { - verifyFiles(addons[header].files, header); -}); +await Promise.all( + Object.keys(addons).flatMap( + (header) => verifyFiles(addons[header].files, header) + )); function verifyFiles(files, blockName) { const fileNames = Object.keys(files); @@ -48,13 +47,13 @@ function verifyFiles(files, blockName) { // Must have a .cc and a .js to be a valid test. if (!fileNames.some((name) => name.endsWith('.cc')) || !fileNames.some((name) => name.endsWith('.js'))) { - return; + return []; } blockName = blockName.toLowerCase().replace(/\s/g, '_').replace(/\W/g, ''); - const dir = resolve( + const dir = new URL( + `./${String(++id).padStart(2, '0')}_${blockName}/`, verifyDir, - `${String(++id).padStart(2, '0')}_${blockName}` ); files = fileNames.map((name) => { @@ -68,14 +67,14 @@ ${files[name].replace( `; } return { - path: resolve(dir, name), - name: name, - content: files[name] + content: files[name], + name, + url: new URL(`./${name}`, dir), }; }); files.push({ - path: resolve(dir, 'binding.gyp'), + url: new URL('./binding.gyp', dir), content: JSON.stringify({ targets: [ { @@ -87,16 +86,8 @@ ${files[name].replace( }) }); - mkdir(dir, () => { - // Ignore errors. + const dirCreation = mkdir(dir); - files.forEach(({ path, content }) => { - writeFile(path, content, (err) => { - if (err) - throw err; - - console.log(`Wrote ${path}`); - }); - }); - }); + return files.map(({ url, content }) => + dirCreation.then(() => writeFile(url, content))); } diff --git a/tools/doc/allhtml.js b/tools/doc/allhtml.mjs similarity index 90% rename from tools/doc/allhtml.js rename to tools/doc/allhtml.mjs index fad74e59d5cb2e..54a51dd6316010 100644 --- a/tools/doc/allhtml.js +++ b/tools/doc/allhtml.mjs @@ -1,18 +1,16 @@ -'use strict'; - // Build all.html by combining the generated toc and apicontent from each // of the generated html files. -const fs = require('fs'); +import fs from 'fs'; -const source = `${__dirname}/../../out/doc/api`; +const source = new URL('../../out/doc/api/', import.meta.url); // Get a list of generated API documents. const htmlFiles = fs.readdirSync(source, 'utf8') .filter((name) => name.includes('.html') && name !== 'all.html'); // Read the table of contents. -const toc = fs.readFileSync(source + '/index.html', 'utf8'); +const toc = fs.readFileSync(new URL('./index.html', source), 'utf8'); // Extract (and concatenate) the toc and apicontent from each document. let contents = ''; @@ -28,7 +26,7 @@ const seen = { for (const link of toc.match(//g)) { const href = /href="(.*?)"/.exec(link)[1]; if (!htmlFiles.includes(href) || seen[href]) continue; - const data = fs.readFileSync(source + '/' + href, 'utf8'); + const data = fs.readFileSync(new URL(`./${href}`, source), 'utf8'); // Split the doc. const match = /(<\/ul>\s*)?<\/\w+>\s*<\w+ id="apicontent">/.exec(data); @@ -74,7 +72,7 @@ all = all.slice(0, apiStart.index + apiStart[0].length) + all.slice(apiEnd); // Write results. -fs.writeFileSync(source + '/all.html', all, 'utf8'); +fs.writeFileSync(new URL('./all.html', source), all, 'utf8'); // Validate all hrefs have a target. const ids = new Set(); diff --git a/tools/doc/alljson.js b/tools/doc/alljson.mjs similarity index 84% rename from tools/doc/alljson.js rename to tools/doc/alljson.mjs index 0d697dde01d091..18afc29e7e9366 100644 --- a/tools/doc/alljson.js +++ b/tools/doc/alljson.mjs @@ -1,18 +1,16 @@ -'use strict'; - // Build all.json by combining the miscs, modules, classes, globals, and methods // from the generated json files. -const fs = require('fs'); +import fs from 'fs'; -const source = `${__dirname}/../../out/doc/api`; +const source = new URL('../../out/doc/api/', import.meta.url); // Get a list of generated API documents. const jsonFiles = fs.readdirSync(source, 'utf8') .filter((name) => name.includes('.json') && name !== 'all.json'); // Read the table of contents. -const toc = fs.readFileSync(source + '/index.html', 'utf8'); +const toc = fs.readFileSync(new URL('./index.html', source), 'utf8'); // Initialize results. Only these four data values will be collected. const results = { @@ -37,7 +35,7 @@ for (const link of toc.match(//g)) { const json = href.replace('.html', '.json'); if (!jsonFiles.includes(json) || seen[json]) continue; const data = JSON.parse( - fs.readFileSync(source + '/' + json, 'utf8') + fs.readFileSync(new URL(`./${json}`, source), 'utf8') .replace(//g)) { } // Write results. -fs.writeFileSync(source + '/all.json', +fs.writeFileSync(new URL('./all.json', source), `${JSON.stringify(results, null, 2)}\n`, 'utf8'); diff --git a/tools/doc/apilinks.js b/tools/doc/apilinks.mjs similarity index 97% rename from tools/doc/apilinks.js rename to tools/doc/apilinks.mjs index 6b80709eb8443c..a1b660f1cfaf54 100644 --- a/tools/doc/apilinks.js +++ b/tools/doc/apilinks.mjs @@ -1,5 +1,3 @@ -'use strict'; - // Scan API sources for definitions. // // Note the output is produced based on a world class parser, adherence to @@ -18,10 +16,11 @@ // `function X(...) {...}`). Over time, we expect to handle more // cases (example: ES2015 class definitions). -const acorn = require('../../deps/acorn/acorn'); -const fs = require('fs'); -const path = require('path'); -const child_process = require('child_process'); +import child_process from 'child_process'; +import fs from 'fs'; +import path from 'path'; + +import * as acorn from '../../deps/acorn/acorn/dist/acorn.mjs'; // Run a command, capturing stdout, ignoring errors. function execSync(command) { diff --git a/tools/doc/checkLinks.js b/tools/doc/checkLinks.mjs similarity index 89% rename from tools/doc/checkLinks.js rename to tools/doc/checkLinks.mjs index 21483c5d534477..cb302ea27fefb6 100644 --- a/tools/doc/checkLinks.js +++ b/tools/doc/checkLinks.mjs @@ -1,9 +1,11 @@ -'use strict'; +import fs from 'fs'; +import { extname, join, resolve } from 'path'; +import { pathToFileURL } from 'url'; + +import gfm from 'remark-gfm'; +import markdown from 'remark-parse'; +import unified from 'unified'; -const fs = require('fs'); -const { extname, join, resolve } = require('path'); -const unified = require('unified'); -const { pathToFileURL } = require('url'); const DIR = resolve(process.argv[2]); console.log('Running Markdown link checker...'); @@ -44,8 +46,8 @@ function findMarkdownFilesRecursively(dirPath) { function checkFile(path) { const tree = unified() - .use(require('remark-parse')) - .use(require('remark-gfm')) + .use(markdown) + .use(gfm) .parse(fs.readFileSync(path)); const base = pathToFileURL(path); diff --git a/tools/doc/common.js b/tools/doc/common.mjs similarity index 77% rename from tools/doc/common.js rename to tools/doc/common.mjs index ae8a392f010d17..2f838e3b15016a 100644 --- a/tools/doc/common.js +++ b/tools/doc/common.mjs @@ -1,20 +1,18 @@ -'use strict'; +import yaml from 'js-yaml'; -const yaml = require('js-yaml'); - -function isYAMLBlock(text) { +export function isYAMLBlock(text) { return /^/.test(text); } -function arrify(value) { +export function arrify(value) { return Array.isArray(value) ? value : [value]; } -function extractAndParseYAML(text) { +export function extractAndParseYAML(text) { text = text.trim() .replace(/^$/, ''); @@ -45,5 +43,3 @@ function extractAndParseYAML(text) { return meta; } - -module.exports = { arrify, isYAMLBlock, isSourceLink, extractAndParseYAML }; diff --git a/tools/doc/generate.js b/tools/doc/generate.mjs similarity index 87% rename from tools/doc/generate.js rename to tools/doc/generate.mjs index d2f3aea27f25a4..3bf60878ab5e27 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.mjs @@ -19,21 +19,22 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -'use strict'; - -const { promises: fs } = require('fs'); -const path = require('path'); -const unified = require('unified'); -const markdown = require('remark-parse'); -const gfm = require('remark-gfm'); -const remark2rehype = require('remark-rehype'); -const raw = require('rehype-raw'); -const htmlStringify = require('rehype-stringify'); - -const { replaceLinks } = require('./markdown'); -const linksMapper = require('./links-mapper'); -const html = require('./html'); -const json = require('./json'); +import { readFileSync, promises as fs } from 'fs'; +import path from 'path'; + +import raw from 'rehype-raw'; +import htmlStringify from 'rehype-stringify'; +import gfm from 'remark-gfm'; +import markdown from 'remark-parse'; +import remark2rehype from 'remark-rehype'; +import unified from 'unified'; + +import * as html from './html.mjs'; +import * as json from './json.mjs'; +import { replaceLinks } from './markdown.mjs'; + +const linksMapperFile = new URL('links-mapper.json', import.meta.url); +const linksMapper = JSON.parse(readFileSync(linksMapperFile, 'utf8')); // Parse the args. // Don't use nopt or whatever for this. It's simple enough. diff --git a/tools/doc/html.js b/tools/doc/html.mjs similarity index 94% rename from tools/doc/html.js rename to tools/doc/html.mjs index 901976a8c915fc..d1662a08c44924 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.mjs @@ -19,26 +19,24 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -'use strict'; - -const common = require('./common.js'); -const fs = require('fs'); -const unified = require('unified'); -const visit = require('unist-util-visit'); -const markdown = require('remark-parse'); -const gfm = require('remark-gfm'); -const remark2rehype = require('remark-rehype'); -const raw = require('rehype-raw'); -const htmlStringify = require('rehype-stringify'); -const path = require('path'); -const typeParser = require('./type-parser.js'); -const { highlight, getLanguage } = require('highlight.js'); - -module.exports = { - toHTML, firstHeader, preprocessText, preprocessElements, buildToc -}; - -const docPath = path.resolve(__dirname, '..', '..', 'doc'); +import fs from 'fs'; +import path from 'path'; + +import highlightJs from 'highlight.js'; +import raw from 'rehype-raw'; +import htmlStringify from 'rehype-stringify'; +import gfm from 'remark-gfm'; +import markdown from 'remark-parse'; +import remark2rehype from 'remark-rehype'; +import unified from 'unified'; +import { visit } from 'unist-util-visit'; + +import * as common from './common.mjs'; +import * as typeParser from './type-parser.mjs'; + +const { highlight, getLanguage } = highlightJs; + +const docPath = new URL('../../doc/', import.meta.url); // Add class attributes to index navigation links. function navClasses() { @@ -50,7 +48,7 @@ function navClasses() { }; } -const gtocPath = path.join(docPath, 'api', 'index.md'); +const gtocPath = new URL('./api/index.md', docPath); const gtocMD = fs.readFileSync(gtocPath, 'utf8') .replace(/\(([^#?]+?)\.md\)/ig, (_, filename) => `(${filename}.html)`) .replace(/^/gms, ''); @@ -63,7 +61,7 @@ const gtocHTML = unified() .use(htmlStringify) .processSync(gtocMD).toString(); -const templatePath = path.join(docPath, 'template.html'); +const templatePath = new URL('./template.html', docPath); const template = fs.readFileSync(templatePath, 'utf8'); function processContent(content) { @@ -87,7 +85,7 @@ function processContent(content) { }) + (firstTime ? '' : ''); } -function toHTML({ input, content, filename, nodeVersion, versions }) { +export function toHTML({ input, content, filename, nodeVersion, versions }) { filename = path.basename(filename, '.md'); const id = filename.replace(/\W+/g, '-'); @@ -115,7 +113,7 @@ function toHTML({ input, content, filename, nodeVersion, versions }) { } // Set the section name based on the first header. Default to 'Index'. -function firstHeader() { +export function firstHeader() { return (tree, file) => { let heading; visit(tree, (node) => { @@ -137,7 +135,7 @@ function firstHeader() { // Handle general body-text replacements. // For example, link man page references to the actual page. -function preprocessText({ nodeVersion }) { +export function preprocessText({ nodeVersion }) { return (tree) => { visit(tree, null, (node) => { if (common.isSourceLink(node.value)) { @@ -197,7 +195,7 @@ function linkJsTypeDocs(text) { const isJSFlavorSnippet = (node) => node.lang === 'cjs' || node.lang === 'mjs'; // Preprocess headers, stability blockquotes, and YAML blocks. -function preprocessElements({ filename }) { +export function preprocessElements({ filename }) { return (tree) => { const STABILITY_RE = /(.*:)\s*(\d)([\s\S]*)/; let headingIndex = -1; @@ -217,7 +215,7 @@ function preprocessElements({ filename }) { `language-js ${node.lang}` : `language-${node.lang}`; const highlighted = - `${(getLanguage(node.lang || '') ? highlight(node.lang, node.value) : node).value}`; + `${(getLanguage(node.lang || '') ? highlight(node.value, { language: node.lang }) : node).value}`; node.type = 'html'; if (isJSFlavorSnippet(node)) { @@ -380,7 +378,7 @@ function versionSort(a, b) { } const DEPRECATION_HEADING_PATTERN = /^DEP\d+:/; -function buildToc({ filename, apilinks }) { +export function buildToc({ filename, apilinks }) { return (tree, file) => { const idCounters = Object.create(null); let toc = ''; diff --git a/tools/doc/json.js b/tools/doc/json.mjs similarity index 98% rename from tools/doc/json.js rename to tools/doc/json.mjs index cf107dc0b132e7..318be8fd2ffb4e 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.mjs @@ -19,18 +19,15 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -'use strict'; +import html from 'remark-html'; +import unified from 'unified'; +import { selectAll } from 'unist-util-select'; -const unified = require('unified'); -const common = require('./common.js'); -const html = require('remark-html'); -const { selectAll } = require('unist-util-select'); - -module.exports = { jsonAPI }; +import * as common from './common.mjs'; // Unified processor: input is https://github.com/syntax-tree/mdast, // output is: https://gist.github.com/1777387. -function jsonAPI({ filename }) { +export function jsonAPI({ filename }) { return (tree, file) => { const exampleHeading = /^example/i; diff --git a/tools/doc/markdown.js b/tools/doc/markdown.mjs similarity index 67% rename from tools/doc/markdown.js rename to tools/doc/markdown.mjs index a3b2f0a94ec561..7c9ebfbf7471e4 100644 --- a/tools/doc/markdown.js +++ b/tools/doc/markdown.mjs @@ -1,15 +1,8 @@ -'use strict'; +import { visit } from 'unist-util-visit'; -const visit = require('unist-util-visit'); +export const referenceToLocalMdFile = /^(?![+a-z]+:)([^#?]+)\.md(#.+)?$/i; -const referenceToLocalMdFile = /^(?![+a-z]+:)([^#?]+)\.md(#.+)?$/i; - -module.exports = { - replaceLinks, - referenceToLocalMdFile, -}; - -function replaceLinks({ filename, linksMapper }) { +export function replaceLinks({ filename, linksMapper }) { return (tree) => { const fileHtmlUrls = linksMapper[filename]; diff --git a/tools/doc/package-lock.json b/tools/doc/package-lock.json index 586e90b4bb62ad..9d9ce759c0896e 100644 --- a/tools/doc/package-lock.json +++ b/tools/doc/package-lock.json @@ -11,18 +11,18 @@ "node-doc-generator": "generate.js" }, "devDependencies": { - "highlight.js": "10.5.0", - "js-yaml": "4.0.0", - "rehype-raw": "5.0.0", + "highlight.js": "10.7.3", + "js-yaml": "4.1.0", + "rehype-raw": "5.1.0", "rehype-stringify": "8.0.0", "remark-gfm": "^1.0.0", "remark-html": "13.0.1", "remark-parse": "^9.0.0", - "remark-rehype": "8.0.0", - "to-vfile": "6.1.0", - "unified": "9.2.0", - "unist-util-select": "3.0.4", - "unist-util-visit": "2.0.3" + "remark-rehype": "8.1.0", + "to-vfile": "7.1.0", + "unified": "9.2.1", + "unist-util-select": "4.0.0", + "unist-util-visit": "3.1.0" }, "engines": { "node": ">=12.10.0" @@ -163,6 +163,18 @@ } } }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -227,9 +239,9 @@ } }, "node_modules/hast-util-raw": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-6.0.2.tgz", - "integrity": "sha512-m7IlmqO8cytmG3EIMDMXUG8LjO2uyApWcxwL6apsGvikIClgykFg3UYps4rnt4kUpY3j8Mc7ANJ8zW6KPPLb+w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-6.1.0.tgz", + "integrity": "sha512-5FoZLDHBpka20OlZZ4I/+RBw5piVQ8iI1doEvffQhx5CbCyTtP8UCq8Tw6NmTAMtXgsQxmhW7Ly8OdFre5/YMQ==", "dev": true, "dependencies": { "@types/hast": "^2.0.0", @@ -238,6 +250,7 @@ "html-void-elements": "^1.0.0", "parse5": "^6.0.0", "unist-util-position": "^3.0.0", + "unist-util-visit": "^2.0.0", "vfile": "^4.0.0", "web-namespaces": "^1.0.0", "xtend": "^4.0.0", @@ -248,6 +261,21 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hast-util-raw/node_modules/unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hast-util-sanitize": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-3.0.2.tgz", @@ -262,9 +290,9 @@ } }, "node_modules/hast-util-to-html": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.2.tgz", - "integrity": "sha512-pu73bvORzdF6XZgwl9eID/0RjBb/jtRfoGRRSykpR1+o9rCdiAHpgkSukZsQBRlIqMg6ylAcd7F0F7myJUb09Q==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.3.tgz", + "integrity": "sha512-yk2+1p3EJTEE9ZEUkgHsUSVhIpCsL/bvT8E5GzmWc+N1Po5gBw+0F8bo7dpxXR0nu0bQVxVZGX2lBGF21CmeDw==", "dev": true, "dependencies": { "ccount": "^1.0.0", @@ -328,9 +356,9 @@ } }, "node_modules/highlight.js": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.5.0.tgz", - "integrity": "sha512-xTmvd9HiIHR6L53TMC7TKolEj65zG1XU+Onr8oi86mYa+nLcIbxTTWkpW7CsEwv/vK7u1zb8alZIMLDqqN6KTw==", + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", + "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", "dev": true, "engines": { "node": "*" @@ -429,9 +457,9 @@ } }, "node_modules/js-yaml": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", - "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { "argparse": "^2.0.1" @@ -476,10 +504,40 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdast-util-definitions/node_modules/unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-find-and-replace": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-1.1.1.tgz", + "integrity": "sha512-9cKl33Y21lyckGzpSmEQnIDjEfeeWelN5s1kUW1LwdB0Fkuq2u+4GdqcGEygYxJE8GVqCl0741bYXHgamfWAZA==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^4.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/mdast-util-from-markdown": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.4.tgz", - "integrity": "sha512-jj891B5pV2r63n2kBTFh8cRI2uR9LQHsXG1zSDqfhXkIlDzrTcIlbB5+5aaYEkl8vOPIOPLf8VT7Ere1wWTMdw==", + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz", + "integrity": "sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==", "dev": true, "dependencies": { "@types/mdast": "^3.0.0", @@ -494,9 +552,9 @@ } }, "node_modules/mdast-util-gfm": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-0.1.1.tgz", - "integrity": "sha512-oE1W1zSXU2L2LHg91V22HC3Z1fbsOZTBYUQq+kpM29f9297TbRm0C1l3bQ88RREl0WaUQaB49G7trvwy5utUKQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-0.1.2.tgz", + "integrity": "sha512-NNkhDx/qYcuOWB7xHUGWZYVXvjPFFd6afg6/e2g+SV4r9q5XUcCbV4Wfa3DLYIiD+xAEZc6K4MGaE/m0KDcPwQ==", "dev": true, "dependencies": { "mdast-util-gfm-autolink-literal": "^0.1.0", @@ -511,10 +569,15 @@ } }, "node_modules/mdast-util-gfm-autolink-literal": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.2.tgz", - "integrity": "sha512-WFeIrcNNsfBety0gyWuiBIPing9UkVcl/m2iZOyW1uHEH2evjFocet2h77M24ub0WyZ4ucnQn/jWhO5Ozl6j4g==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.3.tgz", + "integrity": "sha512-GjmLjWrXg1wqMIO9+ZsRik/s7PLwTaeCHVB7vRxUwLntZc8mzmTsLVr6HW1yLokcnhfURsn5zmSVdi3/xWWu1A==", "dev": true, + "dependencies": { + "ccount": "^1.0.0", + "mdast-util-find-and-replace": "^1.1.0", + "micromark": "^2.11.3" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" @@ -561,9 +624,9 @@ } }, "node_modules/mdast-util-to-hast": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-10.1.1.tgz", - "integrity": "sha512-+hvJrYiUgK2aY0Q1h1LaHQ4h0P7VVumWdAcUuG9k49lYglyU9GtTrA4O8hMh5gRnyT22wC15takM2qrrlpvNxQ==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-10.2.0.tgz", + "integrity": "sha512-JoPBfJ3gBnHZ18icCwHR50orC9kNH81tiR1gs01D8Q5YpV6adHNO9nKNuFBCJQ941/32PT1a63UF/DitmS3amQ==", "dev": true, "dependencies": { "@types/mdast": "^3.0.0", @@ -580,10 +643,25 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdast-util-to-hast/node_modules/unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/mdast-util-to-markdown": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.2.tgz", - "integrity": "sha512-iRczns6WMvu0hUw02LXsPDJshBIwtUPbvHBWo19IQeU0YqmzlA8Pd30U8V7uiI0VPkxzS7A/NXBXH6u+HS87Zg==", + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.5.tgz", + "integrity": "sha512-XeV9sDE7ZlOQvs45C9UKMtfTcctcaj/pGwH8YLbMHoMOXNNCn2LsqVQOqrF1+/NU8lKDAqozme9SCXWyo9oAcQ==", "dev": true, "dependencies": { "@types/unist": "^2.0.0", @@ -615,9 +693,9 @@ "dev": true }, "node_modules/micromark": { - "version": "2.11.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.2.tgz", - "integrity": "sha512-IXuP76p2uj8uMg4FQc1cRE7lPCLsfAXuEfdjtdO55VRiFO1asrCSQ5g43NmPqFtRwzEnEhafRVzn2jg0UiKArQ==", + "version": "2.11.4", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.4.tgz", + "integrity": "sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==", "dev": true, "funding": [ { @@ -635,14 +713,14 @@ } }, "node_modules/micromark-extension-gfm": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-0.3.2.tgz", - "integrity": "sha512-ToQEpLkRgg7Tp8D3GM/SjZFPV0cCwWNxZmoEVIOQivOswRtPg7gg2WlCrtHhUWFNX+DgDjbq0iLOPGp4Y15oug==", + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-0.3.3.tgz", + "integrity": "sha512-oVN4zv5/tAIA+l3GbMi7lWeYpJ14oQyJ3uEim20ktYFAcfX1x3LNlFGGlmrZHt7u9YlKExmyJdDGaTt6cMSR/A==", "dev": true, "dependencies": { "micromark": "~2.11.0", "micromark-extension-gfm-autolink-literal": "~0.5.0", - "micromark-extension-gfm-strikethrough": "~0.6.0", + "micromark-extension-gfm-strikethrough": "~0.6.5", "micromark-extension-gfm-table": "~0.4.0", "micromark-extension-gfm-tagfilter": "~0.3.0", "micromark-extension-gfm-task-list-item": "~0.3.0" @@ -653,12 +731,12 @@ } }, "node_modules/micromark-extension-gfm-autolink-literal": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.4.tgz", - "integrity": "sha512-471VKd4k3SiX7vx9fC+IYeGQL0RnxwBBXeEc5WConb7naJDG5m16guA+VoFzyXchrvmU08t0dUWWPZ0mkJSXVw==", + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.7.tgz", + "integrity": "sha512-ePiDGH0/lhcngCe8FtH4ARFoxKTUelMp4L7Gg2pujYD5CSMb9PbblnyL+AAMud/SNMyusbS2XDSiPIRcQoNFAw==", "dev": true, "dependencies": { - "micromark": "~2.11.0" + "micromark": "~2.11.3" }, "funding": { "type": "opencollective", @@ -666,9 +744,9 @@ } }, "node_modules/micromark-extension-gfm-strikethrough": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.3.tgz", - "integrity": "sha512-MKMoP9x2dsr1aeX46ibBwVf4Q6nJsi5aaUFTOMOID5VOLSxwl4CrqUV4OGFQd6AqhtzBJAxaV+N2trlTBtZDNQ==", + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.5.tgz", + "integrity": "sha512-PpOKlgokpQRwUesRwWEp+fHjGGkZEejj83k9gU5iXCbDG+XBA92BqnRKYJdfqfkrRcZRgGuPuXb7DaK/DmxOhw==", "dev": true, "dependencies": { "micromark": "~2.11.0" @@ -679,9 +757,9 @@ } }, "node_modules/micromark-extension-gfm-table": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.2.tgz", - "integrity": "sha512-AAzmj85XO1ydHYX0Lz52HGhcH2sZLm2AVvkwzELXWgZF6vGdq5yZ3CTByFRsqNUPyQBSIYFKLDAtc6KlnO42aw==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.3.tgz", + "integrity": "sha512-hVGvESPq0fk6ALWtomcwmgLvH8ZSVpcPjzi0AjPclB9FsVRgMtGZkUcpE0zgjOCFAznKepF4z3hX8z6e3HODdA==", "dev": true, "dependencies": { "micromark": "~2.11.0" @@ -720,12 +798,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/not": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/not/-/not-0.1.0.tgz", - "integrity": "sha1-yWkcF0bFXc++VMvYvU/wQbwrUZ0=", - "dev": true - }, "node_modules/nth-check": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", @@ -776,12 +848,12 @@ } }, "node_modules/rehype-raw": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-5.0.0.tgz", - "integrity": "sha512-q/MOBj4fs1WF/LSCh5uOtNhnm5OESuDcSvq1mDQP4/2t6Q52E9MHeVoLeMy9vOn93BEcgVBm4FCokcK2iXRDvA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-5.1.0.tgz", + "integrity": "sha512-MDvHAb/5mUnif2R+0IPCYJU8WjHa9UzGtM/F4AVy5GixPlDZ1z3HacYy4xojDU+uBa+0X/3PIfyQI26/2ljJNA==", "dev": true, "dependencies": { - "hast-util-raw": "^6.0.0" + "hast-util-raw": "^6.1.0" }, "funding": { "type": "opencollective", @@ -844,12 +916,12 @@ } }, "node_modules/remark-rehype": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-8.0.0.tgz", - "integrity": "sha512-gVvOH02TMFqXOWoL6iXU7NXMsDJguNkNuMrzfkQeA4V6WCyHQnOKptn+IQBVVPuIH2sMJBwo8hlrmtn1MLTh9w==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-8.1.0.tgz", + "integrity": "sha512-EbCu9kHgAxKmW1yEYjx3QafMyGY3q8noUbNUI5xyKbaFP89wbhDrKxyIQNukNYthzjNHZu6J7hwFg7hRm1svYA==", "dev": true, "dependencies": { - "mdast-util-to-hast": "^10.0.0" + "mdast-util-to-hast": "^10.2.0" }, "funding": { "type": "opencollective", @@ -900,13 +972,56 @@ } }, "node_modules/to-vfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-6.1.0.tgz", - "integrity": "sha512-BxX8EkCxOAZe+D/ToHdDsJcVI4HqQfmw0tCkp31zf3dNP/XWIAjU4CmeuSwsSoOzOTqHPOL0KUzyZqJplkD0Qw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-7.1.0.tgz", + "integrity": "sha512-t1c42ASuWo39ddjh2R+hX5+kbDcc2CmbhaTSJkVavDYMjnFkpq0L4LeF+rcPoDdieGUsFaivSSkmwuFpYzhBZw==", "dev": true, "dependencies": { "is-buffer": "^2.0.0", - "vfile": "^4.0.0" + "vfile": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/to-vfile/node_modules/unist-util-stringify-position": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.0.tgz", + "integrity": "sha512-SdfAl8fsDclywZpfMDTVDxA2V7LjtRDTOFd44wUJamgl6OlVngsqWjxvermMYf60elWHbxhuRCZml7AnuXCaSA==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/to-vfile/node_modules/vfile": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.0.1.tgz", + "integrity": "sha512-lbcf0k66x96Syy36HG+nIBFaSD/fAk589q4nETZTr0JW7eRRmrVo1vHwbD8NlHszUM5ICtFSWQ5xHC292hYZ/w==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "is-buffer": "^2.0.0", + "unist-util-stringify-position": "^3.0.0", + "vfile-message": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/to-vfile/node_modules/vfile-message": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.0.1.tgz", + "integrity": "sha512-gYmSHcZZUEtYpTmaWaFJwsuUD70/rTY4v09COp8TGtOkix6gGxb/a8iTQByIY9ciTk9GwAwIXd/J9OPfM4Bvaw==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^3.0.0" }, "funding": { "type": "opencollective", @@ -924,9 +1039,9 @@ } }, "node_modules/unified": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.0.tgz", - "integrity": "sha512-vx2Z0vY+a3YoTj8+pttM3tiJHCwY5UFbYdiWrwBEbHmK8pvsPj2rtAX2BFfgXen8T39CJWblWRDT4L5WGXtDdg==", + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.1.tgz", + "integrity": "sha512-juWjuI8Z4xFg8pJbnEZ41b5xjGUWGHqXALmBZ3FC3WX0PIx1CZBIIJ6mXbYMcf6Yw4Fi0rFUTA1cdz/BglbOhA==", "dev": true, "dependencies": { "bail": "^1.0.0", @@ -962,9 +1077,9 @@ } }, "node_modules/unist-util-is": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.4.tgz", - "integrity": "sha512-3dF39j/u423v4BBQrk1AQ2Ve1FxY5W3JKwXxVFzBODQ6WEvccguhgp802qQLKSnxPODE6WuRZtV+ohlUg4meBA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz", + "integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==", "dev": true, "funding": { "type": "opencollective", @@ -982,22 +1097,41 @@ } }, "node_modules/unist-util-select": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/unist-util-select/-/unist-util-select-3.0.4.tgz", - "integrity": "sha512-xf1zCu4okgPqGLdhCDpRnjwBNyv3EqjiXRUbz2SdK1+qnLMB7uXXajfzuBvvbHoQ+JLyp4AEbFCGndmc6S72sw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-select/-/unist-util-select-4.0.0.tgz", + "integrity": "sha512-UJsER0ubbBy8KR+5zZpcF/9/aApWOzjNqfseMjcw1h0wAUqbxAf56mMewspAqXtGKiwBylnYB+PbD/XqwcYrWg==", "dev": true, "dependencies": { "css-selector-parser": "^1.0.0", - "not": "^0.1.0", "nth-check": "^2.0.0", - "unist-util-is": "^4.0.0", - "zwitch": "^1.0.0" + "unist-util-is": "^5.0.0", + "zwitch": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, + "node_modules/unist-util-select/node_modules/unist-util-is": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.0.tgz", + "integrity": "sha512-pWspZ+AvTqYbC+xWeRmzGqbcY8Na08Eowlfs2xchWTYot8vBBAq+syrE/LWS0bw1D/JOu4lwzDbEb6Mz13tK+g==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-select/node_modules/zwitch": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.2.tgz", + "integrity": "sha512-JZxotl7SxAJH0j7dN4pxsTV6ZLXoLdGME+PsjkL/DaBrVryK9kTGq06GfKrwcSOqypP+fdXGoCHE36b99fWVoA==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/unist-util-stringify-position": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", @@ -1012,14 +1146,14 @@ } }, "node_modules/unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", + "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", "dev": true, "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^4.0.0" }, "funding": { "type": "opencollective", @@ -1040,6 +1174,30 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/unist-util-visit/node_modules/unist-util-is": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.0.tgz", + "integrity": "sha512-pWspZ+AvTqYbC+xWeRmzGqbcY8Na08Eowlfs2xchWTYot8vBBAq+syrE/LWS0bw1D/JOu4lwzDbEb6Mz13tK+g==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit/node_modules/unist-util-visit-parents": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", + "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", + "dev": true, + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/vfile": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.1.tgz", @@ -1210,6 +1368,12 @@ "ms": "2.1.2" } }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -1258,9 +1422,9 @@ "dev": true }, "hast-util-raw": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-6.0.2.tgz", - "integrity": "sha512-m7IlmqO8cytmG3EIMDMXUG8LjO2uyApWcxwL6apsGvikIClgykFg3UYps4rnt4kUpY3j8Mc7ANJ8zW6KPPLb+w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-6.1.0.tgz", + "integrity": "sha512-5FoZLDHBpka20OlZZ4I/+RBw5piVQ8iI1doEvffQhx5CbCyTtP8UCq8Tw6NmTAMtXgsQxmhW7Ly8OdFre5/YMQ==", "dev": true, "requires": { "@types/hast": "^2.0.0", @@ -1269,10 +1433,24 @@ "html-void-elements": "^1.0.0", "parse5": "^6.0.0", "unist-util-position": "^3.0.0", + "unist-util-visit": "^2.0.0", "vfile": "^4.0.0", "web-namespaces": "^1.0.0", "xtend": "^4.0.0", "zwitch": "^1.0.0" + }, + "dependencies": { + "unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + } + } } }, "hast-util-sanitize": { @@ -1285,9 +1463,9 @@ } }, "hast-util-to-html": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.2.tgz", - "integrity": "sha512-pu73bvORzdF6XZgwl9eID/0RjBb/jtRfoGRRSykpR1+o9rCdiAHpgkSukZsQBRlIqMg6ylAcd7F0F7myJUb09Q==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.3.tgz", + "integrity": "sha512-yk2+1p3EJTEE9ZEUkgHsUSVhIpCsL/bvT8E5GzmWc+N1Po5gBw+0F8bo7dpxXR0nu0bQVxVZGX2lBGF21CmeDw==", "dev": true, "requires": { "ccount": "^1.0.0", @@ -1335,9 +1513,9 @@ } }, "highlight.js": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.5.0.tgz", - "integrity": "sha512-xTmvd9HiIHR6L53TMC7TKolEj65zG1XU+Onr8oi86mYa+nLcIbxTTWkpW7CsEwv/vK7u1zb8alZIMLDqqN6KTw==", + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", + "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", "dev": true }, "html-void-elements": { @@ -1393,9 +1571,9 @@ "dev": true }, "js-yaml": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", - "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { "argparse": "^2.0.1" @@ -1423,12 +1601,36 @@ "dev": true, "requires": { "unist-util-visit": "^2.0.0" + }, + "dependencies": { + "unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + } + } + } + }, + "mdast-util-find-and-replace": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-1.1.1.tgz", + "integrity": "sha512-9cKl33Y21lyckGzpSmEQnIDjEfeeWelN5s1kUW1LwdB0Fkuq2u+4GdqcGEygYxJE8GVqCl0741bYXHgamfWAZA==", + "dev": true, + "requires": { + "escape-string-regexp": "^4.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" } }, "mdast-util-from-markdown": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.4.tgz", - "integrity": "sha512-jj891B5pV2r63n2kBTFh8cRI2uR9LQHsXG1zSDqfhXkIlDzrTcIlbB5+5aaYEkl8vOPIOPLf8VT7Ere1wWTMdw==", + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz", + "integrity": "sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==", "dev": true, "requires": { "@types/mdast": "^3.0.0", @@ -1439,9 +1641,9 @@ } }, "mdast-util-gfm": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-0.1.1.tgz", - "integrity": "sha512-oE1W1zSXU2L2LHg91V22HC3Z1fbsOZTBYUQq+kpM29f9297TbRm0C1l3bQ88RREl0WaUQaB49G7trvwy5utUKQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-0.1.2.tgz", + "integrity": "sha512-NNkhDx/qYcuOWB7xHUGWZYVXvjPFFd6afg6/e2g+SV4r9q5XUcCbV4Wfa3DLYIiD+xAEZc6K4MGaE/m0KDcPwQ==", "dev": true, "requires": { "mdast-util-gfm-autolink-literal": "^0.1.0", @@ -1452,10 +1654,15 @@ } }, "mdast-util-gfm-autolink-literal": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.2.tgz", - "integrity": "sha512-WFeIrcNNsfBety0gyWuiBIPing9UkVcl/m2iZOyW1uHEH2evjFocet2h77M24ub0WyZ4ucnQn/jWhO5Ozl6j4g==", - "dev": true + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.3.tgz", + "integrity": "sha512-GjmLjWrXg1wqMIO9+ZsRik/s7PLwTaeCHVB7vRxUwLntZc8mzmTsLVr6HW1yLokcnhfURsn5zmSVdi3/xWWu1A==", + "dev": true, + "requires": { + "ccount": "^1.0.0", + "mdast-util-find-and-replace": "^1.1.0", + "micromark": "^2.11.3" + } }, "mdast-util-gfm-strikethrough": { "version": "0.2.3", @@ -1486,9 +1693,9 @@ } }, "mdast-util-to-hast": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-10.1.1.tgz", - "integrity": "sha512-+hvJrYiUgK2aY0Q1h1LaHQ4h0P7VVumWdAcUuG9k49lYglyU9GtTrA4O8hMh5gRnyT22wC15takM2qrrlpvNxQ==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-10.2.0.tgz", + "integrity": "sha512-JoPBfJ3gBnHZ18icCwHR50orC9kNH81tiR1gs01D8Q5YpV6adHNO9nKNuFBCJQ941/32PT1a63UF/DitmS3amQ==", "dev": true, "requires": { "@types/mdast": "^3.0.0", @@ -1499,12 +1706,25 @@ "unist-util-generated": "^1.0.0", "unist-util-position": "^3.0.0", "unist-util-visit": "^2.0.0" + }, + "dependencies": { + "unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + } + } } }, "mdast-util-to-markdown": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.2.tgz", - "integrity": "sha512-iRczns6WMvu0hUw02LXsPDJshBIwtUPbvHBWo19IQeU0YqmzlA8Pd30U8V7uiI0VPkxzS7A/NXBXH6u+HS87Zg==", + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.5.tgz", + "integrity": "sha512-XeV9sDE7ZlOQvs45C9UKMtfTcctcaj/pGwH8YLbMHoMOXNNCn2LsqVQOqrF1+/NU8lKDAqozme9SCXWyo9oAcQ==", "dev": true, "requires": { "@types/unist": "^2.0.0", @@ -1528,9 +1748,9 @@ "dev": true }, "micromark": { - "version": "2.11.2", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.2.tgz", - "integrity": "sha512-IXuP76p2uj8uMg4FQc1cRE7lPCLsfAXuEfdjtdO55VRiFO1asrCSQ5g43NmPqFtRwzEnEhafRVzn2jg0UiKArQ==", + "version": "2.11.4", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.4.tgz", + "integrity": "sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==", "dev": true, "requires": { "debug": "^4.0.0", @@ -1538,41 +1758,41 @@ } }, "micromark-extension-gfm": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-0.3.2.tgz", - "integrity": "sha512-ToQEpLkRgg7Tp8D3GM/SjZFPV0cCwWNxZmoEVIOQivOswRtPg7gg2WlCrtHhUWFNX+DgDjbq0iLOPGp4Y15oug==", + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-0.3.3.tgz", + "integrity": "sha512-oVN4zv5/tAIA+l3GbMi7lWeYpJ14oQyJ3uEim20ktYFAcfX1x3LNlFGGlmrZHt7u9YlKExmyJdDGaTt6cMSR/A==", "dev": true, "requires": { "micromark": "~2.11.0", "micromark-extension-gfm-autolink-literal": "~0.5.0", - "micromark-extension-gfm-strikethrough": "~0.6.0", + "micromark-extension-gfm-strikethrough": "~0.6.5", "micromark-extension-gfm-table": "~0.4.0", "micromark-extension-gfm-tagfilter": "~0.3.0", "micromark-extension-gfm-task-list-item": "~0.3.0" } }, "micromark-extension-gfm-autolink-literal": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.4.tgz", - "integrity": "sha512-471VKd4k3SiX7vx9fC+IYeGQL0RnxwBBXeEc5WConb7naJDG5m16guA+VoFzyXchrvmU08t0dUWWPZ0mkJSXVw==", + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.7.tgz", + "integrity": "sha512-ePiDGH0/lhcngCe8FtH4ARFoxKTUelMp4L7Gg2pujYD5CSMb9PbblnyL+AAMud/SNMyusbS2XDSiPIRcQoNFAw==", "dev": true, "requires": { - "micromark": "~2.11.0" + "micromark": "~2.11.3" } }, "micromark-extension-gfm-strikethrough": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.3.tgz", - "integrity": "sha512-MKMoP9x2dsr1aeX46ibBwVf4Q6nJsi5aaUFTOMOID5VOLSxwl4CrqUV4OGFQd6AqhtzBJAxaV+N2trlTBtZDNQ==", + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.5.tgz", + "integrity": "sha512-PpOKlgokpQRwUesRwWEp+fHjGGkZEejj83k9gU5iXCbDG+XBA92BqnRKYJdfqfkrRcZRgGuPuXb7DaK/DmxOhw==", "dev": true, "requires": { "micromark": "~2.11.0" } }, "micromark-extension-gfm-table": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.2.tgz", - "integrity": "sha512-AAzmj85XO1ydHYX0Lz52HGhcH2sZLm2AVvkwzELXWgZF6vGdq5yZ3CTByFRsqNUPyQBSIYFKLDAtc6KlnO42aw==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.3.tgz", + "integrity": "sha512-hVGvESPq0fk6ALWtomcwmgLvH8ZSVpcPjzi0AjPclB9FsVRgMtGZkUcpE0zgjOCFAznKepF4z3hX8z6e3HODdA==", "dev": true, "requires": { "micromark": "~2.11.0" @@ -1599,12 +1819,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "not": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/not/-/not-0.1.0.tgz", - "integrity": "sha1-yWkcF0bFXc++VMvYvU/wQbwrUZ0=", - "dev": true - }, "nth-check": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", @@ -1644,12 +1858,12 @@ } }, "rehype-raw": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-5.0.0.tgz", - "integrity": "sha512-q/MOBj4fs1WF/LSCh5uOtNhnm5OESuDcSvq1mDQP4/2t6Q52E9MHeVoLeMy9vOn93BEcgVBm4FCokcK2iXRDvA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-5.1.0.tgz", + "integrity": "sha512-MDvHAb/5mUnif2R+0IPCYJU8WjHa9UzGtM/F4AVy5GixPlDZ1z3HacYy4xojDU+uBa+0X/3PIfyQI26/2ljJNA==", "dev": true, "requires": { - "hast-util-raw": "^6.0.0" + "hast-util-raw": "^6.1.0" } }, "rehype-stringify": { @@ -1692,12 +1906,12 @@ } }, "remark-rehype": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-8.0.0.tgz", - "integrity": "sha512-gVvOH02TMFqXOWoL6iXU7NXMsDJguNkNuMrzfkQeA4V6WCyHQnOKptn+IQBVVPuIH2sMJBwo8hlrmtn1MLTh9w==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-8.1.0.tgz", + "integrity": "sha512-EbCu9kHgAxKmW1yEYjx3QafMyGY3q8noUbNUI5xyKbaFP89wbhDrKxyIQNukNYthzjNHZu6J7hwFg7hRm1svYA==", "dev": true, "requires": { - "mdast-util-to-hast": "^10.0.0" + "mdast-util-to-hast": "^10.2.0" } }, "repeat-string": { @@ -1733,13 +1947,46 @@ } }, "to-vfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-6.1.0.tgz", - "integrity": "sha512-BxX8EkCxOAZe+D/ToHdDsJcVI4HqQfmw0tCkp31zf3dNP/XWIAjU4CmeuSwsSoOzOTqHPOL0KUzyZqJplkD0Qw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-7.1.0.tgz", + "integrity": "sha512-t1c42ASuWo39ddjh2R+hX5+kbDcc2CmbhaTSJkVavDYMjnFkpq0L4LeF+rcPoDdieGUsFaivSSkmwuFpYzhBZw==", "dev": true, "requires": { "is-buffer": "^2.0.0", - "vfile": "^4.0.0" + "vfile": "^5.0.0" + }, + "dependencies": { + "unist-util-stringify-position": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.0.tgz", + "integrity": "sha512-SdfAl8fsDclywZpfMDTVDxA2V7LjtRDTOFd44wUJamgl6OlVngsqWjxvermMYf60elWHbxhuRCZml7AnuXCaSA==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0" + } + }, + "vfile": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.0.1.tgz", + "integrity": "sha512-lbcf0k66x96Syy36HG+nIBFaSD/fAk589q4nETZTr0JW7eRRmrVo1vHwbD8NlHszUM5ICtFSWQ5xHC292hYZ/w==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "is-buffer": "^2.0.0", + "unist-util-stringify-position": "^3.0.0", + "vfile-message": "^3.0.0" + } + }, + "vfile-message": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.0.1.tgz", + "integrity": "sha512-gYmSHcZZUEtYpTmaWaFJwsuUD70/rTY4v09COp8TGtOkix6gGxb/a8iTQByIY9ciTk9GwAwIXd/J9OPfM4Bvaw==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^3.0.0" + } + } } }, "trough": { @@ -1749,9 +1996,9 @@ "dev": true }, "unified": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.0.tgz", - "integrity": "sha512-vx2Z0vY+a3YoTj8+pttM3tiJHCwY5UFbYdiWrwBEbHmK8pvsPj2rtAX2BFfgXen8T39CJWblWRDT4L5WGXtDdg==", + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.1.tgz", + "integrity": "sha512-juWjuI8Z4xFg8pJbnEZ41b5xjGUWGHqXALmBZ3FC3WX0PIx1CZBIIJ6mXbYMcf6Yw4Fi0rFUTA1cdz/BglbOhA==", "dev": true, "requires": { "bail": "^1.0.0", @@ -1775,9 +2022,9 @@ "dev": true }, "unist-util-is": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.4.tgz", - "integrity": "sha512-3dF39j/u423v4BBQrk1AQ2Ve1FxY5W3JKwXxVFzBODQ6WEvccguhgp802qQLKSnxPODE6WuRZtV+ohlUg4meBA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz", + "integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==", "dev": true }, "unist-util-position": { @@ -1787,16 +2034,29 @@ "dev": true }, "unist-util-select": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/unist-util-select/-/unist-util-select-3.0.4.tgz", - "integrity": "sha512-xf1zCu4okgPqGLdhCDpRnjwBNyv3EqjiXRUbz2SdK1+qnLMB7uXXajfzuBvvbHoQ+JLyp4AEbFCGndmc6S72sw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-select/-/unist-util-select-4.0.0.tgz", + "integrity": "sha512-UJsER0ubbBy8KR+5zZpcF/9/aApWOzjNqfseMjcw1h0wAUqbxAf56mMewspAqXtGKiwBylnYB+PbD/XqwcYrWg==", "dev": true, "requires": { "css-selector-parser": "^1.0.0", - "not": "^0.1.0", "nth-check": "^2.0.0", - "unist-util-is": "^4.0.0", - "zwitch": "^1.0.0" + "unist-util-is": "^5.0.0", + "zwitch": "^2.0.0" + }, + "dependencies": { + "unist-util-is": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.0.tgz", + "integrity": "sha512-pWspZ+AvTqYbC+xWeRmzGqbcY8Na08Eowlfs2xchWTYot8vBBAq+syrE/LWS0bw1D/JOu4lwzDbEb6Mz13tK+g==", + "dev": true + }, + "zwitch": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.2.tgz", + "integrity": "sha512-JZxotl7SxAJH0j7dN4pxsTV6ZLXoLdGME+PsjkL/DaBrVryK9kTGq06GfKrwcSOqypP+fdXGoCHE36b99fWVoA==", + "dev": true + } } }, "unist-util-stringify-position": { @@ -1809,14 +2069,32 @@ } }, "unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", + "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", "dev": true, "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^4.0.0" + }, + "dependencies": { + "unist-util-is": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.0.tgz", + "integrity": "sha512-pWspZ+AvTqYbC+xWeRmzGqbcY8Na08Eowlfs2xchWTYot8vBBAq+syrE/LWS0bw1D/JOu4lwzDbEb6Mz13tK+g==", + "dev": true + }, + "unist-util-visit-parents": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", + "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0" + } + } } }, "unist-util-visit-parents": { diff --git a/tools/doc/package.json b/tools/doc/package.json index 441249f3282887..223220bcc1c7e5 100644 --- a/tools/doc/package.json +++ b/tools/doc/package.json @@ -4,21 +4,21 @@ "description": "Internal tool for generating Node.js API docs", "version": "0.0.0", "engines": { - "node": ">=12.10.0" + "node": ">=14.8.0" }, "devDependencies": { - "highlight.js": "10.5.0", - "js-yaml": "4.0.0", - "rehype-raw": "5.0.0", + "highlight.js": "10.7.3", + "js-yaml": "4.1.0", + "rehype-raw": "5.1.0", "rehype-stringify": "8.0.0", "remark-gfm": "^1.0.0", "remark-html": "13.0.1", "remark-parse": "^9.0.0", - "remark-rehype": "8.0.0", - "to-vfile": "6.1.0", - "unified": "9.2.0", - "unist-util-select": "3.0.4", - "unist-util-visit": "2.0.3" + "remark-rehype": "8.1.0", + "to-vfile": "7.1.0", + "unified": "9.2.1", + "unist-util-select": "4.0.0", + "unist-util-visit": "3.1.0" }, "bin": { "node-doc-generator": "generate.js" diff --git a/tools/doc/stability.js b/tools/doc/stability.mjs similarity index 79% rename from tools/doc/stability.js rename to tools/doc/stability.mjs index 9ab6fac827e59e..6b5f182a76e7e0 100644 --- a/tools/doc/stability.js +++ b/tools/doc/stability.mjs @@ -1,28 +1,26 @@ -'use strict'; - // Build stability table to documentation.html/json/md by generated all.json -const fs = require('fs'); -const path = require('path'); -const unified = require('unified'); -const raw = require('rehype-raw'); -const markdown = require('remark-parse'); -const htmlStringify = require('rehype-stringify'); -const gfm = require('remark-gfm'); -const remark2rehype = require('remark-rehype'); -const visit = require('unist-util-visit'); - -const source = `${__dirname}/../../out/doc/api`; -const data = require(path.join(source, 'all.json')); +import fs from 'fs'; + +import raw from 'rehype-raw'; +import htmlStringify from 'rehype-stringify'; +import gfm from 'remark-gfm'; +import markdown from 'remark-parse'; +import remark2rehype from 'remark-rehype'; +import unified from 'unified'; +import { visit } from 'unist-util-visit'; + +const source = new URL('../../out/doc/api/', import.meta.url); +const data = JSON.parse(fs.readFileSync(new URL('./all.json', source), 'utf8')); const markBegin = ''; const markEnd = ''; const mark = `${markBegin}(.*)${markEnd}`; const output = { - json: path.join(source, 'stability.json'), - docHTML: path.join(source, 'documentation.html'), - docJSON: path.join(source, 'documentation.json'), - docMarkdown: path.join(source, 'documentation.md'), + json: new URL('./stability.json', source), + docHTML: new URL('./documentation.html', source), + docJSON: new URL('./documentation.json', source), + docMarkdown: new URL('./documentation.md', source), }; function collectStability(data) { diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.mjs similarity index 99% rename from tools/doc/type-parser.js rename to tools/doc/type-parser.mjs index 4fd91f4b478149..c2586a43254ecb 100644 --- a/tools/doc/type-parser.js +++ b/tools/doc/type-parser.mjs @@ -1,5 +1,3 @@ -'use strict'; - const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/'; const jsDataStructuresUrl = `${jsDocPrefix}Data_structures`; @@ -232,7 +230,7 @@ const customTypesMap = { const arrayPart = /(?:\[])+$/; -function toLink(typeInput) { +export function toLink(typeInput) { const typeLinks = []; typeInput = typeInput.replace('{', '').replace('}', ''); const typeTexts = typeInput.split('|'); @@ -273,5 +271,3 @@ function toLink(typeInput) { return typeLinks.length ? typeLinks.join(' | ') : typeInput; } - -module.exports = { toLink }; diff --git a/tools/doc/versions.js b/tools/doc/versions.mjs similarity index 87% rename from tools/doc/versions.js rename to tools/doc/versions.mjs index 6f16b4d1d74ddf..ec623a2dbd206e 100644 --- a/tools/doc/versions.js +++ b/tools/doc/versions.mjs @@ -1,18 +1,16 @@ -'use strict'; +import { readFileSync, writeFileSync } from 'fs'; +import https from 'https'; -const { readFileSync, writeFileSync } = require('fs'); -const path = require('path'); -const srcRoot = path.join(__dirname, '..', '..'); +const srcRoot = new URL('../../', import.meta.url); const isRelease = () => { const re = /#define NODE_VERSION_IS_RELEASE 0/; - const file = path.join(srcRoot, 'src', 'node_version.h'); + const file = new URL('./src/node_version.h', srcRoot); return !re.test(readFileSync(file, { encoding: 'utf8' })); }; const getUrl = (url) => { return new Promise((resolve, reject) => { - const https = require('https'); const request = https.get(url, { timeout: 30000 }, (response) => { if (response.statusCode !== 200) { reject(new Error( @@ -38,7 +36,7 @@ async function versions() { const url = 'https://raw.githubusercontent.com/nodejs/node/HEAD/CHANGELOG.md'; let changelog; - const file = path.join(srcRoot, 'CHANGELOG.md'); + const file = new URL('./CHANGELOG.md', srcRoot); if (kNoInternet) { changelog = readFileSync(file, { encoding: 'utf8' }); } else { diff --git a/vcbuild.bat b/vcbuild.bat index 81a8efb62e553f..694277ff8829ac 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -528,7 +528,7 @@ robocopy /e doc\api %config%\doc\api robocopy /e doc\api_assets %config%\doc\api\assets for %%F in (%config%\doc\api\*.md) do ( - %node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% %%F --output-directory=%%~dF%%~pF + %node_exe% tools\doc\generate.mjs --node-version=v%FULLVERSION% %%F --output-directory=%%~dF%%~pF ) :run @@ -545,7 +545,7 @@ for /d %%F in (test\addons\??_*) do ( rd /s /q %%F ) :: generate -"%node_exe%" tools\doc\addon-verify.js +"%node_exe%" tools\doc\addon-verify.mjs if %errorlevel% neq 0 exit /b %errorlevel% :: building addons setlocal