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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Swift 5.9 #275

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ on:
pull_request: {}

jobs:
macOS:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- name: Resolve
run: swift package resolve
- name: Build
run: swift build
- name: Run tests
run: swift test 2>&1 | xcpretty
linux:
runs-on: ubuntu-latest
container: swift:5.2
test:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
swift: ["5.9.0"]
steps:
- uses: actions/checkout@v2
- uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}
- name: Resolve
run: swift package resolve
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.9

import PackageDescription

Expand All @@ -15,7 +15,7 @@ let package = Package(
.package(url: "https://github.com/mxcl/Version.git", from: "2.0.1")
],
targets: [
.target(name: "Mint", dependencies: ["MintCLI"]),
.executableTarget(name: "Mint", dependencies: ["MintCLI"]),
.target(name: "MintCLI", dependencies: ["Rainbow", "SwiftCLI", "MintKit"]),
.target(name: "MintKit", dependencies: ["Rainbow", "PathKit", "Version", "SwiftCLI"]),
.testTarget(name: "MintTests", dependencies: ["MintKit"]),
Expand Down
6 changes: 2 additions & 4 deletions Sources/MintCLI/MintCLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ public class MintCLI {
extension MintError: ProcessError {

public var message: String? {
return "🌱 \(description.red)"
"🌱 \(description.red)"
}

public var exitStatus: Int32 {
return 1
}
public var exitStatus: Int32 { 1 }
}
2 changes: 1 addition & 1 deletion Sources/MintKit/Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PathKit
struct Cache: Hashable {
struct PackageInfo: Hashable {
var name: String {
return PackageReference(repo: gitRepo).name
PackageReference(repo: gitRepo).name
}

let gitRepo: String
Expand Down
2 changes: 1 addition & 1 deletion Sources/MintKit/InputReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ extension Input {
}

static func confirmation(_ question: String) -> Bool {
return readBool(prompt: "\(question) (y/n)")
readBool(prompt: "\(question) (y/n)")
}
}
6 changes: 3 additions & 3 deletions Sources/MintKit/InstallStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ struct InstallStatus {

var warning: String? {
switch status {
case .file: return "An executable that was not installed by mint already exists at \(path)."
case let .symlink(symlink): return "An executable that was not installed by mint already exists at \(path) that is symlinked to \(symlink)."
default: return nil
case .file: "An executable that was not installed by mint already exists at \(path)."
case let .symlink(symlink): "An executable that was not installed by mint already exists at \(path) that is symlinked to \(symlink)."
default: nil
}
}
}
4 changes: 2 additions & 2 deletions Sources/MintKit/Mint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class Mint {
public var mintFilePath: Path

var packagesPath: Path {
return path + "packages"
path + "packages"
}

var metadataPath: Path {
return path + "metadata.json"
path + "metadata.json"
}

public var standardOut: WritableStream
Expand Down
26 changes: 13 additions & 13 deletions Sources/MintKit/MintError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ public enum MintError: Error, CustomStringConvertible, Equatable, LocalizedError

public var description: String {
switch self {
case let .packageNotFound(package): return "\(package.quoted) package not found"
case let .repoNotFound(repo): return "Git repo not found at \(repo.quoted)"
case let .cloneError(package): return "Couldn't clone \(package.gitPath) \(package.version)"
case let .mintfileNotFound(path): return "\(path) not found"
case let .invalidExecutable(executable): return "Couldn't find executable \(executable.quoted)"
case let .missingExecutable(package): return "Executable product not found in \(package.namedVersion)"
case let .packageResolveError(package): return "Failed to resolve \(package.namedVersion) with SPM"
case let .packageBuildError(package): return "Failed to build \(package.namedVersion) with SPM"
case let .packageReadError(error): return "Failed to read Package.swift file:\n\(error)"
case let .packageNotInstalled(package): return "\(package.namedVersion) not installed"
case let .inconsistentCache(error): return "Inconsistent cache, clear it up.\nError: \(error)"
case let .packageNotFound(package): "\(package.quoted) package not found"
case let .repoNotFound(repo): "Git repo not found at \(repo.quoted)"
case let .cloneError(package): "Couldn't clone \(package.gitPath) \(package.version)"
case let .mintfileNotFound(path): "\(path) not found"
case let .invalidExecutable(executable): "Couldn't find executable \(executable.quoted)"
case let .missingExecutable(package): "Executable product not found in \(package.namedVersion)"
case let .packageResolveError(package): "Failed to resolve \(package.namedVersion) with SPM"
case let .packageBuildError(package): "Failed to build \(package.namedVersion) with SPM"
case let .packageReadError(error): "Failed to read Package.swift file:\n\(error)"
case let .packageNotInstalled(package): "\(package.namedVersion) not installed"
case let .inconsistentCache(error): "Inconsistent cache, clear it up.\nError: \(error)"
}
}

public static func == (lhs: MintError, rhs: MintError) -> Bool {
return lhs.description == rhs.description
lhs.description == rhs.description
}

public var errorDescription: String? {
return description
description
}
}
2 changes: 1 addition & 1 deletion Sources/MintKit/Mintfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public struct Mintfile {
let packages: [PackageReference]

public func package(for repo: String) -> PackageReference? {
return packages.first { $0.repo.lowercased().contains(repo.lowercased()) }
packages.first { $0.repo.lowercased().contains(repo.lowercased()) }
}

public init(path: Path) throws {
Expand Down
10 changes: 5 additions & 5 deletions Sources/MintKit/PackagePath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ struct PackagePath {
self.executable = executable
}

var packagePath: Path { return path + package.repoPath }
var installPath: Path { return packagePath + "build" + package.version }
var executablePath: Path { return installPath + (executable ?? package.name) }
var packagePath: Path { path + package.repoPath }
var installPath: Path { packagePath + "build" + package.version }
var executablePath: Path { installPath + (executable ?? package.name) }

func getExecutables() throws -> [String] {
return try installPath.children()
try installPath.children()
.filter { $0.isFile && !$0.lastComponent.hasPrefix(".") && $0.extension == nil }
.map { $0.lastComponent }
}

var commandVersion: String {
return "\(executable ?? package.name) \(package.version)"
"\(executable ?? package.name) \(package.version)"
}
}
8 changes: 4 additions & 4 deletions Sources/MintKit/PackageReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class PackageReference {
}

public var namedVersion: String {
return "\(name) \(version)"
"\(name) \(version)"
}

public var name: String {
return repo.components(separatedBy: "/").last!.replacingOccurrences(of: ".git", with: "")
repo.components(separatedBy: "/").last!.replacingOccurrences(of: ".git", with: "")
}

public var gitPath: String {
Expand Down Expand Up @@ -75,7 +75,7 @@ public class PackageReference {
}

var repoPath: String {
return gitPath
gitPath
.components(separatedBy: "://").last!
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: ".git", with: "")
Expand All @@ -86,6 +86,6 @@ public class PackageReference {

extension PackageReference: Equatable {
public static func == (lhs: PackageReference, rhs: PackageReference) -> Bool {
return lhs.repo == rhs.repo && lhs.version == rhs.version
lhs.repo == rhs.repo && lhs.version == rhs.version
}
}
2 changes: 1 addition & 1 deletion Sources/MintKit/StringExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Foundation
public extension String {

var quoted: String {
return "\"\(self)\""
"\"\(self)\""
}
}
2 changes: 1 addition & 1 deletion Tests/MintTests/MintTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MintTests: XCTestCase {
let testPackageDir = "github.com_yonaskolb_SimplePackage"
let fullTestRepo = "https://github.com/yonaskolb/SimplePackage.git"
func expectedExecutablePath(_ version: String) -> Path {
return mintPath.absolute() + "packages" + "github.com_yonaskolb_SimplePackage/build/\(version)/simplepackage"
mintPath.absolute() + "packages" + "github.com_yonaskolb_SimplePackage/build/\(version)/simplepackage"
}

override func setUp() {
Expand Down
Loading