The goal of this epic is to develop a Node.js script that collects component adoption metrics from a code base. The script will parse a list of components from a JSON file, traverse all folders and files within a specified folder path, and count the number of instances each component has been used in .tsx and .js files. The results will be outputted in a spreadsheet with each component and its corresponding usage count.
User Stories:
As a developer, I want to input a JSON file containing a list of components so that the script knows which components to look for.
Acceptance Criteria:
The script should accept a JSON file as input.
The JSON file should contain a list of components.
As a developer, I want to specify a folder path so that the script knows where to look for the components.
Acceptance Criteria:
The script should accept a folder path as input.
The script should traverse all folders and files within the given folder path.
As a developer, I want the script to count the number of instances each component has been used in .tsx and .js files so that I can track the usage of each component.
Acceptance Criteria:
The script should count the number of instances each component has been used in .tsx and .js files.
The script should handle errors gracefully and not crash the application.
As a developer, I want the script to output the component usage count in a spreadsheet so that I can easily analyze and visualize the data.
Acceptance Criteria:
The script should output the component usage count in a spreadsheet.
The spreadsheet should contain each component and its corresponding usage count.
Tasks:
Setup the project: Create a new directory for the project and initialize it with npm.
Install necessary packages: Install the glob, fs, and json2csv packages using npm.
Create the script: Create a new index.js file and open it in a text editor.
Import necessary modules: Import the glob, fs, and json2csv modules.
Load the components: Load the list of components from the JSON file.
Initialize the component counts: Initialize a count for each component.
Traverse the file system: Use glob to traverse the file system and find all .tsx and .js files.
Count component usage: For each file, read its contents and increment the count for each component every time it is found.
Convert the results to CSV: Use json2csv to convert the results to CSV format.
Write the results to a file: Write the CSV data to a file.
Acceptance Criteria:
The script should be written in Node.js.
The script should accept a JSON file containing a list of components and a folder path as input.
The script should traverse all folders and files within the given folder path.
The script should count the number of instances each component has been used in .tsx and .js files.
The script should output the component usage count in a spreadsheet.
The script should handle errors gracefully and not crash the application.
The script should be efficient and not consume excessive system resources.
Description:
The goal of this epic is to develop a Node.js script that collects component adoption metrics from a code base. The script will parse a list of components from a JSON file, traverse all folders and files within a specified folder path, and count the number of instances each component has been used in
.tsx
and.js
files. The results will be outputted in a spreadsheet with each component and its corresponding usage count.User Stories:
As a developer, I want to input a JSON file containing a list of components so that the script knows which components to look for.
As a developer, I want to specify a folder path so that the script knows where to look for the components.
As a developer, I want the script to count the number of instances each component has been used in
.tsx
and.js
files so that I can track the usage of each component..tsx
and.js
files.As a developer, I want the script to output the component usage count in a spreadsheet so that I can easily analyze and visualize the data.
Tasks:
glob
,fs
, andjson2csv
packages using npm.index.js
file and open it in a text editor.glob
,fs
, andjson2csv
modules.glob
to traverse the file system and find all.tsx
and.js
files.json2csv
to convert the results to CSV format.Acceptance Criteria:
.tsx
and.js
files.