/
githubmirror
/
DefinitelyTyped
Обзор
Документация
Войти
/
githubmirror
/
DefinitelyTyped
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
scripts/not-needed.js
33 строки
1 KB
Jimmy Leung
🤖 Merge PR #70907 feat: Enable not-needed.js to also remove package in attw.json by @hkleungai
22 окт 2024, 05:14
Не верифицирован
22 окт 2024, 05:14
cc56e6e
Код
Авторство
О чём код?
// Script to remove a package from DefinitelyTyped and add it to notNeededPackages.json import * as fs from "node:fs"; import * as path from "node:path"; const typingsPackageName = process.argv[2]; const asOfVersion = process.argv[3]; const libraryName = process.argv[4] || typingsPackageName; if (process.argv.length !== 4 && process.argv.length !== 5) { console.log("Usage: pnpm run not-needed typingsPackageName asOfVersion [libraryName]"); process.exit(1); } fs.rmSync(path.join("types", typingsPackageName), { recursive: true, force: true, maxRetries: process.platform === "win32" ? 10 : 0, }); /** @type {{packages: Record<string, { libraryName: string; asOfVersion: string; }> }} */ const notNeededPackages = JSON.parse(fs.readFileSync("notNeededPackages.json", "utf-8")); notNeededPackages.packages[typingsPackageName] = { libraryName, asOfVersion }; notNeededPackages.packages = Object.fromEntries(Object.entries(notNeededPackages.packages).sort()); fs.writeFileSync("notNeededPackages.json", JSON.stringify(notNeededPackages, undefined, 4) + "\n", "utf-8"); /** @type {{ failingPackages: string[] }} */ const attw = JSON.parse(fs.readFileSync("attw.json", "utf-8")); const packageWithOptionalVersionRegex = new RegExp(`^${typingsPackageName}(/v\\d+)?$`); attw.failingPackages = attw.failingPackages.filter((failingPackage) => ( !packageWithOptionalVersionRegex.test(failingPackage) )); fs.writeFileSync("attw.json", JSON.stringify(attw, undefined, 4) + "\n", "utf-8");