Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update/PathAliasPart1: updates to eslint, prettier and docker #146

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
force=true
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
],
"importOrderSortSpecifiers": true,
"plugins": [
"prettier-plugin-organize-imports",
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-tailwindcss"
]
Expand Down
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

46 changes: 46 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion models/mistral-large-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion models/multiplayer/mistral-large-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
5 changes: 4 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import tsconfigPaths from "vitest-tsconfig-paths";
import { defineConfig } from "vitest/config";

export default defineConfig({});
export default defineConfig({
plugins: [tsconfigPaths()],
});