Skip to content

Commit

Permalink
Update with-docker example. (#6547)
Browse files Browse the repository at this point in the history
Updating the with-docker example!

Closes TURBO-1707

Things to pay attention to:

- [x] Is tasking correct? Are all tasks successful out-of-the-box? Do I
hit cache when I'm expecting?
- [x] If I add an unused variable in a workspace, do I see a warning in
both my editor and when I run turbo lint?
- [x] Does auto-importing work across packages?
- [x] Anything else wonky in your editor?
- [x] Do I get proper hot-reloading in turbo dev?
- [x] Anything else that may come up!
  • Loading branch information
anthonyshew committed Nov 24, 2023
1 parent 39885f2 commit 3ddfa0e
Show file tree
Hide file tree
Showing 39 changed files with 2,203 additions and 3,084 deletions.
8 changes: 1 addition & 7 deletions examples/with-docker/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
settings: {
next: {
rootDir: ["apps/*/"],
},
},
extends: ["@repo/eslint-config/index.js"],
};
14 changes: 7 additions & 7 deletions examples/with-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ This turborepo uses [Yarn](https://classic.yarnpkg.com/lang/en/) as a package ma

### Apps and Packages

- `web`: a [Next.js](https://nextjs.org/) app
- `api`: an [Express](https://expressjs.com/) server
- `ui`: ui: a React component library
- `eslint-config-custom`: `eslint` configurations for client side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `eslint-config-custom-server`: `eslint` configurations for server side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `@repo/web`: a [Next.js](https://nextjs.org/) app
- `@repo/api`: an [Express](https://expressjs.com/) server
- `@repo/ui`: ui: a React component library
- `@repo/eslint-config-custom`: `eslint` configurations for client side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `@repo/eslint-config-custom-server`: `eslint` configurations for server side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `scripts`: Jest configurations
- `logger`: Isomorphic logger (a small wrapper around console.log)
- `tsconfig`: tsconfig.json;s used throughout the monorepo
- `@repo/logger`: Isomorphic logger (a small wrapper around console.log)
- `@repo/typescript-config`: tsconfig.json's used throughout the monorepo

Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

Expand Down
3 changes: 2 additions & 1 deletion examples/with-docker/apps/api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["custom-server"],
extends: ["@repo/eslint-config/server.js"],
};
2 changes: 1 addition & 1 deletion examples/with-docker/apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ COPY turbo.json turbo.json
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN

RUN yarn turbo run build --filter=api...
RUN yarn turbo build --filter=api...

FROM base AS runner
WORKDIR /app
Expand Down
44 changes: 22 additions & 22 deletions examples/with-docker/apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@
"build": "tsc",
"clean": "rm -rf dist",
"dev": "nodemon --exec \"node -r esbuild-register ./src/index.ts\" -e .ts",
"lint": "tsc --noEmit && eslint \"src/**/*.ts*\"",
"lint": "tsc --noEmit && eslint \"src/**/*.ts*\" --max-warnings 0",
"start": "node -r esbuild-register ./src/index.ts",
"test": "jest --detectOpenHandles"
},
"jest": {
"preset": "jest-presets/jest/node"
"preset": "@repo/jest-presets/jest/node"
},
"dependencies": {
"body-parser": "^1.19.0",
"@repo/logger": "*",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.17.1",
"logger": "*",
"express": "^4.18.2",
"morgan": "^1.10.0"
},
"devDependencies": {
"@types/body-parser": "^1.19.0",
"@types/cors": "^2.8.10",
"@types/express": "^4.17.12",
"@types/jest": "^26.0.22",
"@types/morgan": "^1.9.2",
"@types/node": "^15.12.2",
"@types/supertest": "^2.0.11",
"esbuild": "^0.14.38",
"esbuild-register": "^3.3.2",
"eslint": "^7.32.0",
"eslint-config-custom-server": "*",
"jest": "^26.6.3",
"jest-presets": "*",
"nodemon": "^2.0.15",
"supertest": "^6.1.3",
"tsconfig": "*",
"typescript": "^4.5.3"
"@repo/eslint-config": "*",
"@repo/jest-presets": "*",
"@repo/typescript-config": "*",
"@types/body-parser": "^1.19.5",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.10",
"@types/morgan": "^1.9.9",
"@types/node": "^20.9.4",
"@types/supertest": "^2.0.16",
"esbuild": "^0.19.7",
"esbuild-register": "^3.5.0",
"eslint": "^8.54.0",
"jest": "^29.7.0",
"nodemon": "^3.0.1",
"supertest": "^6.3.3",
"typescript": "^5.3.2"
}
}
2 changes: 1 addition & 1 deletion examples/with-docker/apps/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createServer } from "./server";
import { log } from "logger";
import { log } from "@repo/logger";

const port = process.env.PORT || 3001;
const server = createServer();
Expand Down
3 changes: 1 addition & 2 deletions examples/with-docker/apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"lib": ["ES2015"],
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src"
},
"exclude": ["node_modules"],
"extends": "tsconfig/base.json",
"include": ["src"]
}
7 changes: 6 additions & 1 deletion examples/with-docker/apps/web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["custom"],
extends: ["@repo/eslint-config/next.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
2 changes: 1 addition & 1 deletion examples/with-docker/apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ COPY turbo.json turbo.json
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN

RUN yarn turbo run build --filter=web...
RUN yarn turbo build --filter=web...

FROM base AS runner
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion examples/with-docker/apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require("path");

module.exports = {
reactStrictMode: true,
transpilePackages: ["ui"],
transpilePackages: ["@repo/ui"],
output: "standalone",
experimental: {
outputFileTracingRoot: path.join(__dirname, "../../"),
Expand Down
19 changes: 10 additions & 9 deletions examples/with-docker/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"lint": "eslint . --max-warnings 0",
"start": "next start"
},
"dependencies": {
"next": "^14.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ui": "*"
"@repo/ui": "*"
},
"devDependencies": {
"@types/node": "^17.0.12",
"@types/react": "^18.0.22",
"@types/react-dom": "^18.0.7",
"eslint": "7.32.0",
"eslint-config-custom": "*",
"tsconfig": "*",
"typescript": "^4.5.3"
"@next/eslint-plugin-next": "^14.0.2",
"@types/node": "^20.9.4",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
"eslint": "^8.54.0",
"@repo/eslint-config": "*",
"@repo/typescript-config": "*",
"typescript": "^5.3.2"
}
}
2 changes: 1 addition & 1 deletion examples/with-docker/apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { Button } from "@repo/ui/button";
import { useEffect, useState } from "react";
import { Button } from "ui";

const API_HOST = process.env.NEXT_PUBLIC_API_HOST || "http://localhost:3001";

Expand Down
4 changes: 2 additions & 2 deletions examples/with-docker/apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "tsconfig/nextjs.json",
"extends": "@repo/typescript-config/nextjs.json",
"compilerOptions": {
"plugins": [{ "name": "next" }]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": ["next-env.d.ts", "next.config.js", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
6 changes: 3 additions & 3 deletions examples/with-docker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"dependencies": {},
"devDependencies": {
"eslint-config-custom": "*",
"prettier": "^2.8.8",
"turbo": "^1.9.3"
"@repo/eslint-config": "*",
"prettier": "^3.1.0",
"turbo": "^1.10.16"
},
"packageManager": "yarn@1.22.19",
"engines": {
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions examples/with-docker/packages/eslint-config-custom/index.js

This file was deleted.

15 changes: 0 additions & 15 deletions examples/with-docker/packages/eslint-config-custom/package.json

This file was deleted.

3 changes: 3 additions & 0 deletions examples/with-docker/packages/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@turbo/eslint-config`

Collection of internal eslint configurations.
34 changes: 34 additions & 0 deletions examples/with-docker/packages/eslint-config/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { resolve } = require("node:path");

const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "eslint-config-turbo"],
plugins: ["only-warn"],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
},
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
],
overrides: [
{
files: ["*.js?(x)", "*.ts?(x)"],
},
],
};
42 changes: 42 additions & 0 deletions examples/with-docker/packages/eslint-config/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { resolve } = require("node:path");

const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
"prettier",
require.resolve("@vercel/style-guide/eslint/next"),
"eslint-config-turbo",
],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
},
plugins: ["only-warn"],
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
],
overrides: [
{ files: ["*.js?(x)", "*.ts?(x)"] },
{
files: ["*.ts", "*.tsx"],
rules: {
"no-undef": "off",
},
},
],
};
20 changes: 20 additions & 0 deletions examples/with-docker/packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@repo/eslint-config",
"version": "0.0.0",
"private": true,
"files": [
"library.js",
"next.js",
"react-internal.js",
"server.js"
],
"devDependencies": {
"@vercel/style-guide": "^5.1.0",
"eslint-config-turbo": "^1.10.12",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-only-warn": "^1.1.0",
"@typescript-eslint/parser": "^6.11.0",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"typescript": "^5.2.2"
}
}
Loading

0 comments on commit 3ddfa0e

Please sign in to comment.