Skip to content

Commit

Permalink
replacements update
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Madigan <[email protected]>
  • Loading branch information
jasonmadigan committed Nov 15, 2024
1 parent 7f31b56 commit 7dac28d
Showing 1 changed file with 33 additions and 0 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!');

0 comments on commit 7dac28d

Please sign in to comment.