reflog
v0.0.4
Published
CLI tool to search for references in project files and log results
Readme
Reference Finder
A CLI tool that searches for references in your project and logs the results to a gitignored folder.
Installation
npm install -g reflogOr locally in your project:
npm install reflog --save-devUsage
This tool provides two ways to use it - either through the unified reflog command or through direct commands.
Unified Command Interface
# Search for a single key
reflog search "database.host" --log
# Generate logs for all keys in a configuration
reflog generate --config=path/to/config.json
# Display help information
reflog --helpDirect Commands
Finding References for a Single Key
# Basic usage
find-references "database.host"
# Log the results to file
find-references "database.host" --log
# Specify directory to search
find-references "api.endpoint" --dir "./src"Processing Multiple Keys from Configuration
# Process all keys from a configuration file
generate-conf-references --config=path/to/config.json
# Process keys from the default conf.json in logs folder
generate-conf-referencesConfiguration File
The tool uses a configuration file in JSON format to specify which keys to search for. Example structure:
{
"database.host": "host",
"api.endpoint": "endpoint",
"auth.secret": "secret"
}By default, the tool looks for conf.json in the logs folder. If the file doesn't exist, the tool will prompt you to create it.
Options
For single key searches (reflog search or find-references):
--help, -h: Display help information for the command--log: Log the results to a file in the logs directory (name pattern:search_${value}_${occurrence}occ.log)--dir, -d: Directory to search in (default: current directory)--exclude, -e: Exclude pattern (glob) (default: node_modules/**)
For configuration-based searches (reflog generate or generate-conf-references):
--help, -h: Display help information for the command--config=path/to/file.json: Specify a custom configuration file path
Programmatic Usage
You can also use the package programmatically:
const { findReferences } = require("reference-finder");
const results = findReferences({
key: "database.host",
dir: "./src",
exclude: "node_modules/**,dist/**",
});
console.log(`Found ${results.totalMatches} matches for ${results.key}`);Features
- Unified CLI interface with intuitive subcommands
- Searches for configuration key references in your codebase
- Creates a logs directory (and adds it to .gitignore)
- Generates detailed log files with matches
- Shows progress with a visual progress bar when processing multiple keys
- Can process multiple keys from a configuration file
- Can be used both as a CLI and as a library
Examples
# Find all references to a specific API endpoint (unified interface)
reflog search "api.users.endpoint" --log
# Find all references to a specific API endpoint (direct command)
find-references "api.users.endpoint" --log
# Process all keys defined in the conf.json (unified interface)
reflog generate
# Process all keys defined in the conf.json (direct command)
generate-conf-references
# Use a custom configuration file (unified interface)
reflog generate --config=./my-config.json
# Use a custom configuration file (direct command)
generate-conf-references --config=./my-config.jsonThe unified interface (reflog) is recommended for new usage as it provides a more consistent experience.
