JS|TS import statement report generator
This project was created to automate the analyzis of which component from @blendle/lego
(react component library) is been used in all 4 web projects. With the all imports, an csv
file is generated containing:
<file-path>;<component-name>;<project-name>
Later this data is used in a Google Sheets which shows us visually what's the most and less used component within the library.
In order to make this analyses, it uses:
- Typescript (just because it's nice to have types :p)
- nodeJS file system;
@babel/parser
: to create an Abstract Syntax Tree object and understand what's an import;glob
: to get the absolute path of all desired files
It's a very simple workflow, where:
- It's defined the absolute path of each project;
- With that, it runs
glob
and get it back all files; - Each file is read by node fs and has its content analyzed babel parser;
- It walks through the
AST
and filters only Statements type ofimport
and which it's from@blendle/lego
; - With the component name and file path, it creates a CSV record previously described;
- With all CSV records, it generates the report file;
First, clone this project.
Then, install the dependencies:
yarn
Then, run report
command:
yarn report
A file report.csv
will be created in the root folder with all data analized.