cosmos-explorer/strict-migration-tools/index.js

54 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-check
const path = require("path");
const glob = require("glob");
const { forStrictNullCheckEligibleFiles, forEachFileInSrc } = require("./src/getStrictNullCheckEligibleFiles");
const { getImportsForFile } = require("./src/tsHelper");
const projectRoot = path.join(process.cwd());
const srcRoot = path.join(projectRoot, "src");
let sort = true;
let filter;
let printDependedOnCount = true;
let includeTests = false;
// if (false) {
// // Generate test files listing
// sort = false;
// filter = x => x.endsWith(".test.ts");
// printDependedOnCount = false;
// includeTests = true;
// }
forStrictNullCheckEligibleFiles(projectRoot, () => {}, { includeTests }).then(async eligibleFiles => {
console.log(eligibleFiles);
// const eligibleSet = new Set(eligibleFiles);
// const dependedOnCount = new Map(eligibleFiles.map(file => [file, 0]));
// for (const file of await forEachFileInSrc(srcRoot)) {
// if (eligibleSet.has(file)) {
// // Already added
// continue;
// }
// for (const imp of getImportsForFile(file, srcRoot)) {
// if (dependedOnCount.has(imp)) {
// dependedOnCount.set(imp, dependedOnCount.get(imp) + 1);
// }
// }
// }
// let out = Array.from(dependedOnCount.entries());
// if (filter) {
// out = out.filter(x => filter(x[0]));
// }
// if (sort) {
// out = out.sort((a, b) => b[1] - a[1]);
// }
// for (const pair of out) {
// console.log(toFormattedFilePath(pair[0]) + (printDependedOnCount ? ` — Depended on by **${pair[1]}** files` : ""));
// }
});
// function toFormattedFilePath(file) {
// // return `"./${path.relative(srcRoot, file)}",`;
// return `- [ ] \`"./${path.relative(srcRoot, file)}"\``;
// }