(connectionName: string)
| 5 | import { INPUT_THEME, multiInput, toEnvKey } from './utils.js'; |
| 6 | |
| 7 | export async function collectGiteaConfig(connectionName: string): Promise<CollectResult> { |
| 8 | const env: EnvVars = {}; |
| 9 | const config: GiteaConnectionConfig = { type: 'gitea' }; |
| 10 | |
| 11 | const url = await input({ |
| 12 | message: 'Gitea URL', |
| 13 | default: 'https://gitea.com', |
| 14 | theme: INPUT_THEME, |
| 15 | validate: (v) => { |
| 16 | if (!v?.trim()) { |
| 17 | return 'URL is required'; |
| 18 | } |
| 19 | if (!/^https?:\/\//.test(v)) { |
| 20 | return 'Must start with http:// or https://'; |
| 21 | } |
| 22 | return true; |
| 23 | }, |
| 24 | }); |
| 25 | if (url !== 'https://gitea.com') { |
| 26 | config.url = url; |
| 27 | } |
| 28 | |
| 29 | const giteaEnvKey = toEnvKey(connectionName, 'TOKEN'); |
| 30 | const giteaToken = await password({ |
| 31 | message: `Gitea Access Token (stored locally in .env as ${giteaEnvKey}, leave blank for public repos only)`, |
| 32 | mask: true, |
| 33 | }); |
| 34 | if (giteaToken.trim()) { |
| 35 | env[giteaEnvKey] = giteaToken; |
| 36 | config.token = { env: giteaEnvKey }; |
| 37 | } |
| 38 | |
| 39 | const targets = await checkbox<string>({ |
| 40 | message: 'What do you want to index?', |
| 41 | choices: [ |
| 42 | { value: 'orgs', name: 'Organizations' }, |
| 43 | { value: 'repos', name: 'Specific repositories', description: 'owner/repo format' }, |
| 44 | { value: 'users', name: 'Users' }, |
| 45 | ], |
| 46 | required: true, |
| 47 | }); |
| 48 | |
| 49 | if (targets.includes('orgs')) { |
| 50 | config.orgs = await multiInput({ |
| 51 | message: 'Organizations to index', |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | if (targets.includes('repos')) { |
| 56 | config.repos = await multiInput({ |
| 57 | message: 'Repositories to index (owner/repo)', |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | if (targets.includes('users')) { |
| 62 | config.users = await multiInput({ |
| 63 | message: 'Users to index', |
| 64 | }); |
no test coverage detected