Skip to content

Commit fe1df6a

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 42c7ba9 commit fe1df6a

14 files changed

+34
-644
lines changed

NOTICE.txt

-9
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

-9
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@
7272
"revision": "1d425b0851ffa2695d488cce1d68df2539f42500",
7373
"version": "2.31.2"
7474
}
75-
},
76-
{
77-
"package": "swift-nio-ssl",
78-
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
79-
"state": {
80-
"branch": null,
81-
"revision": "2e74773972bd6254c41ceeda827f229bccbf1c0f",
82-
"version": "2.15.0"
83-
}
8475
}
8576
]
8677
},

Package.swift

-3
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

+22-32
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,15 +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.
9277
/// - port: The port number used by the preview server.
9378
/// - convertAction: The action used to convert the documentation bundle before preview.
9479
/// 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 {
9883
/// is performed.
9984
/// - Throws: If an error is encountered while initializing the documentation context.
10085
public init(
101-
tlsCertificateKey: URL?, tlsCertificateChain: URL?, serverUsername: String?,
102-
serverPassword: String?, port: Int,
86+
port: Int,
10387
createConvertAction: @escaping () throws -> ConvertAction,
10488
workspace: DocumentationWorkspace = DocumentationWorkspace(),
10589
context: DocumentationContext? = nil,
@@ -110,10 +94,6 @@ public final class PreviewAction: Action, RecreatingContext {
11094
}
11195

11296
// Initialize the action context.
113-
self.tlsCertificateKey = tlsCertificateKey
114-
self.tlsCertificateChain = tlsCertificateChain
115-
self.serverUsername = serverUsername
116-
self.serverPassword = serverPassword
11797
self.port = port
11898
self.createConvertAction = createConvertAction
11999
self.convertAction = try createConvertAction()
@@ -123,6 +103,24 @@ public final class PreviewAction: Action, RecreatingContext {
123103
self.context = try context ?? DocumentationContext(dataProvider: workspace, diagnosticEngine: engine)
124104
self.printHTMLTemplatePath = printTemplatePath
125105
}
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+
}
126124

127125
/// Converts a documentation bundle and starts a preview server to render the result of that conversion.
128126
///
@@ -164,20 +162,12 @@ public final class PreviewAction: Action, RecreatingContext {
164162
// Preview the output and monitor the source bundle for changes.
165163
do {
166164
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-
}
165+
print("Starting Local Preview Server", to: &logHandle)
166+
printPreviewAddresses(base: URL(string: "http://localhost:\(port)")!)
177167
print(String(repeating: "=", count: 40), to: &logHandle)
178168

179169
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)
181171

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

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

-4
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

-74
This file was deleted.

Sources/SwiftDocCUtilities/ArgumentParsing/Options/PreviewExternalConnectionOptions.swift

-127
This file was deleted.

Sources/SwiftDocCUtilities/ArgumentParsing/Options/PreviewOptions.swift

-12
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)