diff --git a/frontend-html/custom-scripts/updateVersions.cjs b/frontend-html/custom-scripts/updateVersions.cjs
index befeb1f6a1..6f09fc4ce3 100644
--- a/frontend-html/custom-scripts/updateVersions.cjs
+++ b/frontend-html/custom-scripts/updateVersions.cjs
@@ -1,11 +1,12 @@
const fs = require("fs");
+const path = require('path');
const pluginRegistrationFilePath = "src/plugins/tools/PluginRegistration.ts"
const envFilePath = ".env.production.local";
const pluginVersionsVariableName = "VITE_REACT_APP_ORIGAM_UI_PLUGINS";
-function getPackageName(pluginName, registrationFile) {
+function getPackagePath(pluginName, registrationFile) {
const pluginPackageRegEx = new RegExp('import\\s*{\\s*[\\s,\\w]*\\s*' + pluginName + '\\s*[\\s,\\w]*\\s*}\\s*from\\s*"([@\\w\\/\\-]+)', 'g');
let packageMatch = pluginPackageRegEx.exec(registrationFile);
if(!packageMatch){
@@ -14,6 +15,11 @@ function getPackageName(pluginName, registrationFile) {
return packageMatch[1];
}
+function getPackageNameAndVersionFromPackageJson(pathToPackageJson){
+ const packageJson = JSON.parse(fs.readFileSync(pathToPackageJson).toString());
+ return [packageJson["name"], packageJson["version"]];
+}
+
function findUsedPackageNames(registrationFile) {
const pluginRegEx = /registerPlugin\s*\(\s*"(\w+)",/g;
return [...registrationFile.matchAll(pluginRegEx)].map(x => x[1]);
@@ -38,9 +44,16 @@ const registrationFile = fs.readFileSync(pluginRegistrationFilePath).toString();
const usedPluginNames = findUsedPackageNames(registrationFile)
const packageNamesAndVersions = usedPluginNames
.map(pluginName => {
- const packageName = getPackageName(pluginName, registrationFile);
- const packageReference = require(`../node_modules/${packageName}/package.json`);
- return `${pluginName} - ${packageName}: ${packageReference.version}`;
+ const packagePath = getPackagePath(pluginName, registrationFile);
+ let packageVersion;
+ let packageName;
+ if(packagePath.startsWith("plugins/implementations/")){
+ [packageName, packageVersion] = getPackageNameAndVersionFromPackageJson(`src/${path.dirname(packagePath)}/package.json`)
+ }else{
+ packageName = packagePath;
+ packageVersion = require(`../node_modules/${packagePath}/package.json`).version;
+ }
+ return `${pluginName} - ${packageName}: ${packageVersion}`;
})
.join(";")
@@ -54,4 +67,4 @@ if (fs.existsSync(envFilePath)) {
newEnvFile = `${pluginVersionsVariableName} = ${packageNamesAndVersions}\n`;
}
-fs.writeFileSync(envFilePath, newEnvFile);
+fs.writeFileSync(envFilePath, newEnvFile);
\ No newline at end of file