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

Function selectAddOns

packages/cli/src/ui-prompts.ts:142–213  ·  view source on GitHub ↗
(
  framework: Framework,
  mode: string,
  type: string,
  message: string,
  forcedAddOns: Array<string> = [],
  allowMultiple: boolean = true,
)

Source from the content-addressed store, hash-verified

140}
141
142export async function selectAddOns(
143 framework: Framework,
144 mode: string,
145 type: string,
146 message: string,
147 forcedAddOns: Array<string> = [],
148 allowMultiple: boolean = true,
149): Promise<Array<string>> {
150 const allAddOns = await getAllAddOns(framework, mode)
151 const addOns = allAddOns.filter((addOn) => addOn.type === type)
152 if (addOns.length === 0) {
153 return []
154 }
155
156 if (allowMultiple) {
157 const selectableAddOns = addOns.filter(
158 (addOn) => !forcedAddOns.includes(addOn.id),
159 )
160
161 if (selectableAddOns.length === 0) {
162 return []
163 }
164
165 note(
166 'Use ↑/↓ to navigate • Space to select/deselect • Enter to confirm',
167 'Keyboard Shortcuts',
168 )
169
170 const value = await multiselect({
171 message: `${message} (Space to toggle, Enter to confirm)`,
172 options: selectableAddOns.map((addOn) => ({
173 value: addOn.id,
174 label: addOn.name,
175 hint: addOn.description,
176 })),
177 maxItems: selectableAddOns.length,
178 required: false,
179 })
180
181 if (isCancel(value)) {
182 cancel('Operation cancelled.')
183 process.exit(0)
184 }
185
186 return value
187 } else {
188 const value = await select({
189 message,
190 options: [
191 {
192 value: 'none',
193 label: 'None',
194 },
195 ...addOns
196 .filter((addOn) => !forcedAddOns.includes(addOn.id))
197 .map((addOn) => ({
198 value: addOn.id,
199 label: addOn.name,

Callers 3

ui-prompts.test.tsFile · 0.90
promptForCreateOptionsFunction · 0.70
promptForAddOnsFunction · 0.70

Calls 1

getAllAddOnsFunction · 0.90

Tested by

no test coverage detected