forked from tuist/tuist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract Tuist-specific models from
XcodeGraph
(tuist#6401)
* Remove no-longer needed models * Introduce TuistModels * Fix compilation * Fix Package.swift * Fix some linting issues * Remove TuistModels and merge models into TuistCore
- Loading branch information
Showing
203 changed files
with
540 additions
and
4,719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Foundation | ||
|
||
/// Cloud represents the configuration to connect to the server. | ||
public struct Cloud: Equatable, Hashable { | ||
/// Cloud option. | ||
public enum Option: String, Codable, Equatable { | ||
case optional | ||
} | ||
|
||
/// The base URL that points to the cloud server | ||
public let url: URL | ||
|
||
/// The project unique identifier. | ||
public let projectId: String | ||
|
||
/// Cloud options. | ||
public let options: [Option] | ||
|
||
/// Initializes an instance of Cloud. | ||
/// - Parameters: | ||
/// - url: Cloud server base URL. | ||
/// - projectId: Project unique identifier. | ||
/// - options: Cloud options. | ||
public init(url: URL, projectId: String, options: [Option]) { | ||
self.url = url | ||
self.projectId = projectId | ||
self.options = options | ||
} | ||
} | ||
|
||
#if DEBUG | ||
extension Cloud { | ||
public static func test( | ||
url: URL = URL(string: "https://test.tuist.io")!, | ||
projectId: String = "123", | ||
options: [Cloud.Option] = [] | ||
) -> Cloud { | ||
Cloud(url: url, projectId: projectId, options: options) | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import Foundation | ||
import XcodeGraph | ||
|
||
/// Enum that represents all the Xcode versions that a project or set of projects is compatible with. | ||
public enum CompatibleXcodeVersions: Equatable, Hashable, ExpressibleByArrayLiteral, ExpressibleByStringInterpolation, | ||
CustomStringConvertible | ||
{ | ||
/// The project supports all Xcode versions. | ||
case all | ||
|
||
/// The project supports only a specific Xcode version. | ||
case exact(Version) | ||
|
||
/// The project supports all Xcode versions from the specified version up to but not including the next major version. | ||
case upToNextMajor(Version) | ||
|
||
/// The project supports all Xcode versions from the specified version up to but not including the next minor version. | ||
case upToNextMinor(Version) | ||
|
||
/// List of versions that are supported by the project. | ||
case list([CompatibleXcodeVersions]) | ||
|
||
public func isCompatible(versionString: String) -> Bool { | ||
let xCodeVersion: Version = "\(versionString)" | ||
|
||
switch self { | ||
case .all: | ||
return true | ||
case let .exact(version): | ||
return version == xCodeVersion | ||
case let .upToNextMajor(version): | ||
return xCodeVersion.major == version.major && xCodeVersion >= version | ||
case let .upToNextMinor(version): | ||
return version.major == xCodeVersion.major && version.minor == xCodeVersion.minor && xCodeVersion >= version | ||
case let .list(versions): | ||
return versions.contains { $0.isCompatible(versionString: versionString) } | ||
} | ||
} | ||
|
||
// MARK: - ExpressibleByStringInterpolation | ||
|
||
public init(stringLiteral value: String) { | ||
self = .exact(Version(stringLiteral: value)) | ||
} | ||
|
||
// MARK: - ExpressibleByArrayLiteral | ||
|
||
public init(arrayLiteral elements: [CompatibleXcodeVersions]) { | ||
self = .list(elements) | ||
} | ||
|
||
public init(arrayLiteral elements: CompatibleXcodeVersions...) { | ||
self = .list(elements) | ||
} | ||
|
||
// MARK: - CustomStringConvertible | ||
|
||
public var description: String { | ||
switch self { | ||
case .all: | ||
return "all" | ||
case let .exact(version): | ||
return "\(version)" | ||
case let .upToNextMajor(version): | ||
return "\(version)..<\(version.major + 1).0.0" | ||
case let .upToNextMinor(version): | ||
return "\(version)..<\(version.major).\(version.minor + 1).0" | ||
case let .list(versions): | ||
return "\(versions.map(\.description).joined(separator: " or "))" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...raph/Models/ConfigGenerationOptions.swift → ...Core/Models/ConfigGenerationOptions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import Path | ||
import TSCUtility | ||
|
||
extension Config { | ||
public struct GenerationOptions: Codable, Hashable { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Foundation | ||
import XcodeGraph | ||
|
||
/// Contains the description of custom SPM settings | ||
public struct PackageSettings: Equatable, Codable { | ||
/// The custom `Product` types to be used for SPM targets. | ||
public let productTypes: [String: Product] | ||
|
||
/// Custom destinations to be used for SPM products. | ||
public let productDestinations: [String: Destinations] | ||
|
||
// The base settings to be used for targets generated from SwiftPackageManager | ||
public let baseSettings: Settings | ||
|
||
/// The custom `Settings` to be applied to SPM targets | ||
public let targetSettings: [String: SettingsDictionary] | ||
|
||
/// The custom project options for each project generated from a swift package | ||
public let projectOptions: [String: XcodeGraph.Project.Options] | ||
|
||
/// Swift tools version of the parsed `Package.swift` | ||
public let swiftToolsVersion: Version | ||
|
||
/// Initializes a new `PackageSettings` instance. | ||
/// - Parameters: | ||
/// - productTypes: The custom `Product` types to be used for SPM targets. | ||
/// - baseSettings: The base settings to be used for targets generated from SwiftPackageManager | ||
/// - targetSettings: The custom `SettingsDictionary` to be applied to denoted targets | ||
/// - projectOptions: The custom project options for each project generated from a swift package | ||
public init( | ||
productTypes: [String: Product], | ||
productDestinations: [String: Destinations], | ||
baseSettings: Settings, | ||
targetSettings: [String: SettingsDictionary], | ||
projectOptions: [String: XcodeGraph.Project.Options] = [:], | ||
swiftToolsVersion: Version | ||
) { | ||
self.productTypes = productTypes | ||
self.productDestinations = productDestinations | ||
self.baseSettings = baseSettings | ||
self.targetSettings = targetSettings | ||
self.projectOptions = projectOptions | ||
self.swiftToolsVersion = swiftToolsVersion | ||
} | ||
} | ||
|
||
#if DEBUG | ||
extension PackageSettings { | ||
public static func test( | ||
productTypes: [String: Product] = [:], | ||
productDestinations: [String: Destinations] = [:], | ||
baseSettings: Settings = Settings.default, | ||
targetSettings: [String: SettingsDictionary] = [:], | ||
projectOptions: [String: XcodeGraph.Project.Options] = [:], | ||
swiftToolsVersion: Version = Version("5.4.9") | ||
) -> PackageSettings { | ||
PackageSettings( | ||
productTypes: productTypes, | ||
productDestinations: productDestinations, | ||
baseSettings: baseSettings, | ||
targetSettings: targetSettings, | ||
projectOptions: projectOptions, | ||
swiftToolsVersion: swiftToolsVersion | ||
) | ||
} | ||
} | ||
#endif |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Foundation | ||
|
||
/// The location to a directory containing a `Plugin` manifest. | ||
public enum PluginLocation: Hashable, Equatable { | ||
public enum GitReference: Hashable, Equatable { | ||
case sha(String) | ||
case tag(String) | ||
} | ||
|
||
/// An absolute path `String` to a directory a `Plugin` manifest. | ||
/// | ||
/// Example: | ||
/// ``` | ||
/// .local(path: "/User/local/bin") | ||
/// ``` | ||
case local(path: String) | ||
|
||
/// A `URL` to a `git` repository pointing at a `GitReference` (either sha or tag), and optionally a directory | ||
/// | ||
/// Examples: | ||
/// ``` | ||
/// .git(url: "https://git/helpers.git", gitReference: .tag("1.0.0")) | ||
/// .git(url: "https://git/helpers.git", gitReference: .sha("1.0.0")) | ||
/// ``` | ||
case git(url: String, gitReference: GitReference, directory: String?, releaseUrl: String?) | ||
} | ||
|
||
// MARK: - description | ||
|
||
extension PluginLocation: CustomStringConvertible { | ||
public var description: String { | ||
switch self { | ||
case let .local(path): | ||
return "local path: \(path)" | ||
case let .git(url, .tag(tag), directory, releaseUrl): | ||
return "git url: \(url), tag: \(tag), directory: \(directory ?? "nil"), releaseUrl: \(releaseUrl ?? "nil")" | ||
case let .git(url, .sha(sha), directory, releaseUrl): | ||
return "git url: \(url), sha: \(sha), directory: \(directory ?? "nil"), releaseUrl: \(releaseUrl ?? "nil")" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.