Skip to content

Commit ca34696

Browse files
authored
Merge pull request #9 from wickwirew/xcode26-3
Fixed build error for plugin with Xcode 26.3
2 parents f89612e + f13a4b8 commit ca34696

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

Sources/Compiler/Config.swift

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,31 @@ public struct Config: Codable {
1616
public let additionalImports: [String]?
1717
public let tableNamePattern: String?
1818

19-
struct NotFoundError: Error, CustomStringConvertible {
20-
var description: String { "Config does not exist" }
19+
enum ConfigError: Error, CustomStringConvertible {
20+
case invalidURL(String)
21+
case notFound(searchPath: String)
22+
23+
var description: String {
24+
switch self {
25+
case .invalidURL(let url):
26+
"Invalid URL '\(url)'"
27+
case .notFound(let searchPath):
28+
"Config does not exist in '\(searchPath)'"
29+
}
30+
}
2131
}
2232

2333
public init(at path: String) throws {
24-
var url = URL(fileURLWithPath: path)
34+
guard var url = URL(string: path) else {
35+
throw ConfigError.invalidURL(path)
36+
}
2537

2638
if url.lastPathComponent != "puresql.yaml" {
2739
url.appendPathComponent("puresql.yaml")
2840
}
2941

3042
guard FileManager.default.fileExists(atPath: url.path) else {
31-
throw NotFoundError()
43+
throw ConfigError.notFound(searchPath: url.path)
3244
}
3345

3446
let data = try Data(contentsOf: url)
@@ -37,8 +49,10 @@ public struct Config: Codable {
3749
self = try decoder.decode(Config.self, from: data)
3850
}
3951

40-
public func project(at path: String) -> Project {
41-
let url = URL(fileURLWithPath: path)
52+
public func project(at path: String) throws -> Project {
53+
guard let url = URL(string: path) else {
54+
throw ConfigError.invalidURL(path)
55+
}
4256

4357
return Project(
4458
generatedOutputFile: url.appendingPathComponent(output ?? "Queries.swift"),

Sources/PureSQLCLI/GenerateCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct GenerateCommand: AsyncParsableCommand {
3636

3737
mutating func run() async throws {
3838
let config = try Config(at: path)
39-
var project = config.project(at: path)
39+
var project = try config.project(at: path)
4040

4141
if let overrideOutput, let url = URL(string: overrideOutput) {
4242
project.generatedOutputFile = url

Sources/PureSQLCLI/MigrationsCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct MigrationsCommand: ParsableCommand {
2323

2424
func run() throws {
2525
let config = try Config(at: path)
26-
let project = config.project(at: path)
26+
let project = try config.project(at: path)
2727
try project.addMigration()
2828
}
2929
}

Sources/PureSQLCLI/QueriesCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct QueriesCommand: ParsableCommand {
2525

2626
func run() throws {
2727
let config = try Config(at: path)
28-
let project = config.project(at: path)
28+
let project = try config.project(at: path)
2929

3030
guard !project.doesQueryExist(withName: name) else {
3131
throw SQLError.queryAlreadyExists(fileName: name)

0 commit comments

Comments
 (0)