From c290c49ff856eb8373e57705c673c3492efb08a7 Mon Sep 17 00:00:00 2001 From: Pere Bohigas Date: Sat, 25 Jan 2025 15:12:53 +0100 Subject: [PATCH 1/5] Remove unused or transitive imports --- Sources/MintCLI/Commands/BootstrapCommand.swift | 2 -- Sources/MintCLI/Commands/InstallCommand.swift | 1 - Sources/MintCLI/Commands/ListCommand.swift | 1 - Sources/MintCLI/Commands/MintCommand.swift | 2 -- Sources/MintCLI/Commands/MintFileCommand.swift | 2 -- Sources/MintCLI/Commands/PackageCommand.swift | 2 -- Sources/MintCLI/Commands/RunCommand.swift | 1 - Sources/MintCLI/Commands/UninstallCommand.swift | 1 - Sources/MintCLI/Commands/WhichCommand.swift | 1 - Sources/MintCLI/MintCLI.swift | 1 - Sources/MintKit/Cache.swift | 1 - Sources/MintKit/GitTag.swift | 1 - Sources/MintKit/InputReader.swift | 1 - Sources/MintKit/InstallStatus.swift | 1 - Sources/MintKit/MintError.swift | 1 - Sources/MintKit/Mintfile.swift | 1 - Sources/MintKit/PackagePath.swift | 1 - Sources/MintKit/PackageReference.swift | 1 - Sources/MintKit/StringExtensions.swift | 2 -- Tests/MintTests/Fixtures.swift | 1 - Tests/MintTests/MintfileTests.swift | 1 - Tests/MintTests/PackageTests.swift | 2 -- Tests/MintTests/TestHelpers.swift | 1 - 23 files changed, 29 deletions(-) diff --git a/Sources/MintCLI/Commands/BootstrapCommand.swift b/Sources/MintCLI/Commands/BootstrapCommand.swift index 5b23eb3..f7557a8 100644 --- a/Sources/MintCLI/Commands/BootstrapCommand.swift +++ b/Sources/MintCLI/Commands/BootstrapCommand.swift @@ -1,7 +1,5 @@ -import Foundation import MintKit -import PathKit import SwiftCLI class BootstrapCommand: MintfileCommand { diff --git a/Sources/MintCLI/Commands/InstallCommand.swift b/Sources/MintCLI/Commands/InstallCommand.swift index 463e6de..f896606 100644 --- a/Sources/MintCLI/Commands/InstallCommand.swift +++ b/Sources/MintCLI/Commands/InstallCommand.swift @@ -1,4 +1,3 @@ -import Foundation import MintKit import SwiftCLI diff --git a/Sources/MintCLI/Commands/ListCommand.swift b/Sources/MintCLI/Commands/ListCommand.swift index f4eb138..2d853b3 100644 --- a/Sources/MintCLI/Commands/ListCommand.swift +++ b/Sources/MintCLI/Commands/ListCommand.swift @@ -1,4 +1,3 @@ -import Foundation import MintKit class ListCommand: MintCommand { diff --git a/Sources/MintCLI/Commands/MintCommand.swift b/Sources/MintCLI/Commands/MintCommand.swift index cf71996..01cc495 100644 --- a/Sources/MintCLI/Commands/MintCommand.swift +++ b/Sources/MintCLI/Commands/MintCommand.swift @@ -1,6 +1,4 @@ -import Foundation import MintKit -import PathKit import SwiftCLI class MintCommand: Command { diff --git a/Sources/MintCLI/Commands/MintFileCommand.swift b/Sources/MintCLI/Commands/MintFileCommand.swift index bd02183..91a6cfd 100644 --- a/Sources/MintCLI/Commands/MintFileCommand.swift +++ b/Sources/MintCLI/Commands/MintFileCommand.swift @@ -1,6 +1,4 @@ -import Foundation -import MintKit import PathKit import SwiftCLI diff --git a/Sources/MintCLI/Commands/PackageCommand.swift b/Sources/MintCLI/Commands/PackageCommand.swift index 77b22e1..aa7c075 100644 --- a/Sources/MintCLI/Commands/PackageCommand.swift +++ b/Sources/MintCLI/Commands/PackageCommand.swift @@ -1,6 +1,4 @@ -import Foundation import MintKit -import PathKit import SwiftCLI class PackageCommand: MintfileCommand { diff --git a/Sources/MintCLI/Commands/RunCommand.swift b/Sources/MintCLI/Commands/RunCommand.swift index e31410b..d3ba743 100644 --- a/Sources/MintCLI/Commands/RunCommand.swift +++ b/Sources/MintCLI/Commands/RunCommand.swift @@ -1,4 +1,3 @@ -import Foundation import MintKit import SwiftCLI diff --git a/Sources/MintCLI/Commands/UninstallCommand.swift b/Sources/MintCLI/Commands/UninstallCommand.swift index 3d7cf7a..62878f1 100644 --- a/Sources/MintCLI/Commands/UninstallCommand.swift +++ b/Sources/MintCLI/Commands/UninstallCommand.swift @@ -1,4 +1,3 @@ -import Foundation import MintKit import SwiftCLI diff --git a/Sources/MintCLI/Commands/WhichCommand.swift b/Sources/MintCLI/Commands/WhichCommand.swift index 19b2d61..7dfdcc2 100644 --- a/Sources/MintCLI/Commands/WhichCommand.swift +++ b/Sources/MintCLI/Commands/WhichCommand.swift @@ -1,4 +1,3 @@ -import Foundation import MintKit import SwiftCLI diff --git a/Sources/MintCLI/MintCLI.swift b/Sources/MintCLI/MintCLI.swift index 618ac0f..6dc639a 100644 --- a/Sources/MintCLI/MintCLI.swift +++ b/Sources/MintCLI/MintCLI.swift @@ -1,7 +1,6 @@ import Foundation import MintKit import PathKit -import Rainbow import SwiftCLI public class MintCLI { diff --git a/Sources/MintKit/Cache.swift b/Sources/MintKit/Cache.swift index e9b0359..e8e1a57 100644 --- a/Sources/MintKit/Cache.swift +++ b/Sources/MintKit/Cache.swift @@ -1,4 +1,3 @@ -import Foundation import PathKit /// A struct used as a representation of the cache diff --git a/Sources/MintKit/GitTag.swift b/Sources/MintKit/GitTag.swift index 111f7b5..0dab460 100644 --- a/Sources/MintKit/GitTag.swift +++ b/Sources/MintKit/GitTag.swift @@ -1,4 +1,3 @@ -import Foundation import Version func convertTagsToVersionMap(_ tags: [String]) -> [Version: String] { diff --git a/Sources/MintKit/InputReader.swift b/Sources/MintKit/InputReader.swift index 1df7948..399dc79 100644 --- a/Sources/MintKit/InputReader.swift +++ b/Sources/MintKit/InputReader.swift @@ -1,4 +1,3 @@ -import Foundation import SwiftCLI extension Input { diff --git a/Sources/MintKit/InstallStatus.swift b/Sources/MintKit/InstallStatus.swift index e5c49d2..f0f339a 100644 --- a/Sources/MintKit/InstallStatus.swift +++ b/Sources/MintKit/InstallStatus.swift @@ -1,4 +1,3 @@ -import Foundation import PathKit struct InstallStatus { diff --git a/Sources/MintKit/MintError.swift b/Sources/MintKit/MintError.swift index 56d6c99..07acd31 100644 --- a/Sources/MintKit/MintError.swift +++ b/Sources/MintKit/MintError.swift @@ -1,5 +1,4 @@ import Foundation -import SwiftCLI public enum MintError: Error, CustomStringConvertible, Equatable, LocalizedError { case packageNotFound(String) diff --git a/Sources/MintKit/Mintfile.swift b/Sources/MintKit/Mintfile.swift index 1cf1683..a9a7d3f 100644 --- a/Sources/MintKit/Mintfile.swift +++ b/Sources/MintKit/Mintfile.swift @@ -1,4 +1,3 @@ -import Foundation import PathKit public struct Mintfile { diff --git a/Sources/MintKit/PackagePath.swift b/Sources/MintKit/PackagePath.swift index b5061c8..4fcc506 100644 --- a/Sources/MintKit/PackagePath.swift +++ b/Sources/MintKit/PackagePath.swift @@ -1,4 +1,3 @@ -import Foundation import PathKit /// Contains all the paths for packages diff --git a/Sources/MintKit/PackageReference.swift b/Sources/MintKit/PackageReference.swift index 4054211..d17a3db 100644 --- a/Sources/MintKit/PackageReference.swift +++ b/Sources/MintKit/PackageReference.swift @@ -1,5 +1,4 @@ import Foundation -import PathKit public class PackageReference { public var repo: String diff --git a/Sources/MintKit/StringExtensions.swift b/Sources/MintKit/StringExtensions.swift index 1223190..dd792c9 100644 --- a/Sources/MintKit/StringExtensions.swift +++ b/Sources/MintKit/StringExtensions.swift @@ -1,5 +1,3 @@ -import Foundation - public extension String { var quoted: String { diff --git a/Tests/MintTests/Fixtures.swift b/Tests/MintTests/Fixtures.swift index ec688b2..7ddb90f 100644 --- a/Tests/MintTests/Fixtures.swift +++ b/Tests/MintTests/Fixtures.swift @@ -1,4 +1,3 @@ -import Foundation import PathKit let mintFileFixture = Path(#file) + "../../Fixtures/Mintfile" diff --git a/Tests/MintTests/MintfileTests.swift b/Tests/MintTests/MintfileTests.swift index b334d50..a99b49c 100644 --- a/Tests/MintTests/MintfileTests.swift +++ b/Tests/MintTests/MintfileTests.swift @@ -1,5 +1,4 @@ @testable import MintKit -import PathKit import XCTest class MintfileTests: XCTestCase { diff --git a/Tests/MintTests/PackageTests.swift b/Tests/MintTests/PackageTests.swift index b31dbd3..6c1ca4e 100644 --- a/Tests/MintTests/PackageTests.swift +++ b/Tests/MintTests/PackageTests.swift @@ -1,6 +1,4 @@ @testable import MintKit -import PathKit -import SwiftCLI import XCTest class PackageTests: XCTestCase { diff --git a/Tests/MintTests/TestHelpers.swift b/Tests/MintTests/TestHelpers.swift index 454e8e4..b38cabb 100644 --- a/Tests/MintTests/TestHelpers.swift +++ b/Tests/MintTests/TestHelpers.swift @@ -1,4 +1,3 @@ -import Foundation import XCTest func expectError(_ expectedError: T, file: StaticString = #file, line: UInt = #line, closure: () throws -> Void) where T: Error, T: Equatable { From cc20212666d62117f5febab607422dff3a2b3a33 Mon Sep 17 00:00:00 2001 From: Pere Bohigas Date: Sat, 25 Jan 2025 15:13:24 +0100 Subject: [PATCH 2/5] Remove empty lines --- Sources/MintCLI/Commands/BootstrapCommand.swift | 1 - Sources/MintCLI/Commands/MintFileCommand.swift | 1 - 2 files changed, 2 deletions(-) diff --git a/Sources/MintCLI/Commands/BootstrapCommand.swift b/Sources/MintCLI/Commands/BootstrapCommand.swift index f7557a8..4aac61b 100644 --- a/Sources/MintCLI/Commands/BootstrapCommand.swift +++ b/Sources/MintCLI/Commands/BootstrapCommand.swift @@ -1,4 +1,3 @@ - import MintKit import SwiftCLI diff --git a/Sources/MintCLI/Commands/MintFileCommand.swift b/Sources/MintCLI/Commands/MintFileCommand.swift index 91a6cfd..1288c5b 100644 --- a/Sources/MintCLI/Commands/MintFileCommand.swift +++ b/Sources/MintCLI/Commands/MintFileCommand.swift @@ -1,4 +1,3 @@ - import PathKit import SwiftCLI From 16ec801925b932196e7bccdedce2e7fbc78c54e3 Mon Sep 17 00:00:00 2001 From: Pere Bohigas Date: Sat, 25 Jan 2025 15:15:54 +0100 Subject: [PATCH 3/5] Restrict access control --- Sources/MintCLI/Commands/BootstrapCommand.swift | 4 ++-- Sources/MintCLI/Commands/InstallCommand.swift | 11 ++++++----- Sources/MintCLI/Commands/ListCommand.swift | 2 +- Sources/MintCLI/Commands/MintFileCommand.swift | 4 ++-- Sources/MintCLI/Commands/PackageCommand.swift | 5 +++-- Sources/MintCLI/Commands/RunCommand.swift | 2 +- Sources/MintCLI/Commands/UninstallCommand.swift | 5 +++-- Sources/MintCLI/Commands/WhichCommand.swift | 5 +++-- Sources/MintCLI/MintCLI.swift | 6 +++--- Sources/MintKit/InstallStatus.swift | 2 +- Sources/MintKit/Mint.swift | 16 ++++++++-------- 11 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Sources/MintCLI/Commands/BootstrapCommand.swift b/Sources/MintCLI/Commands/BootstrapCommand.swift index 4aac61b..78be8cb 100644 --- a/Sources/MintCLI/Commands/BootstrapCommand.swift +++ b/Sources/MintCLI/Commands/BootstrapCommand.swift @@ -1,10 +1,10 @@ import MintKit import SwiftCLI -class BootstrapCommand: MintfileCommand { +final class BootstrapCommand: MintfileCommand { @Key("-o", "--overwrite", description: "Automatically overwrite a symlinked executable that is not installed by mint without asking. Either (y/n)") - var overwrite: Bool? + private var overwrite: Bool? init(mint: Mint) { super.init(mint: mint, diff --git a/Sources/MintCLI/Commands/InstallCommand.swift b/Sources/MintCLI/Commands/InstallCommand.swift index f896606..b6d2190 100644 --- a/Sources/MintCLI/Commands/InstallCommand.swift +++ b/Sources/MintCLI/Commands/InstallCommand.swift @@ -1,18 +1,19 @@ import MintKit import SwiftCLI -class InstallCommand: PackageCommand { +final class InstallCommand: PackageCommand { - @Param var executable: String? + @Param + private var executable: String? @Flag("-n", "--no-link", description: "Whether to prevent global linkage") - var noLink: Bool + private var noLink: Bool @Flag("-f", "--force", description: "Force a reinstall even if the package is already installed") - var force: Bool + private var force: Bool @Key("-o", "--overwrite", description: "Automatically overwrite a symlinked executable that is not installed by mint without asking. Either (y/n)") - var overwrite: Bool? + private var overwrite: Bool? init(mint: Mint) { super.init(mint: mint, diff --git a/Sources/MintCLI/Commands/ListCommand.swift b/Sources/MintCLI/Commands/ListCommand.swift index 2d853b3..a3a5236 100644 --- a/Sources/MintCLI/Commands/ListCommand.swift +++ b/Sources/MintCLI/Commands/ListCommand.swift @@ -1,6 +1,6 @@ import MintKit -class ListCommand: MintCommand { +final class ListCommand: MintCommand { init(mint: Mint) { super.init(mint: mint, diff --git a/Sources/MintCLI/Commands/MintFileCommand.swift b/Sources/MintCLI/Commands/MintFileCommand.swift index 1288c5b..e9d3d80 100644 --- a/Sources/MintCLI/Commands/MintFileCommand.swift +++ b/Sources/MintCLI/Commands/MintFileCommand.swift @@ -4,13 +4,13 @@ import SwiftCLI class MintfileCommand: MintCommand { @Flag("-v", "--verbose", description: "Show verbose output") - var verbose: Bool + private var verbose: Bool @Flag("-l", "--link", description: "Install the packages of the Mintfile globally") var link: Bool @Key("-m", "--mintfile", description: "Custom path to a Mintfile. Defaults to Mintfile") - var mintFile: String? + private var mintFile: String? override func execute() throws { try super.execute() diff --git a/Sources/MintCLI/Commands/PackageCommand.swift b/Sources/MintCLI/Commands/PackageCommand.swift index aa7c075..67fdb90 100644 --- a/Sources/MintCLI/Commands/PackageCommand.swift +++ b/Sources/MintCLI/Commands/PackageCommand.swift @@ -3,10 +3,11 @@ import SwiftCLI class PackageCommand: MintfileCommand { - @Param var package: String + @Param + private var package: String @Flag("-s", "--silent", description: "Silences any output from Mint itself") - var silent: Bool + private var silent: Bool init(mint: Mint, name: String, description: String, parameterDescription: String? = nil) { var longDescription = """ diff --git a/Sources/MintCLI/Commands/RunCommand.swift b/Sources/MintCLI/Commands/RunCommand.swift index d3ba743..ce11f69 100644 --- a/Sources/MintCLI/Commands/RunCommand.swift +++ b/Sources/MintCLI/Commands/RunCommand.swift @@ -1,7 +1,7 @@ import MintKit import SwiftCLI -class RunCommand: PackageCommand { +final class RunCommand: PackageCommand { @CollectedParam var arguments: [String] diff --git a/Sources/MintCLI/Commands/UninstallCommand.swift b/Sources/MintCLI/Commands/UninstallCommand.swift index 62878f1..b3f2052 100644 --- a/Sources/MintCLI/Commands/UninstallCommand.swift +++ b/Sources/MintCLI/Commands/UninstallCommand.swift @@ -1,9 +1,10 @@ import MintKit import SwiftCLI -class UninstallCommand: MintCommand { +final class UninstallCommand: MintCommand { - @Param var package: String + @Param + private var package: String init(mint: Mint) { super.init(mint: mint, name: "uninstall", description: "Uninstall a package by name") diff --git a/Sources/MintCLI/Commands/WhichCommand.swift b/Sources/MintCLI/Commands/WhichCommand.swift index 7dfdcc2..140af1e 100644 --- a/Sources/MintCLI/Commands/WhichCommand.swift +++ b/Sources/MintCLI/Commands/WhichCommand.swift @@ -1,9 +1,10 @@ import MintKit import SwiftCLI -class WhichCommand: PackageCommand { +final class WhichCommand: PackageCommand { - @Param var executable: String? + @Param + private var executable: String? init(mint: Mint) { super.init(mint: mint, diff --git a/Sources/MintCLI/MintCLI.swift b/Sources/MintCLI/MintCLI.swift index 6dc639a..9d63d12 100644 --- a/Sources/MintCLI/MintCLI.swift +++ b/Sources/MintCLI/MintCLI.swift @@ -5,10 +5,10 @@ import SwiftCLI public class MintCLI { - public let version = "0.17.5" + private let version = "0.17.5" - let mint: Mint - let cli: CLI + private let mint: Mint + private let cli: CLI public init() { diff --git a/Sources/MintKit/InstallStatus.swift b/Sources/MintKit/InstallStatus.swift index f0f339a..ab7f676 100644 --- a/Sources/MintKit/InstallStatus.swift +++ b/Sources/MintKit/InstallStatus.swift @@ -3,7 +3,7 @@ import PathKit struct InstallStatus { let status: Status - let path: Path + private let path: Path init(path: Path, mintPackagesPath: Path) throws { self.path = path diff --git a/Sources/MintKit/Mint.swift b/Sources/MintKit/Mint.swift index c8c9772..383a58e 100644 --- a/Sources/MintKit/Mint.swift +++ b/Sources/MintKit/Mint.swift @@ -38,11 +38,11 @@ public class Mint { self.mintFilePath = mintFilePath } - func output(_ string: String) { + private func output(_ string: String) { standardOut.print("🌱 \(string)") } - func errorOutput(_ string: String) { + private func errorOutput(_ string: String) { standardError.print("🌱 \(string)") } @@ -55,7 +55,7 @@ public class Mint { var packages: [String: String] } - func writeMetadata(_ metadata: Metadata) throws { + private func writeMetadata(_ metadata: Metadata) throws { let data = try JSONEncoder().encode(metadata) try metadataPath.write(data) } @@ -68,13 +68,13 @@ public class Mint { return try JSONDecoder().decode(Metadata.self, from: data) } - func addPackage(git: String, path: Path) throws { + private func addPackage(git: String, path: Path) throws { var metadata = try readMetadata() metadata.packages[git] = path.lastComponent try writeMetadata(metadata) } - func getGitRepos(name: String) throws -> [String] { + private func getGitRepos(name: String) throws -> [String] { let metadata = try readMetadata() let gitRepos = metadata.packages @@ -118,7 +118,7 @@ public class Mint { /// return whether the version was resolved remotely @discardableResult - func resolvePackage(_ package: PackageReference) throws -> Bool { + private func resolvePackage(_ package: PackageReference) throws -> Bool { // resolve repo and version from MintFile if mintFilePath.exists, @@ -227,7 +227,7 @@ public class Mint { return packagePath.executablePath } - func getPackagePath(for package: PackageReference, with arguments: inout [String], executable: String?) throws -> PackagePath { + private func getPackagePath(for package: PackageReference, with arguments: inout [String], executable: String?) throws -> PackagePath { var packagePath = PackagePath(path: packagesPath, package: package) if let executable = executable { @@ -455,7 +455,7 @@ public class Mint { } } - func linkPackage(_ package: PackageReference, executable: String, overwrite: Bool?) throws { + private func linkPackage(_ package: PackageReference, executable: String, overwrite: Bool?) throws { let packagePath = PackagePath(path: packagesPath, package: package, executable: executable) let installPath = linkPath + packagePath.executable! From 416023e417ebabf3f19bf3fc9b53432a00955c03 Mon Sep 17 00:00:00 2001 From: Pere Bohigas Date: Wed, 29 Jan 2025 23:09:54 +0100 Subject: [PATCH 4/5] Bump GitHub actions --- .github/workflows/swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 45999b9..1d67992 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -13,8 +13,8 @@ jobs: os: [ubuntu-latest, macos-latest] swift: ["5.9.0"] steps: - - uses: actions/checkout@v2 - - uses: swift-actions/setup-swift@v1 + - uses: actions/checkout@v4 + - uses: swift-actions/setup-swift@v2 with: swift-version: ${{ matrix.swift }} - name: Resolve From 21209d351ecb0fb2924b39f9e33df5c8c448f1a8 Mon Sep 17 00:00:00 2001 From: Pere Bohigas Date: Thu, 30 Jan 2025 11:46:59 +0100 Subject: [PATCH 5/5] Bump workflow environment's Swift version --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 1d67992..e78fb75 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - swift: ["5.9.0"] + swift: ["6.0.2"] steps: - uses: actions/checkout@v4 - uses: swift-actions/setup-swift@v2