From 149a6c03de522043ded8941194a145a945e9f680 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Fri, 7 Jan 2022 09:53:12 +0100 Subject: [PATCH] Downstream branding breaks dashboard npm build Fixed bz:1194353 --- .../mgr/dashboard/frontend/angular.json | 16 ------- .../mgr/dashboard/frontend/package.json | 2 + .../mgr/dashboard/frontend/suse-branding.js | 42 +++++++++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/suse-branding.js diff --git a/src/pybind/mgr/dashboard/frontend/angular.json b/src/pybind/mgr/dashboard/frontend/angular.json index 4b71dbe910d42..35f7faed1f8ba 100644 --- a/src/pybind/mgr/dashboard/frontend/angular.json +++ b/src/pybind/mgr/dashboard/frontend/angular.json @@ -89,22 +89,6 @@ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" - }, - { - "replace": "src/app/core/layouts/login-layout/login-layout.component.html", - "with": "src/app/core/layouts/login-layout/login-layout.component.brand.html" - }, - { - "replace": "src/app/core/auth/login/login.component.html", - "with": "src/app/core/auth/login/login.component.brand.html" - }, - { - "replace": "src/app/core/navigation/navigation/navigation.component.html", - "with": "src/app/core/navigation/navigation/navigation.component.brand.html" - }, - { - "replace": "src/app/core/navigation/about/about.component.html", - "with": "src/app/core/navigation/about/about.component.brand.html" } ] }, diff --git a/src/pybind/mgr/dashboard/frontend/package.json b/src/pybind/mgr/dashboard/frontend/package.json index a83f9e66bdb9e..1fd17ac6bb695 100644 --- a/src/pybind/mgr/dashboard/frontend/package.json +++ b/src/pybind/mgr/dashboard/frontend/package.json @@ -9,8 +9,10 @@ "ng": "ng", "start": "npm run env_build && ng serve --host 0.0.0.0 --ssl", "build": "npm run env_build && ng build --configuration=$npm_package_config_locale", + "prebuild:localize": "node suse-branding", "build:localize": "node cd --env --pre && ng build --localize", "postbuild:localize": "node cd --res", + "postpostbuild:localize": "node suse-branding --undo", "env_build": "node cd --env", "i18n": "npm run i18n:extract && npm run i18n:push && npm run i18n:pull && npm run i18n:merge", "i18n:extract": "ng extract-i18n --output-path src/locale --progress=false", diff --git a/src/pybind/mgr/dashboard/frontend/suse-branding.js b/src/pybind/mgr/dashboard/frontend/suse-branding.js new file mode 100644 index 0000000000000..2267530f60ee0 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/suse-branding.js @@ -0,0 +1,42 @@ +const fs = require('fs'); +const child_process = require('child_process'); + +const fileReplacements = [{ + "replace": "src/app/core/layouts/login-layout/login-layout.component.html", + "with": "src/app/core/layouts/login-layout/login-layout.component.brand.html" +},{ + "replace": "src/app/core/auth/login/login.component.html", + "with": "src/app/core/auth/login/login.component.brand.html" +},{ + "replace": "src/app/core/navigation/navigation/navigation.component.html", + "with": "src/app/core/navigation/navigation/navigation.component.brand.html" +},{ + "replace": "src/app/core/navigation/about/about.component.html", + "with": "src/app/core/navigation/about/about.component.brand.html" +}]; + +if (process.argv.includes('--undo')) { + undo(); +} else { + apply(); +} + +function apply() { + fileReplacements.forEach((options) => { + fs.copyFile(options.with, options.replace, (error) => { + if (error) throw error; + logger(`'${options.with}' was copied to '${options.replace}'`); + }); + }); +} + +function undo() { + fileReplacements.forEach((options) => { + child_process.execSync(`git restore ${options.replace}`); + logger(`File '${options.replace}' restored`); + }); +} + +function logger(message) { + console.log(`[suse-branding.js] ${message}`); +} -- 2.39.5