Basic project creation (#3)

This PR contains the work done to create a new *Hummingbird* project with very basic configuration from the _colibri_ executable, just like the project you could create with the [Hummingbird template](https://github.com/hummingbird-project/template) project in Github.

Reviewed-on: #3
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #3.
This commit is contained in:
2025-01-28 00:07:24 +00:00
committed by Javier Cicchelli
parent b8c354e614
commit 9be8fa4a31
52 changed files with 1936 additions and 475 deletions
@@ -0,0 +1,5 @@
import Foundation
// MARK: - Bundleable
extension Bundle: Bundleable {}
@@ -0,0 +1,72 @@
import Foundation
extension Pipe {
// MARK: Computed
var availableData: AsyncAvailableData { .init(self) }
}
// MARK: - AsyncAvailableData
extension Pipe {
struct AsyncAvailableData {
// MARK: Properties
private let pipe: Pipe
// MARK: Initialisers
init(_ pipe: Pipe) {
self.pipe = pipe
}
// MARK: Functions
func append() async -> Data {
var data = Data()
for await availableData in self {
data.append(availableData)
}
return data
}
}
}
// MARK: - AsyncSequence
extension Pipe.AsyncAvailableData: AsyncSequence {
// MARK: Type aliases
typealias AsyncIterator = AsyncStream<Data>.Iterator
typealias Element = Data
// MARK: Functions
func makeAsyncIterator() -> AsyncIterator {
AsyncStream { continuation in
pipe.fileHandleForReading.readabilityHandler = { @Sendable handler in
let data = handler.availableData
guard !data.isEmpty else {
continuation.finish()
return
}
continuation.yield(data)
}
continuation.onTermination = { _ in
pipe.fileHandleForReading.readabilityHandler = nil
}
}
.makeAsyncIterator()
}
}
@@ -0,0 +1,5 @@
import Foundation
// MARK: - Processable
extension Process: Processable {}
@@ -0,0 +1,35 @@
import Foundation
extension URL {
// MARK: Initialisers
init(at filePath: String) {
if #available(macOS 13.0, *) {
self = URL(filePath: filePath)
} else {
self = URL(fileURLWithPath: filePath)
}
}
// MARK: Computed
var pathString: String {
if #available(macOS 13.0, *) {
path(percentEncoded: true)
} else {
path
}
}
// MARK: Functions
func appendingPath(_ path: String) -> URL {
if #available(macOS 13.0, *) {
appending(path: path)
} else {
appendingPathComponent(path)
}
}
}