Removed the "app", "appTests", and "package" cases from the File enumeration in the library target.

This commit is contained in:
2025-02-05 00:16:09 +01:00
parent 91762b18cd
commit af73e6d1a2
6 changed files with 67 additions and 122 deletions
-20
View File
@@ -1,20 +0,0 @@
import AppLibrary
import ArgumentParser
@main
struct App: AsyncParsableCommand {
// MARK: Properties
@OptionGroup var options: Options
// MARK: Functions
mutating func run() async throws {
let builder = AppBuilder(name: "App")
let app = try await builder(options)
try await app.runService()
}
}
-45
View File
@@ -1,45 +0,0 @@
// swift-tools-version:6.0
import PackageDescription
let package = Package(
name: "App",
platforms: [
.macOS(.v14)
],
products: [
.executable(name: "App", targets: ["App"]),
.library(name: "AppLibrary", targets: ["AppLibrary"])
],
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0")
],
targets: [
.executableTarget(
name: "App",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Hummingbird", package: "hummingbird"),
.target(name: "AppLibrary")
],
path: "App"
),
.target(
name: "AppLibrary",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Hummingbird", package: "hummingbird")
],
path: "Library"
),
.testTarget(
name: "AppTests",
dependencies: [
.product(name: "HummingbirdTesting", package: "hummingbird"),
.target(name: "AppLibrary")
],
path: "Test"
)
]
)
@@ -1,33 +0,0 @@
import AppLibrary
import Hummingbird
import HummingbirdTesting
import Testing
struct AppTests {
// MARK: Properties
private let arguments = TestArguments()
private let builder = AppBuilder(name: "App")
// MARK: Route tests
@Test(arguments: ["/"])
func routes(_ uri: String) async throws {
let app = try await builder(arguments)
try await app.test(.router) { client in
try await client.execute(uri: uri, method: .get) { response in
#expect(response.status == .ok)
#expect(response.body == .empty)
}
}
}
}
// MARK: ByteBuffer+Constants
private extension ByteBuffer {
static let empty = ByteBuffer(string: "")
}
@@ -1,16 +1,13 @@
enum File: String {
case app = "App"
case appArguments = "AppArguments"
case appBuilder = "AppBuilder"
case appOptions = "AppOptions"
case appTests = "AppTests"
case dockerFile = "DockerFile"
case dockerIgnore = "DockerIgnore"
case environment = "Environment"
case gitIgnore = "GitIgnore"
case license = "License"
case loggerLevel = "LoggerLevel"
case package = "Package"
case readme = "Readme"
case testArguments = "TestArguments"
@@ -24,11 +21,9 @@ extension File {
var fileName: String {
switch self {
case .app: "App.swift"
case .appArguments: "AppArguments.swift"
case .appBuilder: "AppBuilder.swift"
case .appOptions: "AppOptions.swift"
case .appTests: "AppTests.swift"
case .dockerFile: "Dockerfile"
case .dockerIgnore: ".dockerignore"
case .environment: "Environment+Properties.swift"
@@ -36,7 +31,6 @@ extension File {
case .license: "LICENSE"
case .loggerLevel: "LoggerLevel+Conformances.swift"
case .readme: "README.md"
case .package: "Package.swift"
case .testArguments: "TestArguments.swift"
}
}
@@ -47,9 +41,8 @@ extension File {
var folder: Folder {
switch self {
case .app, .appOptions: .app
case .appOptions: .app
case .appArguments, .appBuilder: .libraryPublic
case .appTests: .testCasesPublic
case .environment, .loggerLevel: .libraryInternal
case .testArguments: .testHelpers
default: .root
@@ -60,9 +53,9 @@ extension File {
let basePath = "Resources/Files/Sources"
return switch self {
case .app, .appOptions: "\(basePath)/App"
case .appOptions: "\(basePath)/App"
case .appArguments, .appBuilder, .environment, .loggerLevel: "\(basePath)/Library"
case .appTests, .testArguments: "\(basePath)/Test"
case .testArguments: "\(basePath)/Test"
default: basePath
}
}