mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
Rename *accountId
& username
as *appleID
.
Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
2eeff82f11
commit
3a5593c12d
4 changed files with 10 additions and 10 deletions
|
@ -32,7 +32,7 @@ extension ISStoreAccount: StoreAccount {
|
||||||
return .value(CKAccountStore.shared().primaryAccount)
|
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
|
// swift-format-ignore: UseEarlyExits
|
||||||
if #available(macOS 10.13, *) {
|
if #available(macOS 10.13, *) {
|
||||||
// Signing in is no longer possible as of High Sierra.
|
// Signing in is no longer possible as of High Sierra.
|
||||||
|
@ -44,7 +44,7 @@ extension ISStoreAccount: StoreAccount {
|
||||||
primaryAccount
|
primaryAccount
|
||||||
.then { account -> Promise<ISStoreAccount> in
|
.then { account -> Promise<ISStoreAccount> in
|
||||||
if account.isSignedIn {
|
if account.isSignedIn {
|
||||||
return Promise(error: MASError.alreadySignedIn(asAccountId: account.identifier))
|
return Promise(error: MASError.alreadySignedIn(asAppleID: account.identifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
let password =
|
let password =
|
||||||
|
@ -57,7 +57,7 @@ extension ISStoreAccount: StoreAccount {
|
||||||
}
|
}
|
||||||
|
|
||||||
let context = ISAuthenticationContext(accountID: 0)
|
let context = ISAuthenticationContext(accountID: 0)
|
||||||
context.appleIDOverride = username
|
context.appleIDOverride = appleID
|
||||||
|
|
||||||
let signInPromise =
|
let signInPromise =
|
||||||
Promise<ISStoreAccount> { seal in
|
Promise<ISStoreAccount> { seal in
|
||||||
|
@ -77,7 +77,7 @@ extension ISStoreAccount: StoreAccount {
|
||||||
}
|
}
|
||||||
|
|
||||||
context.demoMode = true
|
context.demoMode = true
|
||||||
context.demoAccountName = username
|
context.demoAccountName = appleID
|
||||||
context.demoAccountPassword = password
|
context.demoAccountPassword = password
|
||||||
context.demoAutologinMode = true
|
context.demoAutologinMode = true
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,14 @@ extension Mas {
|
||||||
@Flag(help: "Complete login with graphical dialog")
|
@Flag(help: "Complete login with graphical dialog")
|
||||||
var dialog = false
|
var dialog = false
|
||||||
@Argument(help: "Apple ID")
|
@Argument(help: "Apple ID")
|
||||||
var username: String
|
var appleID: String
|
||||||
@Argument(help: "Password")
|
@Argument(help: "Password")
|
||||||
var password: String = ""
|
var password: String = ""
|
||||||
|
|
||||||
/// Runs the command.
|
/// Runs the command.
|
||||||
func run() throws {
|
func run() throws {
|
||||||
do {
|
do {
|
||||||
_ = try ISStoreAccount.signIn(username: username, password: password, systemDialog: dialog).wait()
|
_ = try ISStoreAccount.signIn(appleID: appleID, password: password, systemDialog: dialog).wait()
|
||||||
} catch {
|
} catch {
|
||||||
throw error as? MASError ?? MASError.signInFailed(error: error as NSError)
|
throw error as? MASError ?? MASError.signInFailed(error: error as NSError)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ enum MASError: Error, Equatable {
|
||||||
case notSignedIn
|
case notSignedIn
|
||||||
case noPasswordProvided
|
case noPasswordProvided
|
||||||
case signInFailed(error: NSError?)
|
case signInFailed(error: NSError?)
|
||||||
case alreadySignedIn(asAccountId: String)
|
case alreadySignedIn(asAppleID: String)
|
||||||
|
|
||||||
case purchaseFailed(error: NSError?)
|
case purchaseFailed(error: NSError?)
|
||||||
case downloadFailed(error: NSError?)
|
case downloadFailed(error: NSError?)
|
||||||
|
@ -63,8 +63,8 @@ extension MASError: CustomStringConvertible {
|
||||||
return "Sign in failed: \(error.localizedDescription)"
|
return "Sign in failed: \(error.localizedDescription)"
|
||||||
}
|
}
|
||||||
return "Sign in failed"
|
return "Sign in failed"
|
||||||
case .alreadySignedIn(let accountId):
|
case .alreadySignedIn(let appleID):
|
||||||
return "Already signed in as \(accountId)"
|
return "Already signed in as \(appleID)"
|
||||||
case .purchaseFailed(let error):
|
case .purchaseFailed(let error):
|
||||||
if let error {
|
if let error {
|
||||||
return "Download request failed: \(error.localizedDescription)"
|
return "Download request failed: \(error.localizedDescription)"
|
||||||
|
|
|
@ -59,7 +59,7 @@ class MASErrorTestCase: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAlreadySignedIn() {
|
func testAlreadySignedIn() {
|
||||||
error = .alreadySignedIn(asAccountId: "person@example.com")
|
error = .alreadySignedIn(asAppleID: "person@example.com")
|
||||||
XCTAssertEqual(error.description, "Already signed in as person@example.com")
|
XCTAssertEqual(error.description, "Already signed in as person@example.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue