Skip to content

Commit 2fe9e36

Browse files
authored
Update minimum Swift version (#794)
* Bump the package minimum Swift version to 6.0, update docs accordingly, run swift-format on the code * Convert the tests to SwiftTesting * Swift 6.0 is finicky
1 parent 223b27d commit 2fe9e36

26 files changed

+648
-707
lines changed

Package.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:6.0
22
import PackageDescription
33

44
let package = Package(
@@ -13,8 +13,8 @@ let package = Package(
1313
.library(name: "Fluent", targets: ["Fluent"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.49.0"),
17-
.package(url: "https://github.com/vapor/vapor.git", from: "4.101.0"),
16+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.52.2"),
17+
.package(url: "https://github.com/vapor/vapor.git", from: "4.117.0"),
1818
],
1919
targets: [
2020
.target(
@@ -30,7 +30,7 @@ let package = Package(
3030
dependencies: [
3131
.target(name: "Fluent"),
3232
.product(name: "XCTFluent", package: "fluent-kit"),
33-
.product(name: "XCTVapor", package: "vapor"),
33+
.product(name: "VaporTesting", package: "vapor"),
3434
],
3535
swiftSettings: swiftSettings
3636
),
@@ -39,9 +39,10 @@ let package = Package(
3939

4040
var swiftSettings: [SwiftSetting] { [
4141
.enableUpcomingFeature("ExistentialAny"),
42-
.enableUpcomingFeature("ConciseMagicFile"),
43-
.enableUpcomingFeature("ForwardTrailingClosures"),
44-
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
45-
.enableUpcomingFeature("DisableOutwardActorInference"),
46-
.enableExperimentalFeature("StrictConcurrency=complete"),
42+
.enableUpcomingFeature("InternalImportsByDefault"),
43+
.enableUpcomingFeature("MemberImportVisibility"),
44+
.enableUpcomingFeature("InferIsolatedConformances"),
45+
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
46+
.enableUpcomingFeature("ImmutableWeakCaptures"),
4747
] }
48+

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
<p align="center">
2-
<picture>
3-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/fluent/assets/1130717/f4708c0b-3c9e-4e8b-9508-aa1ca6481c70">
4-
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/fluent/assets/1130717/bc4e1040-1e8a-4c0c-a24d-e87221a01af3">
5-
<img src="https://github.com/vapor/fluent/assets/1130717/bc4e1040-1e8a-4c0c-a24d-e87221a01af3" height="96" alt="Fluent">
6-
</picture>
2+
<img src="https://design.vapor.codes/images/vapor-fluent.svg" height="96" alt="Fluent">
73
<br>
84
<br>
95
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
106
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
117
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
128
<a href="https://github.com/vapor/fluent/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/fluent/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
13-
<a href="https://codecov.io/github/vapor/fluent"><img src="https://img.shields.io/codecov/c/github/vapor/fluent?style=plastic&logo=codecov&label=codecov&token=yDzzHja8lt"></a>
14-
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
9+
<a href="https://codecov.io/github/vapor/fluent"><img src="https://img.shields.io/codecov/c/github/vapor/fluent?style=plastic&logo=codecov&label=codecov&token=yDzzHja8lt" alt="Code Coverage"></a>
10+
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift60up.svg" alt="Swift 6.0+"></a>
1511
</p>
1612

1713
<br>

Sources/Fluent/Concurrency/FluentProvider+Concurrency.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Vapor
21
import FluentKit
2+
public import Vapor
33

44
extension Application {
55
/// Automatically runs forward migrations without confirmation.

Sources/Fluent/Concurrency/ModelCredentialsAuthenticatable+Concurrency.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import NIOCore
2-
import Vapor
3-
import FluentKit
1+
public import FluentKit
2+
public import Vapor
43

54
extension ModelCredentialsAuthenticatable {
65
public static func asyncCredentialsAuthenticator(
@@ -11,8 +10,7 @@ extension ModelCredentialsAuthenticatable {
1110
}
1211

1312
private struct AsyncModelCredentialsAuthenticator<User>: AsyncCredentialsAuthenticator
14-
where User: ModelCredentialsAuthenticatable
15-
{
13+
where User: ModelCredentialsAuthenticatable {
1614
typealias Credentials = ModelCredentials
1715

1816
public let database: DatabaseID?
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import NIOCore
2-
import Vapor
3-
import FluentKit
1+
public import FluentKit
2+
public import Vapor
43

54
extension QueryBuilder {
65
public func paginate(
76
for request: Request
87
) async throws -> Page<Model> {
98
let page = try request.query.decode(PageRequest.self)
10-
return try await self.paginate(page)
9+
return try await self.paginate(page).get()
1110
}
1211
}

Sources/Fluent/Concurrency/Sessions+Concurrency.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import NIOCore
2-
import Vapor
3-
import FluentKit
1+
public import FluentKit
2+
public import Vapor
43

54
extension Model where Self: SessionAuthenticatable, Self.SessionID == Self.IDValue {
65
public static func asyncSessionAuthenticator(
@@ -11,8 +10,7 @@ extension Model where Self: SessionAuthenticatable, Self.SessionID == Self.IDVal
1110
}
1211

1312
private struct AsyncDatabaseSessionAuthenticator<User>: AsyncSessionAuthenticator
14-
where User: SessionAuthenticatable, User: Model, User.SessionID == User.IDValue
15-
{
13+
where User: SessionAuthenticatable, User: Model, User.SessionID == User.IDValue {
1614
let databaseID: DatabaseID?
1715

1816
func authenticate(sessionID: User.SessionID, for request: Request) async throws {
Lines changed: 18 additions & 15 deletions
Loading

Sources/Fluent/Docs.docc/theme-settings.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"theme": {
3-
"aside": { "border-radius": "16px", "border-style": "double", "border-width": "3px" },
3+
"aside": { "border-radius": "16px", "border-width": "3px", "border-style": "double" },
44
"border-radius": "0",
55
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
66
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
77
"color": {
88
"fluent": "#392048",
99
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-fluent) 30%, #000 100%)",
1010
"documentation-intro-accent": "var(--color-fluent)",
11+
"hero-eyebrow": "white",
12+
"documentation-intro-figure": "white",
13+
"hero-title": "white",
1114
"logo-base": { "dark": "#fff", "light": "#000" },
1215
"logo-shape": { "dark": "#000", "light": "#fff" },
1316
"fill": { "dark": "#000", "light": "#fff" }
1417
},
15-
"icons": { "technology": "/fluent/images/vapor-fluent-logo.svg" }
18+
"icons": { "technology": "/fluent/images/Fluent/vapor-fluent-logo.svg" }
1619
},
1720
"features": {
1821
"quickNavigation": { "enable": true },

Sources/Fluent/Fluent+Cache.swift

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import NIOCore
1+
public import FluentKit
22
import Foundation
3-
import Vapor
4-
import FluentKit
3+
public import Vapor
54

65
extension Application.Caches {
76
public var fluent: any Cache {
@@ -28,27 +27,22 @@ extension Application.Caches.Provider {
2827
private struct FluentCache: Cache {
2928
let id: DatabaseID?
3029
let database: any Database
31-
30+
3231
init(id: DatabaseID?, database: any Database) {
3332
self.id = id
3433
self.database = database
3534
}
36-
35+
3736
func get<T>(_ key: String, as type: T.Type) -> EventLoopFuture<T?>
38-
where T: Decodable
39-
{
37+
where T: Decodable & VaporSendableMetatype {
4038
CacheEntry.query(on: self.database)
4139
.filter(\.$key == key)
4240
.first()
4341
.flatMapThrowing { entry -> T? in
44-
if let entry = entry {
45-
return try JSONDecoder().decode(T.self, from: Data(entry.value.utf8))
46-
} else {
47-
return nil
48-
}
42+
try entry.map { try JSONDecoder().decode(T.self, from: Data($0.value.utf8)) }
4943
}
5044
}
51-
45+
5246
func set(_ key: String, to value: (some Encodable)?) -> EventLoopFuture<Void> {
5347
if let value = value {
5448
do {
@@ -65,15 +59,15 @@ private struct FluentCache: Cache {
6559
return CacheEntry.query(on: self.database).filter(\.$key == key).delete()
6660
}
6761
}
68-
62+
6963
func `for`(_ request: Request) -> Self {
7064
.init(id: self.id, database: request.db(self.id))
7165
}
7266
}
7367

7468
public final class CacheEntry: Model, @unchecked Sendable {
7569
public static let schema: String = "_fluent_cache"
76-
70+
7771
struct Create: Migration {
7872
func prepare(on database: any Database) -> EventLoopFuture<Void> {
7973
database.schema("_fluent_cache")
@@ -83,7 +77,7 @@ public final class CacheEntry: Model, @unchecked Sendable {
8377
.unique(on: "key")
8478
.create()
8579
}
86-
80+
8781
func revert(on database: any Database) -> EventLoopFuture<Void> {
8882
database.schema("_fluent_cache").delete()
8983
}
@@ -92,18 +86,18 @@ public final class CacheEntry: Model, @unchecked Sendable {
9286
public static var migration: any Migration {
9387
Create()
9488
}
95-
89+
9690
@ID(key: .id)
9791
public var id: UUID?
98-
92+
9993
@Field(key: "key")
10094
public var key: String
101-
95+
10296
@Field(key: "value")
10397
public var value: String
104-
105-
public init() { }
106-
98+
99+
public init() {}
100+
107101
public init(id: UUID? = nil, key: String, value: String) {
108102
self.key = key
109103
self.value = value

Sources/Fluent/Fluent+History.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Vapor
2-
import FluentKit
1+
public import FluentKit
2+
public import Vapor
33

44
struct RequestQueryHistory: StorageKey {
55
typealias Value = QueryHistory

0 commit comments

Comments
 (0)