Skip to content

Commit

Permalink
Fix: Missing sourceinfo causes property lookup on undefined object
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed May 15, 2024
1 parent 5950af6 commit 0b66f21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/integration/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/integration/PluginManagement/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.matchedVersion || target.latestCompatibleSourceVersion || 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)
Expand Down

0 comments on commit 0b66f21

Please sign in to comment.