Skip to content

Commit 1c08b01

Browse files
committed
add unused plugins to api endpoint + const fix
1 parent 4622d97 commit 1c08b01

1 file changed

Lines changed: 18 additions & 39 deletions

File tree

src/server/extension/monitoring-endpoint.js

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -521,52 +521,31 @@ process.stdin.on('end', () => {
521521
}
522522

523523
function getUnusedPlugins(installedPlugins, currentSchema, baseConfig) {
524-
const usedPluginsMap = { 'monitoring-endpoint': true }
525-
const dependencyMap = {};
526-
const installedPluginNames = [];
527524
const unusedPlugins = [];
528525

529526
// get names of installed plugins and add their dependencies to a map + put disabled plugins into unusedPlugins
530527
installedPlugins.Plugins.forEach(plugin => {
531-
installedPluginNames.push(plugin.Name)
532-
if (!plugin.Enabled) unusedPlugins.push(plugin.Name)
528+
const pluginName = plugin.Name
533529

534-
if (Array.isArray(plugin.Manifest?.PluginBase?.webfrontend?.dependencies)) {
535-
dependencyMap[plugin.Name] = plugin.Manifest.PluginBase.webfrontend.dependencies
536-
}
537-
});
538-
539-
// add all used custom data types to usedPluginMap
540-
currentSchema.tables.forEach(table => {
541-
table.columns.forEach(colum => {
542-
if (colum.kind !== 'column' || !colum.type.startsWith('custom:')) return;
543-
544-
// custom data types always have the form custom:base.custom-data-type-loc.loc
545-
// so we can get the plugin name like this.
546-
const pluginName = colum.type.split('.')[1]
547-
548-
if (usedPluginsMap[pluginName]) return;
549-
550-
usedPluginsMap[pluginName] = true;
551-
})
552-
});
530+
if(pluginName.startsWith('custom-data-type')){
531+
const isUsed = currentSchema.tables.some((table) => {
532+
return table.columns.some((colum) => {
533+
if (colum.kind !== 'column' || !colum.type.startsWith('custom:')) return false;
553534

554-
if (installedPluginNames.includes('default-values-from-pool')) {
555-
if (isDefaultValuesFromPoolUsed(baseConfig)) {
556-
usedPluginsMap['default-values-from-pool'] = true
557-
}
558-
}
559-
560-
// check if a used plugin has a dependency an add that to usedPluginsMap as well
561-
for (const pluginName in usedPluginsMap) {
562-
if (Array.isArray(dependencyMap[pluginName])) {
563-
dependencyMap[pluginName].forEach(dependency => usedPluginsMap[dependency] = true)
535+
const columnPluginName = colum.type.split('.')[1]
536+
return columnPluginName === pluginName
537+
})
538+
})
539+
if(!isUsed){
540+
unusedPlugins.push(pluginName)
541+
}
542+
543+
} else if (pluginName === 'default-values-from-pool') {
544+
if (!isDefaultValuesFromPoolUsed(baseConfig)) {
545+
unusedPlugins.push(pluginName)
546+
}
564547
}
565-
};
566-
567-
// get the difference between the installed plugins and the used plugins and push it into the list of unused plugins
568-
const usedPlugins = Object.keys(usedPluginsMap)
569-
unusedPlugins.push(...installedPluginNames.filter(plugin => !usedPlugins.includes(plugin)));
548+
});
570549

571550
return unusedPlugins
572551
}

0 commit comments

Comments
 (0)