import Foundation enum PluginVersionComparator { static func compare(_ lhs: String, _ rhs: String) -> ComparisonResult { let left = versionComponents(lhs) let right = versionComponents(rhs) let count = max(left.count, right.count) for index in 0.. rightValue { return .orderedDescending } } return .orderedSame } static func isVersion(_ version: String, atLeast required: String) -> Bool { compare(version, required) != .orderedAscending } static func isVersion(_ version: String, newerThan current: String) -> Bool { compare(version, current) == .orderedDescending } private static func versionComponents(_ version: String) -> [Int] { version .split(separator: ".") .map { component in let prefix = component.prefix { $0.isNumber } return Int(prefix) ?? 0 } } }