Skip to content

Commit

Permalink
feat: better monorepo tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1230 committed May 18, 2024
1 parent ab0f5c5 commit db8f2d1
Show file tree
Hide file tree
Showing 40 changed files with 1,547 additions and 265 deletions.
2 changes: 1 addition & 1 deletion apps/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build:sign": "APP_VARIANT=preview eas build -e preview -p ios",
"analyze:web": "source-map-explorer 'dist/_expo/static/js/web/*.js' 'dist/_expo/static/js/web/*.js.map'",
"analyze:ios": "source-map-explorer 'dist/_expo/static/js/ios/*.js' 'dist/_expo/static/js/ios/*.js.map'",
"tsc": "tsc",
"typecheck": "tsc",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . -c eslint.config.js",
"clean": "rm -rf .turbo dist node_modules"
},
Expand Down
3 changes: 2 additions & 1 deletion apps/native/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"tsBuildInfoFile": "../../node_modules/.cache/tsbuildinfo.json"
},
"include": [
"**/*.ts",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"start": "bun run src/index.ts",
"start:prod": "bun run src/index.ts",
"tsc": "tsc --noEmit",
"typecheck": "tsc --noEmit",
"dev": "bun --watch run src/index.ts",
"dev:clean": "DEBUG_RESET_DB=true bun --watch run src/index.ts",
"test": "export TEST_ENV=true jest",
Expand Down
3 changes: 2 additions & 1 deletion apps/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"tsBuildInfoFile": "../../node_modules/.cache/tsbuildinfo.json"
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
13 changes: 13 additions & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",

/** Enables hot reloading for local packages without a build step */
transpilePackages: ["@mychat/agents", "@mychat/shared", "@mychat/db"],

/** We already do linting and typechecking as separate tasks in CI */
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
};

export default nextConfig;
4 changes: 0 additions & 4 deletions apps/web/next.config.mjs

This file was deleted.

1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@mychat/web",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
],
"paths": {
"@/*": ["./src/*"]
}
},
"tsBuildInfoFile": "../../node_modules/.cache/tsbuildinfo.json"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
Expand Down
81 changes: 39 additions & 42 deletions myChat.code-workspace
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
{
"folders": [
{
"path": ".",
},
{
"name": "Apps",
"path": "apps",
},
{
"name": "Packages",
"path": "packages",
},
{
"name": "Tooling",
"path": "tooling",
},
{
"name": "Logs",
"path": "logs",
},
],
"settings": {
"prettier.printWidth": 90,
"tailwindCSS.classAttributes": ["class", "className", "headerClassName"],
"tailwindCSS.lint.cssConflict": "ignore",
"xeslint.options": { "overrideConfigFile": "eslint.config.js" },
"eslint.useFlatConfig": false,
"eslint.workingDirectories": [
{ "pattern": "./apps/native/*/" },
{ "pattern": "./apps/web/*/" },
{ "pattern": "./apps/server/*/" },
{ "pattern": "./packages/agents/*/" },
{ "pattern": "./packages/db/*/" },
{ "pattern": "./packages/shared/*/" },
{ "pattern": "./tooling/logger/*/" },
{ "pattern": "./tooling/eslint/*/" },
],
"typescript.tsdk": "myChat/node_modules/typescript/lib",
"yaml.schemas": {
"https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json": "file:///Users/justin/Projects/myChat/compose.test.yml",
},
},
"folders": [
{
"path": ".",
},
{
"name": "Apps",
"path": "apps",
},
{
"name": "Packages",
"path": "packages",
},
{
"name": "Tooling",
"path": "tooling",
},
{
"name": "Logs",
"path": "logs",
},
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"tailwindCSS.classAttributes": ["class", "className", "headerClassName"],
"tailwindCSS.lint.cssConflict": "ignore",
"xeslint.options": { "overrideConfigFile": "eslint.config.js" },
"eslint.useFlatConfig": false,
"eslint.workingDirectories": [
{ "pattern": "apps/*/" },
{ "pattern": "packages/*/" },
{ "pattern": "tooling/*/" },
],
"typescript.tsdk": "myChat/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"yaml.schemas": {
"https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json": "file:///Users/justin/Projects/myChat/compose.test.yml",
},
},
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
"compose": "docker compose -f compose.yml",
"compose:test": "docker compose -f compose.yml -f compose.test.yml",
"lint": "turbo lint",
"tsc": "turbo tsc",
"typecheck": "turbo typecheck",
"export": "turbo export",
"build": "turbo build --cache-dir=.turbo",
"migration:run": "turbo migration:run",
"dev": "TURBO_EXPERIMENTAL_UI=true turbo dev",
"start": "turbo start",
"start:prod": "turbo start:prod",
"compose:prod": "docker compose -f production.yml",
"clean": "turbo clean && yarn cache clean && rm -rf node_modules yarn.lock ./logs",
"clean": "git clean -xdf node_modules && yarn cache clean && rm -rf ./logs",
"clean:workspaces": "turbo clean",
"tree": "tree -L 4 . --gitignore --dirsfirst --noreport --charset utf-8"
},
"keywords": [],
Expand All @@ -31,8 +32,11 @@
"markdown-it": "14.0.0"
},
"devDependencies": {
"@mychat/prettier-config": "workspace:^",
"@mychat/tsconfig": "workspace:*",
"@turbo/gen": "^1.13.3",
"turbo": "^1.13.3"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"prettier": "@mychat/prettier-config"
}
2 changes: 1 addition & 1 deletion packages/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"scripts": {
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . -c eslint.config.js",
"test": "jest",
"tsc": "tsc",
"typecheck": "tsc",
"clean": "rm -rf logs .turbo"
}
}
3 changes: 2 additions & 1 deletion packages/agents/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"tsBuildInfoFile": "../../node_modules/.cache/tsbuildinfo.json"
}
}
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mychat/db",
"version": "0.0.1",
"description": "Awesome project developed with TypeORM.",
"description": "Database managed with TypeORM.",
"main": "./src/index.ts",
"exports": {
".": "./src",
Expand Down Expand Up @@ -35,7 +35,7 @@
"typeorm": "typeorm-ts-node-commonjs -d src/data-source.ts",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . -c eslint.config.js",
"test": "jest",
"tsc": "tsc",
"typecheck": "tsc",
"clean": "rm -rf logs .turbo"
}
}
3 changes: 2 additions & 1 deletion packages/db/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "./build",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true
"sourceMap": true,
"tsBuildInfoFile": "../../node_modules/.cache/tsbuildinfo.json"
}
}
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dev": "tsc --watch",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . -c eslint.config.js",
"test": "jest",
"tsc": "tsc",
"typecheck": "tsc",
"clean": "rm -rf .turbo"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "@mychat/tsconfig/base.json",
"compilerOptions": {
"tsBuildInfoFile": "../../node_modules/.cache/tsbuildinfo.json"
},
"include": ["**/*.ts", "**/*.tsx"]
}
79 changes: 44 additions & 35 deletions tooling/eslint/base.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
/** @type {import("eslint").Linter.Config} */
const config = {
extends: [
"turbo",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
env: {
es2022: true,
node: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
plugins: ["@typescript-eslint", "import"],
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"@typescript-eslint/consistent-type-imports": [
"warn",
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
],
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/strict-boolean-expressions": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-redeclare": "off",
"import/consistent-type-specifier-style": "off",
"turbo/no-undeclared-env-vars": "off",
},
ignorePatterns: ["**/.eslintrc.js", "**/*.config.js", "dist", "yarn.lock", ".turbo"],
reportUnusedDisableDirectives: true,
extends: [
"turbo",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
env: {
es2022: true,
node: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
plugins: ["@typescript-eslint", "import"],
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"@typescript-eslint/consistent-type-imports": [
"warn",
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
],
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/strict-boolean-expressions": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-redeclare": "off",
"import/consistent-type-specifier-style": "off",
"turbo/no-undeclared-env-vars": "off",
},
ignorePatterns: [
"**/.eslintrc.js",
"**/*.config.js",
"dist",
"yarn.lock",
".turbo",
],
reportUnusedDisableDirectives: true,
settings: {
"import/ignore": ["node_modules(\\\\|/)react-native(\\\\|/)index\\.js$"],
},
};

module.exports = config;
Loading

0 comments on commit db8f2d1

Please sign in to comment.