| 4 | import { multiInput } from './utils.js'; |
| 5 | |
| 6 | export async function collectGerritConfig(): Promise<CollectResult> { |
| 7 | const url = await input({ |
| 8 | message: 'Gerrit URL (e.g. https://gerrit.example.com)', |
| 9 | validate: (v) => { |
| 10 | if (!v?.trim()) { |
| 11 | return 'URL is required'; |
| 12 | } |
| 13 | if (!/^https?:\/\//.test(v)) { |
| 14 | return 'Must start with http:// or https://'; |
| 15 | } |
| 16 | return true; |
| 17 | }, |
| 18 | }); |
| 19 | |
| 20 | const config: GerritConnectionConfig = { |
| 21 | type: 'gerrit', |
| 22 | url, |
| 23 | }; |
| 24 | |
| 25 | const indexAll = await confirm({ |
| 26 | message: 'Index all projects?', |
| 27 | default: true, |
| 28 | }); |
| 29 | |
| 30 | if (!indexAll) { |
| 31 | config.projects = await multiInput({ |
| 32 | message: 'Projects to index', |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | return { connections: [{ config }], env: {} }; |
| 37 | } |