Skip to content

Commit 4640121

Browse files
committed
chore: massive refactor
1 parent ad7d5f3 commit 4640121

File tree

279 files changed

+670
-920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+670
-920
lines changed

cli/create-start-app/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"license": "MIT",
2929
"packageManager": "[email protected]",
3030
"dependencies": {
31-
"@tanstack/cta-cli": "workspace:*"
31+
"@tanstack/cta-cli": "workspace:*",
32+
"@tanstack/cta-templates-react-cra": "workspace:*",
33+
"@tanstack/cta-templates-solid": "workspace:*"
3234
},
3335
"devDependencies": {
3436
"@types/node": "^22.13.4",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env node
22
import { cli } from '@tanstack/cta-cli'
33

4+
import { register as registerReactCra } from '@tanstack/cta-templates-react-cra'
5+
import { register as registerSolid } from '@tanstack/cta-templates-solid'
6+
7+
registerReactCra()
8+
registerSolid()
9+
410
cli({
511
name: 'create-start-app',
612
appName: 'TanStack Start',

cli/create-tanstack/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"license": "MIT",
2929
"packageManager": "[email protected]",
3030
"dependencies": {
31-
"@tanstack/cta-cli": "workspace:*"
31+
"@tanstack/cta-cli": "workspace:*",
32+
"@tanstack/cta-templates-react-cra": "workspace:*",
33+
"@tanstack/cta-templates-solid": "workspace:*"
3234
},
3335
"devDependencies": {
3436
"@types/node": "^22.13.4",

cli/create-tanstack/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env node
22
import { cli } from '@tanstack/cta-cli'
33

4+
import { register as registerReactCra } from '@tanstack/cta-templates-react-cra'
5+
import { register as registerSolid } from '@tanstack/cta-templates-solid'
6+
7+
registerReactCra()
8+
registerSolid()
9+
410
cli({
511
name: 'create-tanstack',
612
appName: 'TanStack',

cli/create-tsrouter-app/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"license": "MIT",
2929
"packageManager": "[email protected]",
3030
"dependencies": {
31-
"@tanstack/cta-cli": "workspace:*"
31+
"@tanstack/cta-cli": "workspace:*",
32+
"@tanstack/cta-templates-react-cra": "workspace:*",
33+
"@tanstack/cta-templates-solid": "workspace:*"
3234
},
3335
"devDependencies": {
3436
"@types/node": "^22.13.4",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env node
22
import { cli } from '@tanstack/cta-cli'
33

4+
import { register as registerReactCra } from '@tanstack/cta-templates-react-cra'
5+
import { register as registerSolid } from '@tanstack/cta-templates-solid'
6+
7+
registerReactCra()
8+
registerSolid()
9+
410
cli({
511
name: 'create-tsrouter-app',
612
appName: 'TanStack',

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"type": "module",
66
"scripts": {
77
"cleanNodeModules": "pnpm -r exec rm -rf node_modules",
8-
"build": "nx run-many --target=build",
8+
"build": "nx run-many --target=build --parallel 5",
99
"cipublish": "node scripts/publish.js",
10+
"dev": "nx run-many --target=dev --parallel 10",
1011
"test": "nx run-many -t test"
1112
},
1213
"repository": {
@@ -28,15 +29,18 @@
2829
"create-tanstack": "workspace:*",
2930
"create-tsrouter-app": "workspace:*",
3031
"@tanstack/cta-cli": "workspace:*",
32+
"@tanstack/cta-core": "workspace:*",
3133
"@tanstack/cta-engine": "workspace:*",
3234
"@tanstack/cta-mcp": "workspace:*",
33-
"@tanstack/cta-ui": "workspace:*"
35+
"@tanstack/cta-ui": "workspace:*",
36+
"@tanstack/cta-templates-react-cra": "workspace:*",
37+
"@tanstack/cta-templates-solid": "workspace:*"
3438
}
3539
},
3640
"workspaces": [
37-
"./apps/*",
3841
"./cli/*",
39-
"./packages/*"
42+
"./packages/*",
43+
"./templates/*"
4044
],
4145
"dependencies": {
4246
"@tanstack/config": "^0.16.2"

packages/cta-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"scripts": {
99
"build": "tsc",
1010
"dev": "tsc --watch",
11-
"cipublish": "node scripts/publish.js",
1211
"test:lint": "eslint ./src"
1312
},
1413
"repository": {
@@ -30,6 +29,7 @@
3029
"license": "MIT",
3130
"packageManager": "[email protected]",
3231
"dependencies": {
32+
"@tanstack/cta-core": "workspace:*",
3333
"@tanstack/cta-engine": "workspace:*",
3434
"@tanstack/cta-mcp": "workspace:*",
3535
"@tanstack/cta-ui": "workspace:*",

packages/cta-cli/src/cli.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import { intro, log } from '@clack/prompts'
33
import chalk from 'chalk'
44

55
import {
6-
DEFAULT_FRAMEWORK,
7-
SUPPORTED_FRAMEWORKS,
86
SUPPORTED_PACKAGE_MANAGERS,
97
SUPPORTED_TOOLCHAINS,
10-
addToApp,
11-
createApp,
128
createDefaultEnvironment,
139
getAllAddOns,
14-
initAddOn,
15-
} from '@tanstack/cta-engine'
10+
getFrameworkById,
11+
getFrameworkByName,
12+
getFrameworks,
13+
} from '@tanstack/cta-core'
14+
import { addToApp, createApp, initAddOn } from '@tanstack/cta-engine'
1615

1716
import { runMCPServer } from '@tanstack/cta-mcp'
1817

@@ -23,12 +22,11 @@ import { normalizeOptions, promptForOptions } from './options.js'
2322
import { createUIEnvironment } from './ui-environment.js'
2423

2524
import type {
26-
Framework,
2725
Mode,
2826
PackageManager,
2927
TemplateOptions,
3028
ToolChain,
31-
} from '@tanstack/cta-engine'
29+
} from '@tanstack/cta-core'
3230

3331
import type { CliOptions } from './types.js'
3432

@@ -43,7 +41,7 @@ async function listAddOns(
4341
},
4442
) {
4543
const addOns = await getAllAddOns(
46-
options.framework || DEFAULT_FRAMEWORK,
44+
getFrameworkById(options.framework || 'react-cra')!,
4745
forcedMode || options.template || 'typescript',
4846
)
4947
for (const addOn of addOns.filter((a) => !forcedAddOns.includes(a.id))) {
@@ -66,6 +64,8 @@ export function cli({
6664

6765
const program = new Command()
6866

67+
const availableFrameworks = getFrameworks().map((f) => f.name)
68+
6969
program.name(name).description(`CLI to create a new ${appName} application`)
7070

7171
program
@@ -124,20 +124,18 @@ export function cli({
124124
)
125125
}
126126
program
127-
.option<Framework>(
127+
.option<string>(
128128
'--framework <type>',
129-
'project framework (solid, react)',
129+
`project framework (${availableFrameworks.join(', ')})`,
130130
(value) => {
131-
if (!SUPPORTED_FRAMEWORKS.includes(value as Framework)) {
131+
if (!availableFrameworks.includes(value)) {
132132
throw new InvalidArgumentError(
133-
`Invalid framework: ${value}. Only the following are allowed: ${SUPPORTED_FRAMEWORKS.join(
134-
', ',
135-
)}`,
133+
`Invalid framework: ${value}. Only the following are allowed: ${availableFrameworks.join(', ')}`,
136134
)
137135
}
138-
return value as Framework
136+
return value
139137
},
140-
DEFAULT_FRAMEWORK,
138+
'react',
141139
)
142140
.option(
143141
'--starter [url]',
@@ -212,6 +210,10 @@ export function cli({
212210
...options,
213211
} as CliOptions
214212

213+
cliOptions.framework = getFrameworkByName(
214+
options.framework || 'react',
215+
)!.id
216+
215217
if (forcedMode) {
216218
cliOptions.template = forcedMode as TemplateOptions
217219
}
@@ -231,7 +233,7 @@ export function cli({
231233
})
232234
}
233235
await createApp(finalOptions, {
234-
environment: createDefaultEnvironment(),
236+
environment: createUIEnvironment(),
235237
cwd: options.targetDir || undefined,
236238
name,
237239
appName,

packages/cta-cli/src/options.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import {
99

1010
import {
1111
CODE_ROUTER,
12-
DEFAULT_FRAMEWORK,
1312
DEFAULT_PACKAGE_MANAGER,
1413
DEFAULT_TOOLCHAIN,
1514
FILE_ROUTER,
1615
SUPPORTED_PACKAGE_MANAGERS,
1716
SUPPORTED_TOOLCHAINS,
1817
finalizeAddOns,
1918
getAllAddOns,
19+
getFrameworkById,
2020
getPackageManager,
2121
loadRemoteAddOn,
22-
} from '@tanstack/cta-engine'
22+
} from '@tanstack/cta-core'
2323

2424
import type {
2525
AddOn,
@@ -28,7 +28,7 @@ import type {
2828
Starter,
2929
TemplateOptions,
3030
Variable,
31-
} from '@tanstack/cta-engine'
31+
} from '@tanstack/cta-core'
3232

3333
import type { CliOptions } from './types.js'
3434

@@ -93,8 +93,9 @@ export async function normalizeOptions(
9393
]),
9494
)
9595
}
96+
const framework = getFrameworkById(cliOptions.framework || 'react-cra')!
9697
chosenAddOns = await finalizeAddOns(
97-
cliOptions.framework || DEFAULT_FRAMEWORK,
98+
framework,
9899
forcedMode || cliOptions.template === 'file-router'
99100
? FILE_ROUTER
100101
: CODE_ROUTER,
@@ -105,7 +106,8 @@ export async function normalizeOptions(
105106
}
106107

107108
return {
108-
framework: cliOptions.framework || 'react',
109+
// TODO: This is a bit to fix the default framework
110+
framework: getFrameworkById(cliOptions.framework || 'react-cra')!,
109111
projectName: cliOptions.projectName,
110112
typescript,
111113
tailwind,
@@ -176,8 +178,10 @@ export async function promptForOptions(
176178
): Promise<Required<Options>> {
177179
const options = {} as Required<Options>
178180

179-
options.framework = cliOptions.framework || DEFAULT_FRAMEWORK
180-
if (options.framework === 'solid') {
181+
const framework = getFrameworkById(cliOptions.framework || 'react-cra')!
182+
options.framework = framework
183+
// TODO: This is a bit of a hack to ensure that the framework is solid
184+
if (options.framework.id === 'solid') {
181185
options.typescript = true
182186
options.tailwind = true
183187
}
@@ -253,7 +257,7 @@ export async function promptForOptions(
253257
}
254258

255259
// Tailwind selection
256-
if (!cliOptions.tailwind && options.framework === 'react') {
260+
if (!cliOptions.tailwind && options.framework.id === 'react-cra') {
257261
const tailwind = await confirm({
258262
message: 'Would you like to use Tailwind CSS?',
259263
initialValue: true,
@@ -264,7 +268,8 @@ export async function promptForOptions(
264268
}
265269
options.tailwind = tailwind
266270
} else {
267-
options.tailwind = options.framework === 'solid' || !!cliOptions.tailwind
271+
// TODO: This is a bit of a hack to ensure that the framework is solid
272+
options.tailwind = options.framework.id === 'solid' || !!cliOptions.tailwind
268273
}
269274

270275
// Package manager selection

0 commit comments

Comments
 (0)