Skip to content

Commit 6a6d785

Browse files
committed
chore: merging and adding add-on creation
2 parents a1cee44 + 6e7b49a commit 6a6d785

File tree

9 files changed

+73
-27
lines changed

9 files changed

+73
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-tsrouter-app",
3-
"version": "0.5.0-alpha",
3+
"version": "0.10.0-alpha",
44
"description": "Tanstack Application Builder",
55
"bin": "./dist/index.js",
66
"type": "module",

src/create-app.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import chalk from 'chalk'
88
import { CODE_ROUTER, FILE_ROUTER } from './constants.js'
99
import { sortObject } from './utils.js'
1010
import { writeConfigFile } from './config-file.js'
11+
import { packageManagerExecute } from './package-manager.js'
1112

1213
import type { Environment } from './environment.js'
1314
import type { Options } from './types.js'
@@ -484,9 +485,11 @@ export async function createApp(
484485
s?.start(
485486
`Installing shadcn components (${Array.from(shadcnComponents).join(', ')})...`,
486487
)
487-
await environment.execute(
488-
'npx',
489-
['shadcn@canary', 'add', '--silent', '--yes', ...shadcnComponents],
488+
await packageManagerExecute(
489+
environment,
490+
options.packageManager,
491+
'shadcn@latest',
492+
['add', '--silent', '--yes', ...shadcnComponents],
490493
resolve(targetDir),
491494
)
492495
s?.stop(`Installed additional shadcn components`)
@@ -723,6 +726,6 @@ Use the following commands to start your app:
723726
% cd ${options.projectName}
724727
% ${startCommand}
725728
726-
Please read README.md for more information on testing, styling, adding routes, react-query, etc.${errorStatement}`)
729+
Please read the README.md for more information on testing, styling, adding routes, react-query, etc.${errorStatement}`)
727730
}
728731
}

src/options.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ import type { CliOptions, Options } from './types.js'
2323
export async function normalizeOptions(
2424
cliOptions: CliOptions,
2525
): Promise<Required<Options> | undefined> {
26+
// in some cases, if you use windows/powershell, the argument for addons
27+
// if sepparated by comma is not really passed as an array, but as a string
28+
// with spaces, We need to normalize this edge case.
29+
if (Array.isArray(cliOptions.addOns) && cliOptions.addOns.length === 1) {
30+
const parseSeparatedArgs = cliOptions.addOns[0].split(' ');
31+
if (parseSeparatedArgs.length > 1) {
32+
cliOptions.addOns = parseSeparatedArgs;
33+
}
34+
}
2635
if (cliOptions.projectName) {
2736
let typescript =
2837
cliOptions.template === 'typescript' ||

src/package-manager.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Environment } from './environment'
2+
13
export const SUPPORTED_PACKAGE_MANAGERS = [
24
'npm',
35
'yarn',
@@ -21,3 +23,24 @@ export function getPackageManager(): PackageManager | undefined {
2123

2224
return packageManager
2325
}
26+
27+
export function packageManagerExecute(
28+
environment: Environment,
29+
packagerManager: PackageManager,
30+
pkg: string,
31+
args: Array<string>,
32+
cwd: string,
33+
) {
34+
switch (packagerManager) {
35+
case 'yarn':
36+
return environment.execute('yarn', ['dlx', pkg, ...args], cwd)
37+
case 'pnpm':
38+
return environment.execute('pnpx', [pkg, ...args], cwd)
39+
case 'bun':
40+
return environment.execute('bunx', ['--bun', pkg, ...args], cwd)
41+
case 'deno':
42+
return environment.execute('deno', ['run', `npm:${pkg}`, ...args], cwd)
43+
default:
44+
return environment.execute('npx', [pkg, ...args], cwd)
45+
}
46+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Shadcn
22

3-
Add components using the canary version of [Shadcn](https://ui.shadcn.com/).
3+
Add components using the latest version of [Shadcn](https://ui.shadcn.com/).
44

55
```bash
6-
pnpx shadcn@canary add button
6+
pnpx shadcn@latest add button
77
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# shadcn instructions
22

3-
Use the canary version of Shadcn to install new components, like this command to add a button component:
3+
Use the latest version of Shadcn to install new components, like this command to add a button component:
44

55
```bash
6-
pnpx shadcn@canary add button
6+
pnpx shadcn@latest add button
77
```

templates/react/example/tanchat/assets/src/utils/demo.ai.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ export interface Message {
1010
content: string
1111
}
1212

13-
const SYSTEM_PROMPT = `You are TanStack Chat, an AI assistant using Markdown for clear and structured responses.`
13+
const SYSTEM_PROMPT = `You are a helpful assistant for a store that sells guitars.
1414
15-
export const genAIResponse = createServerFn({ method: 'GET', response: 'raw' })
15+
You can use the following tools to help the user:
16+
17+
- getGuitars: Get all guitars from the database
18+
- recommendGuitar: Recommend a guitar to the user
19+
`
20+
21+
export const genAIResponse = createServerFn({ method: 'POST', response: 'raw' })
1622
.validator(
1723
(d: {
1824
messages: Array<Message>
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import { experimental_createMCPClient, tool } from 'ai'
2+
//import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
23
import { z } from 'zod'
34
import guitars from '../data/example-guitars'
45

5-
// Example of using an MCP server to get tools
6-
// const mcpCient = await experimental_createMCPClient({
6+
// Example of using an SSE MCP server
7+
// const mcpClient = await experimental_createMCPClient({
78
// transport: {
8-
// type: 'stdio',
9+
// type: "sse",
10+
// url: "http://localhost:8081/sse",
11+
// },
12+
// name: "Demo Service",
13+
// });
14+
15+
// Example of using an STDIO MCP server
16+
// const mcpClient = await experimental_createMCPClient({
17+
// transport: new StdioClientTransport({
18+
// command: "node",
919
// args: [
10-
// '--directory',
11-
// '~/mcp/servers/src/sqlite',
12-
// 'run',
13-
// 'mcp-server-sqlite',
14-
// '--db-path',
15-
// '~/sqlite-example/orders.db',
20+
// "stdio-server.js",
1621
// ],
17-
// command: 'uv',
18-
// },
19-
// })
22+
// }),
23+
// });
2024

21-
const getProducts = tool({
25+
const getGuitars = tool({
2226
description: 'Get all products from the database',
2327
parameters: z.object({}),
2428
execute: async () => {
@@ -37,7 +41,7 @@ export default async function getTools() {
3741
// const mcpTools = await mcpCient.tools()
3842
return {
3943
// ...mcpTools,
40-
getProducts,
44+
getGuitars,
4145
recommendGuitar,
4246
}
4347
}

templates/react/example/tanchat/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
"dependencies": {
33
"@ai-sdk/anthropic": "^1.1.17",
44
"@ai-sdk/react": "^1.1.23",
5-
"ai": "^4.1.61",
5+
"ai": "^4.1.65",
66
"highlight.js": "^11.11.1",
77
"react-markdown": "^9.0.1",
88
"rehype-highlight": "^7.0.0",
99
"rehype-raw": "^7.0.0",
1010
"rehype-sanitize": "^6.0.0",
1111
"remark-gfm": "^4.0.1",
12-
"lucide-react": "^0.475.0"
12+
"lucide-react": "^0.475.0",
13+
"zod": "^3.24.2"
1314
}
1415
}

0 commit comments

Comments
 (0)