2023-03-23 11:26:20 +01:00
import ArgumentParser
2024-05-15 10:37:44 +01:00
import CommandLineTools
2023-03-23 11:26:20 +01:00
import Foundation
struct OutdatedPackages : ParsableCommand {
static var configuration = CommandConfiguration ( abstract : " A tool to check outdated package dependencies. Please make sure you have already run setup-project before using this tool. " )
2024-05-15 10:37:44 +01:00
private var projectSwiftPMDirectoryURL : URL { . projectDirectory . appendingPathComponent ( " ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm " ) }
2023-03-23 11:26:20 +01:00
func run ( ) throws {
try checkToolsDependencies ( )
try checkProjectDependencies ( )
}
func checkToolsDependencies ( ) throws {
2024-05-15 10:37:44 +01:00
guard let output = try Zsh . run ( command : " swift outdated " ) , ! output . isEmpty else { return }
2023-03-23 11:26:20 +01:00
print ( " outdated tools Swift packages: \n \( output ) " )
}
func checkProjectDependencies ( ) throws {
2024-05-15 10:37:44 +01:00
guard let output = try Zsh . run ( command : " swift outdated " , directory : projectSwiftPMDirectoryURL ) , ! output . isEmpty else { return }
2023-03-23 11:26:20 +01:00
print ( " outdated project Swift packages: \n \( output ) " )
}
}