π index.ts β’ 2426 bytes
/**
* CmdCode V0.5 - ιͺθ―η³»η»
* Phase 3: 代η ιͺθ―
*/
// ε―ΌεΊη±»ε
export type {
VerificationType,
VerificationStatus,
VerificationIssue,
VerificationResult,
VerificationReport,
VerificationOptions
} from './types'
// ε―ΌεΊιͺθ―ε¨
export {
checkSyntax,
checkTypes,
runTests,
checkSecurity,
checkConsistency,
getVerifiersForFile,
} from './checker'
// ε―ΌεΊζ₯εηζ
export {
createReport,
addResult,
formatReport,
formatSummary,
getFailedIssues,
shouldFail,
} from './reporter'
// ε―ΌεΊεΈΈι
export {
DEFAULT_VERIFICATION_OPTIONS,
STATUS_LABELS,
TYPE_LABELS,
} from './types'
// ε―Όε
₯εΈΈιδΎζ¬ε°δ½Ώη¨
import {
DEFAULT_VERIFICATION_OPTIONS,
STATUS_LABELS,
TYPE_LABELS,
} from './types'
// ε―Όε
₯ζ¬ε°ε½ζ°
import { createReport, addResult } from './reporter'
import { getVerifiersForFile } from './checker'
/**
* δΈ»ιͺθ―ε½ζ°
*/
export async function verify(
file: string,
options: Partial<VerificationOptions> = {},
verbose: boolean = true
): Promise<VerificationReport> {
const opts = { ...DEFAULT_VERIFICATION_OPTIONS, ...options }
if (verbose) {
console.log('')
console.log(` \x1b[38;5;220mπ εΌε§ιͺθ―: ${file}\x1b[0m`)
console.log(` \x1b[38;5;240mββββββββββββββββββββββββββββββββ\x1b[0m`)
}
// εε»Ίζ₯ε
const report = createReport(file)
// θ·ειη¨ηιͺθ―ε¨
const verifiers = getVerifiersForFile(file, opts)
if (verifiers.length === 0) {
if (verbose) {
console.log(` \x1b[38;5;240mζ ιη¨ηιͺθ―ε¨οΌθ·³θΏ\x1b[0m`)
}
return report
}
// θΏθ‘ιͺθ―
for (const verifier of verifiers) {
if (verbose) {
console.log(` \x1b[38;5;240m ${TYPE_LABELS[verifier.type]}...\x1b[0m`)
}
const result = await verifier.fn()
addResult(report, result)
if (verbose) {
const icon = result.passed ? '\x1b[38;5;208mβ
\x1b[0m' : '\x1b[38;5;196mβ\x1b[0m'
console.log(` ${icon} ${STATUS_LABELS[result.status]} (${result.duration}ms)`)
}
}
if (verbose) {
console.log('')
console.log(` ${report.overallPassed ? '\x1b[38;5;208mβ
\x1b[0m' : '\x1b[38;5;196mβ\x1b[0m'} ιͺθ―${report.overallPassed ? 'ιθΏ' : 'ε€±θ΄₯'}`)
}
return report
}
/** ηζ¬δΏ‘ζ― */
export const VERIFIER_VERSION = '0.6.0-phase3'