diff --git a/.periphery.yml b/.periphery.yml index b8b84be..444752c 100644 --- a/.periphery.yml +++ b/.periphery.yml @@ -1,3 +1,5 @@ retain_public: true targets: - SublimationBonjour +retain_files: +- '**/*+Protobuf.swift' diff --git a/Package.swift b/Package.swift index 89719ba..1e951ab 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,5 @@ // swift-tools-version: 6.0 -// swiftlint:disable explicit_acl explicit_top_level_acl + import PackageDescription let swiftSettings: [SwiftSetting] = [ @@ -61,4 +61,4 @@ let package = Package( ) ] ) -// swiftlint:enable explicit_acl explicit_top_level_acl + diff --git a/Scripts/header.sh b/Scripts/header.sh index 39eff6c..4ed7446 100755 --- a/Scripts/header.sh +++ b/Scripts/header.sh @@ -66,6 +66,13 @@ header_template="// # Loop through each Swift file in the specified directory and subdirectories find "$directory" -type f -name "*.swift" | while read -r file; do + # Check if the first line is the swift-format-ignore indicator + first_line=$(head -n 1 "$file") + if [[ "$first_line" == "// swift-format-ignore-file" ]]; then + echo "Skipping $file due to swift-format-ignore directive." + continue + fi + # Create the header with the current filename filename=$(basename "$file") header=$(printf "$header_template" "$filename" "$package" "$creator" "$year" "$company") @@ -88,4 +95,4 @@ find "$directory" -type f -name "*.swift" | while read -r file; do rm temp_file done -echo "Headers added to all Swift files in the directory and subdirectories." \ No newline at end of file +echo "Headers added or files skipped appropriately across all Swift files in the directory and subdirectories." \ No newline at end of file diff --git a/Scripts/lint.sh b/Scripts/lint.sh index 039e7df..5e5b1d3 100755 --- a/Scripts/lint.sh +++ b/Scripts/lint.sh @@ -46,5 +46,5 @@ $PACKAGE_DIR/scripts/header.sh -d $PACKAGE_DIR/Sources -c "Leo Dion" -o "Bright $MINT_RUN swift-format lint --recursive --parallel $SWIFTFORMAT_OPTIONS $PACKAGE_DIR/Sources pushd $PACKAGE_DIR -$MINT_RUN periphery scan $PERIPHERY_OPTIONS +$MINT_RUN periphery scan $PERIPHERY_OPTIONS --disable-update-check popd diff --git a/Sources/SublimationBonjour/BindingConfiguration+Protobuf.swift b/Sources/SublimationBonjour/BindingConfiguration+Protobuf.swift index e400c41..c62f318 100644 --- a/Sources/SublimationBonjour/BindingConfiguration+Protobuf.swift +++ b/Sources/SublimationBonjour/BindingConfiguration+Protobuf.swift @@ -1,31 +1,4 @@ -// -// BindingConfiguration+Protobuf.swift -// SublimationBonjour -// -// Created by Leo Dion. -// Copyright © 2024 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// +// swift-format-ignore-file private import Foundation public import SwiftProtobuf @@ -84,7 +57,7 @@ public struct BindingConfiguration { extension BindingConfiguration: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = "ServerConfiguration" + public static let protoMessageName: String = "BindingConfiguration" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "is_secure"), 2: .same(proto: "port"), 9: .same(proto: "hosts"), ] diff --git a/Sources/SublimationBonjour/BonjourSublimatory.swift b/Sources/SublimationBonjour/BonjourSublimatory.swift index 814fe39..9720b1b 100644 --- a/Sources/SublimationBonjour/BonjourSublimatory.swift +++ b/Sources/SublimationBonjour/BonjourSublimatory.swift @@ -114,7 +114,7 @@ listener.newConnectionHandler = { connection in connection.stateUpdateHandler = { state in - switch state { case let .waiting(error): + switch state { case .waiting(let error): print("Connection Waiting error: \(error)") @@ -129,7 +129,7 @@ connection.cancel() } ) - case let .failed(error): print("Connection Failure: \(error)") + case .failed(let error): print("Connection Failure: \(error)") default: print("Connection state updated: \(state)") } @@ -141,12 +141,12 @@ return try await withCheckedThrowingContinuation { continuation in listener.stateUpdateHandler = { state in - switch state { case let .waiting(error): + switch state { case .waiting(let error): print("Listener Waiting error: \(error)") continuation.resume(throwing: error) - case let .failed(error): + case .failed(let error): print("Listener Failure: \(error)") continuation.resume(throwing: error) case .cancelled: continuation.resume() diff --git a/Sources/SublimationBonjour/Client/BonjourClient.swift b/Sources/SublimationBonjour/Client/BonjourClient.swift index 3413f82..3eb4761 100644 --- a/Sources/SublimationBonjour/Client/BonjourClient.swift +++ b/Sources/SublimationBonjour/Client/BonjourClient.swift @@ -85,14 +85,14 @@ browser.browseResultsChangedHandler = { results, _ in self.parseResults(results) } } - private static func descriptionFor(state: NWConnection.State) -> String { - switch state { case .setup: "setup" case .waiting: "waiting" case .preparing: "preparing" - case .ready: "ready" - case .failed: "failed" - case .cancelled: "cancelled" - default: "unknown" - } - } + // private static func descriptionFor(state: NWConnection.State) -> String { + // switch state { case .setup: "setup" case .waiting: "waiting" case .preparing: "preparing" + // case .ready: "ready" + // case .failed: "failed" + // case .cancelled: "cancelled" + // default: "unknown" + // } + // } private func append(urls: [URL]) async { await self.streams.yield(urls, logger: self.logger) } @@ -140,7 +140,7 @@ } public func addResults(_ results: Set) { for result in results { - guard case let .bonjour(txtRecord) = result.metadata else { + guard case .bonjour(let txtRecord) = result.metadata else { self.logger?.error("No TXT Record for \(result.endpoint.debugDescription)") continue } diff --git a/Sources/SublimationBonjour/NWListener.swift b/Sources/SublimationBonjour/NWListener.swift index 4258761..6882377 100644 --- a/Sources/SublimationBonjour/NWListener.swift +++ b/Sources/SublimationBonjour/NWListener.swift @@ -33,10 +33,10 @@ extension NWListener.State: @retroactive CustomDebugStringConvertible { public var debugDescription: String { - switch self { case .setup: "setup" case let .waiting(error): + switch self { case .setup: "setup" case .waiting(let error): "waiting: \(error.debugDescription)" case .ready: "ready" - case let .failed(error): "failed: \(error.debugDescription)" + case .failed(let error): "failed: \(error.debugDescription)" case .cancelled: "cancelled" @unknown default: "unknown state" } diff --git a/Sources/SublimationBonjour/Sublimation+Bonjour.swift b/Sources/SublimationBonjour/Sublimation+Bonjour.swift index 7e9991c..c157329 100644 --- a/Sources/SublimationBonjour/Sublimation+Bonjour.swift +++ b/Sources/SublimationBonjour/Sublimation+Bonjour.swift @@ -35,11 +35,11 @@ /// Initializes a `Sublimation` instance with the provided parameters. /// /// - Parameters: + /// - bindingConfiguration: A configuration with addresses, port and tls configuration. + /// - name: Service name. + /// - type: Service type. /// - listenerParameters: The network parameters to use for the listener. Default is `.tcp`. - /// - serviceType: The Bonjour service type. Default is `BonjourSublimatory.httpTCPServiceType`. - /// - maximumCount: The maximum number of connections. Default is `nil`. - /// - addresses: A closure that asynchronously returns a list of addresses. - /// - addressFilter: A closure that filters the addresses. Default is `String.isIPv4NotLocalhost(_:)`. + /// public convenience init( bindingConfiguration: BindingConfiguration, name: String = BonjourSublimatory.defaultName,