UNPKG

ubon

Version:

Security scanner for AI-generated React/Next.js and Python apps. Catches hardcoded secrets, accessibility issues, and vulnerabilities that traditional linters miss.

27 lines (26 loc) 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.installPreCommitHooks = installPreCommitHooks; const fs_1 = require("fs"); const child_process_1 = require("child_process"); function installPreCommitHooks(options) { if (!(0, fs_1.existsSync)('.git')) { throw new Error('Not a git repository (missing .git)'); } const mode = options.mode || 'fast'; const failOn = options.failOn || 'error'; const entry = `ubon check --git-changed-since HEAD ${mode === 'fast' ? '--fast' : ''} --fail-on ${failOn}`.trim(); const yaml = `repos:\n - repo: local\n hooks:\n - id: ubon-security-check\n name: Ubon Security Scanner\n entry: ${entry}\n language: system\n files: \\\.(js|jsx|ts|tsx|py)$\n pass_filenames: false\n`; (0, fs_1.writeFileSync)('.pre-commit-config.yaml', yaml); console.log('✅ Created .pre-commit-config.yaml'); try { (0, child_process_1.execSync)('pre-commit --version', { stdio: 'ignore' }); } catch { console.log('⚠️ pre-commit not installed. Install with: pip install pre-commit'); console.log('Then run: pre-commit install'); return; } (0, child_process_1.execSync)('pre-commit install', { stdio: 'inherit' }); console.log('✅ Ubon pre-commit hooks installed successfully'); }