diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 83a24ff..939ba3a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,6 +7,8 @@ RUN apt update && export DEBIAN_FRONTEND=noninteractive \ RUN git lfs install +RUN npm i -g yarn concurrently + ENV ZSH_CUSTOM /root/.oh-my-zsh/ RUN git clone https://github.com/reobin/typewritten.git $ZSH_CUSTOM/themes/typewritten RUN ln -s "$ZSH_CUSTOM/themes/typewritten/typewritten.zsh-theme" "$ZSH_CUSTOM/themes/typewritten.zsh-theme" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 61ee66d..2b603ec 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,7 @@ "terminal.integrated.shell.linux": "/bin/zsh", "files.exclude": { "**/node_modules": true, - "**/package-lock.json": true, + "**/yarn.lock": true, "**/dist": true, "**/lib": true, "**/.firebase": true @@ -19,7 +19,6 @@ "editor.detectIndentation": false, "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", - "eslint.enable": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, @@ -43,11 +42,11 @@ "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", "workspaceFolder": "/workspace", "mounts": [ - "source=decla-red-root-node_modules-volume2,target=/workspace/node_modules,type=volume", - "source=decla-red-frontend-node_modules-volume2,target=/workspace/frontend/node_modules,type=volume", - "source=decla-red-backend-node_modules-volume2,target=/workspace/backend/node_modules,type=volume", - "source=decla-red-shared-node_modules-volume2,target=/workspace/shared/node_modules,type=volume" + "source=decla-red-root-node_modules-volume3,target=/workspace/node_modules,type=volume", + "source=decla-red-frontend-node_modules-volume3,target=/workspace/frontend/node_modules,type=volume", + "source=decla-red-backend-node_modules-volume3,target=/workspace/backend/node_modules,type=volume", + "source=decla-red-shared-node_modules-volume3,target=/workspace/shared/node_modules,type=volume" ], "forwardPorts": [3000, 8080], - "postCreateCommand": "chown node:node ./**/node_modules && npm install && npm run initialize && npm run build" + "postCreateCommand": "chown node:node ./**/node_modules && yarn" } diff --git a/.gitignore b/.gitignore index bbc4e21..6c971d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ dist lib node_modules -package-lock.json .firebase -lerna-debug.log +yarm-error.log +yarn.lock diff --git a/Dockerfile b/Dockerfile index e4e26b2..79c3b51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM node:14.13.0-alpine3.10 as build COPY . . -RUN npm install && npm run initialize && npm run build +RUN npm i -g concurrently +RUN yarn && yarn run build FROM node:14.13.0-alpine3.10 diff --git a/README.md b/README.md index dd035bf..cec66d2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # decla.red ![Deploy everything](https://github.com/schmelczerandras/decla.red/workflows/Deploy%20everything/badge.svg) + +## Development + +- Open the devconatiner in VS Code +- Run `yarn start` +- Open [localhost:8080](http://localhost:8080) diff --git a/backend/package.json b/backend/package.json index 88ca093..0d61c0d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,19 +1,18 @@ { "name": "declared-server", + "version": "0.0.2", "description": "Game server for decla.red", "keywords": [], "author": "András Schmelczer (https://schmelczer.dev/)", - "version": "0.0.1-try2", "main": "dist/main.js", - "scripts": { - "build": "npx webpack --mode production", - "initialize": "npm install", - "start": "concurrently --kill-others \"npx webpack --mode development -w\" \"cd dist && nodemon --legacy-watch main.js\"", - "try-build": "npm run build && cd dist && node main.js && cd -" - }, "bin": { "declared-server": "./dist/main.js" }, + "scripts": { + "build": "npx webpack --mode production", + "start": "npx concurrently --kill-others-on-fail \"npx webpack --mode development -w\" \"npx nodemon --legacy-watch dist/main.js\"", + "try-build": "npm run build && cd dist && node main.js && cd -" + }, "dependencies": { "@types/config": "0.0.36", "cors": "^2.8.5", @@ -24,12 +23,28 @@ "webpack-node-externals": "^2.5.2" }, "devDependencies": { + "@types/cors": "^2.8.7", + "@types/express": "^4.17.8", + "@types/node": "^14.11.2", + "@types/socket.io": "^2.1.11", + "@typescript-eslint/eslint-plugin": "^3.9.1", + "@typescript-eslint/parser": "^3.9.1", "clean-webpack-plugin": "^3.0.0", "concurrently": "^5.3.0", - "esbuild-loader": "^2.4.0", + "eslint": "^7.2.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-import": "^2.21.2", + "eslint-plugin-json-format": "^2.0.1", + "eslint-plugin-prettier": "^3.1.4", + "eslint-plugin-unused-imports": "^0.1.3", + "file-loader": "^6.1.0", + "ts-loader": "^8.0.3", + "gl-matrix": "^3.3.0", "nodemon": "^2.0.4", + "prettier": "^2.0.5", "raw-loader": "^4.0.1", "resolve-url-loader": "^3.1.1", + "shared": "0.0.0", "terser-webpack-plugin": "^2.3.5", "typescript": "^4.0.3", "webpack": "^4.43.0", diff --git a/backend/tsconfig.json b/backend/tsconfig.json index d477e81..c883490 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "outDir": "dist", "sourceMap": true, "declaration": true, "declarationMap": true, @@ -13,5 +14,5 @@ "composite": true, "lib": ["dom", "es2017"] }, - "include": ["src/**/*.ts", "src/*.ts"] + "include": ["src/**/*.ts"] } diff --git a/backend/webpack.config.js b/backend/webpack.config.js index 84b30bc..90ebc97 100644 --- a/backend/webpack.config.js +++ b/backend/webpack.config.js @@ -1,7 +1,6 @@ const path = require('path'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const nodeExternals = require('webpack-node-externals'); -const { ESBuildPlugin } = require('esbuild-loader'); const TerserJSPlugin = require('terser-webpack-plugin'); const webpack = require('webpack'); @@ -43,7 +42,6 @@ module.exports = (env, argv) => ({ }, plugins: [ new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }), - new ESBuildPlugin(), new CleanWebpackPlugin({ protectWebpackAssets: false, cleanAfterEveryBuildPatterns: [], @@ -63,10 +61,8 @@ module.exports = (env, argv) => ({ }, { test: /\.ts$/, - loader: 'esbuild-loader', - options: { - loader: 'ts', - target: 'es2015', + use: { + loader: 'ts-loader', }, exclude: /node_modules/, }, diff --git a/frontend/package.json b/frontend/package.json index 31d8075..a951f71 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "decla.red-frontend", - "private": true, + "version": "0.0.0", "description": "![logo](media/declared.png)", "keywords": [], "author": "András Schmelczer (https://schmelczer.dev/)", @@ -10,7 +10,6 @@ "main": "index.js", "scripts": { "build": "npx webpack --mode production", - "initialize": "npm install", "start": "npx webpack-dev-server --mode development", "try-build": "npm run build && cd dist && python3 -m http.server 8080" }, @@ -18,25 +17,44 @@ "defaults" ], "devDependencies": { + "@types/socket.io-client": "^1.4.34", + "@typescript-eslint/eslint-plugin": "^3.9.1", + "@typescript-eslint/parser": "^3.9.1", + "autoprefixer": "^9.8.5", "clean-webpack-plugin": "^3.0.0", - "esbuild-loader": "^2.4.0", + "css-loader": "^3.5.2", + "cssnano": "^4.1.10", + "eslint": "^7.2.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-import": "^2.21.2", + "eslint-plugin-json-format": "^2.0.1", + "eslint-plugin-prettier": "^3.1.4", + "eslint-plugin-unused-imports": "^0.1.3", + "file-loader": "^6.1.0", + "firebase": "^7.22.0", + "gl-matrix": "^3.3.0", "html-webpack-inline-source-plugin": "0.0.10", "html-webpack-plugin": "^3.2.0", "image-webpack-loader": "^6.0.0", "mini-css-extract-plugin": "^0.9.0", "optimize-css-assets-webpack-plugin": "^5.0.3", "postcss-loader": "^3.0.0", + "prettier": "^2.0.5", "raw-loader": "^4.0.1", "resolve-url-loader": "^3.1.1", + "ts-loader": "^8.0.3", "sass": "^1.26.3", "sass-loader": "^9.0.2", + "sdf-2d": "^0.5.3", + "shared": "0.0.0", + "socket.io-client": "^2.3.1", + "source-map-loader": "^1.1.0", "svg-url-loader": "^6.0.0", "terser-webpack-plugin": "^4.2.2", "typescript": "^4.0.3", "webpack": "^4.43.0", "webpack-bundle-analyzer": "^3.9.0", "webpack-cli": "^3.3.11", - "source-map-loader": "^1.1.0", "webpack-dev-server": "^3.10.3" }, "postcss": { diff --git a/tsconfig.json b/frontend/tsconfig.json similarity index 87% rename from tsconfig.json rename to frontend/tsconfig.json index 33b118a..c883490 100644 --- a/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "outDir": "dist", "sourceMap": true, "declaration": true, "declarationMap": true, @@ -13,5 +14,5 @@ "composite": true, "lib": ["dom", "es2017"] }, - "include": ["**/*.ts"] + "include": ["src/**/*.ts"] } diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index 3ab9498..f219f3c 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -6,7 +6,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin'); const Sass = require('sass'); const TerserJSPlugin = require('terser-webpack-plugin'); -const { ESBuildPlugin } = require('esbuild-loader'); const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); const PATHS = { @@ -46,7 +45,6 @@ module.exports = (env, argv) => ({ ], }, plugins: [ - new ESBuildPlugin(), new HtmlWebpackPlugin({ xhtml: true, template: './src/index.html', @@ -105,10 +103,8 @@ module.exports = (env, argv) => ({ }, { test: /\.ts$/, - loader: 'esbuild-loader', - options: { - loader: 'ts', - target: 'es2015', + use: { + loader: 'ts-loader', }, exclude: /node_modules/, }, diff --git a/lerna.json b/lerna.json deleted file mode 100644 index e3d3386..0000000 --- a/lerna.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "packages": [ - "frontend", - "shared", - "backend" - ], - "version": "0.0.0" -} \ No newline at end of file diff --git a/package.json b/package.json index 39a8834..31ff546 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,22 @@ { "name": "root", "private": true, + "workspaces": { + "packages": [ + "frontend", + "shared", + "backend" + ], + "nohoist": [ + "**" + ] + }, "scripts": { - "build": "lerna run build-before && lerna run build", - "initialize": "lerna link && lerna run initialize", + "build": "yarn workspaces shared run build && yarn workspaces frontend run build && yarn workspaces backend run build", "lint": "eslint './**/src/**/*.{js,ts,json}' --fix", - "start": "lerna run --parallel start", - "try-build": "lerna run --parallel try-build-before && lerna run --parallel try-build" - }, - "dependencies": { - "decla.red-frontend": "file:frontend", - "shared": "file:shared" - }, - "devDependencies": { - "@types/cors": "^2.8.7", - "@types/express": "^4.17.8", - "@types/node": "^14.11.2", - "@types/socket.io": "^2.1.11", - "@types/socket.io-client": "^1.4.34", - "@types/uuid": "^8.0.0", - "@typescript-eslint/eslint-plugin": "^3.9.1", - "@typescript-eslint/parser": "^3.9.1", - "autoprefixer": "^9.8.5", - "css-loader": "^3.5.2", - "cssnano": "^4.1.10", - "eslint": "^7.2.0", - "eslint-config-prettier": "^6.11.0", - "eslint-plugin-import": "^2.21.2", - "eslint-plugin-json-format": "^2.0.1", - "eslint-plugin-prettier": "^3.1.4", - "eslint-plugin-unused-imports": "^0.1.3", - "file-loader": "^6.1.0", - "firebase": "^7.22.0", - "gl-matrix": "^3.3.0", - "lerna": "^3.22.1", - "prettier": "^2.0.5", - "sdf-2d": "^0.5.2", - "socket.io-client": "^2.3.1", - "typescript": "^4.0.3", - "uuid": "^8.2.0" + "frontend": "yarn workspace decla.red-frontend start", + "shared": "yarn workspace shared start", + "backend": "yarn workspace declared-server start", + "start": "concurrently --kill-others-on-fail \"yarn frontend\" \"yarn shared\" \"yarn backend\"" } } diff --git a/shared/package.json b/shared/package.json index e1c9aa2..2334af1 100644 --- a/shared/package.json +++ b/shared/package.json @@ -1,6 +1,6 @@ { "name": "shared", - "private": true, + "version": "0.0.0", "description": "Shared library between backend and frontend", "main": "lib/main.js", "types": "lib/src/main.d.ts", @@ -8,13 +8,23 @@ "lib" ], "scripts": { - "build-before": "npx webpack --mode production", - "initialize": "npm install", + "build": "npx webpack --mode production", "start": "npx webpack --mode development --watch", "try-build-before": "npx webpack --mode production" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^3.9.1", + "@typescript-eslint/parser": "^3.9.1", "clean-webpack-plugin": "^3.0.0", + "eslint": "^7.2.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-import": "^2.21.2", + "eslint-plugin-json-format": "^2.0.1", + "eslint-plugin-prettier": "^3.1.4", + "eslint-plugin-unused-imports": "^0.1.3", + "file-loader": "^6.1.0", + "gl-matrix": "^3.3.0", + "prettier": "^2.0.5", "terser-webpack-plugin": "^2.3.8", "ts-loader": "^8.0.3", "typescript": "^4.0.3",