MCPcopy Create free account
hub / github.com/Snapchat/Valdi / selectBazelTarget

Function selectBazelTarget

npm_modules/cli/src/utils/applicationUtils.ts:83–110  ·  view source on GitHub ↗
(
  bazel: BazelClient,
  tag: string,
  targetTypeName: string,
  promptText: string,
)

Source from the content-addressed store, hash-verified

81 };
82}
83
84export async function selectBazelTarget(
85 bazel: BazelClient,
86 tag: string,
87 targetTypeName: string,
88 promptText: string,
89): Promise<string> {
90 const unfilteredAvailableTargets = await bazel.queryTargetsForTag(tag);
91 const availableTargets = unfilteredAvailableTargets.filter(c => !c.endsWith('_DO_NOT_USE'));
92
93 if (availableTargets.length === 0) {
94 throw new CliError(`No ${targetTypeName} targets found...`);
95 } else if (availableTargets.length === 1) {
96 console.log(
97 `Only one ${targetTypeName} target found, using it:`,
98 wrapInColor(availableTargets[0], ANSI_COLORS.GREEN_COLOR),
99 );
100
101 return availableTargets[0] ?? '';
102 }
103
104 // Prompt user to select an application target
105 const choices: Array<CliChoice<string>> = availableTargets.map((target, index) => ({
106 name: `${index + 1}. ${target}`,
107 value: target,
108 }));
109
110 return await getUserChoice(choices, promptText);
111}
112
113export function getApplicationTargetTagForPlatform(platform: PLATFORM): string {

Callers 3

getBuildInfoFunction · 0.90
valdiExportFunction · 0.90
valdiPackageFunction · 0.90

Calls 6

wrapInColorFunction · 0.90
getUserChoiceFunction · 0.90
queryTargetsForTagMethod · 0.80
filterMethod · 0.80
logMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected