Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

Run setup during new

Kabir Oberai4cb0b5daf4df
diff --git a/Sources/SupersignCLISupport/AuthCommand.swift b/Sources/SupersignCLISupport/AuthCommand.swift
index f42f0c1..bbbd5ef 100644
--- a/Sources/SupersignCLISupport/AuthCommand.swift
+++ b/Sources/SupersignCLISupport/AuthCommand.swift
@@ -22,10 +22,13 @@ struct AuthOperation {
var logoutFromExisting: Bool
var mode: AuthMode? = nil
+ var quiet = false
func run() async throws {
if let token = try? AuthToken.saved(), !logoutFromExisting {
- print("Logged in.\n\(token)")
+ if !quiet {
+ print("Logged in.\n\(token)")
+ }
return
}
diff --git a/Sources/SupersignCLISupport/DevCommands/DevCommand.swift b/Sources/SupersignCLISupport/DevCommands/DevCommand.swift
index b62e287..5aae43b 100644
--- a/Sources/SupersignCLISupport/DevCommands/DevCommand.swift
+++ b/Sources/SupersignCLISupport/DevCommands/DevCommand.swift
@@ -15,9 +15,27 @@ struct DevSetupCommand: AsyncParsableCommand {
)
func run() async throws {
- try await AuthOperation(logoutFromExisting: false).run()
+ try await DevSetupOperation().run()
+ }
+}
- if try DarwinSDK.current() == nil {
+struct DevSetupOperation {
+ var quiet = false
+
+ func run() async throws {
+ try await AuthOperation(logoutFromExisting: false, quiet: quiet).run()
+
+ switch try DarwinSDK.current()?.isUpToDate() {
+ case true?:
+ if !quiet {
+ print("Darwin SDK is up to date.")
+ }
+ case false?:
+ if !quiet {
+ print("Darwin SDK is outdated.")
+ }
+ fallthrough
+ case nil:
let path = try await Console.prompt("""
Now generating the Darwin SDK.
diff --git a/Sources/SupersignCLISupport/DevCommands/DevNewCommand.swift b/Sources/SupersignCLISupport/DevCommands/DevNewCommand.swift
index e2f3b1c..ae63955 100644
--- a/Sources/SupersignCLISupport/DevCommands/DevNewCommand.swift
+++ b/Sources/SupersignCLISupport/DevCommands/DevNewCommand.swift
@@ -10,7 +10,23 @@ struct DevNewCommand: AsyncParsableCommand {
@Argument var name: String?
+ @Flag(
+ help: ArgumentHelp(
+ "Skip setup steps. (default: false)",
+ discussion: """
+ By default, this command first invokes `supersign dev setup` to complete \
+ any missing setup steps, like authenticating and installing the SDK. Use \
+ this flag to always skip setup.
+ """
+ )
+ ) var skipSetup = false
+
func run() async throws {
+ if !skipSetup {
+ // perform any remaining setup steps first
+ try await DevSetupOperation(quiet: true).run()
+ }
+
let name = try await Console.promptRequired("Package name: ", existing: self.name)
var allowedFirstCharacters: CharacterSet = ["_"]
diff --git a/Sources/SupersignCLISupport/DevCommands/DevSDKCommand.swift b/Sources/SupersignCLISupport/DevCommands/DevSDKCommand.swift
index 26a0fd7..01b8697 100644
--- a/Sources/SupersignCLISupport/DevCommands/DevSDKCommand.swift
+++ b/Sources/SupersignCLISupport/DevCommands/DevSDKCommand.swift
@@ -157,6 +157,10 @@ struct DarwinSDK {
}
}
+ func isUpToDate() -> Bool {
+ true
+ }
+
func remove() throws {
try FileManager.default.removeItem(at: bundle)
}