mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-12-11 07:16:40 +03:00
Validate package version value (#755)
* Validate package version value * Added CHANGELOG entry * Improved testcases for package versions
This commit is contained in:
parent
e0a80685ef
commit
d10dcc9a0e
@ -11,6 +11,7 @@
|
||||
- Don't add framework dependency's directory to `FRAMEWORK_SEARCH_PATHS` if it is implicit [#744](https://github.com/yonaskolb/XcodeGen/pull/744) @ikesyo @yutailang0119
|
||||
- Fixed resolving relative path passed to `XcodeProj` [#751](https://github.com/yonaskolb/XcodeGen/pull/751) @PycKamil
|
||||
- Prefer configurations named "Debug" or "Release" for default scheme build configurations [#752](https://github.com/yonaskolb/XcodeGen/pull/752) @john-flanagan
|
||||
- Added an extra check for package versions. [#755](https://github.com/yonaskolb/XcodeGen/pull/755) @basvankuijck
|
||||
|
||||
#### Internal
|
||||
- Update to SwiftCLI 6.0 and use the new property wrappers [#749](https://github.com/yonaskolb/XcodeGen/pull/749) @yonaskolb
|
||||
|
@ -20,6 +20,28 @@ extension SwiftPackage: JSONObjectConvertible {
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
url = try jsonDictionary.json(atKeyPath: "url")
|
||||
versionRequirement = try VersionRequirement(jsonDictionary: jsonDictionary)
|
||||
try validateVersion()
|
||||
}
|
||||
|
||||
private func validateVersion() throws {
|
||||
switch versionRequirement {
|
||||
|
||||
case .upToNextMajorVersion(let version):
|
||||
try _ = Version(version)
|
||||
|
||||
case .upToNextMinorVersion(let version):
|
||||
try _ = Version(version)
|
||||
|
||||
case .range(let from, let to):
|
||||
try _ = Version(from)
|
||||
try _ = Version(to)
|
||||
|
||||
case .exact(let version):
|
||||
try _ = Version(version)
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1119,6 +1119,25 @@ class SpecLoadingTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testPackagesVersion() {
|
||||
describe {
|
||||
let invalidPackages = [
|
||||
[ "url": "package.git", "majorVersion": "master" ],
|
||||
[ "url": "package.git", "from": "develop" ],
|
||||
[ "url": "package.git", "minVersion": "feature/swift5.2", "maxVersion": "9.1.0" ],
|
||||
[ "url": "package.git", "minorVersion": "x.1.2" ],
|
||||
[ "url": "package.git", "exactVersion": "1.2.3.1" ],
|
||||
[ "url": "package.git", "version": "foo-bar" ]
|
||||
]
|
||||
|
||||
$0.it("is an invalid package version") {
|
||||
for dictionary in invalidPackages {
|
||||
try expect { _ = try SwiftPackage(jsonDictionary: dictionary) }.toThrow()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDecoding() throws {
|
||||
describe {
|
||||
$0.it("decodes dots in dictionary keys") {
|
||||
|
Loading…
Reference in New Issue
Block a user