UNPKG

supernal-coding

Version:

Comprehensive development workflow CLI with kanban task management, project validation, git safety hooks, and cross-project distribution system

129 lines (102 loc) • 3.66 kB
#!/usr/bin/env node /** * Type Duplication Checker CLI Command * Provides a clean interface to the type duplication detection system */ const { spawn } = require('child_process'); const path = require('path'); const fs = require('fs'); class TypeCheckCommand { constructor() { this.scriptPath = path.join(process.cwd(), 'scripts', 'check-type-duplicates.cjs'); } async execute(args = []) { // Verify script exists if (!fs.existsSync(this.scriptPath)) { console.error('āŒ Type duplication checker script not found at:', this.scriptPath); console.error('šŸ’” Run "sc init" to install the complete equipment pack'); process.exit(1); } // Pass through all arguments to the script const child = spawn('node', [this.scriptPath, ...args], { stdio: 'inherit', cwd: process.cwd() }); child.on('error', (error) => { console.error('āŒ Failed to run type duplication checker:', error.message); process.exit(1); }); child.on('exit', (code) => { process.exit(code); }); } static getHelp() { return ` šŸ” Type Duplication Checker USAGE: sc type-check [OPTIONS] DESCRIPTION: Detect and prevent TypeScript/JavaScript type duplications to maintain clean architecture. Uses configuration from supernal-code.config.toml for scan directories and settings. OPTIONS: --help, -h Show this help message --pre-commit Run in pre-commit mode (exit with error on duplications) --force Force commit despite duplications (use with --pre-commit) --show-ignored Include ignored types in output --show-legitimate Include legitimate duplications in output --init-config Create initial .duplication-lint.json config file --add-ignore=TYPE Add a type to the ignore list --add-legitimate=TYPE Add a type to legitimate duplications --update=TYPE_NAME Update only the specified type's report --update-types=TYPE1,TYPE2,TYPE3 Update multiple specific types EXAMPLES: # Full analysis sc type-check # Pre-commit check sc type-check --pre-commit # Force commit despite duplications sc type-check --pre-commit --force # Update specific type after fixes sc type-check --update=ComponentName # Initialize configuration sc type-check --init-config CONFIGURATION: The checker uses settings from supernal-code.config.toml: [type_duplication] enabled = true scan_directories = ["src", "lib", "components"] exclude_directories = ["node_modules", "dist"] pre_commit_hook = true block_commits_on_duplications = true See docs/TYPE_DUPLICATION_CHECKER.md for full configuration options. INTEGRATION: • Pre-commit hooks: Automatically blocks commits with duplications • CI/CD: Returns appropriate exit codes for build systems • Reports: Generates detailed analysis in reports/duplications/ `; } } // Export for CLI system module.exports = { command: 'type-check', description: 'Detect and prevent type duplications', async handler(args) { const typeCheck = new TypeCheckCommand(); // Show help if requested if (args.includes('--help') || args.includes('-h')) { console.log(TypeCheckCommand.getHelp()); return; } await typeCheck.execute(args); } }; // Allow direct execution if (require.main === module) { const typeCheck = new TypeCheckCommand(); const args = process.argv.slice(2); if (args.includes('--help') || args.includes('-h')) { console.log(TypeCheckCommand.getHelp()); process.exit(0); } typeCheck.execute(args); }