@@ -52,19 +52,12 @@ public final class PreviewAction: Action, RecreatingContext {
52
52
53
53
var logHandle = LogHandle . standardOutput
54
54
55
- let tlsCertificateKey : URL ?
56
- let tlsCertificateChain : URL ?
57
- let serverUsername : String ?
58
- let serverPassword : String ?
59
55
let port : Int
60
56
61
57
var convertAction : ConvertAction
62
58
63
59
public var setupContext : ( ( inout DocumentationContext ) -> Void ) ?
64
60
private var previewPaths : [ String ] = [ ]
65
- private var runSecure : Bool {
66
- return tlsCertificateKey != nil && tlsCertificateChain != nil
67
- }
68
61
69
62
// Use for testing to override binding to a system port
70
63
var bindServerToSocketPath : String ?
@@ -80,15 +73,7 @@ public final class PreviewAction: Action, RecreatingContext {
80
73
81
74
/// Creates a new preview action from the given parameters.
82
75
///
83
- /// The `tlsCertificateKey`, `tlsCertificateChain`, `serverUsername`, and `serverPassword`
84
- /// parameters are optional, but if you provide one, all four are expected. They are used by the preview server
85
- /// to serve content on the local network over SSL.
86
- ///
87
76
/// - Parameters:
88
- /// - tlsCertificateKey: The path to the TLS certificate key used by the preview server for SSL configuration.
89
- /// - tlsCertificateChain: The path to the TLS certificate chain used by the preview server for SSL configuration.
90
- /// - serverUsername: The username used by the preview server for HTTP authentication.
91
- /// - serverPassword: The password used by the preview server for HTTP authentication.
92
77
/// - port: The port number used by the preview server.
93
78
/// - convertAction: The action used to convert the documentation bundle before preview.
94
79
/// On macOS, this action will be reused to convert documentation each time the source is modified.
@@ -98,8 +83,7 @@ public final class PreviewAction: Action, RecreatingContext {
98
83
/// is performed.
99
84
/// - Throws: If an error is encountered while initializing the documentation context.
100
85
public init (
101
- tlsCertificateKey: URL ? , tlsCertificateChain: URL ? , serverUsername: String ? ,
102
- serverPassword: String ? , port: Int ,
86
+ port: Int ,
103
87
createConvertAction: @escaping ( ) throws -> ConvertAction ,
104
88
workspace: DocumentationWorkspace = DocumentationWorkspace ( ) ,
105
89
context: DocumentationContext ? = nil ,
@@ -110,10 +94,6 @@ public final class PreviewAction: Action, RecreatingContext {
110
94
}
111
95
112
96
// Initialize the action context.
113
- self . tlsCertificateKey = tlsCertificateKey
114
- self . tlsCertificateChain = tlsCertificateChain
115
- self . serverUsername = serverUsername
116
- self . serverPassword = serverPassword
117
97
self . port = port
118
98
self . createConvertAction = createConvertAction
119
99
self . convertAction = try createConvertAction ( )
@@ -123,6 +103,24 @@ public final class PreviewAction: Action, RecreatingContext {
123
103
self . context = try context ?? DocumentationContext ( dataProvider: workspace, diagnosticEngine: engine)
124
104
self . printHTMLTemplatePath = printTemplatePath
125
105
}
106
+
107
+ @available ( * , deprecated, message: " TLS support has been removed. " )
108
+ public convenience init (
109
+ tlsCertificateKey: URL ? , tlsCertificateChain: URL ? , serverUsername: String ? ,
110
+ serverPassword: String ? , port: Int ,
111
+ createConvertAction: @escaping ( ) throws -> ConvertAction ,
112
+ workspace: DocumentationWorkspace = DocumentationWorkspace ( ) ,
113
+ context: DocumentationContext ? = nil ,
114
+ printTemplatePath: Bool = true ) throws
115
+ {
116
+ try self . init (
117
+ port: port,
118
+ createConvertAction: createConvertAction,
119
+ workspace: workspace,
120
+ context: context,
121
+ printTemplatePath: printTemplatePath
122
+ )
123
+ }
126
124
127
125
/// Converts a documentation bundle and starts a preview server to render the result of that conversion.
128
126
///
@@ -164,20 +162,12 @@ public final class PreviewAction: Action, RecreatingContext {
164
162
// Preview the output and monitor the source bundle for changes.
165
163
do {
166
164
print ( String ( repeating: " = " , count: 40 ) , to: & logHandle)
167
- if runSecure, let serverUsername = serverUsername, let serverPassword = serverPassword {
168
- print ( " Starting TLS-Enabled Web Server " , to: & logHandle)
169
- printPreviewAddresses ( base: URL ( string: " https:// \( ProcessInfo . processInfo. hostName) : \( port) " ) !)
170
- print ( " \t Username: \( serverUsername) " , to: & logHandle)
171
- print ( " \t Password: \( serverPassword) " , to: & logHandle)
172
-
173
- } else {
174
- print ( " Starting Local Preview Server " , to: & logHandle)
175
- printPreviewAddresses ( base: URL ( string: " http://localhost: \( port) " ) !)
176
- }
165
+ print ( " Starting Local Preview Server " , to: & logHandle)
166
+ printPreviewAddresses ( base: URL ( string: " http://localhost: \( port) " ) !)
177
167
print ( String ( repeating: " = " , count: 40 ) , to: & logHandle)
178
168
179
169
let to : PreviewServer . Bind = bindServerToSocketPath. map { . socket( path: $0) } ?? . localhost( port: port)
180
- servers [ serverIdentifier] = try PreviewServer ( contentURL: convertAction. targetDirectory, bindTo: to, username : serverUsername , password : serverPassword , tlsCertificateChainURL : tlsCertificateChain , tlsCertificateKeyURL : tlsCertificateKey , logHandle: & logHandle)
170
+ servers [ serverIdentifier] = try PreviewServer ( contentURL: convertAction. targetDirectory, bindTo: to, logHandle: & logHandle)
181
171
182
172
// When the user stops docc - stop the preview server first before exiting.
183
173
trapSignals ( )
0 commit comments