forked from getsentry/XcodeBuildMCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoctor-cli.ts
More file actions
62 lines (52 loc) · 2.08 KB
/
doctor-cli.ts
File metadata and controls
62 lines (52 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
/**
* XcodeBuildMCP Doctor CLI
*
* This standalone script runs the doctor tool and outputs the results
* to the console. It's designed to be run directly via npx or mise.
*/
import { version } from './version.ts';
import { doctorLogic } from './mcp/tools/doctor/doctor.ts';
import { getDefaultCommandExecutor } from './utils/execution/index.ts';
import { bootstrapRuntime } from './runtime/bootstrap-runtime.ts';
function shouldUseNonRedactedOutput(argv: string[]): boolean {
return argv.includes('--non-redacted');
}
async function runDoctor(): Promise<void> {
try {
// Using console.error to avoid linting issues as it's allowed by the project's linting rules
console.error(`Running XcodeBuildMCP Doctor (v${version})...`);
console.error('Collecting system information and checking dependencies...\n');
await bootstrapRuntime({ runtime: 'cli' });
const nonRedacted = shouldUseNonRedactedOutput(process.argv.slice(2));
if (nonRedacted) {
console.error(
'Warning: --non-redacted is enabled; doctor output may include sensitive data.',
);
}
// Run the doctor tool logic directly with CLI flag enabled
const executor = getDefaultCommandExecutor();
const result = await doctorLogic({ nonRedacted }, executor, true); // showAsciiLogo = true for CLI
// Output the doctor information
if (result.content && result.content.length > 0) {
const textContent = result.content.find((item) => item.type === 'text');
if (textContent?.type === 'text') {
// eslint-disable-next-line no-console
console.log(textContent.text);
} else {
console.error('Error: Unexpected doctor result format');
}
} else {
console.error('Error: No doctor information returned');
}
console.error('\nDoctor run complete. Please include this output when reporting issues.');
} catch (error) {
console.error('Error running doctor:', error);
process.exit(1);
}
}
// Run the doctor
runDoctor().catch((error) => {
console.error('Unhandled exception:', error);
process.exit(1);
});