mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
// @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)}"\``;
|
||
// }
|