Skip to content

Commit e0d6a37

Browse files
committed
fix: fixing up SSE servers and list add-ons
1 parent 4694705 commit e0d6a37

File tree

7 files changed

+231
-162
lines changed

7 files changed

+231
-162
lines changed

cli/create-start-app/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { cli } from '@tanstack/cta-engine'
33

44
cli({
55
name: 'create-start-app',
6+
appName: 'TanStack Start',
67
forcedMode: 'file-router',
78
forcedAddOns: ['start'],
89
})

cli/create-tsrouter-app/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { cli } from '@tanstack/cta-engine'
33

44
cli({
55
name: 'create-tsrouter-app',
6+
appName: 'TanStack',
67
})

packages/cta-engine/src/add-ons.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { readFile } from 'node:fs/promises'
22
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'
33
import { resolve } from 'node:path'
44
import chalk from 'chalk'
5-
import { getTemplatesRoot } from './templates.js'
65

6+
import { getTemplatesRoot } from './templates.js'
77
import { DEFAULT_FRAMEWORK } from './constants.js'
8-
import type { AddOn, CliOptions, Framework } from './types.js'
8+
9+
import type { AddOn, CliOptions, Framework, TemplateOptions } from './types.js'
910

1011
function isDirectory(path: string): boolean {
1112
return statSync(path).isDirectory()
@@ -121,14 +122,21 @@ export async function finalizeAddOns(
121122
return finalAddOns
122123
}
123124

124-
export async function listAddOns(options: CliOptions) {
125-
const mode =
126-
options.template === 'file-router' ? 'file-router' : 'code-router'
125+
export async function listAddOns(
126+
options: CliOptions,
127+
{
128+
forcedMode,
129+
forcedAddOns = [],
130+
}: {
131+
forcedMode?: TemplateOptions
132+
forcedAddOns?: Array<string>
133+
},
134+
) {
127135
const addOns = await getAllAddOns(
128136
options.framework || DEFAULT_FRAMEWORK,
129-
mode,
137+
forcedMode || options.template || 'typescript',
130138
)
131-
for (const addOn of addOns) {
139+
for (const addOn of addOns.filter((a) => !forcedAddOns.includes(a.id))) {
132140
console.log(`${chalk.bold(addOn.id)}: ${addOn.description}`)
133141
}
134142
}

packages/cta-engine/src/cli.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ import type { CliOptions, Framework } from './types.js'
2020

2121
export function cli({
2222
name,
23+
appName,
2324
forcedMode,
2425
forcedAddOns,
2526
}: {
2627
name: string
28+
appName: string
2729
forcedMode?: 'typescript' | 'javascript' | 'file-router'
2830
forcedAddOns?: Array<string>
2931
}) {
3032
const program = new Command()
3133

32-
program
33-
.name('create-tsrouter-app')
34-
.description('CLI to create a new TanStack application')
34+
program.name(name).description(`CLI to create a new ${appName} application`)
3535

3636
// program
3737
// .command('add')
@@ -139,9 +139,16 @@ export function cli({
139139

140140
program.action(async (projectName: string, options: CliOptions) => {
141141
if (options.listAddOns) {
142-
await listAddOns(options)
142+
await listAddOns(options, {
143+
forcedMode,
144+
forcedAddOns,
145+
})
143146
} else if (options.mcp || options.mcpSse) {
144-
await runServer(!!options.mcpSse)
147+
await runServer(!!options.mcpSse, {
148+
forcedMode,
149+
forcedAddOns,
150+
appName,
151+
})
145152
} else {
146153
try {
147154
const cliOptions = {
@@ -155,9 +162,9 @@ export function cli({
155162

156163
let finalOptions = await normalizeOptions(cliOptions, forcedAddOns)
157164
if (finalOptions) {
158-
intro(`Creating a new TanStack app in ${projectName}...`)
165+
intro(`Creating a new ${appName} app in ${projectName}...`)
159166
} else {
160-
intro("Let's configure your TanStack application")
167+
intro(`Let's configure your ${appName} application`)
161168
finalOptions = await promptForOptions(cliOptions, {
162169
forcedMode,
163170
forcedAddOns,
@@ -167,6 +174,7 @@ export function cli({
167174
environment: createDefaultEnvironment(),
168175
cwd: options.targetDir || undefined,
169176
name,
177+
appName,
170178
})
171179
} catch (error) {
172180
log.error(

packages/cta-engine/src/create-app.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,13 @@ export async function createApp(
304304
silent = false,
305305
environment,
306306
cwd,
307-
name = 'create-tsrouter-app',
307+
appName = 'TanStack',
308308
}: {
309309
silent?: boolean
310310
environment: Environment
311311
cwd?: string
312-
name: string
312+
name?: string
313+
appName?: string
313314
},
314315
) {
315316
environment.startRun()
@@ -782,7 +783,7 @@ ${environment.getErrors().join('\n')}`
782783
startCommand = `deno ${isAddOnEnabled('start') ? 'task dev' : 'start'}`
783784
}
784785

785-
outro(`Your TanStack app is ready in '${basename(targetDir)}'.
786+
outro(`Your ${appName} app is ready in '${basename(targetDir)}'.
786787
787788
Use the following commands to start your app:
788789
% cd ${options.projectName}

0 commit comments

Comments
 (0)