MCPcopy Create free account
hub / github.com/Snapchat/Valdi / valdiAgentCheck

Function valdiAgentCheck

npm_modules/cli/src/commands/agentCheck.ts:59–158  ·  view source on GitHub ↗
(argv: ArgumentsResolver<CommandParameters>)

Source from the content-addressed store, hash-verified

57}
58
59async function valdiAgentCheck(argv: ArgumentsResolver<CommandParameters>) {
60 const json = argv.getArgument('json') ?? false;
61 const quick = argv.getArgument('quick') ?? false;
62 const bazelClient = new BazelClient();
63
64 const moduleName = argv.getArgument('module');
65 const targetName = argv.getArgument('target');
66
67 if (!moduleName && !targetName) {
68 throw new Error('Either --module or --target is required');
69 }
70
71 const results: StepResult[] = [];
72 const totalStart = Date.now();
73
74 if (!json) {
75 const mode = quick ? 'Quick' : 'Full';
76 console.log(wrapInColor(`\n═══ Valdi Agent Check (${mode}) ═══\n`, ANSI_COLORS.GREEN_COLOR));
77 }
78
79 let buildTargets: string[] = [];
80 let testTargets: string[] = [];
81
82 if (targetName) {
83 buildTargets = [targetName];
84 } else if (moduleName) {
85 const resolveResult = await runStep('Resolve module targets', async () => {
86 const task = getModuleTargets(bazelClient, moduleName);
87 buildTargets = json
88 ? await task
89 : await LoadingIndicator.fromTask(task)
90 .setText(wrapInColor('Resolving module targets...', ANSI_COLORS.YELLOW_COLOR))
91 .setSuccessText(wrapInColor('Resolved module targets.', ANSI_COLORS.GREEN_COLOR))
92 .setFailureText(wrapInColor('Failed to resolve targets.', ANSI_COLORS.RED_COLOR))
93 .show();
94 if (buildTargets.length === 0) {
95 throw new Error(`No valdi_module targets found for module "${moduleName}"`);
96 }
97 }, json);
98 results.push(resolveResult);
99 if (resolveResult.status === 'fail') {
100 return outputResults(results, totalStart, json);
101 }
102
103 testTargets = await getTestTargets(bazelClient, moduleName).catch(() => []);
104 }
105
106 // Build (skipped in --quick mode because hot reloader handles compilation)
107 if (!quick) {
108 const buildResult = await runStep('Build', async () => {
109 await bazelClient.buildTargets(buildTargets);
110 }, json);
111 results.push(buildResult);
112 } else {
113 if (!json) {
114 console.log(wrapInColor(' ⊘ Build: skipped (--quick mode, hot reloader handles compilation)', ANSI_COLORS.YELLOW_COLOR));
115 }
116 results.push({ name: 'Build', status: 'skip', durationMs: 0, message: 'Skipped in quick mode' });

Callers

nothing calls this directly

Calls 15

buildTargetsMethod · 0.95
testTargetsMethod · 0.95
wrapInColorFunction · 0.90
runStepFunction · 0.85
getModuleTargetsFunction · 0.85
outputResultsFunction · 0.85
getTestTargetsFunction · 0.85
runCliCommandFunction · 0.85
setFailureTextMethod · 0.80
setSuccessTextMethod · 0.80
fromTaskMethod · 0.80
nowMethod · 0.65

Tested by

no test coverage detected