feat: Begin cleaning up cli-client for better separation for current and next versions.
All checks were successful
CI / Ubuntu (push) Successful in 2m33s
All checks were successful
CI / Ubuntu (push) Successful in 2m33s
This commit is contained in:
@@ -3,6 +3,8 @@ import DependenciesMacros
|
||||
import FileClient
|
||||
import Foundation
|
||||
|
||||
// TODO: Add a method to get a semvar / handle a version strategy's ??
|
||||
|
||||
public extension DependencyValues {
|
||||
|
||||
/// Perform operations with configuration files.
|
||||
@@ -16,6 +18,12 @@ public extension DependencyValues {
|
||||
@DependencyClient
|
||||
public struct ConfigurationClient: Sendable {
|
||||
|
||||
fileprivate enum Constants {
|
||||
static let defaultFileNameWithoutExtension = ".bump-version"
|
||||
static let defaultExtension = "json"
|
||||
static var defaultFileName: String { "\(defaultFileNameWithoutExtension).\(defaultExtension)" }
|
||||
}
|
||||
|
||||
/// The default file name for a configuration file.
|
||||
public var defaultFileName: @Sendable () -> String = { "test.json" }
|
||||
|
||||
@@ -89,15 +97,13 @@ extension ConfigurationClient: DependencyKey {
|
||||
private func findConfiguration(_ url: URL?) async throws -> URL? {
|
||||
@Dependency(\.fileClient) var fileClient
|
||||
|
||||
let defaultFileName = ConfigurationClient.Constants.defaultFileNameWithoutExtension
|
||||
|
||||
var url: URL! = url
|
||||
if url == nil {
|
||||
url = try await URL(filePath: fileClient.currentDirectory())
|
||||
}
|
||||
|
||||
if try await fileClient.isDirectory(url.cleanFilePath) {
|
||||
url = url.appending(path: "\(defaultFileName).json")
|
||||
url = url.appending(path: ConfigurationClient.Constants.defaultFileName)
|
||||
}
|
||||
|
||||
if fileClient.fileExists(url) {
|
||||
|
||||
Reference in New Issue
Block a user