1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 20:10:08 +02:00

👌 Check multiple constraints (e.g. "^7.3|^8.0")

This commit is contained in:
2022-01-24 23:56:26 +01:00
parent f6378e7b73
commit e9ae989200

View File

@ -55,6 +55,7 @@ class SiteListCell: NSTableCellView
// Show the current driver
labelDriver.stringValue = "\(site.driver ?? "???")"
// Determine the Laravel version
if site.driver == "Laravel" && site.notableComposerDependencies.keys.contains("laravel/framework") {
let constraint = site.notableComposerDependencies["laravel/framework"]!
labelDriver.stringValue = "Laravel (\(constraint))"
@ -64,9 +65,13 @@ class SiteListCell: NSTableCellView
buttonPhpVersion.title = " PHP \(site.composerPhp) "
buttonPhpVersion.isHidden = (site.composerPhp == "???")
let matchesConstraint = PhpVersionNumberCollection.make(from: [PhpEnv.phpInstall.version.long])
.matching(constraint: site.composerPhp)
.count > 0
// Split the composer list (on "|") to evaluate multiple constraints
// For example, for Laravel 8 projects the value is "^7.3|^8.0"
let matchesConstraint = site.composerPhp.split(separator: "|").map { string in
return PhpVersionNumberCollection.make(from: [PhpEnv.phpInstall.version.long])
.matching(constraint: string.trimmingCharacters(in: .whitespacesAndNewlines))
.count > 0
}.contains(true)
imageViewPhpVersionOK.isHidden = (site.composerPhp == "???" || !matchesConstraint)
}