loqatevars
Version:
Locate JavaScript files with 'const' or 'process.env' usage in LLM-generated codebases
26 lines (20 loc) • 2.17 kB
Markdown
# Modules
This document provides a summary of the key modules in the `loqatevars` project.
* **[`index.js`](index.js)**
* **Purpose**: The main entry point for the `npm` package.
* **Functionality**: It exports the core functions `findMatchingFiles` and `findMatchingFilesDetailed` from [`lib/utils.js`](lib/utils.js), making them available for other Node.js projects to use programmatically.
* **[`cli.js`](cli.js)**
* **Purpose**: The command-line interface for the application.
* **Functionality**: This module handles parsing of command-line arguments, executes the appropriate scanning functions based on user commands (`scan`, `detailed`), and displays the results in a user-friendly format in the console. It also provides a `help` command.
* **[`lib/utils.js`](lib/utils.js)**
* **Purpose**: The core logic of the application.
* **Functionality**: This is where the main work of finding and analyzing files happens.
* `searchFiles`: Uses `globby` to find all relevant files in a directory, respecting ignore patterns.
* `analyzeConstUsage`: Uses `acorn` to perform Abstract Syntax Tree (AST) analysis on file content to identify `const` declarations (excluding `require` statements) and `process.env` usage.
* `findMatchingFiles` and `findMatchingFilesDetailed`: These functions orchestrate the file search and analysis, returning a simple or detailed list of matching files.
* **[`config/localVars.js`](config/localVars.js)**
* **Purpose**: Centralized configuration for the application.
* **Functionality**: This file defines and exports configuration variables, such as `ignoreDirs` (a list of directories to exclude from scans) and any environment variables used in the project. This makes it easy to manage and modify configuration without changing the core logic.
* **[`lib/errors.js`](lib/errors.js)**
* **Purpose**: Defines a custom error class for the application.
* **Functionality**: This file contains the `AppError` class, which is used to create custom errors with unique codes. This is useful for handling specific error cases in the application.