Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Missing sourceinfo causes property lookup on undefined object #204

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.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