@@ -5,34 +5,17 @@ import PackagePlugin
5
5
struct InstallCLIPluginCommand : CommandPlugin {
6
6
7
7
func performCommand( context: PackagePlugin . PluginContext , arguments: [ String ] ) async throws {
8
- var apolloDirectoryPath : Path ? = nil
9
8
let dependencies = context. package . dependencies
10
- dependencies. forEach { dep in
9
+ try dependencies. forEach { dep in
11
10
if dep. package . displayName == " Apollo " {
12
- apolloDirectoryPath = dep. package . directory
11
+ let process = Process ( )
12
+ let path = try context. tool ( named: " sh " ) . path
13
+ process. executableURL = URL ( fileURLWithPath: path. string)
14
+ process. arguments = [ " \( dep. package . directory) /scripts/download-cli.sh " , context. package . directory. string]
15
+ try process. run ( )
16
+ process. waitUntilExit ( )
13
17
}
14
18
}
15
-
16
- guard let apolloPath = apolloDirectoryPath else {
17
- fatalError ( " No Apollo dependency directory path " )
18
- }
19
-
20
- let process = Process ( )
21
- let tarPath = try context. tool ( named: " tar " ) . path
22
- process. executableURL = URL ( fileURLWithPath: tarPath. string)
23
- process. arguments = [ " -xvf " , " \( apolloPath) /CLI/apollo-ios-cli.tar.gz " ]
24
- try process. run ( )
25
- process. waitUntilExit ( )
26
- }
27
-
28
- func createSymbolicLink( from: PackagePlugin . Path , to: PackagePlugin . Path ) throws {
29
- let task = Process ( )
30
- task. standardInput = nil
31
- task. environment = ProcessInfo . processInfo. environment
32
- task. arguments = [ " -c " , " ln -f -s ' \( from. string) ' ' \( to. string) ' " ]
33
- task. executableURL = URL ( fileURLWithPath: " /bin/zsh " )
34
- try task. run ( )
35
- task. waitUntilExit ( )
36
19
}
37
20
38
21
}
@@ -47,9 +30,9 @@ extension InstallCLIPluginCommand: XcodeCommandPlugin {
47
30
print ( " Installing Apollo CLI Plugin to Xcode project \( context. xcodeProject. displayName) " )
48
31
let apolloPath = " \( context. pluginWorkDirectory) /../../checkouts/apollo-ios "
49
32
let process = Process ( )
50
- let tarPath = try context. tool ( named: " tar " ) . path
51
- process. executableURL = URL ( fileURLWithPath: tarPath . string)
52
- process. arguments = [ " -xvf " , " \( apolloPath) /CLI/apollo-ios- cli.tar.gz " ]
33
+ let path = try context. tool ( named: " sh " ) . path
34
+ process. executableURL = URL ( fileURLWithPath: path . string)
35
+ process. arguments = [ " \( apolloPath) /scripts/download- cli.sh " , context . xcodeProject . directory . string ]
53
36
try process. run ( )
54
37
process. waitUntilExit ( )
55
38
}
0 commit comments