Skip to content

Commit

Permalink
Merge pull request #165 from Kuadrant/replacements-update
Browse files Browse the repository at this point in the history
replacements update
  • Loading branch information
openshift-merge-bot[bot] authored Nov 15, 2024
2 parents 7f31b56 + e0148da commit bc8a85e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions downstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand All @@ -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!');
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit bc8a85e

Please sign in to comment.