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

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