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
9 changes: 9 additions & 0 deletions Package.resolved

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

2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let package = Package(
.package(url: "https://github.com/Quick/Quick.git", exact: "7.5.0"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.6.1"),
.package(url: "https://github.com/apple/swift-atomics.git", revision: "239a74d140e0a9dd84fde414260a8c062480550c"),
.package(url: "https://github.com/apple/swift-collections.git", .upToNextMinor(from: "1.1.6")),
.package(url: "https://github.com/funky-monkey/IsoCountryCodes.git", from: "1.0.3"),
.package(url: "https://github.com/mxcl/Version.git", from: "2.2.0"),
],
Expand All @@ -27,6 +28,7 @@ let package = Package(
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "Collections", package: "swift-collections"),
"IsoCountryCodes",
"Version",
],
Expand Down
17 changes: 9 additions & 8 deletions Sources/mas/Commands/Uninstall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

internal import ArgumentParser
private import Collections
private import ScriptingBridge

extension MAS {
Expand Down Expand Up @@ -35,25 +36,25 @@ extension MAS {
throw MASError.runtimeError("Apps installed from the Mac App Store require root permission to remove")
}

let uninstallingAppSet = try uninstallingAppSet(fromInstalledApps: installedApps, printer: printer)
guard !uninstallingAppSet.isEmpty else {
let uninstallingApps = try uninstallingApps(fromInstalledApps: installedApps, printer: printer)
guard !uninstallingApps.isEmpty else {
return
}

if dryRun {
for installedApp in uninstallingAppSet {
for installedApp in uninstallingApps {
printer.notice("'", installedApp.name, "' '", installedApp.path, "'", separator: "")
}
printer.notice("(not removed, dry run)")
} else {
try uninstallApps(atPaths: uninstallingAppSet.map(\.path), printer: printer)
try uninstallApps(atPaths: uninstallingApps.map(\.path), printer: printer)
}
}

private func uninstallingAppSet(
private func uninstallingApps(
fromInstalledApps installedApps: [InstalledApp],
printer: Printer
) throws -> Set<InstalledApp> {
) throws -> [InstalledApp] {
guard let sudoGroupName = ProcessInfo.processInfo.sudoGroupName else {
throw MASError.runtimeError("Failed to get original group name")
}
Expand Down Expand Up @@ -86,14 +87,14 @@ extension MAS {
}
}

var uninstallingAppSet = Set<InstalledApp>()
var uninstallingAppSet = OrderedSet<InstalledApp>()
for appID in appIDsOptionGroup.appIDs {
let apps = installedApps.filter { $0.id == appID }
apps.isEmpty // swiftformat:disable:next indent
? printer.error(appID.notInstalledMessage)
: uninstallingAppSet.formUnion(apps)
}
return uninstallingAppSet
return Array(uninstallingAppSet)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/mas/Controllers/ITunesSearchAppStoreSearcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright © 2018 mas-cli. All rights reserved.
//

private import Collections
private import Foundation

/// Manages searching the MAS catalog.
Expand Down Expand Up @@ -60,7 +61,7 @@ struct ITunesSearchAppStoreSearcher: AppStoreSearcher {
let entities = [Entity.desktopSoftware]
#endif

var appSet = Set<SearchResult>()
var appSet = OrderedSet<SearchResult>()
for entity in entities {
appSet.formUnion(
try await getSearchResults(from: try searchURL(for: searchTerm, inRegion: region, ofEntity: entity))
Expand Down