]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Downstream branding breaks dashboard npm build issue_1194353_fileReplacements
authorVolker Theile <vtheile@suse.com>
Fri, 7 Jan 2022 08:53:12 +0000 (09:53 +0100)
committerVolker Theile <vtheile@suse.com>
Fri, 7 Jan 2022 09:39:26 +0000 (10:39 +0100)
Fixed bz:1194353

src/pybind/mgr/dashboard/frontend/angular.json
src/pybind/mgr/dashboard/frontend/package.json
src/pybind/mgr/dashboard/frontend/suse-branding.js [new file with mode: 0644]

index 4b71dbe910d4237fcbfa330747abc11cf2e09c02..35f7faed1f8ba3dde717fdd71bb1830d36d617a2 100644 (file)
                 {
                   "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"
                 }
               ]
             },
index a83f9e66bdb9e24974207f0327951ab04b12e32c..1fd17ac6bb69524cab5105f8bb9ef14ca1442fbd 100644 (file)
@@ -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 (file)
index 0000000..2267530
--- /dev/null
@@ -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}`);
+}