Skip to content

Commit 5ca9592

Browse files
authored
Merge pull request #16 from GetAutomaApp/11-swiftformat-config-in-root-of-project-with-appropriate-formatting-and-file-header-rules
ISSUE-11 - SwiftFormat config for project + Header + Attribution
2 parents 8a51f71 + dcabd6b commit 5ca9592

File tree

83 files changed

+960
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+960
-329
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.0

.swiftformat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--maxwidth 120
2+
--allman false
3+
--indent 4
4+
--trimwhitespace always
5+
--header "{file}\nCopyright (c) {year} GetAutomaApp\nAll source code and related assets are the property of GetAutomaApp.\nAll rights reserved.\n\nThis package is freely distributable under the MIT license.\nThis Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver."

Example/Package.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ let package = Package(
99
.macOS(.v12),
1010
],
1111
dependencies: [
12-
.package(name: "SwiftWebDriver", path: "../")
12+
.package(name: "SwiftWebDriver", path: "../"),
1313
],
1414
targets: [
1515
.executableTarget(
1616
name: "SeleniumSwiftExample",
1717
dependencies: [
18-
.product(name: "SwiftWebDriver", package: "SwiftWebDriver")
19-
]),
18+
.product(name: "SwiftWebDriver", package: "SwiftWebDriver"),
19+
]
20+
),
2021
.testTarget(
2122
name: "SeleniumSwiftExampleTests",
22-
dependencies: ["SeleniumSwiftExample"]),
23+
dependencies: ["SeleniumSwiftExample"]
24+
),
2325
]
2426
)

Example/Sources/SeleniumSwiftExample/main.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
// main.swift
2+
// Copyright (c) 2025 GetAutomaApp
3+
// All source code and related assets are the property of GetAutomaApp.
4+
// All rights reserved.
5+
//
6+
// This package is freely distributable under the MIT license.
7+
// This Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver.
8+
19
import SwiftWebDriver
210

311
let chromeOption = try ChromeOptions(
4-
args: [
5-
Args(.headless),
6-
]
12+
args: [
13+
Args(.headless),
14+
]
715
)
816

917
let chromeDriver = try ChromeDriver(
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import XCTest
1+
// SeleniumSwiftExampleTests.swift
2+
// Copyright (c) 2025 GetAutomaApp
3+
// All source code and related assets are the property of GetAutomaApp.
4+
// All rights reserved.
5+
//
6+
// This package is freely distributable under the MIT license.
7+
// This Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver.
8+
29
import class Foundation.Bundle
10+
import XCTest
311

412
final class SeleniumSwiftExampleTests: XCTestCase {
513
func testExample() throws {
@@ -15,33 +23,33 @@ final class SeleniumSwiftExampleTests: XCTestCase {
1523
// Mac Catalyst won't have `Process`, but it is supported for executables.
1624
#if !targetEnvironment(macCatalyst)
1725

18-
let fooBinary = productsDirectory.appendingPathComponent("SeleniumSwiftExample")
26+
let fooBinary = productsDirectory.appendingPathComponent("SeleniumSwiftExample")
1927

20-
let process = Process()
21-
process.executableURL = fooBinary
28+
let process = Process()
29+
process.executableURL = fooBinary
2230

23-
let pipe = Pipe()
24-
process.standardOutput = pipe
31+
let pipe = Pipe()
32+
process.standardOutput = pipe
2533

26-
try process.run()
27-
process.waitUntilExit()
34+
try process.run()
35+
process.waitUntilExit()
2836

29-
let data = pipe.fileHandleForReading.readDataToEndOfFile()
30-
let output = String(data: data, encoding: .utf8)
37+
let data = pipe.fileHandleForReading.readDataToEndOfFile()
38+
let output = String(data: data, encoding: .utf8)
3139

32-
XCTAssertEqual(output, "Hello, world!\n")
40+
XCTAssertEqual(output, "Hello, world!\n")
3341
#endif
3442
}
3543

3644
/// Returns path to the built products directory.
3745
var productsDirectory: URL {
38-
#if os(macOS)
39-
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
40-
return bundle.bundleURL.deletingLastPathComponent()
41-
}
42-
fatalError("couldn't find the products directory")
43-
#else
44-
return Bundle.main.bundleURL
45-
#endif
46+
#if os(macOS)
47+
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
48+
return bundle.bundleURL.deletingLastPathComponent()
49+
}
50+
fatalError("couldn't find the products directory")
51+
#else
52+
return Bundle.main.bundleURL
53+
#endif
4654
}
4755
}

Package.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,34 @@ import PackageDescription
55
let package = Package(
66
name: "swift-webdriver",
77
platforms: [
8-
.macOS(.v10_15),
9-
.iOS(.v13),
10-
.tvOS(.v13),
11-
.watchOS(.v6)
8+
.macOS(.v10_15),
9+
.iOS(.v13),
10+
.tvOS(.v13),
11+
.watchOS(.v6),
1212
],
1313
products: [
1414
.library(
1515
name: "SwiftWebDriver",
16-
targets: ["SwiftWebDriver"]),
16+
targets: ["SwiftWebDriver"]
17+
),
1718
],
1819
dependencies: [
1920
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.10.0"),
2021
.package(url: "https://github.com/apple/swift-nio.git", from: "2.80.0"),
21-
.package(url: "https://github.com/GetAutomaApp/swift-any-codable.git", branch: "main")
22+
.package(url: "https://github.com/GetAutomaApp/swift-any-codable.git", branch: "main"),
2223
],
2324
targets: [
2425
.target(
2526
name: "SwiftWebDriver",
2627
dependencies: [
2728
.product(name: "AsyncHTTPClient", package: "async-http-client"),
2829
.product(name: "NIOFoundationCompat", package: "swift-nio"),
29-
.product(name: "AnyCodable", package: "swift-any-codable")
30-
]),
30+
.product(name: "AnyCodable", package: "swift-any-codable"),
31+
]
32+
),
3133
.testTarget(
3234
name: "SwiftWebDriverIntegrationTests",
33-
dependencies: ["SwiftWebDriver"])
35+
dependencies: ["SwiftWebDriver"]
36+
),
3437
]
3538
)

Sources/SwiftWebDriver/API/APIClient.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// APIClient.swift
2+
// Copyright (c) 2025 GetAutomaApp
3+
// All source code and related assets are the property of GetAutomaApp.
4+
// All rights reserved.
5+
//
6+
// This package is freely distributable under the MIT license.
7+
// This Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver.
8+
19
import AsyncHTTPClient
210
import Foundation
311
import NIO
@@ -25,7 +33,7 @@ struct APIClient {
2533
/// - Parameter request: RequestType
2634
/// - Returns: EventLoopFuture<RequestType.Response>
2735
func request<R>(_ request: R) -> EventLoopFuture<R.Response> where R: RequestType {
28-
return httpClient.execute(request: request).flatMapResult { response -> Result<R.Response, Error> in
36+
httpClient.execute(request: request).flatMapResult { response -> Result<R.Response, Error> in
2937

3038
guard response.status == .ok else {
3139
if
@@ -57,6 +65,6 @@ struct APIClient {
5765
/// - Returns: EventLoopFuture<RequestType.Response>
5866
@discardableResult
5967
func request<R>(_ request: R) async throws -> R.Response where R: RequestType {
60-
return try await self.request(request).get()
68+
try await self.request(request).get()
6169
}
6270
}

Sources/SwiftWebDriver/API/Request/DevTools/DevToolTypes.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// DevToolTypes.swift
2+
// Copyright (c) 2025 GetAutomaApp
3+
// All source code and related assets are the property of GetAutomaApp.
4+
// All rights reserved.
5+
//
6+
// This package is freely distributable under the MIT license.
7+
// This Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver.
18

29
public enum JavascriptExecutionTypes {
310
case sync, async

Sources/SwiftWebDriver/API/Request/DevTools/PostExecuteAsyncRequest.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import Foundation
1+
// PostExecuteAsyncRequest.swift
2+
// Copyright (c) 2025 GetAutomaApp
3+
// All source code and related assets are the property of GetAutomaApp.
4+
// All rights reserved.
5+
//
6+
// This package is freely distributable under the MIT license.
7+
// This Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver.
8+
29
import AsyncHTTPClient
3-
import NIOHTTP1
10+
import Foundation
411
import NIO
12+
import NIOHTTP1
513

614
struct PostExecuteAsyncRequest: RequestType {
715
typealias Response = PostExecuteResponse
@@ -25,16 +33,14 @@ struct PostExecuteAsyncRequest: RequestType {
2533
encoder.outputFormatting = .prettyPrinted
2634
let data = try? encoder.encode(javascriptSnippet)
2735

28-
guard let data = data else {
36+
guard let data else {
2937
return nil
3038
}
3139

3240
return .data(data)
3341
}
34-
3542
}
3643

37-
3844
extension PostExecuteAsyncRequest {
3945
struct RequestBody: Codable {
4046
let script: String

Sources/SwiftWebDriver/API/Request/DevTools/PostExecuteSyncRequest.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// PostExecuteSyncRequest.swift
2+
// Copyright (c) 2025 GetAutomaApp
3+
// All source code and related assets are the property of GetAutomaApp.
4+
// All rights reserved.
5+
//
6+
// This package is freely distributable under the MIT license.
7+
// This Package is a modified fork of https://github.com/ashi-psn/SwiftWebDriver.
18

29
import AsyncHTTPClient
310
import Foundation
@@ -39,4 +46,3 @@ extension PostExecuteSyncRequest {
3946
let args: [String]
4047
}
4148
}
42-

0 commit comments

Comments
 (0)