UNPKG

@vocento/wpo-check

Version:

An internal CLI tool to measure and validate Web Performance KPIs during development and CI/CD workflows.

54 lines (47 loc) 1.31 kB
#!/usr/bin/env node import { hideBin } from 'yargs/helpers'; import yargs from 'yargs'; import { executeCheck } from '../lib/cli.js'; import { getThresholds, getConfig } from '../lib/wpo-check-helpers.js'; import { reportResult } from '../lib/reporter.js'; import '../lib/log-descriptor.js'; const argv = yargs(hideBin(process.argv)) .option('mode', { alias: 'm', type: 'string', choices: ['development', 'production'], describe: 'Execution mode', default: 'development' }) .option('report', { alias: 'r', type: 'string', describe: 'Report export path (JSON)', default: 'output/wpo.txt' }) .option('thresholds', { alias: 't', type: 'string', describe: 'Path to the custom file with thresholds', default: './.wpo-check.thresholds.json' }) .option('config', { alias: 'c', type: 'string', describe: 'Path to the configuration file', default: './.wpo-check.config.json' }) .help() .parse(); const { _: urls, mode, report: reportPath, thresholds: thresholdsPath, config: configPath } = argv; const thresholds = getThresholds(thresholdsPath); const config = getConfig(configPath, urls, mode, reportPath); const ok = await executeCheck(thresholds, config); reportResult(ok, reportPath); process.exit(ok ? 0 : 1);