Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

raulfdm/js-ts-import-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Import checker

JS|TS import statement report generator

Why

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.

What's behind

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

Workflow

It's a very simple workflow, where:

  1. It's defined the absolute path of each project;
  2. With that, it runs glob and get it back all files;
  3. Each file is read by node fs and has its content analyzed babel parser;
  4. It walks through the AST and filters only Statements type of import and which it's from @blendle/lego;
  5. With the component name and file path, it creates a CSV record previously described;
  6. With all CSV records, it generates the report file;

How to run

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.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published