From a21d4f8f539d6fa69d2d19f6ad63b02a3bb6b08f Mon Sep 17 00:00:00 2001 From: Claas Augner <495429+caugner@users.noreply.github.com> Date: Fri, 10 Jul 2026 17:41:42 +0200 Subject: [PATCH 1/2] fix(ci): pin npx fred-ssr and rari to their @mdn packages (#44600) --- .github/workflows/pr-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 75cb0153af6bdfe..4a573641331d32f 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -134,12 +134,12 @@ jobs: ARGS+=("-f" "$PWD/$file") done - npx rari build --no-basic --json-issues --data-issues "${ARGS[@]}" + npx @mdn/rari build --no-basic --json-issues --data-issues "${ARGS[@]}" # Workaround, as fred-ssr doesn't copy assets. cp -vR node_modules/@mdn/fred/out/. "$BUILD_OUT_ROOT" - npx fred-ssr + npx --package=@mdn/fred fred-ssr echo "Disk usage size of the build" du -sh $BUILD_OUT_ROOT From acc64b6bd3688ef93337674e75f3d6720f472dad Mon Sep 17 00:00:00 2001 From: Claas Augner <495429+caugner@users.noreply.github.com> Date: Fri, 10 Jul 2026 17:50:20 +0200 Subject: [PATCH 2/2] chore(filecheck): drop `index.html` support and `fs-extra` (#44608) --- package-lock.json | 39 ------------------ package.json | 1 - scripts/filecheck/checker.js | 23 ++++------- scripts/filecheck/checker.test.js | 19 +++------ .../filecheck/fixtures/{md => }/circle.svg | 0 scripts/filecheck/fixtures/html/index.html | 4 -- scripts/filecheck/fixtures/{md => }/index.md | 0 scripts/filecheck/fixtures/md/orphan.png | Bin 592 -> 0 bytes .../fixtures/{html => }/onhandler.svg | 0 .../filecheck/fixtures/{html => }/orphan.png | Bin .../filecheck/fixtures/{html => }/png.jpeg | Bin .../filecheck/fixtures/{html => }/script.svg | 0 .../filecheck/fixtures/{html => }/zero.gif | 0 scripts/sort_and_unique_file_lines.js | 2 +- 14 files changed, 15 insertions(+), 73 deletions(-) rename scripts/filecheck/fixtures/{md => }/circle.svg (100%) delete mode 100644 scripts/filecheck/fixtures/html/index.html rename scripts/filecheck/fixtures/{md => }/index.md (100%) delete mode 100644 scripts/filecheck/fixtures/md/orphan.png rename scripts/filecheck/fixtures/{html => }/onhandler.svg (100%) rename scripts/filecheck/fixtures/{html => }/orphan.png (100%) rename scripts/filecheck/fixtures/{html => }/png.jpeg (100%) rename scripts/filecheck/fixtures/{html => }/script.svg (100%) rename scripts/filecheck/fixtures/{html => }/zero.gif (100%) diff --git a/package-lock.json b/package-lock.json index d3492e5aca6fcb2..d87f9dbddca1951 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,6 @@ "env-cmd": "11.0.0", "fdir": "^6.5.0", "file-type": "^22.0.1", - "fs-extra": "^11.3.6", "gray-matter": "^4.0.3", "imagemin": "^9.0.1", "imagemin-gifsicle": "^7.0.0", @@ -4394,21 +4393,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fs-extra": { - "version": "11.3.6", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.6.tgz", - "integrity": "sha512-w8ZNZr2mKIc7qeNaQ9AVPT1+iFaI+Avd4xudVOvdDJ8VytREi1Ft5Ih7hd9jjehod8vAM5GMsfQ/TpPf4EyoEA==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -6013,19 +5997,6 @@ "dev": true, "license": "MIT" }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/jsonpointer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", @@ -9571,16 +9542,6 @@ "dev": true, "license": "ISC" }, - "node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index fb59e6fdf61fd15..2775681a869b0e7 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "env-cmd": "11.0.0", "fdir": "^6.5.0", "file-type": "^22.0.1", - "fs-extra": "^11.3.6", "gray-matter": "^4.0.3", "imagemin": "^9.0.1", "imagemin-gifsicle": "^7.0.0", diff --git a/scripts/filecheck/checker.js b/scripts/filecheck/checker.js index c9b930bf854dc41..1c2f0d2a6b0c680 100644 --- a/scripts/filecheck/checker.js +++ b/scripts/filecheck/checker.js @@ -5,7 +5,6 @@ import os from "node:os"; import { eachLimit } from "async"; import cliProgress from "cli-progress"; import { fdir } from "fdir"; -import fse from "fs-extra"; import { temporaryDirectory } from "tempy"; import * as cheerio from "cheerio"; import { fileTypeFromFile } from "file-type"; @@ -185,16 +184,13 @@ export async function checkFile(filePath, options = {}) { } } - // The image has to be mentioned in the adjacent index.html document + // The image has to be mentioned in the adjacent index.md document const parentPath = path.dirname(filePath); - const htmlFilePath = path.join(parentPath, "index.html"); - const mdFilePath = path.join(parentPath, "index.md"); - const docFilePath = (await fse.exists(htmlFilePath)) - ? htmlFilePath - : (await fse.exists(mdFilePath)) - ? mdFilePath - : null; - if (!docFilePath) { + const docFilePath = path.join(parentPath, "index.md"); + let rawContent; + try { + rawContent = await fs.readFile(docFilePath, "utf-8"); + } catch { throw new FixableError( `${getRelativePath( filePath, @@ -204,9 +200,6 @@ export async function checkFile(filePath, options = {}) { } // The image must be mentioned (as a string) in the content - const rawContent = docFilePath - ? await fs.readFile(docFilePath, "utf-8") - : null; if (!rawContent.includes(path.basename(filePath))) { throw new FixableError( `${getRelativePath( @@ -297,7 +290,7 @@ async function checkCompression(filePath, options) { 0, )}% smaller.`, ); - fse.copyFileSync(compressed.destinationPath, filePath); + await fs.copyFile(compressed.destinationPath, filePath); } else { throw new FixableError( `${filePath} is ${formatSize( @@ -310,7 +303,7 @@ async function checkCompression(filePath, options) { } } } finally { - fse.removeSync(tempdir); + await fs.rm(tempdir, { recursive: true, force: true }); } } diff --git a/scripts/filecheck/checker.test.js b/scripts/filecheck/checker.test.js index a609a56e20a49c9..72c6f75cdc2bc43 100644 --- a/scripts/filecheck/checker.test.js +++ b/scripts/filecheck/checker.test.js @@ -5,12 +5,11 @@ import { describe, it } from "node:test"; import { checkFile } from "./checker.js"; -const HTML_FIXTURES = new URL("fixtures/html/", import.meta.url); -const MD_FIXTURES = new URL("fixtures/md/", import.meta.url); +const FIXTURES = new URL("fixtures/", import.meta.url); describe("checking files", () => { it("should spot SVGs with scripts inside them", async () => { - const filePath = fileURLToPath(new URL("./script.svg", HTML_FIXTURES)); + const filePath = fileURLToPath(new URL("./script.svg", FIXTURES)); console.assert(fs.existsSync(filePath), `${filePath} does not exist`); await assert.rejects( () => checkFile(filePath), @@ -19,7 +18,7 @@ describe("checking files", () => { }); it("should spot SVGs with onLoad inside an element", async () => { - const filePath = fileURLToPath(new URL("./onhandler.svg", HTML_FIXTURES)); + const filePath = fileURLToPath(new URL("./onhandler.svg", FIXTURES)); console.assert(fs.existsSync(filePath), `${filePath} does not exist`); await assert.rejects( () => checkFile(filePath), @@ -28,25 +27,19 @@ describe("checking files", () => { }); it("should spot files that are not mentioned in source", async () => { - const filePath = fileURLToPath(new URL("./orphan.png", HTML_FIXTURES)); - console.assert(fs.existsSync(filePath), `${filePath} does not exist`); - await assert.rejects(() => checkFile(filePath), /is not mentioned in/); - }); - - it("should spot files that are not mentioned in md source", async () => { - const filePath = fileURLToPath(new URL("./orphan.png", MD_FIXTURES)); + const filePath = fileURLToPath(new URL("./orphan.png", FIXTURES)); console.assert(fs.existsSync(filePath), `${filePath} does not exist`); await assert.rejects(() => checkFile(filePath), /is not mentioned in/); }); it("should spot files that are completely empty", async () => { - const filePath = fileURLToPath(new URL("./zero.gif", HTML_FIXTURES)); + const filePath = fileURLToPath(new URL("./zero.gif", FIXTURES)); console.assert(fs.existsSync(filePath), `${filePath} does not exist`); await assert.rejects(() => checkFile(filePath), /is 0 bytes/); }); it("should spot mismatch between file-type and file extension", async () => { - const filePath = fileURLToPath(new URL("./png.jpeg", HTML_FIXTURES)); + const filePath = fileURLToPath(new URL("./png.jpeg", FIXTURES)); console.assert(fs.existsSync(filePath), `${filePath} does not exist`); await assert.rejects( () => checkFile(filePath), diff --git a/scripts/filecheck/fixtures/md/circle.svg b/scripts/filecheck/fixtures/circle.svg similarity index 100% rename from scripts/filecheck/fixtures/md/circle.svg rename to scripts/filecheck/fixtures/circle.svg diff --git a/scripts/filecheck/fixtures/html/index.html b/scripts/filecheck/fixtures/html/index.html deleted file mode 100644 index f6a05c2a18dca51..000000000000000 --- a/scripts/filecheck/fixtures/html/index.html +++ /dev/null @@ -1,4 +0,0 @@ -

Filecheck fixture

- - - diff --git a/scripts/filecheck/fixtures/md/index.md b/scripts/filecheck/fixtures/index.md similarity index 100% rename from scripts/filecheck/fixtures/md/index.md rename to scripts/filecheck/fixtures/index.md diff --git a/scripts/filecheck/fixtures/md/orphan.png b/scripts/filecheck/fixtures/md/orphan.png deleted file mode 100644 index 791501245adad69de482b0346060771ccd008719..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 592 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+ueoXe|!I#{XiaP zfk$L9kgfz_MvJW-LO=$4iKnkC`(rj~em?#{n~4*ELc2X(978nDC#U>4-ym*aXb`ZX zf%RaI&FufZ{kh-YYp+p1qNlBNu5bI_^IuQF z`#%tT{yJ~X=b*W`YD|7g$lqlWinOK`h^=$~r#@B_cR-(Fms{Nj^4{{c~hKjPK5 z%Q(``uKJslzgI8no|0(7F`~Uv`|6H=mWD`@{|1|S_ z`QJ6N{Xizq|JM5pKS^r#`7%7b{CKnD_AFtbH&jbpBT7;dOH!?pi&B9UgOP!urLKXQ zu910&p{bRjiIt(Lwtt)x7$D3zhS zyj(9cFS|H7u^?41zbJk7I~ysWqVTGah?1bha)pAT{ItxRRE3htf>edff|6tghKf0l zKk;xBhG}S=@;`mX^Jx$Rvog0{GPkg@u=ivUW?==F29v`n%*vZX6i(l`a^lFDBQi(W fPd9ih@X}*=B`#R<$;oso& b ? 1 : 0; }); - for (let i = 0; i < lines.length; ) { + for (let i = 0; i < lines.length;) { const line = lines[i]; if (line.trim() !== "") { uniq.push(line);