Rename Mas as MAS.

Partial #585

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-25 13:21:19 -04:00
parent 6bf5696093
commit ab22e22ace
No known key found for this signature in database
45 changed files with 74 additions and 74 deletions

View file

@ -9,7 +9,7 @@
import ArgumentParser
import StoreFoundation
extension Mas {
extension MAS {
struct Account: ParsableCommand {
static let configuration = CommandConfiguration(
abstract: "Prints the primary account Apple ID"

View file

@ -8,7 +8,7 @@
import ArgumentParser
extension Mas {
extension MAS {
/// Opens app page on MAS Preview. Uses the iTunes Lookup API:
/// https://performance-partners.apple.com/search-api
struct Home: ParsableCommand {

View file

@ -9,7 +9,7 @@
import ArgumentParser
import Foundation
extension Mas {
extension MAS {
/// Displays app details. Uses the iTunes Lookup API:
/// https://performance-partners.apple.com/search-api
struct Info: ParsableCommand {

View file

@ -9,7 +9,7 @@
import ArgumentParser
import CommerceKit
extension Mas {
extension MAS {
/// Installs previously purchased apps from the Mac App Store.
struct Install: ParsableCommand {
static let configuration = CommandConfiguration(

View file

@ -8,7 +8,7 @@
import ArgumentParser
extension Mas {
extension MAS {
/// Command which lists all installed apps.
struct List: ParsableCommand {
static let configuration = CommandConfiguration(

View file

@ -9,7 +9,7 @@
import ArgumentParser
import CommerceKit
extension Mas {
extension MAS {
/// Command which installs the first search result.
///
/// This is handy as many MAS titles can be long with embedded keywords.

View file

@ -11,7 +11,7 @@ import Foundation
private let masScheme = "macappstore"
extension Mas {
extension MAS {
/// Opens app page in MAS app. Uses the iTunes Lookup API:
/// https://performance-partners.apple.com/search-api
struct Open: ParsableCommand {

View file

@ -10,7 +10,7 @@ import ArgumentParser
import Foundation
import PromiseKit
extension Mas {
extension MAS {
/// Command which displays a list of installed apps which have available updates
/// ready to be installed from the Mac App Store.
struct Outdated: ParsableCommand {

View file

@ -9,7 +9,7 @@
import ArgumentParser
import CommerceKit
extension Mas {
extension MAS {
struct Purchase: ParsableCommand {
static let configuration = CommandConfiguration(
abstract: "Purchase and download free apps from the Mac App Store"

View file

@ -9,7 +9,7 @@
import ArgumentParser
import CommerceKit
extension Mas {
extension MAS {
/// Kills several macOS processes as a means to reset the app store.
struct Reset: ParsableCommand {
static let configuration = CommandConfiguration(

View file

@ -8,7 +8,7 @@
import ArgumentParser
extension Mas {
extension MAS {
/// Search the Mac App Store using the iTunes Search API.
///
/// See - https://performance-partners.apple.com/search-api

View file

@ -9,7 +9,7 @@
import ArgumentParser
import StoreFoundation
extension Mas {
extension MAS {
struct SignIn: ParsableCommand {
static let configuration = CommandConfiguration(
commandName: "signin",

View file

@ -9,7 +9,7 @@
import ArgumentParser
import CommerceKit
extension Mas {
extension MAS {
struct SignOut: ParsableCommand {
static let configuration = CommandConfiguration(
commandName: "signout",

View file

@ -9,7 +9,7 @@
import ArgumentParser
import Foundation
extension Mas {
extension MAS {
/// Command which uninstalls apps managed by the Mac App Store.
struct Uninstall: ParsableCommand {
static let configuration = CommandConfiguration(

View file

@ -10,7 +10,7 @@ import ArgumentParser
import Foundation
import PromiseKit
extension Mas {
extension MAS {
/// Command which upgrades apps with new versions available in the Mac App Store.
struct Upgrade: ParsableCommand {
static let configuration = CommandConfiguration(

View file

@ -8,7 +8,7 @@
import ArgumentParser
extension Mas {
extension MAS {
/// Opens vendor's app page in a browser. Uses the iTunes Lookup API:
/// https://performance-partners.apple.com/search-api
struct Vendor: ParsableCommand {

View file

@ -8,7 +8,7 @@
import ArgumentParser
extension Mas {
extension MAS {
/// Command which displays the version of the mas tool.
struct Version: ParsableCommand {
static let configuration = CommandConfiguration(

View file

@ -1,5 +1,5 @@
//
// Mas.swift
// MAS.swift
// mas
//
// Created by Chris Araman on 4/22/21.
@ -11,7 +11,7 @@ import Foundation
import PromiseKit
@main
struct Mas: ParsableCommand {
struct MAS: ParsableCommand {
static let configuration = CommandConfiguration(
abstract: "Mac App Store command-line interface",
subcommands: [

View file

@ -15,13 +15,13 @@ import Quick
public class AccountSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
// account command disabled since macOS 12 Monterey https://github.com/mas-cli/mas#known-issues
describe("Account command") {
it("displays active account") {
expect {
try Mas.Account.parse([]).run()
try MAS.Account.parse([]).run()
}
.to(throwError(MASError.notSupported))
}

View file

@ -17,7 +17,7 @@ public class HomeSpec: QuickSpec {
let openCommand = OpenSystemCommandMock()
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("home command") {
beforeEach {
@ -25,13 +25,13 @@ public class HomeSpec: QuickSpec {
}
it("fails to open app with invalid ID") {
expect {
try Mas.Home.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Home.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError())
}
it("can't find app with unknown ID") {
expect {
try Mas.Home.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Home.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError(MASError.noSearchResultsFound))
}
@ -43,7 +43,7 @@ public class HomeSpec: QuickSpec {
)
storeSearch.apps[mockResult.trackId] = mockResult
expect {
try Mas.Home.parse([String(mockResult.trackId)])
try MAS.Home.parse([String(mockResult.trackId)])
.run(storeSearch: storeSearch, openCommand: openCommand)
return openCommand.arguments
}

View file

@ -17,7 +17,7 @@ public class InfoSpec: QuickSpec {
let storeSearch = StoreSearchMock()
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("Info command") {
beforeEach {
@ -25,13 +25,13 @@ public class InfoSpec: QuickSpec {
}
it("fails to open app with invalid ID") {
expect {
try Mas.Info.parse(["--", "-999"]).run(storeSearch: storeSearch)
try MAS.Info.parse(["--", "-999"]).run(storeSearch: storeSearch)
}
.to(throwError())
}
it("can't find app with unknown ID") {
expect {
try Mas.Info.parse(["999"]).run(storeSearch: storeSearch)
try MAS.Info.parse(["999"]).run(storeSearch: storeSearch)
}
.to(throwError(MASError.noSearchResultsFound))
}
@ -50,7 +50,7 @@ public class InfoSpec: QuickSpec {
storeSearch.apps[mockResult.trackId] = mockResult
expect {
try captureStream(stdout) {
try Mas.Info.parse([String(mockResult.trackId)]).run(storeSearch: storeSearch)
try MAS.Info.parse([String(mockResult.trackId)]).run(storeSearch: storeSearch)
}
}
== """

View file

@ -14,12 +14,12 @@ import Quick
public class InstallSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
xdescribe("install command") {
xit("installs apps") {
expect {
try Mas.Install.parse([]).run(appLibrary: AppLibraryMock())
try MAS.Install.parse([]).run(appLibrary: AppLibraryMock())
}
.toNot(throwError())
}

View file

@ -15,13 +15,13 @@ import Quick
public class ListSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("list command") {
it("lists apps") {
expect {
try captureStream(stderr) {
try Mas.List.parse([]).run(appLibrary: AppLibraryMock())
try MAS.List.parse([]).run(appLibrary: AppLibraryMock())
}
}
== "Error: No installed apps found\n"

View file

@ -17,12 +17,12 @@ public class LuckySpec: QuickSpec {
let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession))
beforeSuite {
Mas.initialize()
MAS.initialize()
}
xdescribe("lucky command") {
xit("installs the first app matching a search") {
expect {
try Mas.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), storeSearch: storeSearch)
try MAS.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), storeSearch: storeSearch)
}
.toNot(throwError())
}

View file

@ -18,7 +18,7 @@ public class OpenSpec: QuickSpec {
let openCommand = OpenSystemCommandMock()
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("open command") {
beforeEach {
@ -26,13 +26,13 @@ public class OpenSpec: QuickSpec {
}
it("fails to open app with invalid ID") {
expect {
try Mas.Open.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Open.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError())
}
it("can't find app with unknown ID") {
expect {
try Mas.Open.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Open.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError(MASError.noSearchResultsFound))
}
@ -44,7 +44,7 @@ public class OpenSpec: QuickSpec {
)
storeSearch.apps[mockResult.trackId] = mockResult
expect {
try Mas.Open.parse([mockResult.trackId.description])
try MAS.Open.parse([mockResult.trackId.description])
.run(storeSearch: storeSearch, openCommand: openCommand)
return openCommand.arguments
}
@ -52,7 +52,7 @@ public class OpenSpec: QuickSpec {
}
it("just opens MAS if no app specified") {
expect {
try Mas.Open.parse([]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Open.parse([]).run(storeSearch: storeSearch, openCommand: openCommand)
return openCommand.arguments
}
== ["macappstore://"]

View file

@ -15,7 +15,7 @@ import Quick
public class OutdatedSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("outdated command") {
it("displays apps with pending updates") {
@ -48,7 +48,7 @@ public class OutdatedSpec: QuickSpec {
)
expect {
try captureStream(stdout) {
try Mas.Outdated.parse([]).run(appLibrary: mockAppLibrary, storeSearch: mockStoreSearch)
try MAS.Outdated.parse([]).run(appLibrary: mockAppLibrary, storeSearch: mockStoreSearch)
}
}
== "490461369 Bandwidth+ (1.27 -> 1.28)\n"

View file

@ -14,12 +14,12 @@ import Quick
public class PurchaseSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
xdescribe("purchase command") {
xit("purchases apps") {
expect {
try Mas.Purchase.parse(["999"]).run(appLibrary: AppLibraryMock())
try MAS.Purchase.parse(["999"]).run(appLibrary: AppLibraryMock())
}
.toNot(throwError())
}

View file

@ -14,12 +14,12 @@ import Quick
public class ResetSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("reset command") {
it("resets the App Store state") {
expect {
try Mas.Reset.parse([]).run()
try MAS.Reset.parse([]).run()
}
.toNot(throwError())
}

View file

@ -17,7 +17,7 @@ public class SearchSpec: QuickSpec {
let storeSearch = StoreSearchMock()
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("search command") {
beforeEach {
@ -33,14 +33,14 @@ public class SearchSpec: QuickSpec {
storeSearch.apps[mockResult.trackId] = mockResult
expect {
try captureStream(stdout) {
try Mas.Search.parse(["slack"]).run(storeSearch: storeSearch)
try MAS.Search.parse(["slack"]).run(storeSearch: storeSearch)
}
}
== " 1111 slack (0.0)\n"
}
it("fails when searching for nonexistent app") {
expect {
try Mas.Search.parse(["nonexistent"]).run(storeSearch: storeSearch)
try MAS.Search.parse(["nonexistent"]).run(storeSearch: storeSearch)
}
.to(throwError(MASError.noSearchResultsFound))
}

View file

@ -15,13 +15,13 @@ import Quick
public class SignInSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
// account command disabled since macOS 10.13 High Sierra https://github.com/mas-cli/mas#known-issues
describe("signin command") {
it("signs in") {
expect {
try Mas.SignIn.parse(["", ""]).run()
try MAS.SignIn.parse(["", ""]).run()
}
.to(throwError(MASError.notSupported))
}

View file

@ -14,12 +14,12 @@ import Quick
public class SignOutSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("signout command") {
it("signs out") {
expect {
try Mas.SignOut.parse([]).run()
try MAS.SignOut.parse([]).run()
}
.toNot(throwError())
}

View file

@ -15,7 +15,7 @@ import Quick
public class UninstallSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
xdescribe("uninstall command") {
let appID: AppID = 12345
@ -29,7 +29,7 @@ public class UninstallSpec: QuickSpec {
let mockLibrary = AppLibraryMock()
context("dry run") {
let uninstall = try! Mas.Uninstall.parse(["--dry-run", String(appID)])
let uninstall = try! MAS.Uninstall.parse(["--dry-run", String(appID)])
beforeEach {
mockLibrary.reset()
@ -51,7 +51,7 @@ public class UninstallSpec: QuickSpec {
}
}
context("wet run") {
let uninstall = try! Mas.Uninstall.parse([String(appID)])
let uninstall = try! MAS.Uninstall.parse([String(appID)])
beforeEach {
mockLibrary.reset()

View file

@ -15,13 +15,13 @@ import Quick
public class UpgradeSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("upgrade command") {
it("finds no upgrades") {
expect {
try captureStream(stderr) {
try Mas.Upgrade.parse([])
try MAS.Upgrade.parse([])
.run(appLibrary: AppLibraryMock(), storeSearch: StoreSearchMock())
}
}

View file

@ -17,7 +17,7 @@ public class VendorSpec: QuickSpec {
let openCommand = OpenSystemCommandMock()
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("vendor command") {
beforeEach {
@ -25,13 +25,13 @@ public class VendorSpec: QuickSpec {
}
it("fails to open app with invalid ID") {
expect {
try Mas.Vendor.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Vendor.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError())
}
it("can't find app with unknown ID") {
expect {
try Mas.Vendor.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
try MAS.Vendor.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand)
}
.to(throwError(MASError.noSearchResultsFound))
}
@ -44,7 +44,7 @@ public class VendorSpec: QuickSpec {
)
storeSearch.apps[mockResult.trackId] = mockResult
expect {
try Mas.Vendor.parse([String(mockResult.trackId)])
try MAS.Vendor.parse([String(mockResult.trackId)])
.run(storeSearch: storeSearch, openCommand: openCommand)
return openCommand.arguments
}

View file

@ -15,13 +15,13 @@ import Quick
public class VersionSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("version command") {
it("displays the current version") {
expect {
try captureStream(stdout) {
try Mas.Version.parse([]).run()
try MAS.Version.parse([]).run()
}
}
== "\(Package.version)\n"

View file

@ -16,7 +16,7 @@ public class MasAppLibrarySpec: QuickSpec {
let library = MasAppLibrary(softwareMap: SoftwareMapMock(products: apps))
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("mas app library") {
it("contains all installed apps") {

View file

@ -14,7 +14,7 @@ import Quick
public class MasStoreSearchSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("url string") {
it("contains the app name") {

View file

@ -32,7 +32,7 @@ class MASErrorTestCase: XCTestCase {
override func setUp() {
super.setUp()
Mas.initialize()
MAS.initialize()
nserror = NSError(domain: errorDomain, code: 999)
localizedDescription = "foo"
}

View file

@ -14,7 +14,7 @@ import Quick
public class OpenSystemCommandSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("open system command") {
context("binary path") {

View file

@ -18,7 +18,7 @@ public class AppListFormatterSpec: QuickSpec {
var products: [SoftwareProduct] = []
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("app list formatter") {
beforeEach {

View file

@ -18,7 +18,7 @@ public class SearchResultFormatterSpec: QuickSpec {
var results: [SearchResult] = []
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("search results formatter") {
beforeEach {

View file

@ -15,7 +15,7 @@ import Quick
public class SearchResultListSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("search result list") {
it("can parse bbedit") {

View file

@ -15,7 +15,7 @@ import Quick
public class SearchResultSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("search result") {
it("can parse things") {

View file

@ -15,7 +15,7 @@ import Quick
public class SoftwareProductSpec: QuickSpec {
override public func spec() {
beforeSuite {
Mas.initialize()
MAS.initialize()
}
describe("software product") {
let app = SoftwareProductMock(

View file

@ -13,7 +13,7 @@ import XCTest
class NetworkManagerTests: XCTestCase {
override func setUp() {
super.setUp()
Mas.initialize()
MAS.initialize()
}
func testSuccessfulAsyncResponse() throws {