-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41bd17b
commit de286e0
Showing
2 changed files
with
49 additions
and
0 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,37 @@ | ||
import Foundation | ||
import PackagePlugin | ||
|
||
@main | ||
struct InstallCLIPluginCommand: CommandPlugin { | ||
|
||
func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws { | ||
let pathToCLI = try context.tool(named: "apollo-ios-cli").path | ||
try createSymbolicLink(from: pathToCLI, to: context.package.directory) | ||
} | ||
|
||
func createSymbolicLink(from: PackagePlugin.Path, to: PackagePlugin.Path) throws { | ||
let task = Process() | ||
task.standardInput = nil | ||
task.environment = ProcessInfo.processInfo.environment | ||
task.arguments = ["-c", "ln -s \(from.string) \(to.string)"] | ||
task.executableURL = URL(fileURLWithPath: "/bin/zsh") | ||
try task.run() | ||
task.waitUntilExit() | ||
} | ||
|
||
} | ||
|
||
#if canImport(XcodeProjectPlugin) | ||
import XcodeProjectPlugin | ||
|
||
extension InstallCLIPluginCommand: XcodeCommandPlugin { | ||
|
||
/// 👇 This entry point is called when operating on an Xcode project. | ||
func performCommand(context: XcodePluginContext, arguments: [String]) throws { | ||
print("Installing Apollo CLI Plugin to Xcode project \(context.xcodeProject.displayName)") | ||
let pathToCLI = try context.tool(named: "apollo-ios-cli").path | ||
try createSymbolicLink(from: pathToCLI, to: context.xcodeProject.directory) | ||
} | ||
|
||
} | ||
#endif |