From dcc63e05d726cb3842846461add890481440e49a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:45:38 -0500 Subject: [PATCH 1/4] Apple Silicon Github-hosted runner for build-test job --- .github/workflows/build-test.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 4ff503c..f6bb9e8 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -28,13 +28,10 @@ jobs: name: Build, Test, and Lint - # GitHub provided runners (in case we need to switch back) + # https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners - # runs-on: macos-latest - - # https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow - # https://github.com/mas-cli/mas/settings/actions/runners - runs-on: [self-hosted, macOS] + # https://github.com/mas-cli/mas/actions/runners + runs-on: macos-latest steps: # https://github.com/actions/checkout#usage From 1d3af6c96f017fb78f5ff765a38978f426e4451a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:57:23 -0500 Subject: [PATCH 2/4] Changed macos-latest to macos-14 because the former is currently an alias for macos-12 --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f6bb9e8..bb86855 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -31,7 +31,7 @@ jobs: # https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners # https://github.com/mas-cli/mas/actions/runners - runs-on: macos-latest + runs-on: macos-14 steps: # https://github.com/actions/checkout#usage From 152b324d2d871c3e94e3f54c6c3108255b6f0291 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 5 Feb 2024 02:52:45 -0500 Subject: [PATCH 3/4] Use swift-format release/5.9 for Swift compiler 5.8+ --- Package.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 4ac6156..f730174 100644 --- a/Package.swift +++ b/Package.swift @@ -71,7 +71,11 @@ let package = Package( ) // https://github.com/apple/swift-format#matching-swift-format-to-your-swift-version-swift-57-and-earlier -#if compiler(>=5.7) +#if compiler(>=5.8) + package.dependencies += [ + .package(url: "https://github.com/apple/swift-format", .branch("release/5.9")) + ] +#elseif compiler(>=5.7) package.dependencies += [ .package(url: "https://github.com/apple/swift-format", .branch("release/5.7")) ] From e6e2ccab0d4cf136a68b8cfd0c011d31ccb6f980 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:03:51 -0500 Subject: [PATCH 4/4] Updated swift source by running: swiftformat Sources Tests --- Sources/MasKit/AppStore/Downloader.swift | 4 ++-- Sources/MasKit/AppStore/SSPurchase.swift | 2 +- Sources/MasKit/Commands/Outdated.swift | 2 +- Sources/MasKit/Commands/Uninstall.swift | 2 +- Sources/MasKit/Controllers/MasStoreSearch.swift | 2 +- Sources/MasKit/Controllers/StoreSearch.swift | 4 ++-- Sources/MasKit/Errors/MASError.swift | 8 ++++---- Sources/MasKit/Formatters/AppInfoFormatter.swift | 2 +- Sources/MasKit/Formatters/AppListFormatter.swift | 2 +- Sources/MasKit/Formatters/SearchResultFormatter.swift | 2 +- Sources/MasKit/Formatters/Utilities.swift | 6 +++--- Sources/MasKit/Network/URLSession+NetworkSession.swift | 4 ++-- Tests/MasKitTests/Network/NetworkSessionMock.swift | 2 +- Tests/MasKitTests/Nimble/ResultPredicates.swift | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Sources/MasKit/AppStore/Downloader.swift b/Sources/MasKit/AppStore/Downloader.swift index 650229d..ca6530c 100644 --- a/Sources/MasKit/AppStore/Downloader.swift +++ b/Sources/MasKit/AppStore/Downloader.swift @@ -81,12 +81,12 @@ private func download(_ appID: UInt64, purchase: Bool = false) -> Promise return Promise { seal in let purchase = SSPurchase(adamId: appID, account: storeAccount, purchase: purchase) purchase.perform { purchase, _, error, response in - if let error = error { + if let error { seal.reject(MASError.purchaseFailed(error: error as NSError?)) return } - guard response?.downloads.isEmpty == false, let purchase = purchase else { + guard response?.downloads.isEmpty == false, let purchase else { print("No downloads") seal.reject(MASError.noDownloads) return diff --git a/Sources/MasKit/AppStore/SSPurchase.swift b/Sources/MasKit/AppStore/SSPurchase.swift index 75ba249..c3d3dcb 100644 --- a/Sources/MasKit/AppStore/SSPurchase.swift +++ b/Sources/MasKit/AppStore/SSPurchase.swift @@ -41,7 +41,7 @@ extension SSPurchase { itemIdentifier = adamId - if let account = account { + if let account { accountIdentifier = account.dsID appleID = account.identifier } diff --git a/Sources/MasKit/Commands/Outdated.swift b/Sources/MasKit/Commands/Outdated.swift index fbb1aa7..e433d78 100644 --- a/Sources/MasKit/Commands/Outdated.swift +++ b/Sources/MasKit/Commands/Outdated.swift @@ -41,7 +41,7 @@ public struct OutdatedCommand: CommandProtocol { firstly { storeSearch.lookup(app: installedApp.itemIdentifier.intValue) }.done { storeApp in - guard let storeApp = storeApp else { + guard let storeApp else { if options.verbose { printWarning( """ diff --git a/Sources/MasKit/Commands/Uninstall.swift b/Sources/MasKit/Commands/Uninstall.swift index ebf0111..97d3767 100644 --- a/Sources/MasKit/Commands/Uninstall.swift +++ b/Sources/MasKit/Commands/Uninstall.swift @@ -1,5 +1,5 @@ // -// Upgrade.swift +// Uninstall.swift // mas-cli // // Created by Ben Chatelain on 2018-12-27. diff --git a/Sources/MasKit/Controllers/MasStoreSearch.swift b/Sources/MasKit/Controllers/MasStoreSearch.swift index feb9d37..2f14575 100644 --- a/Sources/MasKit/Controllers/MasStoreSearch.swift +++ b/Sources/MasKit/Controllers/MasStoreSearch.swift @@ -76,7 +76,7 @@ class MasStoreSearch: StoreSearch { return firstly { self.scrapeVersionFromPage(pageUrl) }.done { pageVersion in - if let pageVersion = pageVersion, pageVersion > searchVersion { + if let pageVersion, pageVersion > searchVersion { results[index].version = pageVersion.description } } diff --git a/Sources/MasKit/Controllers/StoreSearch.swift b/Sources/MasKit/Controllers/StoreSearch.swift index 4fcb5a2..37795a4 100644 --- a/Sources/MasKit/Controllers/StoreSearch.swift +++ b/Sources/MasKit/Controllers/StoreSearch.swift @@ -32,7 +32,7 @@ extension StoreSearch { URLQueryItem(name: "term", value: appName), ] - if let country = country { + if let country { components.queryItems!.append(country) } @@ -50,7 +50,7 @@ extension StoreSearch { components.queryItems = [URLQueryItem(name: "id", value: "\(appId)")] - if let country = country { + if let country { components.queryItems!.append(country) } diff --git a/Sources/MasKit/Errors/MASError.swift b/Sources/MasKit/Errors/MASError.swift index 8217f8b..4fc0648 100644 --- a/Sources/MasKit/Errors/MASError.swift +++ b/Sources/MasKit/Errors/MASError.swift @@ -1,5 +1,5 @@ // -// MAError.swift +// MASError.swift // mas-cli // // Created by Andrew Naylor on 21/08/2015. @@ -47,7 +47,7 @@ extension MASError: CustomStringConvertible { """ case .signInFailed(let error): - if let error = error { + if let error { return "Sign in failed: \(error.localizedDescription)" } else { return "Sign in failed" @@ -57,14 +57,14 @@ extension MASError: CustomStringConvertible { return "Already signed in" case .purchaseFailed(let error): - if let error = error { + if let error { return "Download request failed: \(error.localizedDescription)" } else { return "Download request failed" } case .downloadFailed(let error): - if let error = error { + if let error { return "Download failed: \(error.localizedDescription)" } else { return "Download failed" diff --git a/Sources/MasKit/Formatters/AppInfoFormatter.swift b/Sources/MasKit/Formatters/AppInfoFormatter.swift index 91fefd0..6810cfd 100644 --- a/Sources/MasKit/Formatters/AppInfoFormatter.swift +++ b/Sources/MasKit/Formatters/AppInfoFormatter.swift @@ -9,7 +9,7 @@ import Foundation /// Formats text output for the info command. -struct AppInfoFormatter { +enum AppInfoFormatter { /// Formats text output with app info. /// /// - Parameter app: Search result with app data. diff --git a/Sources/MasKit/Formatters/AppListFormatter.swift b/Sources/MasKit/Formatters/AppListFormatter.swift index 158d7fc..e147595 100644 --- a/Sources/MasKit/Formatters/AppListFormatter.swift +++ b/Sources/MasKit/Formatters/AppListFormatter.swift @@ -9,7 +9,7 @@ import Foundation /// Formats text output for the search command. -struct AppListFormatter { +enum AppListFormatter { static let idColumnMinWidth = 10 static let nameColumnMinWidth = 50 diff --git a/Sources/MasKit/Formatters/SearchResultFormatter.swift b/Sources/MasKit/Formatters/SearchResultFormatter.swift index d3e279c..03160cf 100644 --- a/Sources/MasKit/Formatters/SearchResultFormatter.swift +++ b/Sources/MasKit/Formatters/SearchResultFormatter.swift @@ -9,7 +9,7 @@ import Foundation /// Formats text output for the search command. -struct SearchResultFormatter { +enum SearchResultFormatter { /// Formats text output with search results. /// /// - Parameter results: Search results with app data diff --git a/Sources/MasKit/Formatters/Utilities.swift b/Sources/MasKit/Formatters/Utilities.swift index f76a8e6..33f3b67 100644 --- a/Sources/MasKit/Formatters/Utilities.swift +++ b/Sources/MasKit/Formatters/Utilities.swift @@ -43,12 +43,12 @@ let csi = "\u{001B}[" Swift.print(terminator, terminator: "") } - func print( + func print( _ items: Any..., separator: String = " ", terminator: String = "\n", - to output: inout Target - ) where Target: TextOutputStream { + to output: inout some TextOutputStream + ) { if let observer = printObserver { let output = items diff --git a/Sources/MasKit/Network/URLSession+NetworkSession.swift b/Sources/MasKit/Network/URLSession+NetworkSession.swift index d1e9570..7c15df0 100644 --- a/Sources/MasKit/Network/URLSession+NetworkSession.swift +++ b/Sources/MasKit/Network/URLSession+NetworkSession.swift @@ -13,9 +13,9 @@ extension URLSession: NetworkSession { public func loadData(from url: URL) -> Promise { Promise { seal in dataTask(with: url) { data, _, error in - if let data = data { + if let data { seal.fulfill(data) - } else if let error = error { + } else if let error { seal.reject(error) } else { seal.reject(MASError.noData) diff --git a/Tests/MasKitTests/Network/NetworkSessionMock.swift b/Tests/MasKitTests/Network/NetworkSessionMock.swift index 8715858..4be4b1b 100644 --- a/Tests/MasKitTests/Network/NetworkSessionMock.swift +++ b/Tests/MasKitTests/Network/NetworkSessionMock.swift @@ -24,7 +24,7 @@ class NetworkSessionMock: NetworkSession { /// - url: unused /// - completionHandler: Closure which is delivered either data or an error. func loadData(from _: URL) -> Promise { - guard let data = data else { + guard let data else { return Promise(error: error ?? MASError.noData) } diff --git a/Tests/MasKitTests/Nimble/ResultPredicates.swift b/Tests/MasKitTests/Nimble/ResultPredicates.swift index 4a9c1da..209a3f6 100644 --- a/Tests/MasKitTests/Nimble/ResultPredicates.swift +++ b/Tests/MasKitTests/Nimble/ResultPredicates.swift @@ -1,5 +1,5 @@ // -// ResultPreticates.swift +// ResultPredicates.swift // MasKitTests // // Created by Ben Chatelain on 12/27/18.