fix(server): parse plugin name

This commit is contained in:
chenos 2024-05-09 14:06:43 +08:00
parent 8afe119ac9
commit 61338eedb7

View File

@ -307,22 +307,17 @@ export class PluginManager {
return; return;
} }
this.app.log.info('attempt to add the plugin to the app'); this.app.log.info('attempt to add the plugin to the app');
let packageName: string; const { name, packageName } = await PluginManager.parseName(pluginName);
try {
packageName = await PluginManager.getPackageName(pluginName);
} catch (error) {
packageName = pluginName;
}
const json = await PluginManager.getPackageJson(packageName); const json = await PluginManager.getPackageJson(packageName);
this.app.log.info(`add plugin [${packageName}]`, { this.app.log.info(`add plugin [${packageName}]`, {
name: pluginName, name,
packageName: packageName, packageName,
version: json.version, version: json.version,
}); });
await this.repository.updateOrCreate({ await this.repository.updateOrCreate({
values: { values: {
name: pluginName, name,
packageName: packageName, packageName,
version: json.version, version: json.version,
}, },
filterKeys: ['name'], filterKeys: ['name'],