Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/api-breakage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: swift:6.0
image: swift:6.2
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Swift Format Lint

on:
push:
branches: [main]
paths:
- "**.swift"
pull_request:
branches: [main]
workflow_dispatch:

jobs:
linux:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
image: ["swift:6.2"]

container:
image: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check Format
run: swift format lint -prs .
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ DerivedData/
.netrc
Package.resolved
/.vscode
/.devcontainer
/.devcontainer
.swift-version
63 changes: 63 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version": 1,
"indentation": {
"spaces": 4
},
"tabWidth": 4,
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"spacesAroundRangeFormationOperators": false,
"indentConditionalCompilationBlocks": false,
"indentSwitchCaseLabels": false,
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": true,
"lineLength": 140,
"maximumBlankLines": 1,
"respectsExistingLineBreaks": true,
"prioritizeKeepingFunctionOutputTogether": true,
"multiElementCollectionTrailingCommas": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": false,
"AlwaysUseLowerCamelCase": false,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": false,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": false,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"UseEarlyExits": false,
"UseExplicitNilCheckInConditions": false,
"UseLetInEveryBoundCaseVariable": false,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": false,
"UseSynthesizedInitializer": false,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": false,
"ValidateDocumentationComments": false
}
}
1 change: 0 additions & 1 deletion .swiftformat

This file was deleted.

8 changes: 4 additions & 4 deletions Examples/HummingbirdDemo/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import PackageDescription
let package = Package(
name: "HummingbirdDemo",
platforms: [
.macOS(.v14),
.macOS(.v14)
],
products: [
.executable(name: "App", targets: ["App"]),
.executable(name: "App", targets: ["App"])
],
dependencies: [
.package(path: "../../"),
Expand All @@ -32,9 +32,9 @@ let package = Package(
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
],
resources: [
.copy("Public"),
.copy("Public")
],
swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]
),
)
]
)
4 changes: 2 additions & 2 deletions Examples/HummingbirdDemo/Sources/App/App.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import Hummingbird
import HummingbirdWebSocket
import HummingbirdWSCompression
import HummingbirdWebSocket

@main
struct App {
Expand All @@ -22,7 +22,7 @@ struct App {
onServerRunning: { _ in
print("Server running on http://localhost:8080/")
#if DEBUG
browserSyncReload()
browserSyncReload()
#endif
}
)
Expand Down
18 changes: 9 additions & 9 deletions Examples/HummingbirdDemo/Sources/App/BrowserSync.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Foundation

#if DEBUG
func browserSyncReload() {
let p = Process()
p.executableURL = URL(string: "file:///bin/sh")
p.arguments = ["-c", "browser-sync reload"]
do {
try p.run()
} catch {
print("Could not auto-reload: \(error)")
}
func browserSyncReload() {
let p = Process()
p.executableURL = URL(string: "file:///bin/sh")
p.arguments = ["-c", "browser-sync reload"]
do {
try p.run()
} catch {
print("Could not auto-reload: \(error)")
}
}
#endif
15 changes: 10 additions & 5 deletions Examples/HummingbirdDemo/Sources/App/Views.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ struct MainPage: HTMLDocument {
div(.hx.ext(.ws), .ws.connect("/echo"), .hx.target("#echo")) {
form(.ws.send, .style("display: flex;")) {
input(.type(.text), .name("message"), .value("Hello, World!"), .required)
button(.class("btn btn-primary"), .style("height: 100%; margin-left: 1rem;")) { "Send" }
button(.class("btn btn-primary"), .style("height: 100%; margin-left: 1rem;")) {
"Send"
}
}
div(.id("echo")) {}
}
Expand All @@ -52,7 +54,7 @@ struct MainPage: HTMLDocument {
struct ItemList: HTML {
@Environment(EnvironmentValues.$database) var database

var content: some HTML<HTMLTag.div> {
var body: some HTML<HTMLTag.div> {
div(.id("list")) {
let items = await database.model.items

Expand All @@ -72,7 +74,7 @@ struct ItemList: HTML {
}

struct TimeHeading: HTML {
var content: some HTML<HTMLTag.h4> {
var body: some HTML<HTMLTag.h4> {
h4 {
"Server Time: \(Date())"
}
Expand All @@ -86,8 +88,11 @@ enum EnvironmentValues {
struct WSResponse: HTML {
var echoRequest: EchoRequest

var content: some HTML {
div(.id(echoRequest.headers.hxTarget), .hx.swapOOB(.beforeEnd, "#\(echoRequest.headers.hxTarget)")) {
var body: some HTML {
div(
.id(echoRequest.headers.hxTarget),
.hx.swapOOB(.beforeEnd, "#\(echoRequest.headers.hxTarget)")
) {
"Received: \(echoRequest.message) at \(Date())"
br()
}
Expand Down
8 changes: 4 additions & 4 deletions Examples/VaporDemo/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import PackageDescription
let package = Package(
name: "HummingbirdDemo",
platforms: [
.macOS(.v14),
.macOS(.v14)
],
products: [
.executable(name: "App", targets: ["App"]),
.executable(name: "App", targets: ["App"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor", from: "4.102.0"),
Expand All @@ -27,9 +27,9 @@ let package = Package(
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
],
resources: [
.copy("Public"),
.copy("Public")
],
swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]
),
)
]
)
2 changes: 1 addition & 1 deletion Examples/VaporDemo/Sources/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct App {
addRoutes(to: app)

#if DEBUG
app.lifecycle.use(BrowserSyncHandler())
app.lifecycle.use(BrowserSyncHandler())
#endif

try await app.execute()
Expand Down
2 changes: 1 addition & 1 deletion Examples/VaporDemo/Sources/App/BonusFacts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actor BonusFactStore {
]

func calculateBonusFact() async -> String {
return bonusFacts.randomElement()!
bonusFacts.randomElement()!
}

@TaskLocal static var current: BonusFactStore?
Expand Down
20 changes: 10 additions & 10 deletions Examples/VaporDemo/Sources/App/BrowserSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import Foundation
import Vapor

#if DEBUG
struct BrowserSyncHandler: LifecycleHandler {
func didBoot(_: Application) throws {
let p = Process()
p.executableURL = URL(string: "file:///bin/sh")
p.arguments = ["-c", "browser-sync reload"]
do {
try p.run()
} catch {
print("Could not auto-reload: \(error)")
}
struct BrowserSyncHandler: LifecycleHandler {
func didBoot(_: Application) throws {
let p = Process()
p.executableURL = URL(string: "file:///bin/sh")
p.arguments = ["-c", "browser-sync reload"]
do {
try p.run()
} catch {
print("Could not auto-reload: \(error)")
}
}
}
#endif
14 changes: 10 additions & 4 deletions Examples/VaporDemo/Sources/App/Views.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ struct MainPage: HTMLDocument {
script(.src("/htmx.min.js")) {}
script(.src("/htmxsse.min.js")) {}
script(.src("/htmxws.min.js")) {}
link(.rel(.stylesheet), .href("https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"))
link(
.rel(.stylesheet),
.href("https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css")
)
}

var body: some HTML {
Expand Down Expand Up @@ -60,7 +63,7 @@ struct ResultView: HTML {

@Environment(requiring: BonusFactStore.$current) var bonusFacts

var content: some HTML {
var body: some HTML {
p {
"\(x) + \(y) = "
b { "\(x + y)" }
Expand All @@ -76,7 +79,10 @@ struct ResultView: HTML {
struct WSEcho: HTML {
let message: String

var content: some HTML {
div(.id("echo"), .hx.swapOOB(.beforeEnd)) { "Echo: \(message)"; br() }
var body: some HTML {
div(.id("echo"), .hx.swapOOB(.beforeEnd)) {
"Echo: \(message)"
br()
}
}
}
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ let package = Package(
.library(name: "ElementaryHyperscript", targets: ["ElementaryHyperscript"]),
],
dependencies: [
.package(url: "https://github.com/sliemeobn/elementary.git", from: "0.3.0"),
.package(url: "https://github.com/sliemeobn/elementary.git", from: "0.6.0")
],
targets: [
.target(
name: "ElementaryHTMX",
dependencies: [
.product(name: "Elementary", package: "elementary"),
.product(name: "Elementary", package: "elementary")
],
swiftSettings: featureFlags
),
Expand All @@ -52,7 +52,7 @@ let package = Package(
.target(
name: "ElementaryHyperscript",
dependencies: [
.product(name: "Elementary", package: "elementary"),
.product(name: "Elementary", package: "elementary")
],
swiftSettings: featureFlags
),
Expand Down Expand Up @@ -91,7 +91,7 @@ let package = Package(
.target(
name: "TestUtilities",
dependencies: [
.product(name: "Elementary", package: "elementary"),
.product(name: "Elementary", package: "elementary")
],
path: "Tests/TestUtilities",
swiftSettings: featureFlags
Expand Down
Loading