feat(cli): upgrade to ai sdk v5 (#487)

This commit is contained in:
Aman Varshney
2025-08-10 20:19:55 +05:30
committed by GitHub
parent ea908ddc86
commit f412d8f0c7
18 changed files with 439 additions and 277 deletions

View File

@@ -87,11 +87,11 @@ export const dependencyVersionMap = {
turbo: "^2.5.4",
ai: "^4.3.16",
"@ai-sdk/google": "^1.2.3",
"@ai-sdk/vue": "^1.2.8",
"@ai-sdk/svelte": "^2.1.9",
"@ai-sdk/react": "^1.2.12",
ai: "^5.0.9",
"@ai-sdk/google": "^2.0.3",
"@ai-sdk/vue": "^2.0.9",
"@ai-sdk/svelte": "^3.0.9",
"@ai-sdk/react": "^2.0.9",
"@orpc/server": "^1.5.0",
"@orpc/client": "^1.5.0",

View File

@@ -17,33 +17,44 @@ export async function setupExamples(config: ProjectConfig) {
}
if (examples.includes("ai")) {
const clientDir = path.join(projectDir, "apps/web");
const webClientDir = path.join(projectDir, "apps/web");
const nativeClientDir = path.join(projectDir, "apps/native");
const serverDir = path.join(projectDir, "apps/server");
const clientDirExists = await fs.pathExists(clientDir);
const webClientDirExists = await fs.pathExists(webClientDir);
const nativeClientDirExists = await fs.pathExists(nativeClientDir);
const serverDirExists = await fs.pathExists(serverDir);
const hasNuxt = frontend.includes("nuxt");
const hasSvelte = frontend.includes("svelte");
const hasReact =
const hasReactWeb =
frontend.includes("react-router") ||
frontend.includes("tanstack-router") ||
frontend.includes("next") ||
frontend.includes("tanstack-start") ||
frontend.includes("tanstack-start");
const hasReactNative =
frontend.includes("native-nativewind") ||
frontend.includes("native-unistyles");
if (clientDirExists) {
if (webClientDirExists) {
const dependencies: AvailableDependencies[] = ["ai"];
if (hasNuxt) {
dependencies.push("@ai-sdk/vue");
} else if (hasSvelte) {
dependencies.push("@ai-sdk/svelte");
} else if (hasReact) {
} else if (hasReactWeb) {
dependencies.push("@ai-sdk/react");
}
await addPackageDependency({
dependencies,
projectDir: clientDir,
projectDir: webClientDir,
});
}
if (nativeClientDirExists && hasReactNative) {
await addPackageDependency({
dependencies: ["ai", "@ai-sdk/react"],
projectDir: nativeClientDir,
});
}