add convex for svelte

This commit is contained in:
Aman Varshney
2025-04-30 13:17:19 +05:30
parent 62af82cc29
commit 065f862752
8 changed files with 480 additions and 186 deletions

View File

@@ -1,5 +1,4 @@
import path from "node:path";
import consola from "consola"; // Import consola
import fs from "fs-extra";
import type { AvailableDependencies } from "../constants";
import type { ProjectConfig, ProjectFrontend } from "../types";
@@ -14,16 +13,16 @@ export async function setupApi(config: ProjectConfig): Promise<void> {
const webDirExists = await fs.pathExists(webDir);
const nativeDirExists = await fs.pathExists(nativeDir);
const hasReactWeb = frontend.some((f) =>
["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
);
const hasNuxtWeb = frontend.includes("nuxt");
const hasSvelteWeb = frontend.includes("svelte");
if (!isConvex && api !== "none") {
const serverDir = path.join(projectDir, "apps/server");
const serverDirExists = await fs.pathExists(serverDir);
const hasReactWeb = frontend.some((f) =>
["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
);
const hasNuxtWeb = frontend.includes("nuxt");
const hasSvelteWeb = frontend.includes("svelte");
if (serverDirExists) {
if (api === "orpc") {
await addPackageDependency({
@@ -81,6 +80,7 @@ export async function setupApi(config: ProjectConfig): Promise<void> {
"@orpc/svelte-query",
"@orpc/client",
"@orpc/server",
"@tanstack/svelte-query",
],
projectDir: webDir,
});
@@ -153,7 +153,6 @@ export async function setupApi(config: ProjectConfig): Promise<void> {
} else {
}
}
} else if (needsReactQuery && isConvex) {
}
if (isConvex) {
@@ -165,6 +164,9 @@ export async function setupApi(config: ProjectConfig): Promise<void> {
if (frontend.includes("tanstack-start")) {
webDepsToAdd.push("@convex-dev/react-query");
}
if (hasSvelteWeb) {
webDepsToAdd.push("convex-svelte");
}
await addPackageDependency({
dependencies: webDepsToAdd,