Skip to content

Commit f60f7d2

Browse files
committed
Remove dependency on Swift-NIO SSL
This removes Swift-DocC's dependency on Swift-NIO SSL. The removal is motivated by Swift-NIO SSL deprecating support for CentOS 7 due to BoringSSL removing support for CentOS 7. The Swift-NIO SSL dependency is currently used to support running a documentation preview server over HTTPS which allows users to preview content on a secondary device while authoring it on a primary device since many OS's won't allow accessing non-local content over HTTP. With the introduction of `--transform-for-static-hosting` and the subsequent enabling of that feature by default, there's less need for Swift-DocC to ship a solution for this niche feature out-of-the-box since standard command-line based preview servers now support serving DocC archives with minimal additional configuration. Resolves rdar://93197483.
1 parent 3cf660c commit f60f7d2

File tree

15 files changed

+40
-645
lines changed

15 files changed

+40
-645
lines changed

NOTICE.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ This product contains Swift NIO.
3131

3232
---
3333

34-
This product contains Swift NIO SSL.
35-
36-
* LICENSE (Apache License 2.0):
37-
* https://www.apache.org/licenses/LICENSE-2.0
38-
* HOMEPAGE:
39-
* https://github.com/apple/swift-nio-ssl
40-
41-
---
42-
4334
This product contains Swift Crypto.
4435

4536
* LICENSE (Apache License 2.0):

Package.resolved

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ let package = Package(
6060
name: "SwiftDocCUtilities",
6161
dependencies: [
6262
"SwiftDocC",
63-
.product(name: "NIOSSL", package: "swift-nio-ssl"),
6463
.product(name: "NIOHTTP1", package: "swift-nio"),
6564
.product(name: "ArgumentParser", package: "swift-argument-parser")
6665
]),
@@ -120,7 +119,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
120119
// Building standalone, so fetch all dependencies remotely.
121120
package.dependencies += [
122121
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMinor(from: "2.31.2")),
123-
.package(url: "https://github.com/apple/swift-nio-ssl.git", .upToNextMinor(from: "2.15.0")),
124122
.package(name: "swift-markdown", url: "https://github.com/apple/swift-markdown.git", .branch("main")),
125123
.package(name: "CLMDB", url: "https://github.com/apple/swift-lmdb.git", .branch("main")),
126124
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")),
@@ -138,7 +136,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
138136
// Building in the Swift.org CI system, so rely on local versions of dependencies.
139137
package.dependencies += [
140138
.package(path: "../swift-nio"),
141-
.package(path: "../swift-nio-ssl"),
142139
.package(path: "../swift-markdown"),
143140
.package(name: "CLMDB", path: "../swift-lmdb"),
144141
.package(path: "../swift-argument-parser"),

Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,12 @@ public final class PreviewAction: Action, RecreatingContext {
5252

5353
var logHandle = LogHandle.standardOutput
5454

55-
let tlsCertificateKey: URL?
56-
let tlsCertificateChain: URL?
57-
let serverUsername: String?
58-
let serverPassword: String?
5955
let port: Int
6056

6157
var convertAction: ConvertAction
6258

6359
public var setupContext: ((inout DocumentationContext) -> Void)?
6460
private var previewPaths: [String] = []
65-
private var runSecure: Bool {
66-
return tlsCertificateKey != nil && tlsCertificateChain != nil
67-
}
6861

6962
// Use for testing to override binding to a system port
7063
var bindServerToSocketPath: String?
@@ -80,16 +73,7 @@ public final class PreviewAction: Action, RecreatingContext {
8073

8174
/// Creates a new preview action from the given parameters.
8275
///
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-
///
8776
/// - 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-
/// - port: The port number used by the preview server.
9377
/// - convertAction: The action used to convert the documentation bundle before preview.
9478
/// On macOS, this action will be reused to convert documentation each time the source is modified.
9579
/// - workspace: The documentation workspace used by the the action's documentation context.
@@ -98,8 +82,7 @@ public final class PreviewAction: Action, RecreatingContext {
9882
/// is performed.
9983
/// - Throws: If an error is encountered while initializing the documentation context.
10084
public init(
101-
tlsCertificateKey: URL?, tlsCertificateChain: URL?, serverUsername: String?,
102-
serverPassword: String?, port: Int,
85+
port: Int,
10386
createConvertAction: @escaping () throws -> ConvertAction,
10487
workspace: DocumentationWorkspace = DocumentationWorkspace(),
10588
context: DocumentationContext? = nil,
@@ -110,10 +93,6 @@ public final class PreviewAction: Action, RecreatingContext {
11093
}
11194

11295
// Initialize the action context.
113-
self.tlsCertificateKey = tlsCertificateKey
114-
self.tlsCertificateChain = tlsCertificateChain
115-
self.serverUsername = serverUsername
116-
self.serverPassword = serverPassword
11796
self.port = port
11897
self.createConvertAction = createConvertAction
11998
self.convertAction = try createConvertAction()
@@ -123,6 +102,24 @@ public final class PreviewAction: Action, RecreatingContext {
123102
self.context = try context ?? DocumentationContext(dataProvider: workspace, diagnosticEngine: engine)
124103
self.printHTMLTemplatePath = printTemplatePath
125104
}
105+
106+
@available(*, deprecated, message: "TLS support has been removed.")
107+
public convenience init(
108+
tlsCertificateKey: URL?, tlsCertificateChain: URL?, serverUsername: String?,
109+
serverPassword: String?, port: Int,
110+
createConvertAction: @escaping () throws -> ConvertAction,
111+
workspace: DocumentationWorkspace = DocumentationWorkspace(),
112+
context: DocumentationContext? = nil,
113+
printTemplatePath: Bool = true) throws
114+
{
115+
try self.init(
116+
port: port,
117+
createConvertAction: createConvertAction,
118+
workspace: workspace,
119+
context: context,
120+
printTemplatePath: printTemplatePath
121+
)
122+
}
126123

127124
/// Converts a documentation bundle and starts a preview server to render the result of that conversion.
128125
///
@@ -164,20 +161,12 @@ public final class PreviewAction: Action, RecreatingContext {
164161
// Preview the output and monitor the source bundle for changes.
165162
do {
166163
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("\tUsername: \(serverUsername)", to: &logHandle)
171-
print("\tPassword: \(serverPassword)", to: &logHandle)
172-
173-
} else {
174-
print("Starting Local Preview Server", to: &logHandle)
175-
printPreviewAddresses(base: URL(string: "http://localhost:\(port)")!)
176-
}
164+
print("Starting Local Preview Server", to: &logHandle)
165+
printPreviewAddresses(base: URL(string: "http://localhost:\(port)")!)
177166
print(String(repeating: "=", count: 40), to: &logHandle)
178167

179168
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)
169+
servers[serverIdentifier] = try PreviewServer(contentURL: convertAction.targetDirectory, bindTo: to, logHandle: &logHandle)
181170

182171
// When the user stops docc - stop the preview server first before exiting.
183172
trapSignals()

Sources/SwiftDocCUtilities/ArgumentParsing/ActionExtensions/PreviewAction+CommandInitialization.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ extension PreviewAction {
2323
{
2424
// Initialize the `PreviewAction` from the options provided by the `Preview` command
2525
try self.init(
26-
tlsCertificateKey: previewOptions.externalConnectionOptions.tlsCertificateKeyURL,
27-
tlsCertificateChain: previewOptions.externalConnectionOptions.tlsCertificateChainURL,
28-
serverUsername: previewOptions.externalConnectionOptions.username,
29-
serverPassword: previewOptions.externalConnectionOptions.password,
3026
port: previewOptions.port,
3127
createConvertAction: {
3228
try ConvertAction(

Sources/SwiftDocCUtilities/ArgumentParsing/ArgumentValidation/CredentialArgumentValidator.swift

Lines changed: 0 additions & 74 deletions
This file was deleted.

Sources/SwiftDocCUtilities/ArgumentParsing/Options/PreviewExternalConnectionOptions.swift

Lines changed: 0 additions & 127 deletions
This file was deleted.

Sources/SwiftDocCUtilities/ArgumentParsing/Options/PreviewOptions.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ public struct PreviewOptions: ParsableArguments {
3535
valueName: "port-number"))
3636
public var port: Int = 8000
3737

38-
/// The options used when configuring the preview server for external connections.
39-
///
40-
/// This group of options is only considered valid if either none of
41-
/// the ``PreviewExternalConnectionOptions/username``, ``PreviewExternalConnectionOptions/password``,
42-
/// ``PreviewExternalConnectionOptions/tlsCertificateChainURL``, ``PreviewExternalConnectionOptions/tlsCertificateKeyURL``
43-
/// values were provided **or** if they all were.
44-
///
45-
/// If the ``PreviewExternalConnectionOptions/externalConnectionsAreEnabled`` Boolean value
46-
/// is true, then **all** four values were provided and validated.
47-
@OptionGroup()
48-
public var externalConnectionOptions: PreviewExternalConnectionOptions
49-
5038
public mutating func validate() throws {
5139
// Check that a valid port has been provided
5240
guard port > 1023 else {

0 commit comments

Comments
 (0)