1
1
import { Command , InvalidArgumentError } from 'commander'
2
2
import { intro , log } from '@clack/prompts'
3
+ import chalk from 'chalk'
4
+
5
+ import {
6
+ DEFAULT_FRAMEWORK ,
7
+ SUPPORTED_FRAMEWORKS ,
8
+ SUPPORTED_PACKAGE_MANAGERS ,
9
+ SUPPORTED_TOOLCHAINS ,
10
+ addToApp ,
11
+ createApp ,
12
+ createDefaultEnvironment ,
13
+ getAllAddOns ,
14
+ initAddOn ,
15
+ } from '@tanstack/cta-engine'
16
+
17
+ import { runMCPServer } from '@tanstack/cta-mcp'
3
18
4
- import { createApp } from './create-app.js'
5
19
import { normalizeOptions , promptForOptions } from './options.js'
6
- import { SUPPORTED_PACKAGE_MANAGERS } from './package-manager.js'
7
- import { SUPPORTED_TOOLCHAINS } from './toolchain.js'
8
20
9
- import runServer from './mcp.js'
10
- import { listAddOns } from './add-ons.js'
11
- import { DEFAULT_FRAMEWORK , SUPPORTED_FRAMEWORKS } from './constants.js'
12
- import { initAddOn } from './custom-add-on.js'
21
+ import type {
22
+ Framework ,
23
+ Mode ,
24
+ PackageManager ,
25
+ TemplateOptions ,
26
+ ToolChain ,
27
+ } from '@tanstack/cta-engine'
13
28
14
- import { createDefaultEnvironment } from './environment.js'
15
- import { add } from './add.js'
29
+ import type { CliOptions } from './types.js'
16
30
17
- import type { PackageManager } from './package-manager.js'
18
- import type { ToolChain } from './toolchain.js'
19
- import type { CliOptions , Framework , Mode , TemplateOptions } from './types.js'
31
+ async function listAddOns (
32
+ options : CliOptions ,
33
+ {
34
+ forcedMode,
35
+ forcedAddOns = [ ] ,
36
+ } : {
37
+ forcedMode ?: TemplateOptions
38
+ forcedAddOns ?: Array < string >
39
+ } ,
40
+ ) {
41
+ const addOns = await getAllAddOns (
42
+ options . framework || DEFAULT_FRAMEWORK ,
43
+ forcedMode || options . template || 'typescript' ,
44
+ )
45
+ for ( const addOn of addOns . filter ( ( a ) => ! forcedAddOns . includes ( a . id ) ) ) {
46
+ console . log ( `${ chalk . bold ( addOn . id ) } : ${ addOn . description } ` )
47
+ }
48
+ }
20
49
21
50
export function cli ( {
22
51
name,
@@ -37,7 +66,7 @@ export function cli({
37
66
. command ( 'add' )
38
67
. argument ( 'add-on' , 'Name of the add-on (or add-ons separated by commas)' )
39
68
. action ( async ( addOn : string ) => {
40
- await add ( addOn . split ( ',' ) . map ( ( addon ) => addon . trim ( ) ) )
69
+ await addToApp ( addOn . split ( ',' ) . map ( ( addon ) => addon . trim ( ) ) )
41
70
} )
42
71
43
72
program
@@ -151,7 +180,7 @@ export function cli({
151
180
forcedAddOns,
152
181
} )
153
182
} else if ( options . mcp || options . mcpSse ) {
154
- await runServer ( ! ! options . mcpSse , {
183
+ await runMCPServer ( ! ! options . mcpSse , {
155
184
forcedMode : forcedMode as TemplateOptions ,
156
185
forcedAddOns,
157
186
appName,
0 commit comments