@hyperfrontend/project-scope/cliCLI Module
The cli module provides a command-line interface for analyzing JavaScript/TypeScript projects. It exposes the library's capabilities through an easy-to-use terminal interface.
Usage
# General usage
project-scope <command> [options]
# Get help
project-scope --help
project-scope <command> --help
Commands
analyze
Analyze project structure and technology stack.
# Analyze current directory
project-scope analyze
# Analyze specific project
project-scope analyze ./my-project
# Output as JSON
project-scope analyze --format json
# Deep analysis with all detections
project-scope analyze --depth deep
# Include only specific analyses
project-scope analyze --include frameworks,buildTools
Options:
| Option | Description |
|---|---|
--format <text|json|yaml> |
Output format (default: text) |
--depth <basic|full|deep> |
Analysis depth |
--include <types> |
Analyses to include (comma-separated) |
--exclude <types> |
Analyses to exclude (comma-separated) |
config
Inspect configuration files in the project.
# List all config files
project-scope config
# Filter by type
project-scope config --type typescript
project-scope config --type eslint,prettier
deps
Analyze project dependencies.
# Show dependency summary
project-scope deps
# Show only production dependencies
project-scope deps --type production
# Show dependency graph
project-scope deps --graph
tree
Display file tree visualization.
# Show project structure
project-scope tree
# Limit depth
project-scope tree --depth 3
# Show specific directory
project-scope tree src
Global Options
| Option | Short | Description |
|---|---|---|
--help |
-h |
Show help information |
--version |
-v |
Show version |
--verbose |
Enable verbose output | |
--json |
Output as JSON (shorthand for --format json) | |
--no-color |
Disable colored output |
Programmatic Usage
The CLI can also be invoked programmatically:
import { run } from '@hyperfrontend/project-scope'
// Analyze current directory
const result = run(['analyze'])
// Analyze with options
const result2 = run(['analyze', './my-project', '--format', 'json'])
// Check result
if (result.exitCode === 0) {
console.log(result.output)
} else {
console.error(result.error)
}
Adding Custom Commands
Commands implement the Command interface:
interface Command {
name: string
description: string
execute(args: string[], globalOptions: GlobalOptions): CommandResult
getHelp(): string
}
Output Formats
Text (default)
Human-readable formatted output with colors and structure.
JSON
Machine-readable JSON output for integration with other tools.
YAML
Human-readable structured output (when available).
API Reference
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§options | AnalyzeCommandOptions | Configuration for the analyze operation |
Returns
CommandResultExamples
Basic analysis of current directory
const result = analyzeCommand({ depth: 'basic' })
if (result.exitCode === 0) {
console.log(result.output)
// => "Project Type: Library\nWorkspace: NX Monorepo\n..."
}JSON output with filters
const result = analyzeCommand({
path: './apps/frontend',
format: 'json',
depth: 'deep',
exclude: ['node_modules', 'dist'],
})
// => { exitCode: 0, output: '{"type":"application",...}' }Parameters
| Name | Type | Description |
|---|---|---|
§options | ConfigCommandOptions | Configuration command options |
Returns
CommandResultExamples
Detect all configs in a project
const result = configCommand({ path: './my-project' })
if (result.exitCode === 0) {
console.log(result.output)
// => "TypeScript: tsconfig.json\nLinting: eslint.config.js\n..."
}Filter by type with contents
const result = configCommand({
path: './my-project',
type: 'tsconfig',
showContents: true,
format: 'json',
})
// => { exitCode: 0, output: '[{"type":"tsconfig","path":"tsconfig.json",...}]' }Parameters
| Name | Type | Description |
|---|---|---|
§options | DepsCommandOptions | Parsed command options |
Returns
CommandResultExamples
List all dependencies
const result = depsCommand({ path: './my-project' })
if (result.exitCode === 0) {
console.log(result.output)
// => "Dependencies\n============\nProduction (3):\n react ^18.2.0\n..."
}Filter to dev dependencies as JSON
const result = depsCommand({
path: './my-project',
type: 'development',
format: 'json',
})
// => { exitCode: 0, output: '{"devDependencies":{"typescript":"^5.0.0",...}}' }Parameters
| Name | Type | Description |
|---|---|---|
§args | string[] | Command line arguments (typically process.argv.slice(2)) |
Returns
CommandResultExample
Running analysis via CLI
import { run } from '@hyperfrontend/project-scope'
// Analyze current directory
const result = run(['analyze'])
// Analyze specific project with JSON output
const result2 = run(['analyze', './my-project', '--format', 'json'])
// Show dependency tree
const result3 = run(['deps', '--type', 'production'])
process.exit(result.exitCode)Parameters
| Name | Type | Description |
|---|---|---|
§options | TreeCommandOptions | Configuration for the tree operation |
Returns
CommandResultExamples
Basic tree of current directory
const result = treeCommand({ depth: 2 })
if (result.exitCode === 0) {
console.log(result.output)
// => "src/\n├── index.ts\n├── lib/\n│ └── utils.ts\n..."
}Directories only with metadata
const result = treeCommand({
path: './project',
dirsOnly: true,
showSize: true,
ignore: ['node_modules', '.git'],
format: 'json',
})
// => { exitCode: 0, output: '[{"name":"src","isDirectory":true,...}]' }