JavaScript source analysis and visualizer that generates detailed complexity reports
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Complete CLI for batch analysis, CI/CD integration, and automated reporting workflows. The CLI provides programmatic access to command-line functionality and configuration.
Execute CLI analysis with programmatic override options.
/**
* Execute CLI analysis with programmatic override options
* @param {Object} options - Override CLI options (optional)
* @param {Function} done - Completion callback (optional)
*/
function exec(options, done);Parameters:
options (Object, optional): Override CLI optionsdone (Function, optional): Completion callbackUsage Examples:
const cli = require('plato/lib/cli');
// Execute with default CLI options
cli.exec();
// Execute with custom options
cli.exec({
title: 'Custom Analysis',
recurse: true,
quiet: false
}, function() {
console.log('CLI analysis completed');
});
// Access parsed CLI arguments
console.log('CLI args:', cli.args);
console.log('CLI options:', cli.options);Access to CLI options configuration and parsed command-line arguments.
/** CLI options configuration object */
const options: Object;
/** Parsed command-line arguments object */
const args: Object;Properties:
options (Object): CLI options configuration objectargs (Object): Parsed command-line arguments objectThe CLI supports the following command-line options:
plato -h, --help # Display help text
plato -v, --version # Print version informationplato -d, --dir <String> # Output directory for reports (required)
plato -t, --title <String> # Custom report title
plato -r, --recurse # Recursively search directories
plato -q, --quiet # Reduce output to errors only
plato -n, --noempty # Skip empty lines from line countplato -x, --exclude <String> # File exclusion regex patternplato -l, --jshint <String> # JSHint configuration file path
plato -e, --eslint <String> # ESLint configuration file pathplato -D, --date <String> # Custom report date# Analyze all JavaScript files in src directory
plato -r -d reports src
# Analyze specific files with custom title
plato -d reports -t "My Project Analysis" src/app.js src/utils.js# Exclude test files and node_modules
plato -r -d reports -x "test|spec|node_modules" src
# Use custom JSHint configuration
plato -r -d reports -l .jshintrc src
# Quiet mode for CI/CD
plato -r -d reports -q src# CI/CD pipeline usage
plato -r -d build/reports -q -t "Build $BUILD_NUMBER" src
if [ $? -eq 0 ]; then
echo "Code analysis passed"
else
echo "Code analysis failed"
exit 1
fi
# Generate reports with timestamp
plato -r -d "reports-$(date +%Y%m%d)" -t "Daily Analysis" srcWhen using the exec() function programmatically, you can override CLI options:
interface CLIOptions {
/** Output directory path */
dir?: string;
/** Report title */
title?: string;
/** Recursively search directories */
recurse?: boolean;
/** Quiet mode */
quiet?: boolean;
/** Skip empty lines */
noempty?: boolean;
/** File exclusion regex */
exclude?: string;
/** JSHint config file path */
jshint?: string;
/** ESLint config file path */
eslint?: string;
/** Custom report date */
date?: string;
/** File paths to analyze */
files?: string[];
}Usage Examples:
const cli = require('plato/lib/cli');
// Override CLI options programmatically
cli.exec({
dir: 'custom-reports',
title: 'Automated Analysis',
recurse: true,
quiet: true,
files: ['src/**/*.js']
}, function() {
console.log('Analysis complete');
});The main executable is located at bin/plato and provides the command-line interface:
/** Main CLI executable that delegates to lib/cli.js */
// Handles version (-v) and help (-h) flags
// Calls cli.exec() for main functionalityDirect Execution:
# Using global installation
plato -r -d reports src
# Using npx
npx plato -r -d reports src
# Using local installation
./node_modules/.bin/plato -r -d reports srcThe CLI integrates with the info module for version and help display:
/** Package name constant */
const name: string;
/** Print version to console */
function version(): void;
/** Print help text to console */
function help(): void;Usage in CLI context:
plato --version # Calls info.version()
plato --help # Calls info.help()The CLI uses standard exit codes for automation and CI/CD integration:
0: Analysis completed successfully1: Analysis failed due to errors2: Invalid command-line argumentsCI/CD Integration:
# Bash script example
plato -r -d reports -q src
exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "✓ Code analysis passed"
# Continue with deployment
else
echo "✗ Code analysis failed (exit code: $exit_code)"
exit $exit_code
fiInstall with Tessl CLI
npx tessl i tessl/npm-plato