diff --git a/website/.gitignore b/website/.gitignore index b3de0766e..98ab49eb9 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -1,4 +1,5 @@ .data/ .nuxt/ .output/ +dist/ node_modules/ diff --git a/website/package.json b/website/package.json index fb825d965..870073088 100644 --- a/website/package.json +++ b/website/package.json @@ -3,21 +3,22 @@ "private": true, "type": "module", "scripts": { - "preflight": "node ./scripts/patch-docus-for-deno.mjs", - "dev": "node ./scripts/patch-docus-for-deno.mjs && nuxt dev", - "build": "node ./scripts/patch-docus-for-deno.mjs && nuxt build", - "generate": "node ./scripts/patch-docus-for-deno.mjs && nuxt generate", - "preview": "node ./scripts/patch-docus-for-deno.mjs && nuxt preview" + "dev": "nuxt dev", + "build": "nuxt build", + "generate": "nuxt generate", + "preview": "nuxt preview", + "start": "node .output/server/index.mjs" }, "dependencies": { "@nuxt/content": "^3.13.0", "docus": "5.11.0", + "nuxt": "^4.4.4", "zod": "^3.25.76", "zod-to-json-schema": "^3.25.2" }, "devDependencies": { "esbuild": "^0.27.7", - "@iconify-json/lucide": "^1.2.105", + "@iconify-json/lucide": "^1.2.106", "@iconify-json/simple-icons": "^1.2.81" } } diff --git a/website/scripts/patch-docus-for-deno.mjs b/website/scripts/patch-docus-for-deno.mjs deleted file mode 100644 index 2a8c42aa7..000000000 --- a/website/scripts/patch-docus-for-deno.mjs +++ /dev/null @@ -1,157 +0,0 @@ -import { existsSync } from "node:fs"; -import { lstat, readdir, readFile, symlink, writeFile } from "node:fs/promises"; -import { join } from "node:path"; -import { transform } from "esbuild"; - -const denoModulesDir = join(process.cwd(), "node_modules", ".deno"); - -if (!existsSync(denoModulesDir)) { - process.exit(0); -} - -const entries = await readdir(denoModulesDir, { withFileTypes: true }); -const docusRoots = entries - .filter((entry) => entry.isDirectory() && entry.name.startsWith("docus@")) - .map((entry) => ({ - packageDir: entry.name, - root: join(denoModulesDir, entry.name, "node_modules", "docus"), - })); - -if (docusRoots.length > 0) { - await ensureTopLevelDocusLink(docusRoots[0].packageDir); -} - -for (const { root: docusRoot } of docusRoots) { - await patchAppConfig(join(docusRoot, "app", "app.config.ts")); - await patchTypeScriptFiles(join(docusRoot, "server")); - await patchTypeScriptFiles(join(docusRoot, "utils")); - await patchTypeScriptFiles(join(docusRoot, "modules", "skills", "runtime", "server")); - await patchTypeScriptFiles(join(docusRoot, "modules", "assistant", "runtime", "server")); -} - -async function ensureTopLevelDocusLink(packageDir) { - const linkPath = join(process.cwd(), "node_modules", "docus"); - - try { - const stat = await lstat(linkPath); - - if (stat.isSymbolicLink() || stat.isDirectory()) { - return; - } - } catch (error) { - if (error.code !== "ENOENT") { - throw error; - } - } - - await symlink(join(".deno", packageDir, "node_modules", "docus"), linkPath, "dir"); -} - -async function patchAppConfig(path) { - if (!existsSync(path)) { - return; - } - - const source = await readFile(path, "utf8"); - - if (source.includes("/* patched-for-deno */")) { - return; - } - - await writeFile( - path, - `/* patched-for-deno */\nconst defineAppConfig = (config) => config;\n${source}`, - ); -} - -async function patchTypeScriptFiles(dir) { - if (!existsSync(dir)) { - return; - } - - const entries = await readdir(dir, { withFileTypes: true }); - - for (const entry of entries) { - const path = join(dir, entry.name); - - if (entry.isDirectory()) { - await patchTypeScriptFiles(path); - continue; - } - - if (!entry.name.endsWith(".ts")) { - continue; - } - - const source = await readFile(path, "utf8"); - - if (source.includes("/* patched-for-deno */")) { - await patchServerRouteAutoImports(path, source); - await patchMcpToolAutoImports(path, source); - continue; - } - - const result = await transform(source, { - format: "esm", - loader: "ts", - sourcemap: false, - target: "es2022", - }); - - const patchedSource = addMcpToolAutoImports( - path, - addServerRouteAutoImports(path, result.code), - ); - - await writeFile(path, `/* patched-for-deno */\n${patchedSource}`); - } -} - -async function patchMcpToolAutoImports(path, source) { - const patchedSource = addMcpToolAutoImports(path, source); - - if (patchedSource !== source) { - await writeFile(path, patchedSource); - } -} - -async function patchServerRouteAutoImports(path, source) { - const patchedSource = addServerRouteAutoImports(path, source); - - if (patchedSource !== source) { - await writeFile(path, patchedSource); - } -} - -function addServerRouteAutoImports(path, source) { - if (!path.includes(join("server", "routes"))) { - return source; - } - - if (source.includes("nitropack/runtime")) { - return source; - } - - return [ - 'import { defineEventHandler, setResponseHeader } from "h3";', - 'import { useRuntimeConfig } from "nitropack/runtime";', - source, - ].join("\n"); -} - -function addMcpToolAutoImports(path, source) { - if (!path.includes(join("server", "mcp", "tools"))) { - return source; - } - - if (source.includes("@nuxtjs/mcp-toolkit/server")) { - return source; - } - - return [ - 'import { defineMcpTool } from "@nuxtjs/mcp-toolkit/server";', - 'import { createError, getRequestURL } from "h3";', - 'import { useEvent, useRuntimeConfig } from "nitropack/runtime";', - source, - ].join("\n"); -}