From a97f11dc71dff501b3436227322425321eb91d7a Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 25 Dec 2024 00:34:22 +0800 Subject: [PATCH] fix: collections were not automatically created when enabling the plugin (#5939) * fix: collections were not automatically created when enabling the plugin * fix: error --- .../server/src/plugin-manager/plugin-manager.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/core/server/src/plugin-manager/plugin-manager.ts b/packages/core/server/src/plugin-manager/plugin-manager.ts index a614ca8ebb..ac03912911 100644 --- a/packages/core/server/src/plugin-manager/plugin-manager.ts +++ b/packages/core/server/src/plugin-manager/plugin-manager.ts @@ -141,15 +141,12 @@ export class PluginManager { * @internal */ static async getPackageName(name: string) { - const prefixes = this.getPluginPkgPrefix(); - for (const prefix of prefixes) { - const pkg = resolve(process.env.NODE_MODULES_PATH, `${prefix}${name}`, 'package.json'); - const exists = await fs.exists(pkg); - if (exists) { - return `${prefix}${name}`; - } + const { packageName } = await this.parseName(name); + const packageFile = resolve(process.env.NODE_MODULES_PATH, packageName, 'package.json'); + if (!(await fs.exists(packageFile))) { + return null; } - throw new Error(`${name} plugin does not exist`); + return packageName; } /** @@ -329,7 +326,9 @@ export class PluginManager { try { if (typeof plugin === 'string' && options.name && !options.packageName) { const packageName = await PluginManager.getPackageName(options.name); - options['packageName'] = packageName; + if (packageName) { + options['packageName'] = packageName; + } } if (options.packageName) {