From 7d21def5600b11a053d0762ca41172960c5913d6 Mon Sep 17 00:00:00 2001 From: Oliver Foster Date: Tue, 11 Jun 2024 15:08:56 +0100 Subject: [PATCH] Fix: Missing sourceinfo causes property lookup on undefined object (fixes #204) * Fix: Missing sourceinfo causes property lookup on undefined object * Use correct conditions --- lib/integration/Plugin.js | 12 ++++++++++-- lib/integration/PluginManagement/update.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/integration/Plugin.js b/lib/integration/Plugin.js index b69ff3b..d1ed72f 100644 --- a/lib/integration/Plugin.js +++ b/lib/integration/Plugin.js @@ -79,7 +79,7 @@ export default class Plugin { * @returns {boolean|null} */ get isUpToDate () { - if (!this.hasFrameworkCompatibleVersion) return true; + if (!this.hasFrameworkCompatibleVersion) return true const canCheckSourceAgainstProject = (this.latestSourceVersion && this.projectVersion) if (!canCheckSourceAgainstProject) return null const isLatestVersion = (this.projectVersion === this.latestSourceVersion) @@ -104,6 +104,14 @@ export default class Plugin { return (this._projectInfo?.version || null) } + /** + * the required framework version from the source package json + * @returns {string|null} + */ + get frameworkVersion () { + return (this._sourceInfo?.framework || null) + } + /** * a list of tags denoting the source versions of the plugin * @returns {[string]} @@ -293,7 +301,7 @@ export default class Plugin { // check if the latest version is compatible const satisfiesConstraint = !this.hasValidRequestVersion || semver.satisfies(this._sourceInfo.version, this.requestedVersion, semverOptions) - const satisfiesFramework = semver.satisfies(framework, this._sourceInfo.framework, semverOptions) + const satisfiesFramework = semver.satisfies(framework, this.frameworkVersion, semverOptions) if (!this.latestCompatibleSourceVersion && satisfiesFramework) this.latestCompatibleSourceVersion = this.latestSourceVersion if (satisfiesConstraint && satisfiesFramework) { return this.latestSourceVersion diff --git a/lib/integration/PluginManagement/update.js b/lib/integration/PluginManagement/update.js index c89df22..98fddf4 100644 --- a/lib/integration/PluginManagement/update.js +++ b/lib/integration/PluginManagement/update.js @@ -165,7 +165,7 @@ async function conflictResolution ({ logger, targets, isInteractive }) { } const preFilteredPlugins = targets.filter(target => !target.isLocalSource) const allQuestions = [ - add(preFilteredPlugins.filter(target => !target.hasFrameworkCompatibleVersion), 'There is no compatible version of the following plugins:', checkVersion), + add(preFilteredPlugins.filter(target => !target.hasFrameworkCompatibleVersion && target.latestSourceVersion), 'There is no compatible version of the following plugins:', checkVersion), add(preFilteredPlugins.filter(target => target.hasFrameworkCompatibleVersion && !target.hasValidRequestVersion), 'The version requested is invalid, there are newer compatible versions of the following plugins:', checkVersion), add(preFilteredPlugins.filter(target => target.hasFrameworkCompatibleVersion && target.hasValidRequestVersion && !target.isApplyLatestCompatibleVersion), 'There are newer compatible versions of the following plugins:', checkVersion) ].filter(Boolean)