MCPcopy Create free account
hub / github.com/TanStack/cli / selectDeployment

Function selectDeployment

packages/cli/src/ui-prompts.ts:377–422  ·  view source on GitHub ↗
(
  framework: Framework,
  deployment?: string,
  forcedDeployment?: string,
)

Source from the content-addressed store, hash-verified

375}
376
377export async function selectDeployment(
378 framework: Framework,
379 deployment?: string,
380 forcedDeployment?: string,
381): Promise<string | undefined> {
382 const deployments = new Set<AddOn>()
383 let initialValue: string | undefined = undefined
384 for (const addOn of framework
385 .getAddOns()
386 .sort((a, b) => a.name.localeCompare(b.name))) {
387 if (addOn.type === 'deployment') {
388 deployments.add(addOn)
389 if (deployment && addOn.id === deployment) {
390 return deployment
391 }
392 if (forcedDeployment && addOn.id === forcedDeployment) {
393 initialValue = addOn.id
394 } else if (!initialValue && addOn.default) {
395 initialValue = addOn.id
396 }
397 }
398 }
399
400 if (deployments.size === 0) {
401 return undefined
402 }
403
404 const dp = await select({
405 message: 'Select deployment adapter:',
406 options: [
407 { value: undefined, label: 'None' },
408 ...Array.from(deployments).map((d) => ({
409 value: d.id,
410 label: d.name,
411 })),
412 ],
413 initialValue,
414 })
415
416 if (isCancel(dp)) {
417 cancel('Operation cancelled.')
418 process.exit(0)
419 }
420
421 return dp
422}

Callers 1

promptForCreateOptionsFunction · 0.85

Calls 1

addMethod · 0.80

Tested by

no test coverage detected