From e46042816253cc4cb3235f4765d214cbec607bc4 Mon Sep 17 00:00:00 2001 From: myst Date: Thu, 30 May 2024 00:44:42 +0200 Subject: [PATCH 1/2] chore(frontend): remove unused scripts --- frontend/package.json | 6 +----- .../mud/components/mud-output/mud-output.component.scss | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 4a53f6a7..1a9857bc 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,16 +1,12 @@ { "name": "@webmud3/frontend", "version": "1.0.0-alpha", + "description": "Webmud3 Frontend", "engines": { "node": "20.12.2" }, "scripts": { "format": "prettier --write \"src/**/*.ts\"", - "no-prepare": "npm run build", - "no-prepublishOnly": "npm test && npm run lint", - "preversion": "npm run lint", - "version": "npm run format && git add -A src", - "postversion": "git push && git push --tags", "ng": "ng", "start": "ng serve", "build": "ng build", diff --git a/frontend/src/app/core/mud/components/mud-output/mud-output.component.scss b/frontend/src/app/core/mud/components/mud-output/mud-output.component.scss index 90299fb9..1a6a6250 100644 --- a/frontend/src/app/core/mud/components/mud-output/mud-output.component.scss +++ b/frontend/src/app/core/mud/components/mud-output/mud-output.component.scss @@ -18,7 +18,6 @@ .mud-output { flex: 0 1 100%; - min-height: 400px; overflow-x: auto; overflow-y: auto; flex-direction: column; From d62c6fd3572fbcdf5038b8def07be22c0e7f3d55 Mon Sep 17 00:00:00 2001 From: myst Date: Thu, 30 May 2024 00:47:03 +0200 Subject: [PATCH 2/2] chore(backend): add dotenv - removed --env-file from launch - copied package-lock to dist - npm ci on backend install with only production - removed cpx root - add experimental --- .github/workflows/deploy_to_azure.yml | 13 +------------ backend/package.json | 10 +++++----- backend/src/core/environment/environment.ts | 4 ++++ backend/src/main.ts | 2 +- package-lock.json | 15 +++++++++++++-- package.json | 8 ++++---- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/deploy_to_azure.yml b/.github/workflows/deploy_to_azure.yml index aca9ab2d..4a780c8c 100644 --- a/.github/workflows/deploy_to_azure.yml +++ b/.github/workflows/deploy_to_azure.yml @@ -31,21 +31,10 @@ jobs: npm ci npm run build --if-present - - name: Test - run: | - echo "ls -l" - ls -l - echo "ls -l frontend/dist/frontend" - ls -l frontend/dist/frontend - echo "ls -l backend/dist" - ls -l backend/dist - echo "Test" - - name: Install raw dependencies for backend run: | cd ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} - ls -la - npm install + npm ci --production - name: "Deploy to Azure Web App" id: deploy-to-webapp diff --git a/backend/package.json b/backend/package.json index 904bae54..533fdaef 100644 --- a/backend/package.json +++ b/backend/package.json @@ -20,10 +20,9 @@ "format": "prettier --write \"src/**/*.ts\"", "lint": "eslint ./src --ext .ts", "lint:fix": "eslint ./src --ext .ts --fix", - "postbuild": "cpx package.json dist", - "start": "npm run build && node --env-file .env dist/main.js", + "postbuild": "cpx package.json dist && cpx package-lock.json dist", + "start": "npm run build && node dist/main.js", "serve": "node dist/main.js", - "serve:env": "node --env-file .env dist/main.js", "test": "jest --config=jest.config.cjs" }, "dependencies": { @@ -31,6 +30,7 @@ "body-parser": "~1.20.2", "cookie-session": "~2.1.0", "cors": "~2.8.5", + "dotenv": "^16.4.5", "express": "~4.19.2", "socket.io": "~4.7.5", "socket.io-client": "~4.7.5", @@ -57,9 +57,9 @@ "rimraf": "~5.0.7", "source-map-support": "~0.5.21", "ts-jest": "~29.1.2", + "ts-jest-mock-import-meta": "^1.2.0", "typescript": "~5.4.5", - "winston": "~3.13.0", - "ts-jest-mock-import-meta": "^1.2.0" + "winston": "~3.13.0" }, "type": "module", "author": "Myonara", diff --git a/backend/src/core/environment/environment.ts b/backend/src/core/environment/environment.ts index b1263745..e7d48eca 100644 --- a/backend/src/core/environment/environment.ts +++ b/backend/src/core/environment/environment.ts @@ -3,6 +3,8 @@ import { IEnvironment } from './types/environment.js'; import { getEnvironmentVariable } from './utils/get-environment-variable.js'; import { resolveModulePath } from './utils/resolve-modulepath.js'; +import { config as configureEnvironment } from 'dotenv'; + /** * Environment class to handle environment variables and application settings. * Reads the environment variables once oppon initialisation and provides them as properties. @@ -24,6 +26,8 @@ export class Environment implements IEnvironment { * Initializes the environment variables. */ private constructor() { + configureEnvironment(); + const tls_cert = getEnvironmentVariable('TLS_CERT', false); const tls_key = getEnvironmentVariable('TLS_KEY', false); diff --git a/backend/src/main.ts b/backend/src/main.ts index 025edacf..839d7e9a 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -43,7 +43,7 @@ const mudConfig = loadConfig( logger.info('[Main] Mud Config loaded', { mudConfig }); -const port = process.env.PORT || 3000; +const port = process.env.PORT || 5000; const app = express(); diff --git a/package-lock.json b/package-lock.json index dd591ede..a71a8555 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,7 @@ "backend" ], "devDependencies": { - "cpx": "~1.5.0", - "ncp": "^2.0.0" + "ncp": "~2.0.0" }, "engines": { "node": "20.12.2" @@ -28,6 +27,7 @@ "body-parser": "~1.20.2", "cookie-session": "~2.1.0", "cors": "~2.8.5", + "dotenv": "^16.4.5", "express": "~4.19.2", "socket.io": "~4.7.5", "socket.io-client": "~4.7.5", @@ -16940,6 +16940,17 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/duplexer": { "version": "0.1.2", "license": "MIT" diff --git a/package.json b/package.json index efa85330..c55c7626 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,12 @@ "build": "npm run build --workspaces", "integrate-client": "ncp frontend/dist/frontend backend/dist/wwwroot", "postbuild": "npm run integrate-client", - "start": "npm run build && npm run serve:env --workspace backend", + "start": "npm run build && npm run serve --workspace backend", "test": "npm run test --workspaces", - "lint": "npm run lint --workspaces" + "lint": "npm run lint --workspaces", + "build:experimantal:prod": "npm run build --workspace frontend -- --configuration=production && npm run build --workspace backend" }, "devDependencies": { - "cpx": "~1.5.0", - "ncp": "^2.0.0" + "ncp": "~2.0.0" } }