diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index bffb357..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..165d6cf --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +force=true \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 86a9642..7031279 100644 --- a/.prettierrc +++ b/.prettierrc @@ -7,6 +7,7 @@ ], "importOrderSortSpecifiers": true, "plugins": [ + "prettier-plugin-organize-imports", "@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss" ] diff --git a/Dockerfile b/Dockerfile index 2542bb0..d7bd0fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,11 @@ FROM base AS builder WORKDIR /app +ARG BUILD_PROJECT=true + +RUN if [ "$BUILD_PROJECT" = "true" ]; then echo "skip apt installation"; else apt update; apt install -y git xdg-utils watch; fi + +COPY .npmrc ./ COPY package.json ./ RUN npm install --silent @@ -16,7 +21,10 @@ ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production ENV NEXT_PUBLIC_ENABLE_UNAMI=true -RUN npm run build +RUN if [ "$BUILD_PROJECT" = "true"]; then npm run build; else echo "running in dev"; fi; + +CMD npm run dev + FROM base AS runner WORKDIR /app diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..669121c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +services: + app: + build: + context: . + args: + - GEMINI_API_KEY=${GEMINI_API_KEY} + - OPENAI_API_KEY=${OPENAI_API_KEY} + - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} + - BUILD_PROJECT=false + dockerfile: Dockerfile + target: builder + image: node:20-alpine + ports: + - "3000:3000" + environment: + - NODE_ENV=development + - SITE_URL=http://localhost:3000 + # Add other environment variables as needed + - GEMINI_API_KEY=${GEMINI_API_KEY} + - OPENAI_API_KEY=${OPENAI_API_KEY} + - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} + - PERPLEXITY_API_KEY=${PERPLEXITY_API_KEY} + - MISTRAL_API_KEY=${MISTRAL_API_KEY} + working_dir: /app + restart: unless-stopped + volumes: + - .:/app + # - /app/node_modules + # command: npm run dev + diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..13e8ac6 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,46 @@ +import { FlatCompat } from "@eslint/eslintrc"; +import { default as js, default as pluginJs } from "@eslint/js"; +import eslintPluginImport from "eslint-plugin-import"; +import eslintPluginOrganizeImports from "eslint-plugin-organize-imports"; +import pathAlias from "eslint-plugin-path-alias"; +import pluginReact from "eslint-plugin-react"; +import globals from "globals"; +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, +}); + +/** @type {import('eslint').Linter.Config[]} */ +const config= [ + ...compat.extends("next/core-web-vitals"), + { files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] }, + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, + ...tseslint.configs.recommended, + // pluginReact.configs.flat.recommended, + { + // ignores: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/coverage/**", "**/*.config.js", "**/*.config.mjs", "**/*.config.cjs", "**/*.config.ts", "**/*.config.tsx", "**/*.config.jsx"], + plugins: { + "path-alias": pathAlias, + eslintPluginOrganizeImports: eslintPluginOrganizeImports, + import: eslintPluginImport, + }, + rules: { + "path-alias/no-relative": ["error", { exceptions: ["*.module.css"] }], + "import/first": "error", + "import/newline-after-import": "error", + "import/no-duplicates": "error", + "import/no-relative-packages": "error", + "no-undef": "error", + }, + }, +]; + +export default config \ No newline at end of file diff --git a/models/mistral-large-2.ts b/models/mistral-large-2.ts index d3a28ba..21e29a4 100644 --- a/models/mistral-large-2.ts +++ b/models/mistral-large-2.ts @@ -40,7 +40,7 @@ export const mistralLarge2: ModelHandler = async ( }, }); - const content = completion.choices?.[0].message.content ?? ""; + const content = (completion.choices?.[0].message.content ?? "")+''; if (!isJSON(content)) { throw new Error("Response received from Mistral is not JSON"); diff --git a/models/multiplayer/mistral-large-2.ts b/models/multiplayer/mistral-large-2.ts index 0df387a..b45859a 100644 --- a/models/multiplayer/mistral-large-2.ts +++ b/models/multiplayer/mistral-large-2.ts @@ -35,7 +35,7 @@ export const mistralLarge2: MultiplayerModelHandler = async ( }, }); - const content = completion.choices?.[0].message.content ?? ""; + const content = (completion.choices?.[0].message.content ?? "")+''; const parsedContent = JSON.parse(content); const response = await responseSchema.safeParseAsync(parsedContent); diff --git a/package.json b/package.json index 45c41e9..c650622 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,10 @@ "private": true, "scripts": { "dev": "npm-run-all dev:init --parallel dev:frontend dev:backend", + "dc:dev":"docker compose run -iP app;", + "dc:fix-missing-convex": "docker compose exec app npm install --force; docker stop $(docker ps -f name=surv| grep node |awk '{print $1}');npm run dev", + "dc:test":"docker compose exec app npm test", + "dc:shell": "docker compose exec app bash", "dev:frontend": "next dev", "dev:backend": "convex dev --tail-logs", "dev:init": "convex dev --run init --until-success", @@ -50,20 +54,29 @@ "zod": "^3.23.8" }, "devDependencies": { + "@eslint/js": "^9.17.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "autoprefixer": "^10.4.20", "dotenv": "^16.4.5", - "eslint": "^8", + "eslint": "^8.57.1", "eslint-config-next": "14.2.5", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-organize-imports": "^0.0.46", + "eslint-plugin-path-alias": "^2.1.0", + "eslint-plugin-react": "^7.37.3", + "globals": "^15.14.0", "npm-run-all": "^4.1.5", "postcss": "^8", "prettier": "^3.3.2", + "prettier-plugin-organize-imports": "^4.1.0", "prettier-plugin-tailwindcss": "^0.6.8", "tailwindcss": "^3.4.1", "typescript": "^5", - "vitest": "^2.1.3" + "typescript-eslint": "^8.19.1", + "vitest": "^2.1.3", + "vitest-tsconfig-paths": "^3.4.1" } } diff --git a/vitest.config.ts b/vitest.config.ts index 8fb6f2d..1e6f378 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,3 +1,6 @@ +import tsconfigPaths from "vitest-tsconfig-paths"; import { defineConfig } from "vitest/config"; -export default defineConfig({}); +export default defineConfig({ + plugins: [tsconfigPaths()], +});