diff --git a/downstream.js b/downstream.js index 8f492e2..e301f61 100755 --- a/downstream.js +++ b/downstream.js @@ -5,6 +5,7 @@ const path = require('path'); const constantsPath = path.join('src', 'constants', 'links.ts'); const localesPath = path.join('locales'); +const consoleExtensionsPath = path.join('console-extensions.json'); const localeFile = path.join(localesPath, 'en', 'plugin__kuadrant-console-plugin.json'); const upstreamName = 'Kuadrant'; @@ -72,6 +73,31 @@ function updateFileContent(filePath, replacements) { } } +function updateConsoleExtensions(filePath, searchValue, replaceValue) { + try { + const content = fs.readFileSync(filePath, 'utf-8'); + const jsonContent = JSON.parse(content); + + let updated = false; + + jsonContent.forEach((item) => { + if (item.properties && item.properties.name === searchValue) { + item.properties.name = replaceValue; + updated = true; + } + }); + + if (updated) { + fs.writeFileSync(filePath, JSON.stringify(jsonContent, null, 2)); + console.log(`Updated console extensions in ${filePath}`); + } else { + console.log(`No changes made to ${filePath}`); + } + } catch (error) { + console.error(`Failed to update ${filePath}: ${error}`); + } +} + console.log(`Updating locale files to ${isUpstream ? 'upstream' : 'downstream'}...`); updateJsonValues(localeFile, nameToReplace, nameToInsert); @@ -82,4 +108,11 @@ updateFileContent(constantsPath, [ { searchValue: releaseNotesToReplace, replaceValue: releaseNotesToInsert }, ]); +console.log(`Updating console-extensions.json to ${isUpstream ? 'upstream' : 'downstream'}...`); +updateConsoleExtensions( + consoleExtensionsPath, + `%plugin__kuadrant-console-plugin~${nameToReplace}%`, + nameToInsert, +); + console.log('Update complete!'); diff --git a/package.json b/package.json index 8fcccb4..8ba6859 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kuadrant-console-plugin", - "version": "0.0.12", + "version": "0.0.13", "description": "Kuadrant OpenShift Console plugin", "private": true, "license": "Apache-2.0", @@ -72,7 +72,7 @@ }, "consolePlugin": { "name": "kuadrant-console-plugin", - "version": "0.0.12", + "version": "0.0.13", "displayName": "Kuadrant OpenShift Console Plugin", "description": "Kuadrant OpenShift Console Plugin", "exposedModules": {