2
0
Fork 0
mirror of https://github.com/mas-cli/mas synced 2025-03-06 23:57:21 +00:00

Revert SoftwareMapAppLibrary.swift to a class.

Partial 

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2025-01-02 08:46:12 -05:00
parent b9de23aa2a
commit e68ef510e0
No known key found for this signature in database

View file

@ -10,17 +10,24 @@ import CommerceKit
import ScriptingBridge
/// Utility for managing installed apps.
struct SoftwareMapAppLibrary: AppLibrary {
class SoftwareMapAppLibrary: AppLibrary {
/// CommerceKit's singleton manager of installed software.
private let softwareMap: SoftwareMap
/// Array of installed software products.
let installedApps: [SoftwareProduct]
lazy var installedApps = softwareMap.allSoftwareProducts()
.filter { product in
product.bundlePath.starts(with: "/Applications/")
}
/// Internal initializer for providing a mock software map.
/// - Parameter softwareMap: SoftwareMap to use
init(softwareMap: SoftwareMap = CKSoftwareMap.shared()) {
installedApps = softwareMap.allSoftwareProducts()
.filter { product in
product.bundlePath.starts(with: "/Applications/")
}
self.softwareMap = softwareMap
}
deinit {
// do nothing
}
/// Uninstalls all apps located at any of the elements of `appPaths`.