Merge branch 'master' into feature/install-multiple-apps-at-once

This commit is contained in:
Andrew Naylor 2016-09-14 21:59:09 +01:00
commit aebfca64c0
5 changed files with 89 additions and 1 deletions

View file

@ -32,6 +32,7 @@
EDA3BE521B8B84AF00C18D70 /* SSPurchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDA3BE511B8B84AF00C18D70 /* SSPurchase.swift */; }; EDA3BE521B8B84AF00C18D70 /* SSPurchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDA3BE511B8B84AF00C18D70 /* SSPurchase.swift */; };
EDB6CE8C1BAEC3D400648B4D /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB6CE8B1BAEC3D400648B4D /* Version.swift */; }; EDB6CE8C1BAEC3D400648B4D /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB6CE8B1BAEC3D400648B4D /* Version.swift */; };
EDC90B651C70045E0019E396 /* SignIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC90B641C70045E0019E396 /* SignIn.swift */; }; EDC90B651C70045E0019E396 /* SignIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC90B641C70045E0019E396 /* SignIn.swift */; };
EDCBF9531D89AC6F000039C6 /* Reset.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDCBF9521D89AC6F000039C6 /* Reset.swift */; };
EDD3B3631C34709400B56B88 /* Upgrade.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDD3B3621C34709400B56B88 /* Upgrade.swift */; }; EDD3B3631C34709400B56B88 /* Upgrade.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDD3B3621C34709400B56B88 /* Upgrade.swift */; };
EDE296531C700F4300554778 /* SignOut.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE296521C700F4300554778 /* SignOut.swift */; }; EDE296531C700F4300554778 /* SignOut.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDE296521C700F4300554778 /* SignOut.swift */; };
EDEAA0C01B51CE6200F2FC3F /* StoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDEAA0BF1B51CE6200F2FC3F /* StoreFoundation.framework */; }; EDEAA0C01B51CE6200F2FC3F /* StoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDEAA0BF1B51CE6200F2FC3F /* StoreFoundation.framework */; };
@ -91,6 +92,7 @@
EDB6CE8B1BAEC3D400648B4D /* Version.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = "<group>"; }; EDB6CE8B1BAEC3D400648B4D /* Version.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = "<group>"; };
EDC90B621C6FF50B0019E396 /* ISAccountService-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ISAccountService-Protocol.h"; sourceTree = "<group>"; }; EDC90B621C6FF50B0019E396 /* ISAccountService-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ISAccountService-Protocol.h"; sourceTree = "<group>"; };
EDC90B641C70045E0019E396 /* SignIn.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignIn.swift; sourceTree = "<group>"; }; EDC90B641C70045E0019E396 /* SignIn.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignIn.swift; sourceTree = "<group>"; };
EDCBF9521D89AC6F000039C6 /* Reset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reset.swift; sourceTree = "<group>"; };
EDD3B3621C34709400B56B88 /* Upgrade.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Upgrade.swift; sourceTree = "<group>"; }; EDD3B3621C34709400B56B88 /* Upgrade.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Upgrade.swift; sourceTree = "<group>"; };
EDE2964F1C700B0300554778 /* ISAuthenticationContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISAuthenticationContext.h; sourceTree = "<group>"; }; EDE2964F1C700B0300554778 /* ISAuthenticationContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISAuthenticationContext.h; sourceTree = "<group>"; };
EDE296501C700B0300554778 /* ISServiceRemoteObject-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ISServiceRemoteObject-Protocol.h"; sourceTree = "<group>"; }; EDE296501C700B0300554778 /* ISServiceRemoteObject-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ISServiceRemoteObject-Protocol.h"; sourceTree = "<group>"; };
@ -206,6 +208,7 @@
ED0F237E1B87522400AE40CD /* Install.swift */, ED0F237E1B87522400AE40CD /* Install.swift */,
ED0F23821B87533A00AE40CD /* List.swift */, ED0F23821B87533A00AE40CD /* List.swift */,
ED0F23841B87536A00AE40CD /* Outdated.swift */, ED0F23841B87536A00AE40CD /* Outdated.swift */,
EDCBF9521D89AC6F000039C6 /* Reset.swift */,
693A98981CBFFA760004D3B4 /* Search.swift */, 693A98981CBFFA760004D3B4 /* Search.swift */,
EDC90B641C70045E0019E396 /* SignIn.swift */, EDC90B641C70045E0019E396 /* SignIn.swift */,
EDE296521C700F4300554778 /* SignOut.swift */, EDE296521C700F4300554778 /* SignOut.swift */,
@ -369,6 +372,7 @@
30EA893640B02CCF679F9C57 /* Option.swift in Sources */, 30EA893640B02CCF679F9C57 /* Option.swift in Sources */,
ED0F23851B87536A00AE40CD /* Outdated.swift in Sources */, ED0F23851B87536A00AE40CD /* Outdated.swift in Sources */,
ED0F23891B87543D00AE40CD /* PurchaseDownloadObserver.swift in Sources */, ED0F23891B87543D00AE40CD /* PurchaseDownloadObserver.swift in Sources */,
EDCBF9531D89AC6F000039C6 /* Reset.swift in Sources */,
0EBF5CDD379D7462C3389536 /* Result.swift in Sources */, 0EBF5CDD379D7462C3389536 /* Result.swift in Sources */,
319FDBA6ED6443A912B9A65F /* ResultType.swift in Sources */, 319FDBA6ED6443A912B9A65F /* ResultType.swift in Sources */,
693A98991CBFFA760004D3B4 /* Search.swift in Sources */, 693A98991CBFFA760004D3B4 /* Search.swift in Sources */,

View file

@ -0,0 +1,81 @@
//
// Reset.swift
// mas-cli
//
// Created by Andrew Naylor on 14/09/2016.
// Copyright © 2016 Andrew Naylor. All rights reserved.
//
struct ResetCommand: CommandType {
typealias Options = ResetOptions
let verb = "reset"
let function = "Resets the Mac App Store"
func run(options: Options) -> Result<(), MASError> {
/*
The "Reset Application" command in the Mac App Store debug menu performs
the following steps
- killall Dock
- killall storeagent (storeagent no longer exists)
- rm com.apple.appstore download directory
- clear cookies (appears to be a no-op)
As storeagent no longer exists we will implement a slight variant and kill all
App Store-associated processes
- storeaccountd
- storeassetd
- storedownloadd
- storeinstalld
- storelegacy
*/
// Kill processes
let killProcs = [
"Dock",
"storeaccountd",
"storeassetd",
"storedownloadd",
"storeinstalld",
"storelegacy",
]
let kill = NSTask()
let stdout = NSPipe()
let stderr = NSPipe()
kill.launchPath = "/usr/bin/killall"
kill.arguments = killProcs
kill.standardOutput = stdout
kill.standardError = stderr
kill.launch()
kill.waitUntilExit()
if kill.terminationStatus != 0 && options.debug {
let output = stderr.fileHandleForReading.readDataToEndOfFile()
print("==> killall failed:\r\n\(String(data: output, encoding: NSUTF8StringEncoding)!)")
}
// Wipe Download Directory
let directory = CKDownloadDirectory(nil)
do {
try NSFileManager.defaultManager().removeItemAtPath(directory)
} catch {
if options.debug {
print("removeItemAtPath:\"\(directory)\" failed, \(error)")
}
}
return .Success(())
}
}
struct ResetOptions: OptionsType {
let debug: Bool
static func evaluate(m: CommandMode) -> Result<ResetOptions, CommandantError<MASError>> {
return curry(ResetOptions.init)
<*> m <| Switch(flag: nil, key: "debug", usage: "Enable debug mode")
}
}

View file

@ -20,6 +20,7 @@ registry.register(AccountCommand())
registry.register(InstallCommand()) registry.register(InstallCommand())
registry.register(ListCommand()) registry.register(ListCommand())
registry.register(OutdatedCommand()) registry.register(OutdatedCommand())
registry.register(ResetCommand())
registry.register(SearchCommand()) registry.register(SearchCommand())
registry.register(SignInCommand()) registry.register(SignInCommand())
registry.register(SignOutCommand()) registry.register(SignOutCommand())

View file

@ -39,4 +39,6 @@
@end @end
NSString* CKDownloadDirectory(NSString *target);
#endif /* mas_cli_Bridging_Header_h */ #endif /* mas_cli_Bridging_Header_h */

View file

@ -11,6 +11,6 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>mas-cli</string> <string>mas-cli</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.0</string> <string>1.2.2</string>
</dict> </dict>
</plist> </plist>