gitリポジトリのurlを貼り付けるだけでアプリケーションのビルドを実行するアプリ。 macOS用
Revision | da5427fe686b36ec704418986d142e22878f1f3c (tree) |
---|---|
Zeit | 2018-05-26 21:43:15 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
URL(fileURLWithPath:relativeTo:)を利用するようにした
@@ -48,8 +48,8 @@ struct BuildInfo { | ||
48 | 48 | switch type { |
49 | 49 | |
50 | 50 | case .xcworkspace: |
51 | - self.buildURL = ApplicationDirecrories.support.appendingPathComponent(BuildInfo.buildDir) | |
52 | - self.productURL = buildURL.appendingPathComponent("Build/Products/Release") | |
51 | + self.buildURL = URL(fileURLWithPath: BuildInfo.buildDir, relativeTo: ApplicationDirecrories.support) | |
52 | + self.productURL = URL(fileURLWithPath: "Build/Products/Release", relativeTo: buildURL) | |
53 | 53 | self.arguments = [ |
54 | 54 | "-workspace", |
55 | 55 | projectFileURL.lastPathComponent, |
@@ -62,8 +62,8 @@ struct BuildInfo { | ||
62 | 62 | ] |
63 | 63 | |
64 | 64 | case .xcodeproj: |
65 | - self.buildURL = projectURL.appendingPathComponent("build") | |
66 | - self.productURL = buildURL.appendingPathComponent("Release") | |
65 | + self.buildURL = URL(fileURLWithPath: "build", relativeTo: projectURL) | |
66 | + self.productURL = URL(fileURLWithPath: "Release", relativeTo: buildURL) | |
67 | 67 | self.arguments = ["-configuration", "Release"] |
68 | 68 | } |
69 | 69 | } |
@@ -26,7 +26,8 @@ final class Git { | ||
26 | 26 | |
27 | 27 | var repository: URL { |
28 | 28 | |
29 | - return ApplicationDirecrories.support.appendingPathComponent(repositoryName) | |
29 | + return URL(fileURLWithPath: repositoryName, | |
30 | + relativeTo: ApplicationDirecrories.support) | |
30 | 31 | } |
31 | 32 | |
32 | 33 | init(_ url: URL) { |
@@ -62,7 +63,6 @@ final class Git { | ||
62 | 63 | |
63 | 64 | completeHandler?(GitError.other("Unknown Error: \(error)")) |
64 | 65 | } |
65 | - | |
66 | 66 | } |
67 | 67 | |
68 | 68 | private func excuteGit(workingURL: URL, args: [String]) throws { |
@@ -72,8 +72,10 @@ final class Git { | ||
72 | 72 | throw GitError.other("Iligal arguments") |
73 | 73 | } |
74 | 74 | |
75 | - let xcodeURL = NSApplication.appDelegate.xcodeURL | |
76 | - guard let gitURL = xcodeURL?.appendingPathComponent("/Contents/Developer/usr/bin/git") else { | |
75 | + let gitURL = URL(fileURLWithPath: "Contents/Developer/usr/bin/git", | |
76 | + relativeTo: NSApplication.appDelegate.xcodeURL) | |
77 | + guard let gitReachable = try? gitURL.checkResourceIsReachable(), | |
78 | + gitReachable else { | |
77 | 79 | |
78 | 80 | throw GitError.other("git is not found.") |
79 | 81 | } |
@@ -128,20 +130,16 @@ final class Git { | ||
128 | 130 | |
129 | 131 | private func submoduleUpdate(shouldInit: Bool = false) throws { |
130 | 132 | |
131 | - let workingURL = ApplicationDirecrories.support.appendingPathComponent(repositoryName) | |
132 | - | |
133 | 133 | let args = shouldInit ? ["submodule", "update", "-i"] : ["submodule", "update"] |
134 | 134 | |
135 | - try excuteGit(workingURL: workingURL, args: args) | |
135 | + try excuteGit(workingURL: repository, args: args) | |
136 | 136 | } |
137 | 137 | |
138 | 138 | private func pull() throws { |
139 | 139 | |
140 | - let workingURL = ApplicationDirecrories.support.appendingPathComponent(repositoryName) | |
141 | - | |
142 | 140 | let args = ["pull"] |
143 | 141 | |
144 | - try excuteGit(workingURL: workingURL, args: args) | |
142 | + try excuteGit(workingURL: repository, args: args) | |
145 | 143 | } |
146 | 144 | |
147 | 145 | private func tryPull(completeHandler: ((GitError) -> ())?) { |
@@ -10,7 +10,7 @@ import Foundation | ||
10 | 10 | |
11 | 11 | private func fileURL(for name: String) -> URL? { |
12 | 12 | |
13 | - let base = ApplicationDirecrories.support.appendingPathComponent("Logs") | |
13 | + let base = URL(fileURLWithPath: "Logs", relativeTo: ApplicationDirecrories.support) | |
14 | 14 | guard checkDirectory(base) else { |
15 | 15 | |
16 | 16 | return base.appendingPathComponent(name) |
@@ -39,10 +39,12 @@ final class ProjectBuilder { | ||
39 | 39 | |
40 | 40 | func build() throws { |
41 | 41 | |
42 | - let xcodeURL = NSApplication.appDelegate.xcodeURL | |
43 | - guard let builderURL = xcodeURL?.appendingPathComponent("/Contents/Developer/usr/bin/xcodebuild") else { | |
44 | - | |
45 | - throw ProjectBuilderError.commandNotFound | |
42 | + let builderURL = URL(fileURLWithPath: "Contents/Developer/usr/bin/xcodebuild", | |
43 | + relativeTo: NSApplication.appDelegate.xcodeURL) | |
44 | + guard let xcodebuildReachable = try? builderURL.checkResourceIsReachable(), | |
45 | + xcodebuildReachable else { | |
46 | + | |
47 | + throw ProjectBuilderError.commandNotFound | |
46 | 48 | } |
47 | 49 | |
48 | 50 | guard let reachable = try? info.projectURL.checkResourceIsReachable(), |