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 Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
brew "actionlint" # 1.7.9
brew "actionlint" # 1.7.10
brew "gh" # 2.83.2
brew "git" # 2.52.0
brew "ipsw" # 3.1.647
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Get.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ extension MAS {
@OptionGroup
private var forceOptionGroup: ForceOptionGroup
@OptionGroup
private var requiredAppIDsOptionGroup: RequiredAppIDsOptionGroup
private var catalogAppIDsOptionGroup: CatalogAppIDsOptionGroup

func run() async throws {
try await AppStore.get.apps(
withAppIDs: requiredAppIDsOptionGroup.appIDs,
withAppIDs: catalogAppIDsOptionGroup.appIDs,
force: forceOptionGroup.force,
installedApps: try await installedApps,
lookupAppFromAppID: lookup(appID:),
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ extension MAS {
)

@OptionGroup
private var requiredAppIDsOptionGroup: RequiredAppIDsOptionGroup
private var catalogAppIDsOptionGroup: CatalogAppIDsOptionGroup

func run() async {
await run(lookupAppFromAppID: lookup(appID:))
}

private func run(lookupAppFromAppID: (AppID) async throws -> CatalogApp) async {
await run(
catalogApps: await requiredAppIDsOptionGroup.appIDs.lookupCatalogApps(lookupAppFromAppID: lookupAppFromAppID),
catalogApps: await catalogAppIDsOptionGroup.appIDs.lookupCatalogApps(lookupAppFromAppID: lookupAppFromAppID),
)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ extension MAS {
@OptionGroup
private var forceOptionGroup: ForceOptionGroup
@OptionGroup
private var requiredAppIDsOptionGroup: RequiredAppIDsOptionGroup
private var catalogAppIDsOptionGroup: CatalogAppIDsOptionGroup

func run() async throws {
try await AppStore.install.apps(
withAppIDs: requiredAppIDsOptionGroup.appIDs,
withAppIDs: catalogAppIDsOptionGroup.appIDs,
force: forceOptionGroup.force,
installedApps: try await installedApps,
lookupAppFromAppID: lookup(appID:),
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ extension MAS {
)

@OptionGroup
private var optionalAppIDsOptionGroup: OptionalAppIDsOptionGroup
private var installedAppIDsOptionGroup: InstalledAppIDsOptionGroup

func run() async throws {
run(installedApps: try await installedApps)
}

func run(installedApps: [InstalledApp]) {
let installedApps = installedApps.filter(for: optionalAppIDsOptionGroup.appIDs)
let installedApps = installedApps.filter(for: installedAppIDsOptionGroup.appIDs)
guard
let maxADAMIDLength = installedApps.map({ String(describing: $0.adamID).count }).max(),
let maxNameLength = installedApps.map(\.name.count).max()
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ extension MAS {
)

@OptionGroup
private var requiredAppIDsOptionGroup: RequiredAppIDsOptionGroup
private var catalogAppIDsOptionGroup: CatalogAppIDsOptionGroup

func run() async {
await run(lookupAppFromAppID: lookup(appID:))
}

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

func run(catalogApps: [CatalogApp]) { // swiftformat:disable:this organizeDeclarations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// RequiredAppIDsOptionGroup.swift
// CatalogAppIDsOptionGroup.swift
// mas
//
// Copyright © 2025 mas-cli. All rights reserved.
//

internal import ArgumentParser

struct RequiredAppIDsOptionGroup: ParsableArguments {
struct CatalogAppIDsOptionGroup: ParsableArguments {
@OptionGroup
private var forceBundleIDOptionGroup: ForceBundleIDOptionGroup
@Argument(help: ArgumentHelp("App ID", valueName: "app-id"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// OptionalAppIDsOptionGroup.swift
// InstalledAppIDsOptionGroup.swift
// mas
//
// Copyright © 2025 mas-cli. All rights reserved.
//

internal import ArgumentParser

struct OptionalAppIDsOptionGroup: ParsableArguments {
struct InstalledAppIDsOptionGroup: ParsableArguments {
@OptionGroup
private var forceBundleIDOptionGroup: ForceBundleIDOptionGroup
@Argument(help: ArgumentHelp("App ID", valueName: "app-id"))
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Outdated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension MAS {
@OptionGroup
private var verboseOptionGroup: VerboseOptionGroup
@OptionGroup
private var optionalAppIDsOptionGroup: OptionalAppIDsOptionGroup
private var installedAppIDsOptionGroup: InstalledAppIDsOptionGroup

func run() async throws {
await run(installedApps: try await installedApps.filter(!\.isTestFlight), lookupAppFromAppID: lookup(appID:))
Expand All @@ -34,7 +34,7 @@ extension MAS {
lookupAppFromAppID: lookupAppFromAppID,
accurateOptionGroup: accurateOptionGroup,
verboseOptionGroup: verboseOptionGroup,
optionalAppIDsOptionGroup: optionalAppIDsOptionGroup,
installedAppIDsOptionGroup: installedAppIDsOptionGroup,
),
)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/mas/Commands/Seller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ extension MAS {
)

@OptionGroup
private var requiredAppIDsOptionGroup: RequiredAppIDsOptionGroup
private var catalogAppIDsOptionGroup: CatalogAppIDsOptionGroup

func run() async {
await run(lookupAppFromAppID: lookup(appID:))
}

private func run(lookupAppFromAppID: (AppID) async throws -> CatalogApp) async {
await run(
catalogApps: await requiredAppIDsOptionGroup.appIDs.lookupCatalogApps(lookupAppFromAppID: lookupAppFromAppID),
catalogApps: await catalogAppIDsOptionGroup.appIDs.lookupCatalogApps(lookupAppFromAppID: lookupAppFromAppID),
)
}

Expand Down
14 changes: 9 additions & 5 deletions Sources/mas/Commands/Uninstall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ extension MAS {
)

/// Flag indicating that uninstall shouldn't be performed.
@Flag(help: "Perform dry run")
private var dryRun = false
@Flag(name: .customLong("dry-run"), help: "Perform dry run")
private var isPerformingDryRun = false
@Flag(name: .customLong("all"), help: "Uninstall all App Store apps")
private var isUninstallingAll = false
@OptionGroup
private var requiredAppIDsOptionGroup: RequiredAppIDsOptionGroup
private var installedAppIDsOptionGroup: InstalledAppIDsOptionGroup

func run() async throws {
try run(installedApps: try await installedApps)
}

private func run(installedApps: [InstalledApp]) throws {
let uninstallingAppByPath = requiredAppIDsOptionGroup.appIDs // swiftformat:disable indent
let uninstallingAppByPath = (
isUninstallingAll ? installedApps.map { AppID.adamID($0.adamID) } : installedAppIDsOptionGroup.appIDs,
) // swiftformat:disable indent
.reduce(into: OrderedDictionary<String, InstalledApp>()) { uninstallingAppByPath, appID in
let uninstallingApps = installedApps.filter { $0.matches(appID) }
guard !uninstallingApps.isEmpty else {
Expand All @@ -43,7 +47,7 @@ extension MAS {
guard !uninstallingAppByPath.isEmpty else { // swiftformat:enable indent
return
}
guard !dryRun else {
guard !isPerformingDryRun else {
printer.notice("Dry run. A wet run would uninstall:\n")
for appPath in uninstallingAppByPath.keys {
printer.info(appPath)
Expand Down
6 changes: 3 additions & 3 deletions Sources/mas/Commands/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension MAS {
@OptionGroup
private var verboseOptionGroup: VerboseOptionGroup
@OptionGroup
private var optionalAppIDsOptionGroup: OptionalAppIDsOptionGroup
private var installedAppIDsOptionGroup: InstalledAppIDsOptionGroup

func run() async throws {
try await run(installedApps: try await installedApps.filter(!\.isTestFlight), lookupAppFromAppID: lookup(appID:))
Expand All @@ -34,13 +34,13 @@ extension MAS {
async throws { // swiftformat:disable:this indent
try await run(
outdatedApps: forceOptionGroup.force // swiftformat:disable:next indent
? installedApps.filter(for: optionalAppIDsOptionGroup.appIDs).map { ($0, "") }
? installedApps.filter(for: installedAppIDsOptionGroup.appIDs).map { ($0, "") }
: await outdatedApps(
installedApps: installedApps,
lookupAppFromAppID: lookupAppFromAppID,
accurateOptionGroup: accurateOptionGroup,
verboseOptionGroup: verboseOptionGroup,
optionalAppIDsOptionGroup: optionalAppIDsOptionGroup,
installedAppIDsOptionGroup: installedAppIDsOptionGroup,
),
)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/mas/Models/OutdatedApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ func outdatedApps(
lookupAppFromAppID: (AppID) async throws -> CatalogApp,
accurateOptionGroup: AccurateOptionGroup,
verboseOptionGroup: VerboseOptionGroup,
optionalAppIDsOptionGroup: OptionalAppIDsOptionGroup,
installedAppIDsOptionGroup: InstalledAppIDsOptionGroup,
) async -> [OutdatedApp] {
await accurateOptionGroup.outdatedApps(
accurate: { shouldIgnoreUnknownApps in
await withTaskGroup { group in
let installedApps = await installedApps
.filter(for: optionalAppIDsOptionGroup.appIDs) // swiftformat:disable indent
.filter(for: installedAppIDsOptionGroup.appIDs) // swiftformat:disable indent
.filterOutApps(
unknownTo: lookupAppFromAppID,
if: shouldIgnoreUnknownApps,
Expand Down Expand Up @@ -147,7 +147,7 @@ func outdatedApps(
},
inaccurate: {
await installedApps
.filter(for: optionalAppIDsOptionGroup.appIDs) // swiftformat:disable indent
.filter(for: installedAppIDsOptionGroup.appIDs) // swiftformat:disable indent
.compactMap { installedApp in
do {
let catalogApp = try await lookupAppFromAppID(.adamID(installedApp.adamID))
Expand Down
6 changes: 3 additions & 3 deletions Sources/mas/Utilities/Version+SemVer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct UniversalSemVer: SemVerSyntax {
}
}

private extension BigInt {
private extension BigUInt {
func compare(to that: Self) -> ComparisonResult {
self < that ? .orderedAscending : self == that ? .orderedSame : .orderedDescending
}
Expand All @@ -176,8 +176,8 @@ private extension String {
range: Range<Self.Index>? = nil,
locale: Locale? = nil,
) -> ComparisonResult {
let selfInteger = BigInt(self)
let thatInteger = BigInt(that)
let selfInteger = BigUInt(self)
let thatInteger = BigUInt(that)
return selfInteger.map { thatInteger.map($0.compare(to:)) ?? .orderedAscending }
?? thatInteger.map { _ in .orderedDescending } // swiftformat:disable:this indent
?? compare(that, options: mask, range: range, locale: locale) // swiftformat:disable:this indent
Expand Down
Loading