2023-02-10 14:04:00 +01:00
|
|
|
import ArgumentParser
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct SetupProject: ParsableCommand {
|
|
|
|
static var configuration = CommandConfiguration(abstract: "A tool to setup the required components to efficiently run and contribute to Element X iOS")
|
|
|
|
|
2023-04-12 12:03:11 +02:00
|
|
|
@Flag(help: "Use this only on ci to avoid installing failing packages")
|
|
|
|
var ci = false
|
|
|
|
|
2023-02-10 14:04:00 +01:00
|
|
|
func run() throws {
|
|
|
|
try setupGitHooks()
|
|
|
|
try brewBundleInstall()
|
2023-04-12 12:03:11 +02:00
|
|
|
try mintPackagesInstall()
|
2023-09-29 17:29:27 +01:00
|
|
|
try linkGitLFS()
|
2023-02-10 14:04:00 +01:00
|
|
|
try xcodegen()
|
|
|
|
}
|
|
|
|
|
|
|
|
func setupGitHooks() throws {
|
|
|
|
try Utilities.zsh("git config core.hooksPath .githooks")
|
|
|
|
}
|
|
|
|
|
|
|
|
func brewBundleInstall() throws {
|
2023-04-12 12:03:11 +02:00
|
|
|
try Utilities.zsh("brew install xcodegen swiftgen swiftformat git-lfs sourcery mint kiliankoe/formulae/swift-outdated localazy/tools/localazy")
|
|
|
|
if !ci {
|
|
|
|
try Utilities.zsh("brew install swiftlint")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func mintPackagesInstall() throws {
|
|
|
|
try Utilities.zsh("mint install Asana/locheck")
|
2023-02-10 14:04:00 +01:00
|
|
|
}
|
2023-09-29 17:29:27 +01:00
|
|
|
|
|
|
|
func linkGitLFS() throws {
|
|
|
|
guard let gitPath = try Utilities.zsh("git --exec-path")?.replacingOccurrences(of: "\n", with: "") else { return }
|
|
|
|
|
|
|
|
let lfsPath = URL(fileURLWithPath: gitPath).appendingPathComponent("git-lfs").path
|
|
|
|
|
|
|
|
guard !FileManager.default.fileExists(atPath: lfsPath) else {
|
|
|
|
print("Git LFS already linked.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
try Utilities.zsh("ln -s \"$(which git-lfs)\" \"\(lfsPath)\"")
|
|
|
|
}
|
2023-02-10 14:04:00 +01:00
|
|
|
|
|
|
|
func xcodegen() throws {
|
|
|
|
try Utilities.zsh("xcodegen")
|
|
|
|
}
|
|
|
|
}
|