From: Volker Theile Date: Fri, 7 Jan 2022 08:53:12 +0000 (+0100) Subject: Downstream branding breaks dashboard npm build X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fheads%2Fissue_1194353_fileReplacements;p=ceph.git Downstream branding breaks dashboard npm build Fixed bz:1194353 --- diff --git a/src/pybind/mgr/dashboard/frontend/angular.json b/src/pybind/mgr/dashboard/frontend/angular.json index 4b71dbe910d..35f7faed1f8 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 a83f9e66bdb..1fd17ac6bb6 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 00000000000..2267530f60e --- /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}`); +}