Files
张翔 08ea5fbe98 feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
2026-03-28 14:37:29 +08:00

76 lines
2.0 KiB
TypeScript

import * as fs from 'fs';
import * as yargs from 'yargs';
import { SmartTestSelector } from '../smart-test-selector';
const argv = yargs
.option('input', {
alias: 'i',
type: 'string',
description: '变更文件列表文件路径',
})
.option('output', {
alias: 'o',
type: 'string',
description: '输出文件路径',
default: 'selected-tests.json',
})
.option('report', {
alias: 'r',
type: 'string',
description: '分析报告输出路径',
default: 'test-selection-report.md',
})
.option('priority', {
alias: 'p',
type: 'string',
choices: ['high', 'medium', 'low', 'all'],
default: 'all',
description: '测试优先级过滤',
})
.option('level', {
alias: 'l',
type: 'string',
choices: ['smoke', 'functional', 'all'],
default: 'all',
description: '测试级别过滤',
})
.argv as any;
async function main() {
const selector = new SmartTestSelector();
let changedFiles: string[] = [];
if (argv.input) {
// 从文件读取变更文件列表
const content = fs.readFileSync(argv.input, 'utf-8');
changedFiles = content.split('\n').filter(f => f.trim());
} else {
// 从Git获取变更文件
changedFiles = selector.getChangedFilesFromGit();
}
console.log(`📊 分析 ${changedFiles.length} 个变更文件...`);
const result = selector.selectTestsByChanges(changedFiles, {
priority: argv.priority,
testLevel: argv.level,
});
// 保存结果
fs.writeFileSync(argv.output, JSON.stringify(result, null, 2));
console.log(`✅ 测试选择结果已保存到: ${argv.output}`);
// 保存报告
fs.writeFileSync(argv.report, result.analysisReport);
console.log(`✅ 分析报告已保存到: ${argv.report}`);
// 输出摘要
console.log('\n=== 选择结果摘要 ===');
console.log(`变更文件: ${result.changedFiles.length}`);
console.log(`受影响模块: ${result.affectedModules.length}`);
console.log(`选中测试: ${result.selectedTests.length}`);
}
main().catch(console.error);