merge experimental/migrate-to-pnpm

This commit is contained in:
vchikalkin 2023-11-28 23:47:19 +03:00
parent 1a7cf3f3c5
commit b28c5a4f3f
20 changed files with 9432 additions and 14517 deletions

6
.eslintignore Normal file
View File

@ -0,0 +1,6 @@
node_modules
dist
*.config.*
next-env.d.ts
.next
.eslintrc.js

1
.npmrc Normal file
View File

@ -0,0 +1 @@
auto-install-peers = true

View File

@ -29,5 +29,6 @@
"typescriptreact", "typescriptreact",
"yaml" "yaml"
], ],
"eslint.lintTask.enable": true "eslint.lintTask.enable": true,
"editor.inlineSuggest.showToolbar": "onHover"
} }

View File

@ -1,24 +1,32 @@
# Turborepo starter # Turborepo starter
This is an official Yarn v1 starter turborepo. This is an official starter Turborepo.
## Using this example
Run the following command:
```sh
npx create-turbo@latest
```
## What's inside? ## What's inside?
This turborepo uses [Yarn](https://classic.yarnpkg.com/) as a package manager. It includes the following packages/apps: This Turborepo includes the following packages/apps:
### Apps and Packages ### Apps and Packages
- `docs`: a [Next.js](https://nextjs.org/) app - `docs`: a [Next.js](https://nextjs.org/) app
- `web`: another [Next.js](https://nextjs.org/) app - `web`: another [Next.js](https://nextjs.org/) app
- `ui`: a stub React component library shared by both `web` and `docs` applications - `@repo/ui`: a stub React component library shared by both `web` and `docs` applications
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) - `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `tsconfig`: `tsconfig.json`s used throughout the monorepo - `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
### Utilities ### Utilities
This turborepo has some additional tools already setup for you: This Turborepo has some additional tools already setup for you:
- [TypeScript](https://www.typescriptlang.org/) for static type checking - [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting - [ESLint](https://eslint.org/) for code linting
@ -30,7 +38,7 @@ To build all apps and packages, run the following command:
``` ```
cd my-turborepo cd my-turborepo
yarn run build pnpm build
``` ```
### Develop ### Develop
@ -39,7 +47,7 @@ To develop all apps and packages, run the following command:
``` ```
cd my-turborepo cd my-turborepo
yarn run dev pnpm dev
``` ```
### Remote Caching ### Remote Caching
@ -55,7 +63,7 @@ npx turbo login
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo: Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
``` ```
npx turbo link npx turbo link
@ -65,7 +73,7 @@ npx turbo link
Learn more about the power of Turborepo: Learn more about the power of Turborepo:
- [Pipelines](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks) - [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks)
- [Caching](https://turbo.build/repo/docs/core-concepts/caching) - [Caching](https://turbo.build/repo/docs/core-concepts/caching)
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) - [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching)
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering) - [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering)

View File

@ -1,2 +0,0 @@
node_modules
dist

View File

@ -1,12 +1,13 @@
module.exports = { const { createConfig } = require('@vchikalkin/eslint-config-awesome');
root: true,
extends: [ module.exports = createConfig('typescript', {
'@vchikalkin/eslint-config-awesome/typescript/config',
'@vchikalkin/eslint-config-awesome/typescript/rules',
],
parserOptions: { parserOptions: {
project: './tsconfig.json', project: './tsconfig.json',
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
sourceType: 'module',
}, },
}; ignorePatterns: ['*.config.js', '.eslintrc.js'],
rules: {
'import/no-duplicates': 'off',
'import/consistent-type-specifier-style': 'off',
},
});

View File

@ -1,19 +1,22 @@
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker. # This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs. # Make sure you update both files!
FROM node:alpine AS builder FROM node:alpine AS builder
RUN corepack enable && corepack prepare pnpm@latest --activate
ENV PNPM_HOME=/usr/local/bin
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
RUN apk update RUN apk update
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
RUN yarn global add turbo RUN pnpm add -g turbo dotenv-cli
RUN yarn global add dotenv-cli
COPY . . COPY . .
RUN turbo prune --scope=api --docker RUN turbo prune --scope=api --docker
# Add lockfile and package.json's of isolated subworkspace # Add lockfile and package.json's of isolated subworkspace
FROM node:alpine AS installer FROM node:alpine AS installer
RUN corepack enable && corepack prepare pnpm@latest --activate
ENV PNPM_HOME=/usr/local/bin
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
RUN apk update RUN apk update
WORKDIR /app WORKDIR /app
@ -21,13 +24,15 @@ WORKDIR /app
# First install dependencies (as they change less often) # First install dependencies (as they change less often)
COPY .gitignore .gitignore COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN yarn install COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm install
# Build the project and its dependencies # Build the project and its dependencies
COPY --from=builder /app/out/full/ . COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json COPY turbo.json turbo.json
RUN yarn dotenv -e .env turbo run build --filter=api... COPY .env .env
RUN pnpm dotenv -e .env turbo run build --filter=web...
FROM node:alpine AS runner FROM node:alpine AS runner
WORKDIR /app WORKDIR /app

View File

@ -58,8 +58,9 @@
"@types/ldap-authentication": "^2.2.1", "@types/ldap-authentication": "^2.2.1",
"@types/node": "^20.8.6", "@types/node": "^20.8.6",
"@types/supertest": "^2.0.14", "@types/supertest": "^2.0.14",
"@vchikalkin/eslint-config-awesome": "^1.1.2", "@vchikalkin/eslint-config-awesome": "^1.1.5",
"eslint": "^8.51.0", "eslint": "^8.51.0",
"fastify": "^4.24.3",
"jest": "29.7.0", "jest": "29.7.0",
"prettier": "^3.0.3", "prettier": "^3.0.3",
"source-map-support": "^0.5.21", "source-map-support": "^0.5.21",
@ -68,7 +69,7 @@
"ts-loader": "^9.5.0", "ts-loader": "^9.5.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsconfig-paths": "4.2.0", "tsconfig-paths": "4.2.0",
"typescript": "4.9.5" "typescript": "5.3.2"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@ -17,5 +17,6 @@
"strictBindCallApply": false, "strictBindCallApply": false,
"forceConsistentCasingInFileNames": false, "forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false "noFallthroughCasesInSwitch": false
} },
"exclude": ["node_modules"]
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,14 @@
module.exports = { const { createConfig } = require('@vchikalkin/eslint-config-awesome');
extends: [
'@vchikalkin/eslint-config-awesome/next-typescript/config', module.exports = createConfig('next-typescript', {
'@vchikalkin/eslint-config-awesome/next-typescript/rules',
],
parserOptions: { parserOptions: {
project: './tsconfig.json', project: './tsconfig.json',
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
}, },
root: true, rules: {
}; 'import/no-duplicates': 'off',
'import/consistent-type-specifier-style': 'off',
'react/forbid-component-props': 'off',
},
ignorePatterns: ['*.config.js', '.eslintrc.js'],
});

View File

@ -2,47 +2,47 @@
# Make sure you update both files! # Make sure you update both files!
FROM node:alpine AS builder FROM node:alpine AS builder
RUN corepack enable && corepack prepare pnpm@latest --activate
ENV PNPM_HOME=/usr/local/bin
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
RUN apk update RUN apk update
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
RUN yarn global add turbo RUN pnpm add -g turbo dotenv-cli
RUN yarn global add dotenv-cli
COPY . . COPY . .
RUN turbo prune --scope=web --docker RUN turbo prune --scope=web --docker
# Add lockfile and package.json's of isolated subworkspace # Add lockfile and package.json's of isolated subworkspace
FROM node:alpine AS installer FROM node:alpine AS installer
RUN corepack enable && corepack prepare pnpm@latest --activate
ENV PNPM_HOME=/usr/local/bin
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
RUN apk update RUN apk update
WORKDIR /app WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED 1
# First install the dependencies (as they change less often) # First install the dependencies (as they change less often)
COPY .gitignore .gitignore COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN yarn install COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm install
# Build the project # Build the project
COPY --from=builder /app/out/full/ . COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json COPY turbo.json turbo.json
COPY .env .env COPY .env .env
RUN yarn dotenv -e .env turbo run build --filter=web... RUN pnpm dotenv -e .env turbo run build --filter=web...
FROM node:alpine AS runner FROM node:alpine AS runner
WORKDIR /app WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED 1
# Don't run production as root # Don't run production as root
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
USER nextjs USER nextjs
COPY --from=installer /app/apps/web/next.config.mjs . COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json . COPY --from=installer /app/apps/web/package.json .
# Automatically leverage output traces to reduce image size # Automatically leverage output traces to reduce image size

View File

@ -1,8 +1,8 @@
import { z } from 'zod'; const { z } = require('zod');
const envSchema = z.object({ const envSchema = z.object({
APP_DESCRIPTION: z.string(), APP_DESCRIPTION: z.string(),
APP_BASE_PATH: z.string().optional().default(''), APP_BASE_PATH: z.string().optional().default(''),
}); });
export default envSchema; module.exports = envSchema;

View File

@ -1,14 +1,10 @@
import envSchema from './config/schema/env.js'; const envSchema = require('./config/schema/env.js');
import { dirname, join } from 'path'; const { join } = require('path');
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const runtimeConfig = envSchema.parse(process.env); const runtimeConfig = envSchema.parse(process.env);
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { module.exports = {
basePath: process.env.APP_BASE_PATH, basePath: process.env.APP_BASE_PATH,
eslint: { eslint: {
ignoreDuringBuilds: true, ignoreDuringBuilds: true,
@ -22,5 +18,3 @@ const nextConfig = {
serverRuntimeConfig: runtimeConfig, serverRuntimeConfig: runtimeConfig,
swcMinify: true, swcMinify: true,
}; };
export default nextConfig;

View File

@ -2,7 +2,6 @@
"name": "web", "name": "web",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
@ -12,20 +11,20 @@
}, },
"dependencies": { "dependencies": {
"@fontsource/montserrat": "^5.0.13", "@fontsource/montserrat": "^5.0.13",
"@types/node": "^20", "@types/node": "^20.10.0",
"@types/react": "^18", "@types/react": "^18.2.39",
"@types/react-dom": "^18", "@types/react-dom": "^18.2.17",
"axios": "^1.5.1", "axios": "^1.5.1",
"next": "^14.0.0", "next": "^14.0.3",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"sass": "^1.69.3", "sass": "^1.69.3",
"typescript": "4.9.5", "typescript": "5.3.2",
"zod": "^3.22.4" "zod": "^3.22.4"
}, },
"devDependencies": { "devDependencies": {
"@vchikalkin/eslint-config-awesome": "^1.1.2", "@vchikalkin/eslint-config-awesome": "^1.1.5",
"eslint": "^8.51.0" "eslint": "^8.51.0"
} }
} }

View File

@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig", "$schema": "https://json.schemastore.org/tsconfig",
"display": "Next.js", "display": "Next.js",
"compilerOptions": { "compilerOptions": {
"target": "ES2022",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,

View File

@ -2,9 +2,6 @@
"name": "evo-auth", "name": "evo-auth",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"workspaces": [
"apps/*"
],
"scripts": { "scripts": {
"build": "dotenv -e .env turbo run build", "build": "dotenv -e .env turbo run build",
"dev": "dotenv -e .env.local turbo run dev", "dev": "dotenv -e .env.local turbo run dev",
@ -19,9 +16,8 @@
"prettier": "latest", "prettier": "latest",
"turbo": "latest" "turbo": "latest"
}, },
"packageManager": "pnpm@8.9.0",
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=18"
}, }
"dependencies": {},
"packageManager": "yarn@1.22.19"
} }

9341
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

3
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,3 @@
packages:
- "apps/*"
- "packages/*"

8677
yarn.lock

File diff suppressed because it is too large Load Diff