diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d4bd22f..c842129 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,12 +13,12 @@ jobs: steps: - name: Set up Swift - uses: swift-actions/setup-swift@3aed395c5397f62deb91d8fe7af1418a9ae4d16f # v2.1.0 + uses: SwiftyLab/setup-swift@38f54a76b70d989321de9dc7c840618c08cf56e9 # v1.14.0 with: - swift-version: "5.10.0" + swift-version: "6.3.1" - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Test run: make test diff --git a/.gitignore b/.gitignore index 410dfea..16e8489 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,5 @@ fastlane/test_output .release/ .smoke/ + +.vscode/ diff --git a/.swift-version b/.swift-version index 509b0b6..dc0208a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.10.0 +6.3.1 diff --git a/Package.swift b/Package.swift index 7b9e4b3..12cf3a9 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.10 +// swift-tools-version: 6.3 import PackageDescription @@ -17,7 +17,7 @@ let package = Package( targets: [ .target( name: "ComicSans", - path: "Sources/Comicsans" + path: "Sources/ComicSans", ), .executableTarget( name: "CommandLineTool", @@ -25,14 +25,14 @@ let package = Package( .product(name: "ArgumentParser", package: "swift-argument-parser"), "ComicSans", ], - path: "Sources/CommandLineTool" + path: "Sources/CommandLineTool", ), .testTarget( name: "ComicSansTests", dependencies: [ "ComicSans", ], - path: "Tests/ComicSansTests" + path: "Tests/ComicSansTests", ), - ] + ], ) diff --git a/Sources/ComicSans/ComicSans.swift b/Sources/ComicSans/ComicSans.swift index 3fa022c..0f86a9d 100644 --- a/Sources/ComicSans/ComicSans.swift +++ b/Sources/ComicSans/ComicSans.swift @@ -1,23 +1,31 @@ import Foundation import SwiftUI -public struct ComicSans { +public struct ComicSans: Sendable { let text: String - public let view: ComicSansView + let padding: Int + let horizontalAlignment: HorizontalAlignmentOption + let verticalAlignment: VerticalAlignmentOption + + @MainActor public var view: ComicSansView { + ComicSansView( + text: text, + padding: padding, + horizontalAlignment: horizontalAlignment, + verticalAlignment: verticalAlignment, + ) + } public init( _ text: String, padding: Int = 4, horizontalAlignment: HorizontalAlignmentOption = .leading, - verticalAlignment: VerticalAlignmentOption = .center + verticalAlignment: VerticalAlignmentOption = .center, ) { self.text = text - view = ComicSansView( - text: text, - padding: padding, - horizontalAlignment: horizontalAlignment, - verticalAlignment: verticalAlignment - ) + self.padding = padding + self.horizontalAlignment = horizontalAlignment + self.verticalAlignment = verticalAlignment } public func emojiName() -> String? { diff --git a/Sources/ComicSans/ComicSansView.swift b/Sources/ComicSans/ComicSansView.swift index 5c09683..db41886 100644 --- a/Sources/ComicSans/ComicSansView.swift +++ b/Sources/ComicSans/ComicSansView.swift @@ -13,7 +13,7 @@ public struct ComicSansView: View { text: String, padding: Int, horizontalAlignment: HorizontalAlignmentOption, - verticalAlignment: VerticalAlignmentOption + verticalAlignment: VerticalAlignmentOption, ) { self.text = text self.padding = padding @@ -30,7 +30,7 @@ public struct ComicSansView: View { horizontalAlignment: HorizontalAlignmentOption, verticalAlignment: VerticalAlignmentOption, lineHeightMultiple: CGFloat, - debug: Bool + debug: Bool, ) { self.text = text self.padding = padding @@ -139,7 +139,7 @@ enum Constants { horizontalAlignment: horizontalAlignment, verticalAlignment: verticalAlignment, lineHeightMultiple: lineHeightMultiple, - debug: debug + debug: debug, ) } .padding(1) @@ -171,7 +171,7 @@ enum Constants { padding: 8, horizontalAlignment: .leading, verticalAlignment: .center, - debug: true + debug: true, ) } diff --git a/Sources/ComicSans/HorizontalAlignmentOption.swift b/Sources/ComicSans/HorizontalAlignmentOption.swift index 81e3c50..aa35927 100644 --- a/Sources/ComicSans/HorizontalAlignmentOption.swift +++ b/Sources/ComicSans/HorizontalAlignmentOption.swift @@ -1,6 +1,6 @@ import SwiftUI -public enum HorizontalAlignmentOption: String, CaseIterable { +public enum HorizontalAlignmentOption: String, CaseIterable, Sendable { case leading case center case trailing diff --git a/Sources/ComicSans/VerticalAlignmentOption.swift b/Sources/ComicSans/VerticalAlignmentOption.swift index 42d1f66..a8b7e39 100644 --- a/Sources/ComicSans/VerticalAlignmentOption.swift +++ b/Sources/ComicSans/VerticalAlignmentOption.swift @@ -1,4 +1,4 @@ -public enum VerticalAlignmentOption: String, CaseIterable { +public enum VerticalAlignmentOption: String, CaseIterable, Sendable { case top case center case bottom diff --git a/Sources/CommandLineTool/cs.swift b/Sources/CommandLineTool/cs.swift index aa76e3a..a9cf875 100644 --- a/Sources/CommandLineTool/cs.swift +++ b/Sources/CommandLineTool/cs.swift @@ -4,8 +4,8 @@ import Darwin import SwiftUI @main -struct CommandLineTool: ParsableCommand { - static var configuration = CommandConfiguration( +struct CommandLineTool: @MainActor ParsableCommand { + static let configuration = CommandConfiguration( commandName: "cs", abstract: "cs (comic sans) for :pink-slack-emoji:", usage: """ @@ -19,7 +19,7 @@ struct CommandLineTool: ParsableCommand { Converts text to pink comic sans slack emoji. https://github.com/keyz/comicsans """, version: "0.5.0", - helpNames: .long + helpNames: .long, ) @Argument(help: "Text to convert") @@ -38,7 +38,7 @@ struct CommandLineTool: ParsableCommand { var output: URL = .currentDirectory() private lazy var isBeingPiped: Bool = isatty(fileno(stdin)) == 0 - private lazy var isExpectingPipe: Bool = text == "-" && CommandLine.arguments.last == "-" + private lazy var isExpectingPipe: Bool = text == "-" mutating func validate() throws { guard [0, 4, 8, 12, 16, 20, 24].contains(padding) else { @@ -64,12 +64,12 @@ struct CommandLineTool: ParsableCommand { text, padding: padding, horizontalAlignment: horizontal, - verticalAlignment: vertical + verticalAlignment: vertical, ) let targetPath = try uniqueFilePath( basename: result.emojiName() ?? "unknown", - fileExtension: "png" + fileExtension: "png", ) guard let pngData = result.pngRepresentation() else {