mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-28 09:25:47 +00:00
Remove Current.shell sudo functionality
This'll be done in the helper
This commit is contained in:
parent
9971e0b45d
commit
f00ae396a6
2 changed files with 0 additions and 26 deletions
|
|
@ -27,28 +27,11 @@ public struct Shell {
|
|||
public var unxip: (URL) -> Promise<ProcessOutput> = { Process.run(Path.root.usr.bin.xip, workingDirectory: $0.deletingLastPathComponent(), "--expand", "\($0.path)") }
|
||||
public var spctlAssess: (URL) -> Promise<ProcessOutput> = { Process.run(Path.root.usr.sbin.spctl, "--assess", "--verbose", "--type", "execute", "\($0.path)") }
|
||||
public var codesignVerify: (URL) -> Promise<ProcessOutput> = { Process.run(Path.root.usr.bin.codesign, "-vv", "-d", "\($0.path)") }
|
||||
public var devToolsSecurityEnable: (String?) -> Promise<ProcessOutput> = { Process.sudo(password: $0, Path.root.usr.sbin.DevToolsSecurity, "-enable") }
|
||||
public var addStaffToDevelopersGroup: (String?) -> Promise<ProcessOutput> = { Process.sudo(password: $0, Path.root.usr.sbin.dseditgroup, "-o", "edit", "-t", "group", "-a", "staff", "_developer") }
|
||||
public var acceptXcodeLicense: (InstalledXcode, String?) -> Promise<ProcessOutput> = { Process.sudo(password: $1, $0.path.join("/Contents/Developer/usr/bin/xcodebuild"), "-license", "accept") }
|
||||
public var runFirstLaunch: (InstalledXcode, String?) -> Promise<ProcessOutput> = { Process.sudo(password: $1, $0.path.join("/Contents/Developer/usr/bin/xcodebuild"),"-runFirstLaunch") }
|
||||
public var buildVersion: () -> Promise<ProcessOutput> = { Process.run(Path.root.usr.bin.sw_vers, "-buildVersion") }
|
||||
public var xcodeBuildVersion: (InstalledXcode) -> Promise<ProcessOutput> = { Process.run(Path.root.usr.libexec.PlistBuddy, "-c", "Print :ProductBuildVersion", "\($0.path.string)/Contents/version.plist") }
|
||||
public var getUserCacheDir: () -> Promise<ProcessOutput> = { Process.run(Path.root.usr.bin.getconf, "DARWIN_USER_CACHE_DIR") }
|
||||
public var touchInstallCheck: (String, String, String) -> Promise<ProcessOutput> = { Process.run(Path.root.usr.bin/"touch", "\($0)com.apple.dt.Xcode.InstallCheckCache_\($1)_\($2)") }
|
||||
|
||||
public var validateSudoAuthentication: () -> Promise<ProcessOutput> = { Process.run(Path.root.usr.bin.sudo, "-nv") }
|
||||
public var authenticateSudoerIfNecessary: (@escaping () -> Promise<String>) -> Promise<String?> = { passwordInput in
|
||||
firstly { () -> Promise<String?> in
|
||||
Current.shell.validateSudoAuthentication().map { _ in return nil }
|
||||
}
|
||||
.recover { _ -> Promise<String?> in
|
||||
return passwordInput().map(Optional.init)
|
||||
}
|
||||
}
|
||||
public func authenticateSudoerIfNecessary(passwordInput: @escaping () -> Promise<String>) -> Promise<String?> {
|
||||
authenticateSudoerIfNecessary(passwordInput)
|
||||
}
|
||||
|
||||
public var xcodeSelectPrintPath: () -> AnyPublisher<ProcessOutput, Error> = { Process.run(Path.root.usr.bin.join("xcode-select"), "-p") }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,15 +5,6 @@ import Path
|
|||
public typealias ProcessOutput = (status: Int32, out: String, err: String)
|
||||
|
||||
extension Process {
|
||||
@discardableResult
|
||||
static func sudo(password: String? = nil, _ executable: Path, workingDirectory: URL? = nil, _ arguments: String...) -> Promise<ProcessOutput> {
|
||||
var arguments = [executable.string] + arguments
|
||||
if password != nil {
|
||||
arguments.insert("-S", at: 0)
|
||||
}
|
||||
return run(Path.root.usr.bin.sudo.url, workingDirectory: workingDirectory, input: password, arguments)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
static func run(_ executable: Path, workingDirectory: URL? = nil, input: String? = nil, _ arguments: String...) -> Promise<ProcessOutput> {
|
||||
return run(executable.url, workingDirectory: workingDirectory, input: input, arguments)
|
||||
|
|
|
|||
Loading…
Reference in a new issue