Skip to content

Commit 1b343ca

Browse files
committed
fix: making nitro the default
1 parent 40e9151 commit 1b343ca

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

packages/cta-cli/src/command-line.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ export async function normalizeOptions(
9393
selectedAddOns.add(cliOptions.host)
9494
}
9595

96+
if (!cliOptions.host) {
97+
selectedAddOns.add('nitro')
98+
}
99+
96100
return await finalizeAddOns(framework, mode, Array.from(selectedAddOns))
97101
}
98102

packages/cta-cli/src/ui-prompts.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import type { AddOn, PackageManager } from '@tanstack/cta-engine'
1717

1818
import type { Framework } from '@tanstack/cta-engine/dist/types/types.js'
19+
import { InitialData } from '../../cta-ui/src/types'
1920

2021
export async function getProjectName(): Promise<string> {
2122
const value = await text({
@@ -189,6 +190,7 @@ export async function selectHost(
189190
host?: string,
190191
): Promise<string | undefined> {
191192
const hosts = new Set<AddOn>()
193+
let initialValue: string | undefined = undefined
192194
for (const addOn of framework
193195
.getAddOns()
194196
.sort((a, b) => a.name.localeCompare(b.name))) {
@@ -197,6 +199,9 @@ export async function selectHost(
197199
if (host && addOn.id === host) {
198200
return host
199201
}
202+
if (addOn.default) {
203+
initialValue = addOn.id
204+
}
200205
}
201206
}
202207

@@ -212,7 +217,7 @@ export async function selectHost(
212217
label: h.name,
213218
})),
214219
],
215-
initialValue: undefined,
220+
initialValue: initialValue,
216221
})
217222

218223
if (isCancel(hp)) {

packages/cta-ui-base/src/store/add-ons.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export function getAddOnStatus(
1515
}
1616
>()
1717

18+
const getAddOnType = (addOn: string) =>
19+
availableAddOns.find((a) => a.id === addOn)!.type
20+
21+
const isMultiSelect = (addOn: string) => getAddOnType(addOn) === 'host'
22+
23+
const areAddonsOfThisTypeCurrentlyChosen = (addOn: string) =>
24+
chosenAddOns.some((a) => getAddOnType(a) === getAddOnType(addOn))
25+
1826
for (const addOn of availableAddOns) {
1927
addOnMap.set(addOn.id, {
2028
selected: false,
@@ -40,7 +48,7 @@ export function getAddOnStatus(
4048
const dependsOnAddOn = addOnMap.get(dependsOnId)
4149
if (dependsOnAddOn) {
4250
dependsOnAddOn.selected = true
43-
dependsOnAddOn.enabled = false
51+
dependsOnAddOn.enabled = isMultiSelect(dependsOnId) ? true : false
4452
dependsOnAddOn.dependedUpon = true
4553
selectAndDisableDependsOn(dependsOnId)
4654
}
@@ -60,11 +68,23 @@ export function getAddOnStatus(
6068
for (const addOn of originalAddOns) {
6169
const addOnInfo = addOnMap.get(addOn)
6270
if (addOnInfo) {
63-
addOnInfo.selected = true
64-
addOnInfo.enabled = false
65-
addOnInfo.dependedUpon = true
71+
if (isMultiSelect(addOn)) {
72+
if (areAddonsOfThisTypeCurrentlyChosen(addOn)) {
73+
addOnInfo.selected = false
74+
addOnInfo.enabled = true
75+
addOnInfo.dependedUpon = false
76+
} else {
77+
addOnInfo.selected = true
78+
addOnInfo.enabled = true
79+
addOnInfo.dependedUpon = true
80+
}
81+
} else {
82+
addOnInfo.selected = true
83+
addOnInfo.enabled = false
84+
addOnInfo.dependedUpon = true
85+
cycleGuardedSelectAndDisableDependsOn(addOn)
86+
}
6687
}
67-
cycleGuardedSelectAndDisableDependsOn(addOn)
6888
}
6989

7090
for (const addOnId of chosenAddOns) {

0 commit comments

Comments
 (0)