Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacements update #165

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading