From 89531d1703843c331e5369cc5f3e8a3d6d8d42b9 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Thu, 9 May 2024 19:18:17 +0000 Subject: [PATCH] Update custom sv html --- frontend/generate-config.js | 29 ++++++++++--------- ...index.sv.html => index.mempool.onbtc.html} | 10 +++---- 2 files changed, 20 insertions(+), 19 deletions(-) rename frontend/src/{index.sv.html => index.mempool.onbtc.html} (70%) diff --git a/frontend/generate-config.js b/frontend/generate-config.js index 8f911dfe6..91a9a2abb 100644 --- a/frontend/generate-config.js +++ b/frontend/generate-config.js @@ -10,6 +10,7 @@ let settings = []; let configContent = {}; let gitCommitHash = ''; let packetJsonVersion = ''; +let customConfig; try { const rawConfig = fs.readFileSync(CONFIG_FILE_NAME); @@ -23,7 +24,13 @@ try { } } -const indexFilePath = configContent.BASE_MODULE ? 'src/index.' + configContent.BASE_MODULE + '.html' : 'src/index.mempool.html'; +if (configContent && configContent.CUSTOMIZATION) { + customConfig = readConfig(configContent.CUSTOMIZATION); +} + +const baseModuleName = configContent.BASE_MODULE || 'mempool'; +const customBuildName = (customConfig && configContent.enterprise) ? ('.' + configContent.enterprise) : ''; +const indexFilePath = 'src/index.' + baseModuleName + customBuildName + '.html'; try { fs.copyFileSync(indexFilePath, 'src/index.html'); @@ -111,20 +118,14 @@ writeConfigTemplate(GENERATED_TEMPLATE_CONFIG_FILE_NAME, newConfigTemplate); const currentConfig = readConfig(GENERATED_CONFIG_FILE_NAME); let customConfigJs = ''; -if (configContent && configContent.CUSTOMIZATION) { - const customConfig = readConfig(configContent.CUSTOMIZATION); - if (customConfig) { - console.log(`Customizing frontend using ${configContent.CUSTOMIZATION}`); - customConfigJs = `(function (window) { - window.__env = window.__env || {}; - window.__env.customize = ${customConfig}; - }((typeof global !== 'undefined') ? global : this)); - `; - } else { - throw new Error('Failed to load customization file'); - } +if (customConfig) { + console.log(`Customizing frontend using ${configContent.CUSTOMIZATION}`); + customConfigJs = `(function (window) { + window.__env = window.__env || {}; + window.__env.customize = ${customConfig}; + }((typeof global !== 'undefined') ? global : this)); + `; } - writeConfig(GENERATED_CUSTOMIZATION_FILE_NAME, customConfigJs); if (currentConfig && currentConfig === newConfig) { diff --git a/frontend/src/index.sv.html b/frontend/src/index.mempool.onbtc.html similarity index 70% rename from frontend/src/index.sv.html rename to frontend/src/index.mempool.onbtc.html index 71430e239..c2be0bf00 100644 --- a/frontend/src/index.sv.html +++ b/frontend/src/index.mempool.onbtc.html @@ -3,22 +3,22 @@ - Bitcoin Office - Explorer + National Bitcoin Office of El Salvador - + - + - - + +