Skip to content

Commit

Permalink
Cleaned up dependency installation
Browse files Browse the repository at this point in the history
Made production npm installs only install prod dependencies through --production flag.

Removed some unused dependencies and moved some dependency definitions if they were only
used in specific packages.

Made lerna a devDependency, which works fine in production builds.

Ran depcheck on all packages to identify and fix most extraneous or unspecified dependencies.

Removed a number of top-level npm scripts that just called a script. Replaced any calls to
those npm scripts with the appropriate command.
  • Loading branch information
barankyle committed Jun 6, 2023
1 parent 75061f2 commit a60beec
Show file tree
Hide file tree
Showing 37 changed files with 208 additions and 353 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ENV VITE_READY_PLAYER_ME_URL=$VITE_READY_PLAYER_ME_URL
ENV VITE_DISABLE_LOG=$VITE_DISABLE_LOG

ARG CACHE_DATE
RUN npm run check-db-exists
RUN npx cross-env ts-node --swc scripts/check-db-exists.ts
RUN npm run build-client

RUN rm -r packages/client/public
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/api/Dockerfile-api
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /app
COPY packages/server/package.json ./packages/server/

ARG NODE_ENV
RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production

COPY . .

Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/api/Dockerfile-api-client
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /app
COPY packages/server/package.json ./packages/server/

ARG NODE_ENV
RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production

COPY . .

Expand All @@ -37,7 +37,7 @@ COPY packages/ui/package.json ./packages/ui/
COPY patches/ ./patches/

ARG NODE_ENV
RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production

# copy then compile the code
COPY . .
Expand Down Expand Up @@ -89,7 +89,7 @@ ENV VITE_DISABLE_LOG=$VITE_DISABLE_LOG

RUN npm run build-client

RUN if [ "$SERVE_CLIENT_FROM_STORAGE_PROVIDER" = "true" ] && [ "$STORAGE_PROVIDER" = "s3" ] ; then npm run push-client-dist-to-s3 ; fi
RUN if [ "$SERVE_CLIENT_FROM_STORAGE_PROVIDER" = "true" ] && [ "$STORAGE_PROVIDER" = "s3" ] ; then npx cross-env ts-node --swc scripts/push-client-to-s3.ts ; fi

RUN rm -r packages/client/public

Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/client/Dockerfile-client
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY packages/ui/package.json ./packages/ui/
COPY patches/ ./patches/

ARG NODE_ENV
RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production

# copy then compile the code
COPY . .
Expand Down Expand Up @@ -67,7 +67,7 @@ ENV VITE_DISABLE_LOG=$VITE_DISABLE_LOG

RUN npm run build-client

RUN if [ "$SERVE_CLIENT_FROM_STORAGE_PROVIDER" = "true" ] && [ "$STORAGE_PROVIDER" = "s3" ] ; then npm run push-client-dist-to-s3 ; fi
RUN if [ "$SERVE_CLIENT_FROM_STORAGE_PROVIDER" = "true" ] && [ "$STORAGE_PROVIDER" = "s3" ] ; then npx cross-env ts-node --swc scripts/push-client-to-s3.ts ; fi

RUN rm -r packages/client/public

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/instanceserver/Dockerfile-instanceserver
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /app
COPY packages/instanceserver/package.json ./packages/instanceserver/

ARG NODE_ENV
RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/taskserver/Dockerfile-taskserver
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /app
COPY packages/taskserver/package.json ./packages/taskserver/

ARG NODE_ENV
RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/testbot/Dockerfile-testbot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM ${ECR_URL}/${REPO_NAME}-root:latest_${STAGE} as builder
# Create app directory
WORKDIR /app

RUN npm install --loglevel notice --legacy-peer-deps
RUN npm install --loglevel notice --legacy-peer-deps --production
# copy then compile the code
COPY . .

Expand Down
39 changes: 4 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@
"scripts": {
"build-client": "cd packages/client && npm run build",
"check": "npm run lint && npm run check-errors && npm run test && npm run test:projects && npm run build-client",
"check-db-exists": "cross-env ts-node --swc scripts/check-db-exists.ts",
"check-db-exists-only": "cross-env ts-node --swc scripts/check-db-exists-only.ts",
"check-errors": "lerna run check-errors",
"clean-node-modules": "npx rimraf node_modules && npx rimraf package-lock.json && npx lerna exec npx rimraf node_modules && npx lerna exec npx rimraf package-lock.json",
"cleanup-tests": "node tests/cleanup-tests.js",
"clear-projects-rebuild": "cross-env ts-node --swc scripts/clear-projects-rebuild",
"create-root-package-json": "cross-env ts-node --swc scripts/create-root-package-json",
"depcheck": "lerna exec --no-bail --stream -- depcheck",
"dev": "npm run dev-docker && concurrently -n agones,server,client,taskserver npm:dev-agones-silent npm:dev-server npm:dev-client npm:dev-taskserver",
Expand All @@ -58,47 +54,34 @@
"dev-docker": "cd scripts && docker-compose up -d",
"dev-tabs": "cd scripts && ./dev-tabs.sh",
"fetch-projects": "lerna exec 'git fetch -p && git rebase' --parallel --ignore @etherealengine/*",
"dev-nginx": "",
"dev-reinit": "npm run dev-docker && cd packages/server && npm run dev-reinit-db",
"dev-server": "cd packages/server && npm run dev",
"dev-windows": "npm run dev-docker && concurrently -n agones,server,client npm:dev-agones-silent npm:dev-server npm:dev-client",
"diff": "lerna diff",
"edit": "node scripts/open-editor.js",
"format": "prettier --write \"packages/**/*.{ts,tsx}\"",
"format-scss": "stylelint \"packages/**/*.scss\" --fix",
"format-staged": "lint-staged",
"init-db-production": "cross-env APP_ENV=production FORCE_DB_REFRESH=true EXIT_ON_DB_INIT=true ts-node --swc packages/server/src/index.ts",
"install-projects": "ts-node --swc scripts/install-projects.js",
"lint": "prettier --check \"packages/**/*.{ts,tsx}\"",
"list-client-s3-files-to-delete": "cross-env APP_ENV=production ts-node --swc scripts/get-deletable-client-files.ts",
"local": "npm run dev-docker && cross-env VITE_LOCAL_BUILD=true LOCAL=true concurrently -n agones,server,worldserver,mediaserver,client,files npm:dev-agones-silent \"cd packages/server && npm run start\" \"cd packages/instanceserver && npm run start\" \"cd packages/instanceserver && npm run start-channel\" \"cd packages/client && npm run local\" \"cd packages/server && npm run serve-local-files\"",
"make-user-admin": "ts-node --swc scripts/make-user-admin.js",
"migrate": "cd packages/server-core && npm run migrate",
"postinstall": "patch-package",
"precommit": "no-master-commits -b master",
"prepare-database": "cross-env APP_ENV=production PREPARE_DATABASE=true EXIT_ON_DB_INIT=true ts-node --swc packages/server/src/index.ts",
"prune-docker-cache": "cross-env ts-node --swc scripts/prune_docker_cache.ts",
"publish": "lerna publish from-package --yes --registry https://registry.npmjs.org",
"publish-npm": "lerna publish from-package --yes --no-verify-access --ignore-scripts --registry https://registry.npmjs.org",
"publish-github": "lerna publish from-package --yes --no-verify-access --ignore-scripts --registry https://npm.pkg.github.com",
"delete-old-s3-files": "cross-env APP_ENV=production ts-node --swc scripts/delete-old-s3-files.ts",
"push-client-dist-to-s3": "cross-env APP_ENV=production ts-node --swc scripts/push-client-to-s3.ts",
"copy-client-to-localstorage": "cross-env APP_ENV=production ts-node --swc scripts/copy-client-to-localstorage.ts",
"resave-all-scenes": "ts-node --swc scripts/resave-all-scenes.ts",
"start": "npm run dev",
"test": "cross-env TEST=true lerna run test",
"test-e2e": "ts-node --swc scripts/run_e2e_tests.ts",
"test:projects": "cross-env TEST=true lerna run test:projects",
"test:ci": "cpy --no-overwrite --rename=.env.local '.env.local.default' . && cross-env CI=true npm run test",
"validate": "npm run lint && lerna run validate",
"version-increment": "lerna version --conventional-commits --yes",
"version-increment-no-tag": "lerna version --conventional-commits --yes --no-git-tag-version",
"bump-project-versions": "cross-env ts-node --swc scripts/bump-project-versions.js",
"create-build-status": "cross-env ts-node --swc scripts/create-build-status.ts",
"record-build-error": "cross-env ts-node --swc scripts/record-build-error.ts",
"record-build-success": "cross-env ts-node --swc scripts/record-build-success",
"updateProject": "cross-env ts-node --swc scripts/update-project.ts",
"updateCronjobImage": "cross-env ts-node --swc scripts/update-cronjob-image.ts"
"record-build-success": "cross-env ts-node --swc scripts/record-build-success"
},
"types": "lib/",
"pre-commit": [
Expand All @@ -114,7 +97,6 @@
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "3.7.1",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@swc/core": "^1.3.41",
"@types/app-root-path": "1.2.4",
"@types/cli": "0.11.21",
Expand All @@ -123,10 +105,12 @@
"@typescript-eslint/eslint-plugin": "5.56.0",
"@typescript-eslint/parser": "5.56.0",
"concurrently": "7.6.0",
"deep-object-diff": "^1.1.9",
"depcheck": "1.4.3",
"eslint": "8.36.0",
"jsdom": "^21.1.1",
"kill-port": "2.0.1",
"lerna": "6.5.1",
"lint-staged": "13.2.0",
"mocha": "10.2.0",
"no-master-commits": "1.1.1",
Expand All @@ -142,34 +126,19 @@
"supertest": "6.3.3"
},
"dependencies": {
"@aws-sdk/client-cloudfront": "^3.321.1",
"@aws-sdk/client-ecr": "^3.319.0",
"@aws-sdk/client-s3": "^3.319.0",
"@aws-sdk/lib-storage": "^3.321.1",
"@aws-sdk/s3-presigned-post": "^3.321.1",
"@feathersjs/commons": "5.0.1",
"@feathersjs/errors": "5.0.1",
"@feathersjs/feathers": "5.0.1",
"@feathersjs/schema": "5.0.1",
"@feathersjs/typebox": "5.0.1",
"app-root-path": "3.1.0",
"cli": "1.0.1",
"daisyui": "^2.51.4",
"dotenv": "16.0.3",
"fix-esm": "^1.0.1",
"lerna": "6.5.1",
"patch-package": "^6.5.1",
"pino": "^8.11.0",
"pino-pretty": "^10.0.0",
"postcss": "^8.4.21",
"qrcode.react": "^3.1.0",
"react-json-view": "^1.21.3",
"tailwindcss": "^3.2.7",
"three": "0.150.1",
"three.quarks": "^0.10.2",
"ts-node": "10.9.1",
"typescript": "5.0.2",
"vite-plugin-node": "^3.0.2",
"ws": "8.13.0"
"typescript": "5.0.2"
}
}
3 changes: 2 additions & 1 deletion packages/client-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"react": "18.2.0"
},
"dependencies": {
"@digitalcredentials/ed25519-signature-2020": "^3.0.2",
"@etherealengine/common": "^1.3.0",
"@etherealengine/engine": "^1.3.0",
"@etherealengine/hyperflux": "^1.3.0",
Expand All @@ -44,6 +43,7 @@
"@mui/material": "5.11.13",
"@mui/styled-engine-sc": "5.11.11",
"@mui/x-date-pickers": "5.0.0-beta.4",
"@vladmandic/face-api": "^1.7.9",
"apexcharts": "^3.37.1",
"axios": "1.3.4",
"classnames": "2.3.2",
Expand All @@ -62,6 +62,7 @@
"notistack": "^3.0.1",
"primus": "^8.0.6",
"primus-client": "^7.3.4",
"qrcode.react": "^3.1.0",
"react": "18.2.0",
"react-apexcharts": "^1.4.0",
"react-color": "^2.19.3",
Expand Down
9 changes: 2 additions & 7 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
"test": "exit 0",
"local": "npm run localbuild && npm run localstart",
"localbuild": "cross-env APP_ENV=production VITE_LOCAL_BUILD=true npm run build && rm -rf ../server/upload/client && cp -r ./dist ../server/upload/client",
"localstart": "cross-env APP_ENV=production VITE_LOCAL_BUILD=true npm run start",
"buildenv": "cross-env APP_ENV=production ts-node --swc scripts/create-env-production.ts",
"populate-assetlinks": "cross-env APP_ENV=production ts-node --swc scripts/populate-assetlinks.ts"
"localstart": "cross-env APP_ENV=production VITE_LOCAL_BUILD=true npm run start"
},
"resolutions": {
"@types/react": "18.0.28",
Expand All @@ -38,17 +36,14 @@
"@etherealengine/editor": "^1.3.0",
"@etherealengine/engine": "^1.3.0",
"@etherealengine/hyperflux": "^1.3.0",
"@etherealengine/matchmaking": "^1.3.0",
"@etherealengine/projects": "^1.3.0",
"@etherealengine/ui": "^1.3.0",
"@feathersjs/koa": "^5.0.5",
"@heroicons/react": "^2.0.16",
"@hookstate/core": "4.0.0-rc21",
"@mui/icons-material": "5.11.11",
"@mui/material": "5.11.13",
"@mui/styled-engine-sc": "5.11.11",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@swc/core": "^1.2.210",
"@swc/core": "^1.3.41",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/typography": "^0.5.9",
"@vitejs/plugin-basic-ssl": "^1.0.1",
Expand Down
9 changes: 0 additions & 9 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,11 @@
"author": "Ethereal Engine",
"license": "MIT",
"dependencies": {
"@digitalbazaar/did-method-key": "^3.0.0",
"@digitalbazaar/security-document-loader": "^2.0.0",
"@digitalcredentials/bnid": "^2.1.2",
"@digitalcredentials/did-method-key": "^2.0.3",
"@digitalcredentials/vc": "^4.1.1",
"@interop/did-web-resolver": "^2.2.1",
"cross-fetch": "^3.1.5",
"crypto-ld": "^7.0.0",
"deep-object-diff": "^1.1.9",
"lru-cache": "8.0.4"
},
"devDependencies": {
"@types/mocha": "10.0.1",
"cross-env": "7.0.3",
"rimraf": "4.4.0"
},
"gitHead": "2313453697ca7c6b8d36b3b166b5a6445fe1c851"
Expand Down
Loading

0 comments on commit a60beec

Please sign in to comment.