Skip to content

Commit

Permalink
Merge 9041bcf into ffaa3a5
Browse files Browse the repository at this point in the history
  • Loading branch information
evandcoleman authored Sep 1, 2021
2 parents ffaa3a5 + 9041bcf commit 8bb7b00
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/Scipio/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension Command {
.init(
commandName: "Scipio",
abstract: "A program to pre-build and cache Swift packages",
version: "0.1.12",
version: "0.1.13",
subcommands: [
Command.Build.self,
Command.Upload.self,
Expand Down
13 changes: 7 additions & 6 deletions Sources/ScipioKit/Dependency Processors/CocoaPodProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,24 @@ project '\(projectPath.string)'

private func installPods(in path: Path) throws -> [CocoaPodDescriptor] {
let ruby = try Ruby()
var podCommandPath = try? which("pod")

if podCommandPath == nil {
do {
try sh("pod", "--version")
.waitUntilExit()
} catch {
log.info("🍫 Installing CocoaPods...")

try ruby.installGem("cocoapods")

podCommandPath = try which("pod")
try ruby.bundle(install: "cocoapods", at: path)
}

log.info("🍫 Installing Pods...")

let sandboxPath = path + "Pods"
let manifestPath = path + "Pods/Manifest.lock"
let podCommandPath = try which("pod")

try path.chdir {
try sh(podCommandPath!, "install")
try sh(podCommandPath, "install")
.logOutput()
.waitUntilExit()
}
Expand Down
29 changes: 29 additions & 0 deletions Sources/ScipioKit/Helpers/Ruby.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,35 @@ struct Ruby {
.waitUntilExit()
}

func bundle(install gems: String..., at path: Path) throws {
try bundle(install: gems, at: path)
}

func bundle(install gems: [String], at path: Path) throws {
let gemfilePath = path + "Gemfile"

try gemfilePath.write("""
source "https://rubygems.org"
\(gems.map { #"gem "\#($0)""# }.joined(separator: "\n"))
""")

do {
try sh("bundle", "--version")
.waitUntilExit()
} catch {
try installGem("bundler")
}

let bundlePath = try which("bundle")

try path.chdir {
try sh(bundlePath, "install")
.logOutput()
.waitUntilExit()
}
}

func commandExists(_ command: String) -> Bool {
return (try? which(command)) != nil
}
Expand Down
1 change: 1 addition & 0 deletions Sources/ScipioKit/Helpers/ShellCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func sh(_ command: String, _ arguments: [String], asAdministrator: Bool = false,
ShellCommand.sh(command: command, arguments: arguments, asAdministrator: asAdministrator, passEnvironment: passEnvironment)
}

@discardableResult
func which(_ command: String) throws -> Path {
do {
let output = try sh("/usr/bin/which", command, passEnvironment: true)
Expand Down

0 comments on commit 8bb7b00

Please sign in to comment.