Skip to content

Commit

Permalink
Merge pull request code100x#60 from SujithThirumalaisamy/main
Browse files Browse the repository at this point in the history
Migrated to pnpm, Fixed Dark mode in problem
  • Loading branch information
siinghd committed Jun 25, 2024
2 parents 92b8738 + 2e6a6b3 commit 1d8790a
Show file tree
Hide file tree
Showing 21 changed files with 9,362 additions and 19,964 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ WORKDIR /usr/src/app
COPY . .

# Install dependencies
RUN yarn install
RUN pnpm install

# Generate Prisma client
RUN cd packages/db && npx prisma generate
RUN cd packages/db && pnpm dlx prisma generate

# Expose ports for both applications
EXPOSE 3000

WORKDIR /usr/src/app

# Command to start both services
CMD ["yarn", "run", "dev:docker"]
CMD ["pnpm", "run", "dev:docker"]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ docker-compose up -d
```
3. Install dependencies
```bash
yarn install
pnpm install
```
4. Copy env files
```bash
Expand All @@ -18,11 +18,11 @@ cp packages/db/.env.example packages/db/.env
5. Update the mount path in the ``apps/web/.env``
6. Migrate Database and install local package
```bash
npx turbo db:migrate && yarn install
pnpm dlx turbo db:migrate && yarn install
```
7. Start Dev
```bash
yarn dev
pnpm dev
```
---
### Own Configuration
Expand All @@ -36,7 +36,7 @@ docker-compose up server workers -d
```
4. Install dependencies
```bash
yarn install
pnpm install
```
5. Copy env files and configure with the same conf you updated in the judge0
```bash
Expand All @@ -46,11 +46,11 @@ cp packages/db/.env.example packages/db/.env
6. Update the mount path in the ``apps/web/.env``
7. Migrate Database and install local package
```bash
npx turbo db:migrate && yarn install
pnpm dlx turbo db:migrate && yarn install
```
8. Start Dev
```bash
yarn dev
pnpm dev
```

### If you use JUDGE0 in windows, change the mount path to have the \ instead of / for the mounting of judge0.conf and mounting of problems.
7 changes: 4 additions & 3 deletions apps/boilerplate-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "npx esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js",
"boiler:generate": "npm run build && node dist/index.js",
"build": "pnpm esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js",
"boiler:generate": "pnpm run build && node dist/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^20.12.12",
"antlr4": "^4.13.1-patch-1"
"antlr4": "^4.13.1-patch-1",
"esbuild": "^0.21.5"
}
}
8 changes: 6 additions & 2 deletions apps/sweeper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@repo/db": "*",
"@repo/db": "workspace:*",
"esbuild": "^0.21.5",
"nodemon": "^3.1.3"
"nodemon": "^3.1.3",
"ts-node": "^10.9.2"
},
"scripts": {
"build": "esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.js --sourcemap",
"start": "esbuild ./src/index.ts --bundle --platform=node --outfile=dist/index.js --sourcemap && nodemon dist/index.js",
"dev": "nodemon ./src/index.ts",
"docker": "nodemon ./src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@types/node": "^20.14.6"
}
}
24 changes: 8 additions & 16 deletions apps/sweeper/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */

/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand All @@ -23,10 +21,9 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"rootDir": "./src", /* Specify the root folder within your source files. */
"module": "commonjs", /* Specify what module code is generated. */
"rootDir": "./src", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
Expand All @@ -42,20 +39,18 @@
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
Expand All @@ -72,17 +67,15 @@
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -101,9 +94,8 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
4 changes: 2 additions & 2 deletions apps/web/components/ModeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
} from "../../../packages/ui/src/@/components/ui/dropdown-menu"

export function ModeToggle() {
const { resolvedTheme,setTheme } = useTheme()
const { resolvedTheme, setTheme } = useTheme()
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button style={{color:resolvedTheme=='dark'?'white':'black'}} variant="outline" size="icon">
<Button style={{ color: resolvedTheme == 'dark' ? 'black' : 'white' }} >
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/ProblemStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import remarkGfm from "remark-gfm";

export function ProblemStatement({ description }: { description: string }) {
return (
<div className="prose lg:prose-xl">
<div className="prose lg:prose-xl dark:prose-gray dark:prose-h2:text-gray-200 dark:prose-h4:text-gray-200">
<Markdown remarkPlugins={[remarkGfm]}>{description}</Markdown>
</div>
);
Expand Down
6 changes: 4 additions & 2 deletions apps/web/components/ProblemSubmitBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@ function SubmitProblem({
/>
</div>
<div className="flex justify-end">
<Turnstile
{process.env.NODE_ENV === "production" ?
< Turnstile
onSuccess={(token: string) => {
setToken(token);
}}
siteKey={TURNSTILE_SITE_KEY}
/>
/> : null
}
<Button
disabled={status === SubmitStatus.PENDING}
type="submit"
Expand Down
9 changes: 5 additions & 4 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"dependencies": {
"@marsidev/react-turnstile": "^0.7.1",
"@monaco-editor/react": "^4.6.0",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-slot": "^1.0.2",
"@repo/ui": "*",
"@repo/common": "workspace:*",
"@repo/ui": "workspace:*",
"@types/bcrypt": "^5.0.2",
"axios": "^1.7.2",
"bcrypt": "^5.1.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"ioredis": "^5.4.1",
"jose": "^5.4.1",
"lucide-react": "^0.383.0",
"next": "^14.1.1",
"next-auth": "^4.24.7",
Expand All @@ -35,8 +36,8 @@
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.1.1",
"@repo/eslint-config": "*",
"@repo/typescript-config": "*",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@tailwindcss/typography": "^0.5.13",
"@types/eslint": "^8.56.5",
"@types/node": "^20.11.24",
Expand Down
10 changes: 7 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ services:
env_file: judge0.conf
ports:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -d $$POSTGRES_DB -U $$POSTGRES_USER']
interval: 10s
Expand Down Expand Up @@ -74,7 +76,9 @@ services:
- '6379:6379'
logging:
driver: none

volumes:
- cache:/data
volumes:
postgres-data:
external: false
postgres_data:
cache:
driver: local
8 changes: 5 additions & 3 deletions docker/problems/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ WORKDIR /usr/src/app

COPY ./apps/problems /usr/src/app/apps/problems

RUN npm install pnpm -g -y

# Install dependencies
RUN npm install
RUN pnpm install

# Generate Prisma client
RUN cd packages/db && npx prisma generate
RUN cd packages/db && pnpm dlx prisma generate

# Expose ports for both applications
EXPOSE 3000
EXPOSE 3000
19 changes: 11 additions & 8 deletions docker/sweeper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ WORKDIR /usr/src/app
COPY ./packages /usr/src/app/packages
COPY ./apps/sweeper /usr/src/app/apps/sweeper
COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
COPY turbo.json /usr/src/app/
COPY tsconfig.json /usr/src/app/
COPY pnpm-lock.yaml /usr/src/app/pnpm-lock.yaml
COPY pnpm-workspace.yaml /usr/src/app/pnpm-workspace.yaml
COPY turbo.json /usr/src/app/turbo.json
COPY tsconfig.json /usr/src/app/tsconfig.json

RUN npm install pnpm -g -y

# Install dependencies
RUN npm install
RUN pnpm install

# Generate Prisma client
RUN cd packages/db && DATABASE_URL=$DATABASE_URL npx prisma generate
RUN cd packages/db && DATABASE_URL=$DATABASE_URL pnpm dlx prisma generate

WORKDIR /usr/src/app
WORKDIR /usr/src/app/apps/sweeper

# Command to start both services
RUN npm run build --prefix apps/sweeper
CMD ["npm", "run", "start:sweeper"]
RUN pnpm run build
CMD ["pnpm", "run", "start"]
19 changes: 11 additions & 8 deletions docker/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ WORKDIR /usr/src/app
COPY ./packages /usr/src/app/packages
COPY ./apps/web /usr/src/app/apps/web
COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
COPY turbo.json /usr/src/app/
COPY tsconfig.json /usr/src/app/
COPY pnpm-lock.yaml /usr/src/app/pnpm-lock.yaml
COPY pnpm-workspace.yaml /usr/src/app/pnpm-workspace.yaml
COPY turbo.json /usr/src/app/turbo.json
COPY tsconfig.json /usr/src/app/tsconfig.json

RUN npm install pnpm -g -y

# Install dependencies
RUN npm install
RUN pnpm install

# Generate Prisma client
RUN cd packages/db && DATABASE_URL=$DATABASE_URL npx prisma generate
RUN cd packages/db && DATABASE_URL=$DATABASE_URL pnpm dlx prisma generate

# Expose ports for both applications
EXPOSE 3000

WORKDIR /usr/src/app
WORKDIR /usr/src/app/apps/web

# Command to start both services
RUN npm run build --prefix apps/web
CMD ["npm", "run", "start:web"]
RUN pnpm run build
CMD ["pnpm", "run", "start"]
Loading

0 comments on commit 1d8790a

Please sign in to comment.