Skip to content

Commit 1d60de6

Browse files
Update from Hummingbird Project Template (#7)
* Update from hummingbird-project-template 572d468b2cabeca286314c5a35196bd42445c8ef * run swift-format * Remove .swiftformat --------- Co-authored-by: adam-fowler <[email protected]> Co-authored-by: Adam Fowler <[email protected]>
1 parent 76e02f8 commit 1d60de6

20 files changed

+384
-209
lines changed

.github/workflows/validate.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ concurrency:
88

99
jobs:
1010
validate:
11-
runs-on: macOS-latest
11+
runs-on: ubuntu-latest
1212
timeout-minutes: 15
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 1
18-
- name: Install Dependencies
19-
run: |
20-
brew install mint
21-
mint install NickLockwood/[email protected] --no-link
2218
- name: run script
2319
run: ./scripts/validate.sh

.swift-format

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version" : 1,
3+
"indentation" : {
4+
"spaces" : 4
5+
},
6+
"tabWidth" : 4,
7+
"fileScopedDeclarationPrivacy" : {
8+
"accessLevel" : "private"
9+
},
10+
"spacesAroundRangeFormationOperators" : false,
11+
"indentConditionalCompilationBlocks" : false,
12+
"indentSwitchCaseLabels" : false,
13+
"lineBreakAroundMultilineExpressionChainComponents" : false,
14+
"lineBreakBeforeControlFlowKeywords" : false,
15+
"lineBreakBeforeEachArgument" : true,
16+
"lineBreakBeforeEachGenericRequirement" : true,
17+
"lineLength" : 150,
18+
"maximumBlankLines" : 1,
19+
"respectsExistingLineBreaks" : true,
20+
"prioritizeKeepingFunctionOutputTogether" : true,
21+
"multiElementCollectionTrailingCommas" : true,
22+
"rules" : {
23+
"AllPublicDeclarationsHaveDocumentation" : false,
24+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
25+
"AlwaysUseLowerCamelCase" : false,
26+
"AmbiguousTrailingClosureOverload" : true,
27+
"BeginDocumentationCommentWithOneLineSummary" : false,
28+
"DoNotUseSemicolons" : true,
29+
"DontRepeatTypeInStaticProperties" : true,
30+
"FileScopedDeclarationPrivacy" : true,
31+
"FullyIndirectEnum" : true,
32+
"GroupNumericLiterals" : true,
33+
"IdentifiersMustBeASCII" : true,
34+
"NeverForceUnwrap" : false,
35+
"NeverUseForceTry" : false,
36+
"NeverUseImplicitlyUnwrappedOptionals" : false,
37+
"NoAccessLevelOnExtensionDeclaration" : true,
38+
"NoAssignmentInExpressions" : true,
39+
"NoBlockComments" : true,
40+
"NoCasesWithOnlyFallthrough" : true,
41+
"NoEmptyTrailingClosureParentheses" : true,
42+
"NoLabelsInCasePatterns" : true,
43+
"NoLeadingUnderscores" : false,
44+
"NoParensAroundConditions" : true,
45+
"NoVoidReturnOnFunctionSignature" : true,
46+
"OmitExplicitReturns" : true,
47+
"OneCasePerLine" : true,
48+
"OneVariableDeclarationPerLine" : true,
49+
"OnlyOneTrailingClosureArgument" : true,
50+
"OrderedImports" : true,
51+
"ReplaceForEachWithForLoop" : true,
52+
"ReturnVoidInsteadOfEmptyTuple" : true,
53+
"UseEarlyExits" : false,
54+
"UseExplicitNilCheckInConditions" : false,
55+
"UseLetInEveryBoundCaseVariable" : false,
56+
"UseShorthandTypeNames" : true,
57+
"UseSingleLinePropertyGetter" : false,
58+
"UseSynthesizedInitializer" : false,
59+
"UseTripleSlashForDocumentationComments" : true,
60+
"UseWhereClausesInForLoops" : false,
61+
"ValidateDocumentationComments" : false
62+
}
63+
}

.swiftformat

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

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ The main development branch of the repository is `main`.
2828

2929
### Formatting
3030

31-
We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.53.10.
31+
We use Apple's swift-format for formatting code. PRs will not be accepted if they haven't be formatted.

Package.swift

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,47 @@ let package = Package(
2424
.package(url: "https://github.com/swift-server/swift-service-lifecycle", from: "2.0.0"),
2525
],
2626
targets: [
27-
.target(name: "WSClient", dependencies: [
28-
.byName(name: "WSCore"),
29-
.product(name: "HTTPTypes", package: "swift-http-types"),
30-
.product(name: "Logging", package: "swift-log"),
31-
.product(name: "NIOCore", package: "swift-nio"),
32-
.product(name: "NIOHTTPTypesHTTP1", package: "swift-nio-extras"),
33-
.product(name: "NIOPosix", package: "swift-nio"),
34-
.product(name: "NIOSSL", package: "swift-nio-ssl"),
35-
.product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
36-
.product(name: "NIOWebSocket", package: "swift-nio"),
37-
], swiftSettings: swiftSettings),
38-
.target(name: "WSCore", dependencies: [
39-
.product(name: "HTTPTypes", package: "swift-http-types"),
40-
.product(name: "NIOCore", package: "swift-nio"),
41-
.product(name: "NIOWebSocket", package: "swift-nio"),
42-
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
43-
], swiftSettings: swiftSettings),
44-
.target(name: "WSCompression", dependencies: [
45-
.byName(name: "WSCore"),
46-
.product(name: "CompressNIO", package: "compress-nio"),
47-
], swiftSettings: swiftSettings),
27+
.target(
28+
name: "WSClient",
29+
dependencies: [
30+
.byName(name: "WSCore"),
31+
.product(name: "HTTPTypes", package: "swift-http-types"),
32+
.product(name: "Logging", package: "swift-log"),
33+
.product(name: "NIOCore", package: "swift-nio"),
34+
.product(name: "NIOHTTPTypesHTTP1", package: "swift-nio-extras"),
35+
.product(name: "NIOPosix", package: "swift-nio"),
36+
.product(name: "NIOSSL", package: "swift-nio-ssl"),
37+
.product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
38+
.product(name: "NIOWebSocket", package: "swift-nio"),
39+
],
40+
swiftSettings: swiftSettings
41+
),
42+
.target(
43+
name: "WSCore",
44+
dependencies: [
45+
.product(name: "HTTPTypes", package: "swift-http-types"),
46+
.product(name: "NIOCore", package: "swift-nio"),
47+
.product(name: "NIOWebSocket", package: "swift-nio"),
48+
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
49+
],
50+
swiftSettings: swiftSettings
51+
),
52+
.target(
53+
name: "WSCompression",
54+
dependencies: [
55+
.byName(name: "WSCore"),
56+
.product(name: "CompressNIO", package: "compress-nio"),
57+
],
58+
swiftSettings: swiftSettings
59+
),
4860

49-
.testTarget(name: "WebSocketTests", dependencies: [
50-
.byName(name: "WSClient"),
51-
.byName(name: "WSCompression"),
52-
]),
61+
.testTarget(
62+
name: "WebSocketTests",
63+
dependencies: [
64+
.byName(name: "WSClient"),
65+
.byName(name: "WSCompression"),
66+
]
67+
),
5368
],
5469
swiftLanguageVersions: [.v5, .version("6")]
5570
)

Sources/WSClient/Client/ClientConnection.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
import Logging
1616
import NIOCore
1717
import NIOPosix
18+
import NIOWebSocket
19+
1820
#if canImport(Network)
1921
import Network
2022
import NIOTransportServices
2123
#endif
22-
import NIOWebSocket
2324

2425
/// A generic client connection to a server.
2526
///
@@ -104,7 +105,9 @@ public struct ClientConnection<ClientChannel: ClientConnectionChannel>: Sendable
104105
bootstrap = tsBootstrap
105106
} else {
106107
#if os(iOS) || os(tvOS)
107-
self.logger.warning("Running BSD sockets on iOS or tvOS is not recommended. Please use NIOTSEventLoopGroup, to run with the Network framework")
108+
self.logger.warning(
109+
"Running BSD sockets on iOS or tvOS is not recommended. Please use NIOTSEventLoopGroup, to run with the Network framework"
110+
)
108111
#endif
109112
bootstrap = self.createSocketsBootstrap()
110113
}
@@ -117,13 +120,15 @@ public struct ClientConnection<ClientChannel: ClientConnectionChannel>: Sendable
117120
do {
118121
switch address.value {
119122
case .hostname(let host, let port):
120-
result = try await bootstrap
123+
result =
124+
try await bootstrap
121125
.connect(host: host, port: port) { channel in
122126
clientChannel.setup(channel: channel, logger: self.logger)
123127
}
124128
self.logger.debug("Client connnected to \(host):\(port)")
125129
case .unixDomainSocket(let path):
126-
result = try await bootstrap
130+
result =
131+
try await bootstrap
127132
.connect(unixDomainSocketPath: path) { channel in
128133
clientChannel.setup(channel: channel, logger: self.logger)
129134
}
@@ -137,15 +142,16 @@ public struct ClientConnection<ClientChannel: ClientConnectionChannel>: Sendable
137142

138143
/// create a BSD sockets based bootstrap
139144
private func createSocketsBootstrap() -> ClientBootstrap {
140-
return ClientBootstrap(group: self.eventLoopGroup)
145+
ClientBootstrap(group: self.eventLoopGroup)
141146
.channelOption(ChannelOptions.allowRemoteHalfClosure, value: true)
142147
}
143148

144149
#if canImport(Network)
145150
/// create a NIOTransportServices bootstrap using Network.framework
146151
private func createTSBootstrap() -> NIOTSConnectionBootstrap? {
147-
guard let bootstrap = NIOTSConnectionBootstrap(validatingGroup: self.eventLoopGroup)?
148-
.channelOption(ChannelOptions.allowRemoteHalfClosure, value: true)
152+
guard
153+
let bootstrap = NIOTSConnectionBootstrap(validatingGroup: self.eventLoopGroup)?
154+
.channelOption(ChannelOptions.allowRemoteHalfClosure, value: true)
149155
else {
150156
return nil
151157
}

0 commit comments

Comments
 (0)