Skip to content
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
2 changes: 1 addition & 1 deletion .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# .markdownlint-cli2.yaml
# mas
#
# markdownlint-cli2 0.20.0 / markdownlint 0.40.0
# markdownlint-cli2 0.21.0 / markdownlint 0.40.0
#
---
gitignore: true
Expand Down
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ brew "actionlint" # 1.7.11
brew "gh" # 2.86.0
brew "git" # 2.53.0
brew "ipsw" # 3.1.651
brew "markdownlint-cli2" # 0.20.0
brew "markdownlint-cli2" # 0.21.0
brew "periphery" if MacOS.version >= :sequoia && `/usr/bin/arch` == "arm64" # 3.5.1
brew "shellcheck" # 0.11.0
brew "swiftformat" # 0.59.1
Expand Down
11 changes: 1 addition & 10 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ _ = Package(
dependencies: [
.package(url: "https://github.com/KittyMac/Sextant.git", from: "0.4.38"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.1.2"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.3.0"),
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.7.0"),
Expand All @@ -33,7 +32,6 @@ _ = Package(
name: "mas",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "OrderedCollections", package: "swift-collections"),
"BigInt",
Expand Down
12 changes: 1 addition & 11 deletions Scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ print_notice '🧹 Formatting' "${@}"

ensure_command_available markdownlint-cli2 swiftformat swiftlint

zmodload zsh/zutil
zparseopts -D -A received_flag A

export -r MAS_DISTRIBUTION=format

printf -- $'--> 🕊​ SwiftFormat\n'
Expand All @@ -28,15 +25,8 @@ script -q /dev/null swiftformat --strict --markdown-files format-strict . |
printf -- $'--> 🦅 SwiftLint\n'
swiftlint --fix --quiet --reporter relative-path

# shellcheck disable=SC1046,SC1047,SC1072,SC1073
if ! [[ -v 'received_flag[-A]' ]]; then
printf -- $'--> 🔬 SwiftLint Analyze\n'
# shellcheck disable=SC1036
swiftlint analyze --fix --quiet --reporter relative-path --compiler-log-path\
=(xcodebuild -scheme mas -destination "platform=macOS,arch=$(arch),variant=macos" 2>&1)
fi

printf -- $'--> 〽️ Markdown\n'
# shellcheck disable=SC1036
markdownlint-cli2 --fix -- ***/*.md(.)

printf -- $'--> 🚷 Non-Executables\n'
Expand Down
14 changes: 3 additions & 11 deletions Scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
# Please keep in sync with Scripts/format.
#

# shellcheck disable=SC1036,SC1056,SC1072
. "${0:A:h}/_setup_script"

print_notice '🚨 Linting' "${@}"

ensure_command_available actionlint git markdownlint-cli2 shellcheck swiftformat swiftlint yamllint || exit
[[ "$(/usr/bin/arch)" = arm64 && "${$(sw_vers -productVersion)%%.*}" -ge 15 ]]
integer -r can_use_periphery="$((! ?))"
# shellcheck disable=SC1083
# shellcheck disable=SC1073,SC1083
((can_use_periphery)) && { ensure_command_available periphery || exit }

zmodload zsh/zutil
zparseopts -D -A received_flag A P
zparseopts -D -A received_flag P

export -r MAS_DISTRIBUTION=lint

Expand All @@ -36,15 +37,6 @@ printf -- $'--> 🦅 SwiftLint\n'
swiftlint --strict --quiet --reporter relative-path
((exit_status |= ${?}))

# shellcheck disable=SC1046,SC1047,SC1072,SC1073
if ! [[ -v 'received_flag[-A]' ]]; then
printf -- $'--> 🔬 SwiftLint Analyze\n'
# shellcheck disable=SC1036
swiftlint analyze --strict --quiet --reporter relative-path --compiler-log-path\
=(xcodebuild -scheme mas -destination "platform=macOS,arch=$(arch),variant=macos" 2>&1)
((exit_status |= ${?}))
fi

if ((can_use_periphery)) && ! [[ -v 'received_flag[-P]' ]]; then
printf -- $'--> 🌀 Periphery\n'
periphery scan --exclude-tests |
Expand Down
6 changes: 3 additions & 3 deletions Sources/mas/AppStore/AppStoreAction+download.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,16 @@ private actor DownloadQueueObserver: CKDownloadQueueObserver {

guard
let appFolderURLSubstring = standardErrorString
.matches(of: unsafe appFolderURLRegex) // swiftformat:disable:next preferKeyPath
.compactMap({ $0.1 }) // swiftlint:disable:this prefer_key_path
.matches(of: unsafe appFolderURLRegex)
.compactMap(\.1)
.min(by: { $0.count < $1.count })
else {
throw MASError.error(
"Failed to find app folder URL in installer output for \(appNameAndVersion)",
error: standardErrorString,
)
}
guard let appFolderURL = URL(string: String(appFolderURLSubstring)) else {
guard let appFolderURL = URL(string: .init(appFolderURLSubstring)) else {
throw MASError.error(
"Failed to parse app folder URL for \(appNameAndVersion) from \(appFolderURLSubstring)",
error: standardErrorString,
Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/AppStore/AppStoreAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum AppStoreAction: Sendable {
withAppIDs appIDs: [AppID],
force: Bool,
installedApps: [InstalledApp],
lookupAppFromAppID: (AppID) async throws -> CatalogApp,
lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp,
) async throws {
try await apps(
withADAMIDs: await appIDs.lookupCatalogApps(using: lookupAppFromAppID).map(\.adamID),
Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Commands/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension MAS {
await run(lookupAppFromAppID: lookup(appID:))
}

private func run(lookupAppFromAppID: (AppID) async throws -> CatalogApp) async {
private func run(lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp) async {
await run(catalogApps: await catalogAppIDsOptionGroup.appIDs.lookupCatalogApps(using: lookupAppFromAppID))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Commands/Lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension MAS {
await run(lookupAppFromAppID: lookup(appID:))
}

private func run(lookupAppFromAppID: (AppID) async throws -> CatalogApp) async {
private func run(lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp) async {
run(catalogApps: await catalogAppIDsOptionGroup.appIDs.lookupCatalogApps(using: lookupAppFromAppID))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Commands/MAS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct MAS: AsyncParsableCommand, Sendable {

let errorCount = printer.errorCount
if errorCount > 0 {
throw ExitCode(errorCount >= UInt64(Int32.max) ? Int32.max : Int32(errorCount))
throw ExitCode(errorCount >= UInt64(Int32.max) ? .max : .init(errorCount))
}
} catch {
exit(withError: error)
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Open.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension MAS {

@OptionGroup
private var forceBundleIDOptionGroup: ForceBundleIDOptionGroup
@Argument(help: ArgumentHelp("App ID", valueName: "app-id"))
@Argument(help: .init("App ID", valueName: "app-id"))
private var appIDString: String?

func run() async throws {
Expand Down Expand Up @@ -67,7 +67,7 @@ private func openMacAppStore() async throws {
throw MASError.error("Failed to find app to open macappstore URLs")
}

try await workspace.openApplication(at: appURL, configuration: NSWorkspace.OpenConfiguration())
try await workspace.openApplication(at: appURL, configuration: .init())
}

private func openMacAppStorePage(forAppStorePageURLString appStorePageURLString: String) async throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal import ArgumentParser
struct CatalogAppIDsOptionGroup: ParsableArguments {
@OptionGroup
private var forceBundleIDOptionGroup: ForceBundleIDOptionGroup
@Argument(help: ArgumentHelp("App ID", valueName: "app-id"))
@Argument(help: .init("App ID", valueName: "app-id"))
private var appIDStrings: [String]

var appIDs: [AppID] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal import ArgumentParser
struct InstalledAppIDsOptionGroup: ParsableArguments {
@OptionGroup
private var forceBundleIDOptionGroup: ForceBundleIDOptionGroup
@Argument(help: ArgumentHelp("App ID", valueName: "app-id"))
@Argument(help: .init("App ID", valueName: "app-id"))
private var appIDStrings = [String]()

var appIDs: [AppID] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
internal import ArgumentParser

struct SearchTermOptionGroup: ParsableArguments {
@Argument(help: ArgumentHelp("Search terms are concatenated into a single search", valueName: "search-term"))
@Argument(help: .init("Search terms are concatenated into a single search", valueName: "search-term"))
private var searchTermElements: [String]

var searchTerm: String {
Expand Down
8 changes: 5 additions & 3 deletions Sources/mas/Commands/Outdated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ extension MAS {
await run(installedApps: try await installedApps.filter(!\.isTestFlight), lookupAppFromAppID: lookup(appID:))
}

private func run(installedApps: [InstalledApp], lookupAppFromAppID: (AppID) async throws -> CatalogApp) async {
private func run(
installedApps: [InstalledApp],
lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp,
) async {
run(
outdatedApps: await outdatedApps(
from: installedApps,
outdatedApps: await installedApps.outdatedApps(
filterFor: installedAppIDsOptionGroup.appIDs,
lookupAppFromAppID: lookupAppFromAppID,
accuracy: accuracyOptionGroup.accuracy,
Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Commands/Reset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension MAS {
return
}

var executablePathBuffer = [CChar](repeating: 0, count: Int(PATH_MAX))
var executablePathBuffer = [CChar](repeating: 0, count: .init(PATH_MAX))
for pid in unsafe kinfoProcs.map(\.kp_proc.p_pid) {
guard
unsafe proc_pidpath(pid, &executablePathBuffer, UInt32(executablePathBuffer.count)) > 0,
Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Commands/Seller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension MAS {
await run(lookupAppFromAppID: lookup(appID:))
}

private func run(lookupAppFromAppID: (AppID) async throws -> CatalogApp) async {
private func run(lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp) async {
await run(catalogApps: await catalogAppIDsOptionGroup.appIDs.lookupCatalogApps(using: lookupAppFromAppID))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Commands/Uninstall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension MAS {

var uninstalledAppNSURL = NSURL?.none // swiftlint:disable:this legacy_objc_type
try unsafe fileManager.trashItem(
at: URL(filePath: appPath, directoryHint: .isDirectory),
at: .init(filePath: appPath, directoryHint: .isDirectory),
resultingItemURL: &uninstalledAppNSURL,
)
guard let uninstalledAppPath = uninstalledAppNSURL?.path else {
Expand Down
9 changes: 5 additions & 4 deletions Sources/mas/Commands/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ extension MAS {
try await run(installedApps: try await installedApps.filter(!\.isTestFlight), lookupAppFromAppID: lookup(appID:))
}

private func run(installedApps: [InstalledApp], lookupAppFromAppID: (AppID) async throws -> CatalogApp)
async throws { // swiftformat:disable:this indent
private func run(
installedApps: [InstalledApp],
lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp,
) async throws {
try await run(
outdatedApps: forceOptionGroup.force // swiftformat:disable:next indent
? installedApps.filter(for: installedAppIDsOptionGroup.appIDs).map { ($0, "") }
: await outdatedApps(
from: installedApps,
: await installedApps.outdatedApps(
filterFor: installedAppIDsOptionGroup.appIDs,
lookupAppFromAppID: lookupAppFromAppID,
accuracy: accuracyOptionGroup.accuracy,
Expand Down
11 changes: 4 additions & 7 deletions Sources/mas/Controllers/CatalogApp+ITunesSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Copyright © 2018 mas-cli. All rights reserved.
//

private import AsyncAlgorithms
internal import Foundation
private import Sextant
private import SwiftSoup
Expand Down Expand Up @@ -33,7 +32,7 @@ func lookup(
let queryItem =
switch appID {
case let .adamID(adamID):
URLQueryItem(name: "id", value: String(adamID))
URLQueryItem(name: "id", value: .init(adamID))
case let .bundleID(bundleID):
URLQueryItem(name: "bundleId", value: bundleID)
}
Expand Down Expand Up @@ -63,7 +62,7 @@ private extension CatalogApp {
do {
return try await URL(string: appStorePageURLString)
.flatMap { url in // swiftformat:disable indent
try SwiftSoup.parse(try await dataFrom(url).0, appStorePageURLString)
try unsafe SwiftSoup.parse(try await dataFrom(url).0, appStorePageURLString)
.select("#serialized-server-data")
.first()?
.data()
Expand Down Expand Up @@ -109,9 +108,7 @@ func search(
dataFrom: dataSource,
)
.filter { ($0.supportedDevices?.contains("MacDesktop-MacDesktop") ?? false) && !adamIDSet.contains($0.adamID) }
.async
.map { $0.with(minimumOSVersion: await $0.minimumOSVersion(dataFrom: dataSource)) }
.array,
.concurrentMap { $0.with(minimumOSVersion: await $0.minimumOSVersion(dataFrom: dataSource)) },
) { $0.name.similarity(to: searchTerm) }
}

Expand Down Expand Up @@ -142,7 +139,7 @@ async throws -> [CatalogApp] { // swiftformat:disable:this indent
do {
return try JSONDecoder().decode(CatalogAppResults.self, from: data).results
} catch {
throw MASError.error("Failed to parse JSON from response \(url)", error: String(data: data, encoding: .utf8) ?? "")
throw MASError.error("Failed to parse JSON from response \(url)", error: .init(data: data, encoding: .utf8) ?? "")
}
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/mas/Models/AppID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ enum AppID: CustomStringConvertible, Sendable {
}

extension [AppID] { // swiftlint:disable:this file_types_order
func lookupCatalogApps(using lookupAppFromAppID: (AppID) async throws -> CatalogApp) async -> [CatalogApp] {
await compactMap(attemptingTo: "lookup app for", lookupAppFromAppID)
func lookupCatalogApps(using lookupAppFromAppID: @escaping @Sendable (AppID) async throws -> CatalogApp)
async -> [CatalogApp] { // swiftformat:disable:this indent
await concurrentCompactMap(attemptingTo: "lookup app for", lookupAppFromAppID)
}
}

Expand Down
Loading
Loading