Skip to content

Commit

Permalink
Update Tuist.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matty Cross committed Dec 17, 2024
1 parent 6c57caa commit bc6bc58
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 182 deletions.
117 changes: 0 additions & 117 deletions .package.resolved
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
{
"object": {
"pins": [
{
"package": "AEXML",
"repositoryURL": "https://github.com/tadija/AEXML.git",
"state": {
"branch": null,
"revision": "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",
"version": "4.6.1"
}
},
{
"package": "FileKit",
"repositoryURL": "https://github.com/nvzqz/FileKit.git",
"state": {
"branch": null,
"revision": "9006d2888025fbe893c3c396327b2fe45a8c177b",
"version": "6.1.0"
}
},
{
"package": "OCMock",
"repositoryURL": "https://github.com/erikdoe/ocmock.git",
Expand All @@ -27,105 +9,6 @@
"revision": "2c0bfd373289f4a7716db5d6db471640f91a6507",
"version": null
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version": "1.0.1"
}
},
{
"package": "Rainbow",
"repositoryURL": "https://github.com/onevcat/Rainbow",
"state": {
"branch": null,
"revision": "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",
"version": "4.0.1"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version": "0.10.1"
}
},
{
"package": "Stencil",
"repositoryURL": "https://github.com/kylef/Stencil.git",
"state": {
"branch": null,
"revision": "4f222ac85d673f35df29962fc4c36ccfdaf9da5b",
"version": "0.15.1"
}
},
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version": "1.2.3"
}
},
{
"package": "swift-cmark",
"repositoryURL": "https://github.com/apple/swift-cmark.git",
"state": {
"branch": null,
"revision": "f218e5d7691f78b55bfa39b367763f4612486c35",
"version": "0.3.0"
}
},
{
"package": "swift-format",
"repositoryURL": "https://github.com/apple/swift-format.git",
"state": {
"branch": null,
"revision": "83248b4fa37919f78ffbd4650946759bcc54c2b5",
"version": "509.0.0"
}
},
{
"package": "swift-markdown",
"repositoryURL": "https://github.com/apple/swift-markdown.git",
"state": {
"branch": null,
"revision": "e4f95e2dc23097a1a9a1dfdfe3fe3ee44de77378",
"version": "0.3.0"
}
},
{
"package": "swift-syntax",
"repositoryURL": "https://github.com/apple/swift-syntax.git",
"state": {
"branch": null,
"revision": "74203046135342e4a4a627476dd6caf8b28fe11b",
"version": "509.0.0"
}
},
{
"package": "TOMLKit",
"repositoryURL": "https://github.com/LebJe/TOMLKit.git",
"state": {
"branch": null,
"revision": "404c4dd011743461bff12d00a5118d0ed59d630c",
"version": "0.5.5"
}
},
{
"package": "XcodeProj",
"repositoryURL": "https://github.com/tuist/XcodeProj.git",
"state": {
"branch": null,
"revision": "3797181813ee963fe305d939232bc576d23ddbb0",
"version": "8.15.0"
}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion .tuist-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.0
4.37.0
30 changes: 15 additions & 15 deletions Generator/Project.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ProjectDescription
import ProjectDescriptionHelpers

let target = Target(
let target = Target.target(
name: "Cuckoonator",
platform: .macOS,
destinations: .macOS,
product: .commandLineTool,
productName: "cuckoonator",
bundleId: "Cuckoonator",
deploymentTarget: .macOS(targetVersion: "12.0"),
deploymentTargets: .macOS("12.0"),
sources: "Sources/**",
dependencies: [
"FileKit",
Expand All @@ -18,16 +18,16 @@ let target = Target(
"TOMLKit",
"XcodeProj",
"Rainbow",
].map(TargetDependency.package(product:))
].map { TargetDependency.package(product: $0) }
)

let testTarget = Target(
let testTarget = Target.target(
name: "CuckoonatorTests",
platform: .macOS,
destinations: .macOS,
product: .unitTests,
bundleId: "CuckoonatorTests",
deploymentTarget: target.deploymentTarget,
sources: SourceFilesList(globs: [
deploymentTargets: target.deploymentTargets,
sources: SourceFilesList.sourceFilesList(globs: [
// TODO: This is wrong but testing CLI is not supported, must separate generator into CLI and internal targets.
target.sources?.globs,
["Tests/**"],
Expand Down Expand Up @@ -56,30 +56,30 @@ let project = Project(
testTarget,
],
schemes: [
Scheme(
Scheme.scheme(
name: "Generator",
buildAction: BuildAction.buildAction(
targets: ["Cuckoonator"],
postActions: [
ExecutionAction(
ExecutionAction.executionAction(
title: "Copy executable",
scriptText: #"\cp "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" "$PROJECT_DIR/bin/cuckoonator""#,
target: "Cuckoonator"
)
],
runPostActionsOnFailure: false
),
testAction: TestAction.targets([TestableTarget(target: testTarget.reference)]),
testAction: TestAction.targets([TestableTarget.testableTarget(target: testTarget.reference)]),
runAction: RunAction.runAction(
executable: "Cuckoonator",
arguments: Arguments(
environment: [
arguments: Arguments.arguments(
environmentVariables: [
"PROJECT_DIR": Environment.projectDir.requireString(message: "TUIST_PROJECT_DIR environment property is required."),
],
launchArguments: [
// Any changes here should be reflected in `../Project.swift` as well.
LaunchArgument(name: "--configuration ./Cuckoofile", isEnabled: true),
LaunchArgument(name: "--verbose", isEnabled: true),
LaunchArgument.launchArgument(name: "--configuration ./Cuckoofile", isEnabled: true),
LaunchArgument.launchArgument(name: "--verbose", isEnabled: true),
]
)
)
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:6.0

import PackageDescription

Expand Down
30 changes: 15 additions & 15 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func platformSet(platform: PlatformType) -> (targets: [Target], schemes: [Scheme
var schemes: [Scheme] = []

// MARK: Swift targets.
let defaultTarget = Target(
let defaultTarget = Target.target(
name: "Cuckoo-\(platform)",
platform: platform.platform,
destinations: platform.destinations,
product: .framework,
bundleId: "org.brightify.Cuckoo",
deploymentTarget: platform.libraryDeploymentTarget,
deploymentTargets: platform.deploymentTargets,
infoPlist: .default,
sources: [
"Source/**",
Expand All @@ -38,12 +38,12 @@ func platformSet(platform: PlatformType) -> (targets: [Target], schemes: [Scheme
)
targets.append(defaultTarget)

let mocksTarget = Target(
let mocksTarget = Target.target(
name: "Cuckoo-\(platform)Tests-Mocks",
platform: platform.platform,
destinations: platform.destinations,
product: .framework,
bundleId: "org.brightify.Cuckoo",
deploymentTarget: platform.libraryDeploymentTarget,
deploymentTargets: platform.deploymentTargets,
infoPlist: .default,
sources: [
"Tests/Swift/Generated/*.swift",
Expand All @@ -70,21 +70,21 @@ func platformSet(platform: PlatformType) -> (targets: [Target], schemes: [Scheme
),
],
dependencies: [
.target(name: defaultTarget.name),
.target(defaultTarget),
.sdk(name: "XCTest", type: .framework, status: .optional),
],
settings: Settings.settings(base: mocksBuildSettingsBase)
)
targets.append(mocksTarget)

let defaultTestTarget = Target(
let defaultTestTarget = Target.target(
name: "Cuckoo-\(platform)Tests",
platform: platform.platform,
destinations: platform.destinations,
product: .unitTests,
bundleId: "org.brightify.Cuckoo",
deploymentTarget: platform.testDeploymentTarget,
deploymentTargets: platform.deploymentTargets,
infoPlist: .default,
sources: .init(globs: [
sources: SourceFilesList.sourceFilesList(globs: [
.glob("Tests/Common/**"),
.glob("Tests/OCMock/**"),
.glob("Tests/Swift/**", excluding: [
Expand All @@ -93,19 +93,19 @@ func platformSet(platform: PlatformType) -> (targets: [Target], schemes: [Scheme
]),
]),
dependencies: [
.target(name: defaultTarget.name),
.target(name: mocksTarget.name),
.target(defaultTarget),
.target(mocksTarget),
.package(product: "OCMock"),
]
)
targets.append(defaultTestTarget)

// MARK: Schemes.
schemes.append(
Scheme(
Scheme.scheme(
name: defaultTarget.name,
buildAction: BuildAction.buildAction(targets: [defaultTarget.reference, mocksTarget.reference]),
testAction: TestAction.targets([.init(target: defaultTestTarget.reference)])
testAction: TestAction.targets([TestableTarget.testableTarget(target: defaultTestTarget.reference)])
)
)

Expand Down
12 changes: 2 additions & 10 deletions Tuist/ProjectDescriptionHelpers/Environment+convenience.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import ProjectDescription

public extension Optional<Environment.Value> {
func requireString(message: String) -> String {
func requireString(message: String, isEnabled: Bool = true) -> EnvironmentVariable {
if case .string(let value) = self {
return value
} else {
fatalError(message)
}
}

func requireBool(message: String) -> Bool {
if case .boolean(let value) = self {
return value
return EnvironmentVariable.environmentVariable(value: value, isEnabled: isEnabled)
} else {
fatalError(message)
}
Expand Down
33 changes: 10 additions & 23 deletions Tuist/ProjectDescriptionHelpers/PlatformType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,29 @@ public enum PlatformType: String {
case tvOS
case watchOS

public var platform: Platform {
public var destinations: Destinations {
switch self {
case .iOS:
return .iOS
return [.iPhone, .iPad]
case .macOS:
return .macOS
return [.mac]
case .tvOS:
return .tvOS
return [.appleTv]
case .watchOS:
return .watchOS
return [.appleWatch]
}
}

public var libraryDeploymentTarget: DeploymentTarget {
public var deploymentTargets: DeploymentTargets {
switch self {
case .iOS:
return .iOS(targetVersion: "13.0", devices: [.iphone, .ipad])
return .iOS("13.0")
case .macOS:
return .macOS(targetVersion: "10.15")
return .macOS("10.15")
case .tvOS:
return .tvOS(targetVersion: "13.0")
return .tvOS("13.0")
case .watchOS:
return .watchOS(targetVersion: "8.0")
}
}

public var testDeploymentTarget: DeploymentTarget {
switch self {
case .iOS:
return .iOS(targetVersion: "13.0", devices: [.iphone, .ipad])
case .macOS:
return .macOS(targetVersion: "10.15")
case .tvOS:
return .tvOS(targetVersion: "13.0")
case .watchOS:
return .watchOS(targetVersion: "8.0")
return .watchOS("8.0")
}
}
}

0 comments on commit bc6bc58

Please sign in to comment.