@@ -16,9 +16,7 @@ struct Main
16
16
var development : Swiftinit . ServerOptions . Development
17
17
18
18
var redirect : Bool
19
- /// Whether to enable GitHub integration if access keys are available.
20
- /// Defaults to false.
21
- var github : Bool
19
+ var mirror : Bool
22
20
var mongo : Mongo . Host
23
21
24
22
private
@@ -28,7 +26,7 @@ struct Main
28
26
self . certificates = " Local/Server/Certificates "
29
27
self . development = . init( )
30
28
self . redirect = false
31
- self . github = false
29
+ self . mirror = false
32
30
self . mongo = " unidoc-mongod "
33
31
}
34
32
}
@@ -84,6 +82,9 @@ extension Main
84
82
case " --enable-whitelists " :
85
83
self . development. whitelists = true
86
84
85
+ case " -q " , " --mirror " :
86
+ self . mirror = true
87
+
87
88
case " -r " , " --redirect " :
88
89
self . redirect = true
89
90
@@ -104,7 +105,9 @@ extension Main
104
105
}
105
106
106
107
case " --enable-github " :
107
- self . github = true
108
+ Log [ . warning] = """
109
+ This option is deprecated, GitHub integration is now always enabled.
110
+ """
108
111
109
112
case " -p " , " --port " :
110
113
guard let port: String = arguments. next ( )
@@ -155,31 +158,36 @@ extension Main
155
158
// configuration.applicationProtocols = ["h2", "http/1.1"]
156
159
configuration. applicationProtocols = [ " h2 " ]
157
160
158
- var options : Swiftinit . ServerOptions = . init(
159
- authority : self . authority . init ( tls: try . init( configuration: configuration) ) )
161
+ let authority : any ServerAuthority = self . authority . init (
162
+ tls: try . init( configuration: configuration) )
160
163
161
164
let assets : FilePath = " Assets "
165
+ let github : GitHub . Integration ?
162
166
do
163
167
{
164
- options . github = try . load( secrets: assets / " secrets " , active : self . github )
168
+ github = try . load( secrets: assets / " secrets " )
165
169
}
166
170
catch let error
167
171
{
168
172
// Temporary workaround for bypassing backtrace collection.
169
173
Log [ . debug] = " GitHub integration disabled ( \( error) ) "
174
+ github = nil
170
175
}
171
176
172
177
if self . authority is Localhost . Type
173
178
{
174
- options. mode = . development( . init( source: assets) , self . development)
175
- options. bucket = self . development. bucket
179
+ return . init( authority: authority,
180
+ github: github,
181
+ bucket: self . development. bucket,
182
+ mode: . development( . init( source: assets) , self . development) )
176
183
}
177
184
else
178
185
{
179
- options. bucket = . init( region: . us_east_1, name: " symbolgraphs " )
186
+ return . init( authority: authority,
187
+ github: github,
188
+ bucket: . init( region: . us_east_1, name: " symbolgraphs " ) ,
189
+ mode: . production( mirror: self . mirror) )
180
190
}
181
-
182
- return options
183
191
}
184
192
185
193
private consuming
@@ -222,18 +230,25 @@ extension Main
222
230
{
223
231
@Sendable ( pool: Mongo . SessionPool) in
224
232
225
- var plugins : [ any Swiftinit . ServerPlugin ] =
226
- [
227
- Swiftinit . LinkerPlugin. init ( bucket: options. bucket) ,
228
- ]
233
+ var plugins : [ any Swiftinit . ServerPlugin ] = [ ]
229
234
230
235
if options. whitelists
231
236
{
232
237
plugins. append ( Swiftinit . PolicyPlugin. init ( ) )
233
238
}
234
- if let github: GitHub . Integration = options. github,
235
- github. active
239
+
240
+ nonmirror:
241
+ if !options. mode. mirror
236
242
{
243
+ plugins. append ( Swiftinit . LinkerPlugin. init ( bucket: options. bucket) )
244
+
245
+ guard
246
+ let github: GitHub . Integration = options. github
247
+ else
248
+ {
249
+ break nonmirror
250
+ }
251
+
237
252
plugins. append ( GitHub . CrawlerPlugin< GitHub . RepoTelescope> . init(
238
253
api: github. api,
239
254
id: " telescope " ) )
0 commit comments