( platforms: string[], promptMessage: string, selectedPlatformName?: string, )
| 333 | } |
| 334 | |
| 335 | export async function promptForPlatform( |
| 336 | platforms: string[], |
| 337 | promptMessage: string, |
| 338 | selectedPlatformName?: string, |
| 339 | ): Promise<string> { |
| 340 | const { prompt } = await import('prompts'); |
| 341 | |
| 342 | if (!selectedPlatformName) { |
| 343 | const answers = await prompt( |
| 344 | [ |
| 345 | { |
| 346 | type: 'select', |
| 347 | name: 'mode', |
| 348 | message: promptMessage, |
| 349 | choices: platforms.map((p) => ({ title: p, value: p })), |
| 350 | }, |
| 351 | ], |
| 352 | { onCancel: () => process.exit(1) }, |
| 353 | ); |
| 354 | |
| 355 | return answers.mode.toLowerCase().trim(); |
| 356 | } |
| 357 | |
| 358 | const platformName = selectedPlatformName.toLowerCase().trim(); |
| 359 | |
| 360 | if (!(await isValidPlatform(platformName))) { |
| 361 | const knownPlatforms = await getKnownPlatforms(); |
| 362 | |
| 363 | fatal(`Invalid platform: ${c.input(platformName)}.\n` + `Valid platforms include: ${knownPlatforms.join(', ')}`); |
| 364 | } |
| 365 | |
| 366 | return platformName; |
| 367 | } |
| 368 | |
| 369 | export interface PlatformTarget { |
| 370 | id: string; |
no test coverage detected