From 44b34fb464f4e24b323ff45bdd9658f383b28d1c Mon Sep 17 00:00:00 2001 From: Thuc Pham <51660321+thucpn@users.noreply.github.com> Date: Thu, 14 Nov 2024 09:47:35 +0700 Subject: [PATCH] chore: update nextjs v15, react v19 and eslint v9 (#420) --- .changeset/swift-donuts-own.md | 5 +++ helpers/typescript.ts | 8 ++--- .../types/streaming/express/eslint.config.mjs | 31 +++++++++++++++++++ .../types/streaming/express/eslintrc.json | 10 ------ templates/types/streaming/express/index.ts | 1 - .../types/streaming/express/package.json | 6 ++-- .../nextjs/app/api/files/[...slug]/route.ts | 6 ++-- .../types/streaming/nextjs/next.config.json | 22 ++++++------- templates/types/streaming/nextjs/package.json | 12 +++---- .../types/streaming/nextjs/tsconfig.json | 3 +- 10 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 .changeset/swift-donuts-own.md create mode 100644 templates/types/streaming/express/eslint.config.mjs delete mode 100644 templates/types/streaming/express/eslintrc.json diff --git a/.changeset/swift-donuts-own.md b/.changeset/swift-donuts-own.md new file mode 100644 index 000000000..53854cf0a --- /dev/null +++ b/.changeset/swift-donuts-own.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +chore: update eslint 9, nextjs 15, react 19 diff --git a/helpers/typescript.ts b/helpers/typescript.ts index b443286f2..7d08ed447 100644 --- a/helpers/typescript.ts +++ b/helpers/typescript.ts @@ -58,11 +58,9 @@ export const installTSTemplate = async ({ console.log("\nUsing static site generation\n"); } else { if (vectorDb === "milvus") { - nextConfigJson.experimental.serverComponentsExternalPackages = - nextConfigJson.experimental.serverComponentsExternalPackages ?? []; - nextConfigJson.experimental.serverComponentsExternalPackages.push( - "@zilliz/milvus2-sdk-node", - ); + nextConfigJson.serverExternalPackages = + nextConfigJson.serverExternalPackages ?? []; + nextConfigJson.serverExternalPackages.push("@zilliz/milvus2-sdk-node"); } } await fs.writeFile( diff --git a/templates/types/streaming/express/eslint.config.mjs b/templates/types/streaming/express/eslint.config.mjs new file mode 100644 index 000000000..f085a674c --- /dev/null +++ b/templates/types/streaming/express/eslint.config.mjs @@ -0,0 +1,31 @@ +import { FlatCompat } from "@eslint/eslintrc"; +import js from "@eslint/js"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import tseslint from "typescript-eslint"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [ + ...compat.extends("eslint:recommended", "prettier"), + ...tseslint.configs.recommended, + { + ignores: ["prettier.config.cjs"], + }, + { files: ["**/*.{ts}"] }, + { + rules: { + "max-params": ["error", 4], + "prefer-const": "error", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-unused-vars": "off", + }, + }, +]; diff --git a/templates/types/streaming/express/eslintrc.json b/templates/types/streaming/express/eslintrc.json deleted file mode 100644 index ef95da351..000000000 --- a/templates/types/streaming/express/eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["eslint:recommended", "prettier"], - "rules": { - "max-params": ["error", 4], - "prefer-const": "error" - }, - "parserOptions": { - "sourceType": "module" - } -} diff --git a/templates/types/streaming/express/index.ts b/templates/types/streaming/express/index.ts index c0fc67b5c..29ca60f62 100644 --- a/templates/types/streaming/express/index.ts +++ b/templates/types/streaming/express/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable turbo/no-undeclared-env-vars */ import cors from "cors"; import "dotenv/config"; import express, { Express, Request, Response } from "express"; diff --git a/templates/types/streaming/express/package.json b/templates/types/streaming/express/package.json index d39e2cf32..ce9032fc6 100644 --- a/templates/types/streaming/express/package.json +++ b/templates/types/streaming/express/package.json @@ -12,7 +12,8 @@ "format:write": "prettier --ignore-unknown --write .", "build": "tsup index.ts --format esm --dts", "start": "node dist/index.js", - "dev": "concurrently \"tsup index.ts --format esm --dts --watch\" \"nodemon --watch dist/index.js\"" + "dev": "concurrently \"tsup index.ts --format esm --dts --watch\" \"nodemon --watch dist/index.js\"", + "lint": "eslint ." }, "dependencies": { "ai": "3.3.42", @@ -34,10 +35,11 @@ "@types/cors": "^2.8.16", "@types/express": "^4.17.21", "@types/node": "^20.9.5", + "typescript-eslint": "^8.14.0", "@llamaindex/workflow": "^0.0.3", "@types/papaparse": "^5.3.15", "concurrently": "^8.2.2", - "eslint": "^8.54.0", + "eslint": "^9.14.0", "eslint-config-prettier": "^8.10.0", "nodemon": "^3.0.1", "prettier": "^3.2.5", diff --git a/templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts b/templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts index 5bb2e06e4..7ccaeda90 100644 --- a/templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts +++ b/templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts @@ -9,9 +9,9 @@ import { DATA_DIR } from "../../chat/engine/loader"; */ export async function GET( _request: NextRequest, - { params }: { params: { slug: string[] } }, + { params }: { params: Promise<{ slug: string[] }> }, ) { - const slug = params.slug; + const slug = (await params).slug; if (!slug) { return NextResponse.json({ detail: "Missing file slug" }, { status: 400 }); @@ -21,7 +21,7 @@ export async function GET( return NextResponse.json({ detail: "Invalid file path" }, { status: 400 }); } - const [folder, ...pathTofile] = params.slug; // data, file.pdf + const [folder, ...pathTofile] = slug; // data, file.pdf const allowedFolders = ["data", "output"]; if (!allowedFolders.includes(folder)) { diff --git a/templates/types/streaming/nextjs/next.config.json b/templates/types/streaming/nextjs/next.config.json index da1622405..edc2084d3 100644 --- a/templates/types/streaming/nextjs/next.config.json +++ b/templates/types/streaming/nextjs/next.config.json @@ -1,16 +1,14 @@ { - "experimental": { - "outputFileTracingIncludes": { - "/*": ["./cache/**/*"] - }, - "outputFileTracingExcludes": { - "/api/files/*": [ - ".next/**/*", - "node_modules/**/*", - "public/**/*", - "app/**/*" - ] - } + "outputFileTracingIncludes": { + "/*": ["./cache/**/*"] + }, + "outputFileTracingExcludes": { + "/api/files/*": [ + ".next/**/*", + "node_modules/**/*", + "public/**/*", + "app/**/*" + ] }, "transpilePackages": ["highlight.js"] } diff --git a/templates/types/streaming/nextjs/package.json b/templates/types/streaming/nextjs/package.json index 6e4c036a2..6c5e6d509 100644 --- a/templates/types/streaming/nextjs/package.json +++ b/templates/types/streaming/nextjs/package.json @@ -29,10 +29,10 @@ "got": "^14.4.1", "llamaindex": "0.8.2", "lucide-react": "^0.294.0", - "next": "^14.2.4", + "next": "^15.0.3", + "react": "19.0.0-rc-5c56b873-20241107", + "react-dom": "19.0.0-rc-5c56b873-20241107", "papaparse": "^5.4.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", "supports-color": "^8.1.1", "tailwind-merge": "^2.1.0", "tiktoken": "^1.0.15", @@ -49,9 +49,9 @@ "@types/papaparse": "^5.3.15", "autoprefixer": "^10.4.16", "cross-env": "^7.0.3", - "eslint": "^8.55.0", - "eslint-config-next": "^14.2.4", - "eslint-config-prettier": "^8.10.0", + "eslint": "^9.14.0", + "eslint-config-next": "^15.0.3", + "eslint-config-prettier": "^9.1.0", "postcss": "^8.4.32", "prettier": "^3.2.5", "prettier-plugin-organize-imports": "^3.2.4", diff --git a/templates/types/streaming/nextjs/tsconfig.json b/templates/types/streaming/nextjs/tsconfig.json index e7ff90fd2..64c21044c 100644 --- a/templates/types/streaming/nextjs/tsconfig.json +++ b/templates/types/streaming/nextjs/tsconfig.json @@ -19,7 +19,8 @@ ], "paths": { "@/*": ["./*"] - } + }, + "target": "ES2017" }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"]