@@ -19,14 +19,19 @@ import FirebaseManifest
1919import Foundation
2020import Utils
2121
22+ enum ParsingMode : String , EnumerableFlag {
23+ case forNoticesGeneration
24+ case forGHAMatrixGeneration
25+ }
26+
2227struct ManifestParser : ParsableCommand {
2328 @Option ( help: " The path of the SDK repo. " ,
2429 transform: { str in
2530 if NSString ( string: str) . isAbsolutePath { return URL ( fileURLWithPath: str) }
2631 let documentDir = URL ( fileURLWithPath: FileManager . default. currentDirectoryPath)
2732 return documentDir. appendingPathComponent ( str)
2833 } )
29- var SDKRepoURL : URL
34+ var SDKRepoURL : URL ?
3035
3136 /// Path of a text file for Firebase Pods' names.
3237 @Option ( help: " An output file with Podspecs " ,
@@ -35,32 +40,45 @@ struct ManifestParser: ParsableCommand {
3540 let documentDir = URL ( fileURLWithPath: FileManager . default. currentDirectoryPath)
3641 return documentDir. appendingPathComponent ( str)
3742 } )
38- var specOutputFilePath : URL
43+ var outputFilePath : URL
3944
4045 @Option ( parsing: . upToNextOption, help: " Podspec files that will not be included. " )
4146 var excludedSpecs : [ String ]
4247
48+ @Flag ( help: " Parsing mode for manifest " )
49+ var mode : ParsingMode
50+
4351 func parsePodNames( _ manifest: Manifest ) throws {
4452 var output : [ String ] = [ ]
4553 for pod in manifest. pods {
4654 output. append ( pod. name)
4755 }
4856 do {
4957 try output. joined ( separator: " , " )
50- . write ( to: specOutputFilePath , atomically: true ,
58+ . write ( to: outputFilePath , atomically: true ,
5159 encoding: String . Encoding. utf8)
52- print ( " \( output) is written in \n \( specOutputFilePath ) . " )
60+ print ( " \( output) is written in \n \( outputFilePath ) . " )
5361 } catch {
5462 throw error
5563 }
5664 }
5765
5866 func run( ) throws {
59- let specCollector = GHAMatrixSpecCollector (
60- SDKRepoURL: SDKRepoURL,
61- outputSpecFileURL: specOutputFilePath
62- )
63- try specCollector. generateMatrixJson ( to: specOutputFilePath)
67+ switch mode {
68+ case . forNoticesGeneration:
69+ try parsePodNames ( FirebaseManifest . shared)
70+ case . forGHAMatrixGeneration:
71+ guard let sdkRepoURL = SDKRepoURL else {
72+ throw fatalError (
73+ " --sdk-repo-url should be specified when --for-gha-matrix-generation is on. "
74+ )
75+ }
76+ let specCollector = GHAMatrixSpecCollector (
77+ SDKRepoURL: sdkRepoURL,
78+ outputSpecFileURL: outputFilePath
79+ )
80+ try specCollector. generateMatrixJson ( to: outputFilePath)
81+ }
6482 }
6583}
6684
0 commit comments