diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index 339a5be688de..0a96f329ab53 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -2,7 +2,7 @@ name: Clean up abandoned files on: schedule: - - cron: '30 0 * * 1' + - cron: '0 2 * * 1' workflow_dispatch: jobs: update: diff --git a/.github/workflows/update-tr.yml b/.github/workflows/update-tr.yml index 2d0f00a47d19..d997f2372d69 100644 --- a/.github/workflows/update-tr.yml +++ b/.github/workflows/update-tr.yml @@ -1,6 +1,6 @@ on: schedule: - - cron: '11 11 * * 1' + - cron: '0 1 * * 1' workflow_dispatch: name: Update TR report jobs: diff --git a/tools/clean-abandoned-files.js b/tools/clean-abandoned-files.js index 9221a8734452..6dae14b0ff0a 100644 --- a/tools/clean-abandoned-files.js +++ b/tools/clean-abandoned-files.js @@ -4,6 +4,7 @@ const ed = require("../ed/index.json"); const tr = require("../tr/index.json"); const subdirs = ["dfns", "css", "headings", "idl", "idlparsed", "links", "refs"]; +const idlnamesSubdirs = ["idlnames", "idlnamesparsed"]; const removeExtension = f => { @@ -21,7 +22,45 @@ function checkDir(path, index) { } } +function checkIdlNames(path, index) { + // Build the list of IDL names from idlparsed extracts + const idlFiles = new Set(index.results.map(spec => spec.idlparsed).filter(s => !!s)); + let idlNames = new Set(); + for (const idlFile of idlFiles) { + const idlparsed = require("../" + path + "/" + idlFile); + if (!idlparsed || !idlparsed.idlparsed) { + continue; + } + if (idlparsed.idlparsed.idlNames) { + for (const name of Object.keys(idlparsed.idlparsed.idlNames)) { + idlNames.add(name); + } + } + if (idlparsed.idlparsed.idlExtendedNames) { + for (const name of Object.keys(idlparsed.idlparsed.idlExtendedNames)) { + idlNames.add(name); + } + } + } + + // Parse subfolders that contain files named after IDL names + for (const subdir of idlnamesSubdirs) { + if (!fs.existsSync(path + "/" + subdir)) { + continue; + } + const filenames = fs.readdirSync(path + "/" + subdir); + for (const filename of filenames) { + const name = filename.match(/(.+)\.[^\.]+$/)[1]; + if (!idlNames.has(name)) { + fs.unlinkSync(path + "/" + subdir + "/" + filename); + } + } + } +} + for (let dir of subdirs) { checkDir("ed/" + dir, ed); checkDir("tr/" + dir, tr); } +checkIdlNames("ed", ed); +checkIdlNames("tr", tr);