Merge pull request #1085 from tuist/cloud-config
Add cloudURL attribute to Config
This commit is contained in:
commit
06368544b6
|
@ -12,11 +12,14 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
|
|||
### Added
|
||||
|
||||
- `tuist lint` command https://github.com/tuist/tuist/pull/1043 by @pepibumur.
|
||||
- Add `--verbose` https://github.com/tuist/tuist/pull/1027 by @ollieatkinson.
|
||||
- Add `--verbose` https://github.com/tuist/tuist/pull/1027 by @ollieatkinson.
|
||||
- `TuistInsights` target https://github.com/tuist/tuist/pull/1084 by @pepibumur.
|
||||
- Add `cloudURL` attribute to `Config` https://github.com/tuist/tuist/pull/1085 by @pepibumur.
|
||||
- Add `--verbose` https://github.com/tuist/tuist/pull/1027 by @ollieatkinson.
|
||||
|
||||
### Changed
|
||||
- Rename `TuistConfig.swift` to `Config.swift` https://github.com/tuist/tuist/pull/1083 by @pepibumur.
|
||||
|
||||
- Rename `TuistConfig.swift` to `Config.swift` https://github.com/tuist/tuist/pull/1083 by @pepibumur.
|
||||
|
||||
## 1.3.0
|
||||
|
||||
|
|
|
@ -17,15 +17,21 @@ public struct Config: Codable, Equatable {
|
|||
/// List of Xcode versions that the project supports.
|
||||
public let compatibleXcodeVersions: CompatibleXcodeVersions
|
||||
|
||||
/// URL to the server that caching and insights will interact with.
|
||||
public let cloudURL: String?
|
||||
|
||||
/// Initializes the tuist cofiguration.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - compatibleXcodeVersions: .
|
||||
/// - compatibleXcodeVersions: List of Xcode versions the project is compatible with.
|
||||
/// - cloudURL: URL to the server that caching and insights will interact with.
|
||||
/// - generationOptions: List of Xcode versions that the project supports. An empty list means that
|
||||
public init(compatibleXcodeVersions: CompatibleXcodeVersions = .all,
|
||||
cloudURL: String? = nil,
|
||||
generationOptions: [GenerationOptions]) {
|
||||
self.generationOptions = generationOptions
|
||||
self.compatibleXcodeVersions = compatibleXcodeVersions
|
||||
self.generationOptions = generationOptions
|
||||
self.cloudURL = cloudURL
|
||||
dumpIfNeeded(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,19 +17,25 @@ public struct Config: Equatable, Hashable {
|
|||
/// List of Xcode versions the project or set of projects is compatible with.
|
||||
public let compatibleXcodeVersions: CompatibleXcodeVersions
|
||||
|
||||
/// URL to the server that caching and insights will interact with.
|
||||
public let cloudURL: URL?
|
||||
|
||||
/// Returns the default Tuist configuration.
|
||||
public static var `default`: Config {
|
||||
Config(compatibleXcodeVersions: .all, generationOptions: [])
|
||||
Config(compatibleXcodeVersions: .all, cloudURL: nil, generationOptions: [])
|
||||
}
|
||||
|
||||
/// Initializes the tuist cofiguration.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - compatibleXcodeVersions: List of Xcode versions the project or set of projects is compatible with.
|
||||
/// - cloudURL: URL to the server that caching and insights will interact with.
|
||||
/// - generationOptions: Generation options.
|
||||
public init(compatibleXcodeVersions: CompatibleXcodeVersions,
|
||||
cloudURL: URL?,
|
||||
generationOptions: [GenerationOption]) {
|
||||
self.compatibleXcodeVersions = compatibleXcodeVersions
|
||||
self.cloudURL = cloudURL
|
||||
self.generationOptions = generationOptions
|
||||
}
|
||||
|
||||
|
@ -37,5 +43,7 @@ public struct Config: Equatable, Hashable {
|
|||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(generationOptions)
|
||||
hasher.combine(cloudURL)
|
||||
hasher.combine(compatibleXcodeVersions)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import Foundation
|
|||
|
||||
public extension Config {
|
||||
static func test(compatibleXcodeVersions: CompatibleXcodeVersions = .all,
|
||||
cloudURL: URL? = nil,
|
||||
generationOptions: [GenerationOption] = []) -> Config {
|
||||
Config(compatibleXcodeVersions: compatibleXcodeVersions,
|
||||
cloudURL: cloudURL,
|
||||
generationOptions: generationOptions)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,26 @@ import ProjectDescription
|
|||
import TuistCore
|
||||
import TuistSupport
|
||||
|
||||
enum ConfigManifestMapperError: FatalError {
|
||||
/// Thrown when the cloud URL is invalid.
|
||||
case invalidCloudURL(String)
|
||||
|
||||
/// Error type.
|
||||
var type: ErrorType {
|
||||
switch self {
|
||||
case .invalidCloudURL: return .abort
|
||||
}
|
||||
}
|
||||
|
||||
/// Error description.
|
||||
var description: String {
|
||||
switch self {
|
||||
case let .invalidCloudURL(url):
|
||||
return "The cloud URL '\(url)' is not a valid URL"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TuistCore.Config {
|
||||
/// Maps a ProjectDescription.Config instance into a TuistCore.Config model.
|
||||
/// - Parameters:
|
||||
|
@ -12,7 +32,15 @@ extension TuistCore.Config {
|
|||
static func from(manifest: ProjectDescription.Config) throws -> TuistCore.Config {
|
||||
let generationOptions = try manifest.generationOptions.map { try TuistCore.Config.GenerationOption.from(manifest: $0) }
|
||||
let compatibleXcodeVersions = TuistCore.CompatibleXcodeVersions.from(manifest: manifest.compatibleXcodeVersions)
|
||||
return TuistCore.Config(compatibleXcodeVersions: compatibleXcodeVersions, generationOptions: generationOptions)
|
||||
var cloudURL: URL?
|
||||
if let manifestCloudURL = manifest.cloudURL {
|
||||
if let manifestCloudURL = URL(string: manifestCloudURL) {
|
||||
cloudURL = manifestCloudURL
|
||||
} else {
|
||||
throw ConfigManifestMapperError.invalidCloudURL(manifestCloudURL)
|
||||
}
|
||||
}
|
||||
return TuistCore.Config(compatibleXcodeVersions: compatibleXcodeVersions, cloudURL: cloudURL, generationOptions: generationOptions)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ import XCTest
|
|||
|
||||
final class ConfigTests: XCTestCase {
|
||||
func test_config_toJSON() throws {
|
||||
let config = Config(generationOptions:
|
||||
[.xcodeProjectName("someprefix-\(.projectName)")])
|
||||
let config = Config(cloudURL: "https://tuist.io",
|
||||
generationOptions:
|
||||
[.xcodeProjectName("someprefix-\(.projectName)")])
|
||||
|
||||
XCTAssertCodable(config)
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
import Foundation
|
||||
import Foundation
|
||||
|
|
|
@ -324,7 +324,7 @@ final class MultipleConfigurationsIntegrationTests: TuistUnitTestCase {
|
|||
}
|
||||
|
||||
private func createConfig() -> Config {
|
||||
Config(compatibleXcodeVersions: .all, generationOptions: [])
|
||||
Config(compatibleXcodeVersions: .all, cloudURL: nil, generationOptions: [])
|
||||
}
|
||||
|
||||
private func createWorkspace(projects: [String]) throws -> Workspace {
|
||||
|
|
|
@ -128,7 +128,7 @@ final class StableXcodeProjIntegrationTests: TuistUnitTestCase {
|
|||
}
|
||||
|
||||
private func createConfig() -> Config {
|
||||
Config(compatibleXcodeVersions: .all, generationOptions: [])
|
||||
Config(compatibleXcodeVersions: .all, cloudURL: nil, generationOptions: [])
|
||||
}
|
||||
|
||||
private func createWorkspace(projects: [String]) throws -> Workspace {
|
||||
|
|
Loading…
Reference in New Issue