@@ -19,14 +19,19 @@ import FirebaseManifest
19
19
import Foundation
20
20
import Utils
21
21
22
+ enum ParsingMode : String , EnumerableFlag {
23
+ case forNoticesGeneration
24
+ case forGHAMatrixGeneration
25
+ }
26
+
22
27
struct ManifestParser : ParsableCommand {
23
28
@Option ( help: " The path of the SDK repo. " ,
24
29
transform: { str in
25
30
if NSString ( string: str) . isAbsolutePath { return URL ( fileURLWithPath: str) }
26
31
let documentDir = URL ( fileURLWithPath: FileManager . default. currentDirectoryPath)
27
32
return documentDir. appendingPathComponent ( str)
28
33
} )
29
- var SDKRepoURL : URL
34
+ var SDKRepoURL : URL ?
30
35
31
36
/// Path of a text file for Firebase Pods' names.
32
37
@Option ( help: " An output file with Podspecs " ,
@@ -35,32 +40,45 @@ struct ManifestParser: ParsableCommand {
35
40
let documentDir = URL ( fileURLWithPath: FileManager . default. currentDirectoryPath)
36
41
return documentDir. appendingPathComponent ( str)
37
42
} )
38
- var specOutputFilePath : URL
43
+ var outputFilePath : URL
39
44
40
45
@Option ( parsing: . upToNextOption, help: " Podspec files that will not be included. " )
41
46
var excludedSpecs : [ String ]
42
47
48
+ @Flag ( help: " Parsing mode for manifest " )
49
+ var mode : ParsingMode
50
+
43
51
func parsePodNames( _ manifest: Manifest ) throws {
44
52
var output : [ String ] = [ ]
45
53
for pod in manifest. pods {
46
54
output. append ( pod. name)
47
55
}
48
56
do {
49
57
try output. joined ( separator: " , " )
50
- . write ( to: specOutputFilePath , atomically: true ,
58
+ . write ( to: outputFilePath , atomically: true ,
51
59
encoding: String . Encoding. utf8)
52
- print ( " \( output) is written in \n \( specOutputFilePath ) . " )
60
+ print ( " \( output) is written in \n \( outputFilePath ) . " )
53
61
} catch {
54
62
throw error
55
63
}
56
64
}
57
65
58
66
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
+ }
64
82
}
65
83
}
66
84
0 commit comments