You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB
JavaScript

2 years ago
"use strict";
const chalk = require("chalk");
const escapeRegexString = require("escape-regex-string");
const packages = require("./packages.json");
const issues = require("./all-issues.json");
let blacklist = new Set(["file", "at", "boot", "instead", "check", "more", "non", "roundup", "root", "screen", "src", "t", "which", "arguments", "wrap", "up", "unit", "units"]);
function normalizeString(string) {
return string.replace(/'/g, "").replace(/[^a-zA-Z0-9]/g, " ").replace(/\s{2,}/g, " ");
}
let classifiedIssues = new Set();
packages.filter((pkg) => {
return !blacklist.has(pkg);
}).forEach((pkg) => {
let searchString = normalizeString(pkg);
let regex = new RegExp(`\\b${escapeRegexString(searchString)}\\b`)
let matches = issues.filter((issue) => {
if (issue.title != null) {
let normalizedTitle = normalizeString(issue.title);
return regex.test(normalizedTitle);
} else {
// occurs on rate-limiting errors
return false;
}
});
matches.forEach((issue) => {
classifiedIssues.add(issue.id);
});
if (matches.length > 0) {
console.log(chalk.yellow.bold(pkg));
matches.forEach((match) => {
console.log(`\t ${chalk.bold(`#${match.number}`)} ${match.title}`);
});
}
});
console.log(`Classified ${classifiedIssues.size} issues. Failed to classify ${issues.length - classifiedIssues.size} issues.`);