MCPcopy Index your code
hub / github.com/adobe/react-spectrum / main

Function main

scripts/reportExports.js:32–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30main();
31
32function main() {
33 let exportFiles = fg
34 .sync('**/exports/**/*.ts', {
35 cwd: packagesDir,
36 absolute: true,
37 ignore: ['**/*.d.ts']
38 })
39 .sort((a, b) => a.localeCompare(b));
40
41 let program = ts.createProgram(exportFiles, {
42 allowJs: false,
43 checkJs: false,
44 jsx: ts.JsxEmit.ReactJSX,
45 module: ts.ModuleKind.ESNext,
46 moduleResolution: ts.ModuleResolutionKind.Bundler,
47 noEmit: true,
48 skipLibCheck: true,
49 target: ts.ScriptTarget.ESNext
50 });
51
52 let checker = program.getTypeChecker();
53 let report = [];
54
55 for (let fileName of exportFiles) {
56 let sourceFile = program.getSourceFile(fileName);
57 if (!sourceFile) {
58 continue;
59 }
60
61 let moduleSymbol = checker.getSymbolAtLocation(sourceFile);
62 let exports = moduleSymbol ? checker.getExportsOfModule(moduleSymbol) : [];
63 let exportNames = exports.map(symbol => symbol.getName()).sort((a, b) => a.localeCompare(b));
64
65 let specifier = getImportSpecifier(fileName);
66
67 report.push({
68 specifier,
69 packageName: getPackageName(specifier),
70 isRoot: isRootSpecifier(specifier),
71 isPrivate: specifier.includes('/private/'),
72 exports: exportNames
73 });
74 }
75
76 report.sort((a, b) => a.specifier.localeCompare(b.specifier));
77 let packageData = buildPackageData(report);
78 let noteFilters = args.values.note ?? [];
79
80 for (let entry of report) {
81 let lines = [];
82 let {specifier, exports: exportNames} = entry;
83
84 for (let exportName of exportNames) {
85 let notes = getExportNotes(entry, exportName, packageData);
86 if (matchesNoteFilter(notes, noteFilters)) {
87 lines.push(`- \`${exportName}\`${notes.length > 0 ? ` (${notes.join(', ')})` : ''}`);
88 }
89 }

Callers 1

reportExports.jsFile · 0.70

Calls 8

getImportSpecifierFunction · 0.85
getPackageNameFunction · 0.85
isRootSpecifierFunction · 0.85
buildPackageDataFunction · 0.85
getExportNotesFunction · 0.85
matchesNoteFilterFunction · 0.85
pushMethod · 0.80
sortMethod · 0.65

Tested by

no test coverage detected