From b0d0f4aacdf12bf73c3b84e8229152840b3dfa60 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:53:26 -0400 Subject: [PATCH] `appIDValue` to encapsulate `uint64Value`. Resolve #574 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Commands/Outdated.swift | 2 +- Sources/mas/Commands/Upgrade.swift | 4 ++-- Sources/mas/Mas.swift | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Sources/mas/Commands/Outdated.swift b/Sources/mas/Commands/Outdated.swift index 52b12ba..f7b3ce5 100644 --- a/Sources/mas/Commands/Outdated.swift +++ b/Sources/mas/Commands/Outdated.swift @@ -33,7 +33,7 @@ extension Mas { fulfilled: appLibrary.installedApps.map { installedApp in firstly { - storeSearch.lookup(appID: installedApp.itemIdentifier.uint64Value) + storeSearch.lookup(appID: installedApp.itemIdentifier.appIDValue) }.done { storeApp in guard let storeApp else { if verbose { diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index afa1b5d..cfc7b66 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -44,7 +44,7 @@ extension Mas { .joined(separator: "\n")) do { - try downloadAll(apps.map(\.installedApp.itemIdentifier.uint64Value)).wait() + try downloadAll(apps.map(\.installedApp.itemIdentifier.appIDValue)).wait() } catch { throw error as? MASError ?? .downloadFailed(error: error as NSError) } @@ -70,7 +70,7 @@ extension Mas { let promises = apps.map { installedApp in // only upgrade apps whose local version differs from the store version firstly { - storeSearch.lookup(appID: installedApp.itemIdentifier.uint64Value) + storeSearch.lookup(appID: installedApp.itemIdentifier.appIDValue) }.map { result -> (SoftwareProduct, SearchResult)? in guard let storeApp = result, installedApp.isOutdatedWhenComparedTo(storeApp) else { return nil diff --git a/Sources/mas/Mas.swift b/Sources/mas/Mas.swift index a3a28ec..1d273fa 100644 --- a/Sources/mas/Mas.swift +++ b/Sources/mas/Mas.swift @@ -7,10 +7,9 @@ // import ArgumentParser +import Foundation import PromiseKit -typealias AppID = UInt64 - @main struct Mas: ParsableCommand { static let configuration = CommandConfiguration( @@ -56,3 +55,11 @@ struct Mas: ParsableCommand { } } } + +typealias AppID = UInt64 + +extension NSNumber { + var appIDValue: AppID { + uint64Value + } +}