@reliverse/rse-sdk
Version:
@reliverse/rse-sdk allows you to create new plugins for @reliverse/rse CLI, interact with reliverse.org, and even extend your own CLI functionality (you may also try @reliverse/dler-sdk for this case).
39 lines (38 loc) • 1.54 kB
JavaScript
import fs from "@reliverse/relifso";
import path from "node:path";
import { addPackageDependency } from "../../utils/add-package-deps.js";
export async function setupExamples(config) {
const { examples, frontend, backend, projectDir } = config;
if (backend === "convex" || !examples || examples.length === 0 || examples[0] === "none") {
return;
}
if (examples.includes("ai")) {
const clientDir = path.join(projectDir, "apps/web");
const serverDir = path.join(projectDir, "apps/server");
const clientDirExists = await fs.pathExists(clientDir);
const serverDirExists = await fs.pathExists(serverDir);
const hasNuxt = frontend.includes("nuxt");
const hasSvelte = frontend.includes("svelte");
const hasReact = frontend.includes("react-router") || frontend.includes("tanstack-router") || frontend.includes("next") || frontend.includes("tanstack-start") || frontend.includes("native-nativewind") || frontend.includes("native-unistyles");
if (clientDirExists) {
const dependencies = ["ai"];
if (hasNuxt) {
dependencies.push("@ai-sdk/vue");
} else if (hasSvelte) {
dependencies.push("@ai-sdk/svelte");
} else if (hasReact) {
dependencies.push("@ai-sdk/react");
}
await addPackageDependency({
dependencies,
projectDir: clientDir
});
}
if (serverDirExists && backend !== "none") {
await addPackageDependency({
dependencies: ["ai", "@ai-sdk/google"],
projectDir: serverDir
});
}
}
}