From fefe2d562a9dbbffd35ecacc79f095207c6cfeff Mon Sep 17 00:00:00 2001 From: Gulfaraz Rahman Date: Wed, 21 Aug 2024 15:44:13 +0200 Subject: [PATCH] ci: add angular file replacements for NG_CONFIGURATION --- interfaces/IBF-dashboard/.gitignore | 75 ++++++++++--------- interfaces/IBF-dashboard/_set-env-variabes.js | 4 +- interfaces/IBF-dashboard/angular.json | 29 ++++++- interfaces/IBF-dashboard/package.json | 4 +- ...ts.template.js => environment.template.ts} | 0 5 files changed, 68 insertions(+), 44 deletions(-) rename interfaces/IBF-dashboard/src/environments/{environment.prod.ts.template.js => environment.template.ts} (100%) diff --git a/interfaces/IBF-dashboard/.gitignore b/interfaces/IBF-dashboard/.gitignore index 2003e1091..e5ae54c9e 100644 --- a/interfaces/IBF-dashboard/.gitignore +++ b/interfaces/IBF-dashboard/.gitignore @@ -1,38 +1,39 @@ /.angular/cache -# IDE / Editors -.vscode -.idea -*.sublime-project -*.sublime-workspace - - -# Configuration, secrets, etc: -.env -environment.prod.ts - - -# Assets ONLY included during build -src/assets/leaflet - - -# Generated files -dist -coverage -platforms -plugins -www - - -# External code -node_modules - - -# Logs / Cache / temporary files -logs -*.log -npm-debug.log* -.npm -.ionic -.sass-cache -.sourcemaps -.versions +# IDE / Editors +.vscode +.idea +*.sublime-project +*.sublime-workspace + + +# Configuration, secrets, etc: +.env +environment.* +!environment.template.ts + + +# Assets ONLY included during build +src/assets/leaflet + + +# Generated files +dist +coverage +platforms +plugins +www + + +# External code +node_modules + + +# Logs / Cache / temporary files +logs +*.log +npm-debug.log* +.npm +.ionic +.sass-cache +.sourcemaps +.versions diff --git a/interfaces/IBF-dashboard/_set-env-variabes.js b/interfaces/IBF-dashboard/_set-env-variabes.js index e0b8f2daf..5def9fff3 100644 --- a/interfaces/IBF-dashboard/_set-env-variabes.js +++ b/interfaces/IBF-dashboard/_set-env-variabes.js @@ -4,8 +4,8 @@ const dotenv = require('dotenv'); // Load environment-variables from .env file (if available) dotenv.config(); -const configFileTemplate = require('./src/environments/environment.prod.ts.template.js'); -const targetPath = './src/environments/environment.prod.ts'; +const configFileTemplate = require('./src/environments/environment.template.ts'); +const targetPath = `./src/environments/environment.${process.env.NG_CONFIGURATION}.ts`; fs.writeFile(targetPath, configFileTemplate, (err) => { if (err) { diff --git a/interfaces/IBF-dashboard/angular.json b/interfaces/IBF-dashboard/angular.json index 8ee0a2920..69cec1996 100644 --- a/interfaces/IBF-dashboard/angular.json +++ b/interfaces/IBF-dashboard/angular.json @@ -67,7 +67,7 @@ "fileReplacements": [ { "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" + "with": "src/environments/environment.production.ts" } ], "optimization": true, @@ -86,6 +86,12 @@ "serviceWorker": "ngsw-config.json" }, "stage": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.stage.ts" + } + ], "assets": [ { "glob": "**/*", @@ -135,13 +141,30 @@ "input": "src/assets/icons/test", "output": "assets/icons" } + ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.test.ts" + } ] }, "development": { - "fileReplacements": [] + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.development.ts" + } + ] }, "ci": { - "progress": false + "progress": false, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.ci.ts" + } + ] } }, "defaultConfiguration": "" diff --git a/interfaces/IBF-dashboard/package.json b/interfaces/IBF-dashboard/package.json index 0a85d79e0..94935e9ff 100644 --- a/interfaces/IBF-dashboard/package.json +++ b/interfaces/IBF-dashboard/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "ng build", "build:prod": "npm run build -- --configuration production", - "compress": "gzipper compress --skip-compressed --remove-larger --gzip --gzip-level 9 ./www/", + "compress": "gzipper compress --skip-compressed --remove-larger --gzip --gzip-level 9 ./www/browser/", "e2e": "ng e2e", "format:fix": "npm run format:check -- --write", "format:check": "prettier --check \"**/*.{md,js,ts,scss,html}\" ", @@ -16,7 +16,7 @@ "postbuild:prod": "npm run compress", "prebuild": "npm run set-env-variables", "prestart": "npm install --no-audit --no-fund", - "serve:static": "cp www/index.html www/404.html && npx http-server www/ -c-1 --gzip", + "serve:static": "cp www/browser/index.html www/browser/404.html && npx http-server www/browser/ -c-1 --gzip", "set-env-variables": "node ./_set-env-variabes.js", "start": "ng serve", "start:no-install": "ng serve", diff --git a/interfaces/IBF-dashboard/src/environments/environment.prod.ts.template.js b/interfaces/IBF-dashboard/src/environments/environment.template.ts similarity index 100% rename from interfaces/IBF-dashboard/src/environments/environment.prod.ts.template.js rename to interfaces/IBF-dashboard/src/environments/environment.template.ts