Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn some models from TuistCore that are classes into structs #870

Merged
merged 6 commits into from Jan 8, 2020
@@ -12,6 +12,9 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/

- The class name of the source files generated by the init command https://github.com/tuist/tuist/pull/850 by @pepibumur.

### Changed
- Turn models from `TuistCore` that are clases into structs https://github.com/tuist/tuist/pull/870 by @pepibumur.

## 1.1.0

### Changed
@@ -0,0 +1,23 @@
import Foundation

public struct ArchiveAction: Equatable, Codable {
public let configurationName: String
public let revealArchiveInOrganizer: Bool
public let customArchiveName: String?
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

public init(
configurationName: String,
revealArchiveInOrganizer: Bool = true,
customArchiveName: String? = nil,
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []
) {
self.configurationName = configurationName
self.revealArchiveInOrganizer = revealArchiveInOrganizer
self.customArchiveName = customArchiveName
self.preActions = preActions
self.postActions = postActions
}
}
@@ -0,0 +1,12 @@
import Foundation

public struct Arguments: Equatable, Codable {
public let environment: [String: String]
public let launch: [String: Bool]

public init(environment: [String: String] = [:],
launch: [String: Bool] = [:]) {
self.environment = environment
self.launch = launch
}
}
@@ -0,0 +1,15 @@
import Foundation

public struct BuildAction: Equatable, Codable {
public let targets: [TargetReference]
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

public init(targets: [TargetReference],
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []) {
self.targets = targets
self.preActions = preActions
self.postActions = postActions
}
}
@@ -0,0 +1,13 @@
import Foundation

public struct ExecutionAction: Equatable, Codable {
public let title: String
public let scriptText: String
public let target: TargetReference?

public init(title: String = "Run Script", scriptText: String, target: TargetReference? = nil) {
self.title = title
self.scriptText = scriptText
self.target = target
}
}
@@ -0,0 +1,23 @@
import Foundation

public struct RunAction: Equatable, Codable {
public let configurationName: String
public let executable: TargetReference?
public let arguments: Arguments?

public init(configurationName: String,
executable: TargetReference? = nil,
arguments: Arguments? = nil) {
self.configurationName = configurationName
self.executable = executable
self.arguments = arguments
}

public init(config: PresetBuildConfiguration = .debug,
executable: TargetReference? = nil,
arguments: Arguments? = nil) {
self.init(configurationName: config.name,
executable: executable,
arguments: arguments)
}
}
@@ -24,176 +24,3 @@ public struct Scheme: Equatable, Codable {
self.archiveAction = archiveAction
}
}

// MARK: - ExecutionAction
public struct ExecutionAction: Equatable, Codable {
public let title: String
public let scriptText: String
public let target: TargetReference?

public init(title: String = "Run Script", scriptText: String, target: TargetReference? = nil) {
self.title = title
self.scriptText = scriptText
self.target = target
}
}

// MARK: - Arguments
public struct Arguments: Equatable, Codable {
public let environment: [String: String]
public let launch: [String: Bool]

public init(environment: [String: String] = [:],
launch: [String: Bool] = [:]) {
self.environment = environment
self.launch = launch
}
}

// MARK: - BuildAction
public struct BuildAction: Equatable, Codable {
public let targets: [TargetReference]
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

public init(targets: [TargetReference],
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []) {
self.targets = targets
self.preActions = preActions
self.postActions = postActions
}
}

// MARK: - TestAction
public struct TestAction: Equatable, Codable {
public let targets: [TestableTarget]
public let arguments: Arguments?
public let configurationName: String
public let coverage: Bool
public let codeCoverageTargets: [TargetReference]
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

public init(targets: [TestableTarget] = [],
arguments: Arguments? = nil,
configurationName: String,
coverage: Bool = false,
codeCoverageTargets: [TargetReference] = [],
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []) {
self.targets = targets
self.arguments = arguments
self.configurationName = configurationName
self.coverage = coverage
self.preActions = preActions
self.postActions = postActions
self.codeCoverageTargets = codeCoverageTargets
}

public init(targets: [TestableTarget],
arguments: Arguments? = nil,
config: PresetBuildConfiguration = .debug,
coverage: Bool = false,
codeCoverageTargets: [TargetReference] = [],
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []) {
self.init(targets: targets,
arguments: arguments,
configurationName: config.name,
coverage: coverage,
codeCoverageTargets: codeCoverageTargets,
preActions: preActions,
postActions: postActions)
}
}

public struct TestableTarget: Equatable, Codable, ExpressibleByStringLiteral {
public let target: TargetReference
public let isSkipped: Bool
public let isParallelizable: Bool
public let isRandomExecutionOrdering: Bool

public init(target: TargetReference, skipped: Bool = false, parallelizable: Bool = false, randomExecutionOrdering: Bool = false) {
self.target = target
isSkipped = skipped
isParallelizable = parallelizable
isRandomExecutionOrdering = randomExecutionOrdering
}

public init(stringLiteral value: String) {
self.init(target: .init(projectPath: nil, target: value))
}
}

// MARK: - RunAction
public struct RunAction: Equatable, Codable {
public let configurationName: String
public let executable: TargetReference?
public let arguments: Arguments?

public init(configurationName: String,
executable: TargetReference? = nil,
arguments: Arguments? = nil) {
self.configurationName = configurationName
self.executable = executable
self.arguments = arguments
}

public init(config: PresetBuildConfiguration = .debug,
executable: TargetReference? = nil,
arguments: Arguments? = nil) {
self.init(configurationName: config.name,
executable: executable,
arguments: arguments)
}
}

// MARK: - Archive Action
public struct ArchiveAction: Equatable, Codable {
public let configurationName: String
public let revealArchiveInOrganizer: Bool
public let customArchiveName: String?
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

public init(
configurationName: String,
revealArchiveInOrganizer: Bool = true,
customArchiveName: String? = nil,
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []
) {
self.configurationName = configurationName
self.revealArchiveInOrganizer = revealArchiveInOrganizer
self.customArchiveName = customArchiveName
self.preActions = preActions
self.postActions = postActions
}
}

// MARK: - Target Reference
public struct TargetReference: Equatable, Codable, ExpressibleByStringLiteral {
public var projectPath: Path?
public var targetName: String

public init(projectPath: Path?, target: String) {
self.projectPath = projectPath
targetName = target
}

public init(stringLiteral value: String) {
self = .init(projectPath: nil, target: value)
}

public static func project(path: Path, target: String) -> TargetReference {
.init(projectPath: path, target: target)
}
}
@@ -0,0 +1,19 @@
import Foundation

public struct TargetReference: Equatable, Codable, ExpressibleByStringLiteral {
public var projectPath: Path?
public var targetName: String

public init(projectPath: Path?, target: String) {
self.projectPath = projectPath
targetName = target
}

public init(stringLiteral value: String) {
self = .init(projectPath: nil, target: value)
}

public static func project(path: Path, target: String) -> TargetReference {
This conversation was marked as resolved by pepibumur

This comment has been minimized.

Copy link
@lakpa

lakpa Jan 7, 2020

Contributor

wondering if we need this static builder function?

This comment has been minimized.

Copy link
@pepibumur

pepibumur Jan 8, 2020

Author Contributor

You are right. I think is a leftover from copying and pasting the model from ProjectDescription. I'll remove it 馃憤

.init(projectPath: path, target: target)
}
}
@@ -0,0 +1,43 @@
import Foundation

public struct TestAction: Equatable, Codable {
public let targets: [TestableTarget]
public let arguments: Arguments?
public let configurationName: String
public let coverage: Bool
public let codeCoverageTargets: [TargetReference]
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

public init(targets: [TestableTarget] = [],

This comment has been minimized.

Copy link
@lakpa

lakpa Jan 7, 2020

Contributor

only difference between these two initialisers are one takes configurationName and other config, we can wrap these two parameters under an enum.

This comment has been minimized.

Copy link
@pepibumur

pepibumur Jan 8, 2020

Author Contributor

That's a good suggestion, although I wouldn't do it as part of this PR.

arguments: Arguments? = nil,
configurationName: String,
coverage: Bool = false,
codeCoverageTargets: [TargetReference] = [],
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []) {
self.targets = targets
self.arguments = arguments
self.configurationName = configurationName
self.coverage = coverage
self.preActions = preActions
self.postActions = postActions
self.codeCoverageTargets = codeCoverageTargets
}

public init(targets: [TestableTarget],
arguments: Arguments? = nil,
config: PresetBuildConfiguration = .debug,
coverage: Bool = false,
codeCoverageTargets: [TargetReference] = [],
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []) {
self.init(targets: targets,
arguments: arguments,
configurationName: config.name,
coverage: coverage,
codeCoverageTargets: codeCoverageTargets,
preActions: preActions,
postActions: postActions)
}
}
@@ -0,0 +1,19 @@
import Foundation

public struct TestableTarget: Equatable, Codable, ExpressibleByStringLiteral {
public let target: TargetReference
public let isSkipped: Bool
public let isParallelizable: Bool
public let isRandomExecutionOrdering: Bool

public init(target: TargetReference, skipped: Bool = false, parallelizable: Bool = false, randomExecutionOrdering: Bool = false) {
self.target = target
isSkipped = skipped
isParallelizable = parallelizable
isRandomExecutionOrdering = randomExecutionOrdering
}

public init(stringLiteral value: String) {
self.init(target: .init(projectPath: nil, target: value))
}
}
@@ -0,0 +1,28 @@
import Basic
import Foundation

public struct ArchiveAction: Equatable {
// MARK: - Attributes
public let configurationName: String
public let revealArchiveInOrganizer: Bool
public let customArchiveName: String?
public let preActions: [ExecutionAction]
public let postActions: [ExecutionAction]

// MARK: - Init
public init(
configurationName: String,
revealArchiveInOrganizer: Bool = true,
customArchiveName: String? = nil,
preActions: [ExecutionAction] = [],
postActions: [ExecutionAction] = []
) {
self.configurationName = configurationName
self.revealArchiveInOrganizer = revealArchiveInOrganizer
self.customArchiveName = customArchiveName
self.preActions = preActions
self.postActions = postActions
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can鈥檛 perform that action at this time.