-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #496 from nimblehq/chore/490-modify-deliverable-sw…
…ift-commmand [#490] Migrate `set_up_deliverable.sh` to Swift command
- Loading branch information
Showing
6 changed files
with
92 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Foundation | ||
|
||
@discardableResult | ||
func safeShell(_ command: String) throws -> String? { | ||
let task = Process() | ||
let pipe = Pipe() | ||
|
||
task.standardOutput = pipe | ||
task.standardError = pipe | ||
task.arguments = ["-c", command] | ||
task.executableURL = URL(fileURLWithPath: "/bin/zsh") | ||
task.standardInput = nil | ||
|
||
try task.run() | ||
|
||
let data = pipe.fileHandleForReading.readDataToEndOfFile() | ||
let output = String(data: data, encoding: .utf8) | ||
|
||
return output | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/swift | ||
|
||
import Foundation | ||
|
||
let fileManager = FileManager.default | ||
|
||
enum CICDService { | ||
case github, bitrise, codemagic, later | ||
|
||
init?(_ name: String) { | ||
switch name.lowercased() { | ||
case "g", "github": | ||
self = .github | ||
case "b", "bitrise": | ||
self = .bitrise | ||
case "c", "codemagic": | ||
self = .codemagic | ||
case "l", "later": | ||
self = .later | ||
default: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
var service: CICDService? = nil | ||
|
||
while service == nil { | ||
print("Which CI/CD service do you use (Can be edited later) [(g)ithub/(b)itrise/(c)odemagic/(l)ater]: ") | ||
service = CICDService(readLine() ?? "") | ||
} | ||
|
||
switch service { | ||
case .github: | ||
print("Setting template for Github Actions") | ||
fileManager.removeItems(in: "bitrise.yml") | ||
fileManager.removeItems(in: "codemagic.yaml") | ||
case .bitrise: | ||
print("Setting template for Bitrise") | ||
fileManager.removeItems(in: "codemagic.yaml") | ||
fileManager.removeItems(in: ".github/workflows") | ||
case .codemagic: | ||
print("Setting template for CodeMagic") | ||
fileManager.removeItems(in: "bitrise.yml") | ||
fileManager.removeItems(in: ".github/workflows") | ||
case .later: | ||
print("You can manually setup the template later.") | ||
} | ||
|
||
print("✅ Completed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/swift | ||
|
||
import Foundation | ||
|
||
let fileManager = FileManager.default | ||
|
||
print("Do you want to set up Constants values? (Can be edited later) [Y/n]: ") | ||
|
||
var arg = readLine() ?? "y" | ||
|
||
switch arg.lowercased() { | ||
case "y", "yes", "": | ||
let error = try safeShell("open -a Xcode fastlane/Constants/Constant.swift") | ||
guard let error = error, !error.isEmpty else { break } | ||
print("Could not open Xcode. Make sure Xcode is installed and try again.\nRaw error: \(error)") | ||
default: | ||
print("✅ Completed. You can edit this file at 'fastlane/Constants/Constant.swift'.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.