(program: Command)
| 7 | import type { Command } from 'commander'; |
| 8 | |
| 9 | export function evalSetupCommand(program: Command) { |
| 10 | program |
| 11 | .command('setup [configDirectory]') |
| 12 | .description('Start browser UI and open to eval setup') |
| 13 | .option('-p, --port <number>', 'Port number', getDefaultPort().toString()) |
| 14 | .option('--env-file, --env-path <path>', 'Path to .env file') |
| 15 | .action( |
| 16 | async ( |
| 17 | directory: string | undefined, |
| 18 | cmdObj: { |
| 19 | port: number; |
| 20 | apiBaseUrl?: string; |
| 21 | envPath?: string; |
| 22 | } & Command, |
| 23 | ) => { |
| 24 | setupEnv(cmdObj.envPath); |
| 25 | telemetry.record('eval setup', {}); |
| 26 | |
| 27 | if (directory) { |
| 28 | setConfigDirectoryPath(directory); |
| 29 | } |
| 30 | |
| 31 | const isRunning = await checkServerRunning(); |
| 32 | const browserBehavior = BrowserBehavior.OPEN_TO_EVAL_SETUP; |
| 33 | |
| 34 | if (isRunning) { |
| 35 | await openBrowser(browserBehavior); |
| 36 | } else { |
| 37 | await startServer(cmdObj.port, browserBehavior); |
| 38 | } |
| 39 | }, |
| 40 | ); |
| 41 | } |
no test coverage detected
searching dependent graphs…