diff --git a/lib/integration/Plugin.js b/lib/integration/Plugin.js index c35ed2c..399b333 100644 --- a/lib/integration/Plugin.js +++ b/lib/integration/Plugin.js @@ -335,6 +335,8 @@ export default class Plugin { */ async getType () { if (this._type) return this._type + const pathType = this.getTypeFromProjectPath() + if (pathType) return (this._type = pathType) const info = await this.getInfo() if (!info) return null const foundAttributeType = PLUGIN_TYPES.find(type => info[type]) @@ -347,6 +349,20 @@ export default class Plugin { return (this._type = foundAttributeType || foundKeywordType || PLUGIN_DEFAULT_TYPE) } + /** + * Infer plugin type from the installed project path. + * e.g. src/menu/adapt-contrib-boxMenu → 'menu' + * @returns {string|null} + */ + getTypeFromProjectPath () { + if (!this.projectPath) return null + const folderToType = Object.fromEntries( + Object.entries(PLUGIN_TYPE_FOLDERS).map(([type, folder]) => [folder, type]) + ) + const parentFolder = path.basename(path.dirname(this.projectPath)) + return folderToType[parentFolder] || null + } + async getTypeFolder () { const type = await this.getType() return PLUGIN_TYPE_FOLDERS[type] diff --git a/lib/integration/PluginManagement/install.js b/lib/integration/PluginManagement/install.js index 1098bfd..e955c47 100644 --- a/lib/integration/PluginManagement/install.js +++ b/lib/integration/PluginManagement/install.js @@ -95,6 +95,12 @@ async function loadPluginData ({ logger, project, targets }) { percentage => logger?.logProgress?.(`${chalk.bold.cyan('')} Getting plugin info ${percentage}% complete`) ) logger?.log(`${chalk.bold.cyan('')} Getting plugin info 100% complete`) + await eachOfLimitProgress( + targets, + target => target.fetchProjectInfo(), + percentage => logger?.logProgress?.(`${chalk.bold.cyan('')} Checking installed plugins ${percentage}% complete`) + ) + logger?.log(`${chalk.bold.cyan('')} Checking installed plugins 100% complete`) await eachOfLimitProgress( targets, target => target.findCompatibleVersion(frameworkVersion), diff --git a/lib/integration/Target.js b/lib/integration/Target.js index 5bf271c..ba65a0c 100644 --- a/lib/integration/Target.js +++ b/lib/integration/Target.js @@ -122,6 +122,7 @@ export default class Target extends Plugin { markInstallable () { if (!this.isApplyLatestCompatibleVersion && !(this.isLocalSource && this.latestSourceVersion)) return + if (this.projectVersion === this.matchedVersion) return this.versionToApply = this.matchedVersion }