Skip to content

Commit d7eac47

Browse files
committed
chore: package refactoring
1 parent 473bd3a commit d7eac47

File tree

24 files changed

+403
-114
lines changed

24 files changed

+403
-114
lines changed

cli/create-start-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"license": "MIT",
2929
"packageManager": "[email protected]",
3030
"dependencies": {
31-
"@tanstack/cta-engine": "workspace:*"
31+
"@tanstack/cta-cli": "workspace:*"
3232
},
3333
"devDependencies": {
3434
"@types/node": "^22.13.4",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import { cli } from '@tanstack/cta-engine'
2+
import { cli } from '@tanstack/cta-cli'
33

44
cli({
55
name: 'create-start-app',

cli/create-tanstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"license": "MIT",
2929
"packageManager": "[email protected]",
3030
"dependencies": {
31-
"@tanstack/cta-engine": "workspace:*"
31+
"@tanstack/cta-cli": "workspace:*"
3232
},
3333
"devDependencies": {
3434
"@types/node": "^22.13.4",

cli/create-tanstack/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import { cli } from '@tanstack/cta-engine'
2+
import { cli } from '@tanstack/cta-cli'
33

44
cli({
55
name: 'create-tanstack',

cli/create-tsrouter-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"license": "MIT",
2929
"packageManager": "[email protected]",
3030
"dependencies": {
31-
"@tanstack/cta-engine": "workspace:*"
31+
"@tanstack/cta-cli": "workspace:*"
3232
},
3333
"devDependencies": {
3434
"@types/node": "^22.13.4",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import { cli } from '@tanstack/cta-engine'
2+
import { cli } from '@tanstack/cta-cli'
33

44
cli({
55
name: 'create-tsrouter-app',

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
"pnpm": {
2626
"overrides": {
2727
"create-start-app": "workspace:*",
28+
"create-tanstack": "workspace:*",
2829
"create-tsrouter-app": "workspace:*",
29-
"@tanstack/cta-engine": "workspace:*"
30+
"@tanstack/cta-cli": "workspace:*",
31+
"@tanstack/cta-engine": "workspace:*",
32+
"@tanstack/cta-mcp": "workspace:*"
3033
}
3134
},
3235
"workspaces": [

packages/cta-cli/package.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@tanstack/cta-cli",
3+
"version": "0.10.0-alpha.15",
4+
"description": "Tanstack Application Builder CLI",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"types": "./dist/types/index.d.ts",
8+
"scripts": {
9+
"build": "tsc",
10+
"dev": "tsc --watch",
11+
"cipublish": "node scripts/publish.js",
12+
"test:lint": "eslint ./src"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/TanStack/create-tsrouter-app.git"
17+
},
18+
"homepage": "https://tanstack.com/router",
19+
"funding": {
20+
"type": "github",
21+
"url": "https://github.com/sponsors/tannerlinsley"
22+
},
23+
"keywords": [
24+
"react",
25+
"tanstack",
26+
"router",
27+
"create-react-app"
28+
],
29+
"author": "Jack Herrington <[email protected]>",
30+
"license": "MIT",
31+
"packageManager": "[email protected]",
32+
"dependencies": {
33+
"@tanstack/cta-engine": "workspace:*",
34+
"@tanstack/cta-mcp": "workspace:*",
35+
"@clack/prompts": "^0.10.0",
36+
"chalk": "^5.4.1",
37+
"commander": "^13.1.0"
38+
},
39+
"devDependencies": {
40+
"@tanstack/config": "^0.16.2",
41+
"@types/node": "^22.13.4",
42+
"eslint": "^9.20.0",
43+
"typescript": "^5.6.3",
44+
"vitest": "^3.0.8"
45+
}
46+
}

packages/cta-engine/src/cli.ts renamed to packages/cta-cli/src/cli.ts

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
import { Command, InvalidArgumentError } from 'commander'
22
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'
318

4-
import { createApp } from './create-app.js'
519
import { normalizeOptions, promptForOptions } from './options.js'
6-
import { SUPPORTED_PACKAGE_MANAGERS } from './package-manager.js'
7-
import { SUPPORTED_TOOLCHAINS } from './toolchain.js'
820

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'
1328

14-
import { createDefaultEnvironment } from './environment.js'
15-
import { add } from './add.js'
29+
import type { CliOptions } from './types.js'
1630

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+
}
2049

2150
export function cli({
2251
name,
@@ -37,7 +66,7 @@ export function cli({
3766
.command('add')
3867
.argument('add-on', 'Name of the add-on (or add-ons separated by commas)')
3968
.action(async (addOn: string) => {
40-
await add(addOn.split(',').map((addon) => addon.trim()))
69+
await addToApp(addOn.split(',').map((addon) => addon.trim()))
4170
})
4271

4372
program
@@ -151,7 +180,7 @@ export function cli({
151180
forcedAddOns,
152181
})
153182
} else if (options.mcp || options.mcpSse) {
154-
await runServer(!!options.mcpSse, {
183+
await runMCPServer(!!options.mcpSse, {
155184
forcedMode: forcedMode as TemplateOptions,
156185
forcedAddOns,
157186
appName,

packages/cta-cli/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { cli } from './cli.js'

0 commit comments

Comments
 (0)