Rename *accountId & username as *appleID.

Partial #585

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-25 12:14:14 -04:00
parent 2eeff82f11
commit 3a5593c12d
No known key found for this signature in database
4 changed files with 10 additions and 10 deletions

View file

@ -32,7 +32,7 @@ extension ISStoreAccount: StoreAccount {
return .value(CKAccountStore.shared().primaryAccount)
}
static func signIn(username: String, password: String, systemDialog: Bool) -> Promise<ISStoreAccount> {
static func signIn(appleID: String, password: String, systemDialog: Bool) -> Promise<ISStoreAccount> {
// swift-format-ignore: UseEarlyExits
if #available(macOS 10.13, *) {
// Signing in is no longer possible as of High Sierra.
@ -44,7 +44,7 @@ extension ISStoreAccount: StoreAccount {
primaryAccount
.then { account -> Promise<ISStoreAccount> in
if account.isSignedIn {
return Promise(error: MASError.alreadySignedIn(asAccountId: account.identifier))
return Promise(error: MASError.alreadySignedIn(asAppleID: account.identifier))
}
let password =
@ -57,7 +57,7 @@ extension ISStoreAccount: StoreAccount {
}
let context = ISAuthenticationContext(accountID: 0)
context.appleIDOverride = username
context.appleIDOverride = appleID
let signInPromise =
Promise<ISStoreAccount> { seal in
@ -77,7 +77,7 @@ extension ISStoreAccount: StoreAccount {
}
context.demoMode = true
context.demoAccountName = username
context.demoAccountName = appleID
context.demoAccountPassword = password
context.demoAutologinMode = true

View file

@ -19,14 +19,14 @@ extension Mas {
@Flag(help: "Complete login with graphical dialog")
var dialog = false
@Argument(help: "Apple ID")
var username: String
var appleID: String
@Argument(help: "Password")
var password: String = ""
/// Runs the command.
func run() throws {
do {
_ = try ISStoreAccount.signIn(username: username, password: password, systemDialog: dialog).wait()
_ = try ISStoreAccount.signIn(appleID: appleID, password: password, systemDialog: dialog).wait()
} catch {
throw error as? MASError ?? MASError.signInFailed(error: error as NSError)
}

View file

@ -18,7 +18,7 @@ enum MASError: Error, Equatable {
case notSignedIn
case noPasswordProvided
case signInFailed(error: NSError?)
case alreadySignedIn(asAccountId: String)
case alreadySignedIn(asAppleID: String)
case purchaseFailed(error: NSError?)
case downloadFailed(error: NSError?)
@ -63,8 +63,8 @@ extension MASError: CustomStringConvertible {
return "Sign in failed: \(error.localizedDescription)"
}
return "Sign in failed"
case .alreadySignedIn(let accountId):
return "Already signed in as \(accountId)"
case .alreadySignedIn(let appleID):
return "Already signed in as \(appleID)"
case .purchaseFailed(let error):
if let error {
return "Download request failed: \(error.localizedDescription)"

View file

@ -59,7 +59,7 @@ class MASErrorTestCase: XCTestCase {
}
func testAlreadySignedIn() {
error = .alreadySignedIn(asAccountId: "person@example.com")
error = .alreadySignedIn(asAppleID: "person@example.com")
XCTAssertEqual(error.description, "Already signed in as person@example.com")
}