feat: Uses curl to download toml config to allow for pre-built binaries.
Some checks failed
CI / Run Tests (push) Failing after 2m44s
Some checks failed
CI / Run Tests (push) Failing after 2m44s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import CodersClient
|
||||
import CommandClient
|
||||
import Dependencies
|
||||
import DependenciesMacros
|
||||
import FileClient
|
||||
@@ -155,6 +156,7 @@ struct LiveConfigurationClient {
|
||||
private let environment: [String: String]
|
||||
|
||||
@Dependency(\.coders) var coders
|
||||
@Dependency(\.commandClient) var commandClient
|
||||
@Dependency(\.fileClient) var fileManager
|
||||
@Dependency(\.logger) var logger
|
||||
|
||||
@@ -245,19 +247,13 @@ struct LiveConfigurationClient {
|
||||
try await fileManager.createDirectory(fileDirectory)
|
||||
}
|
||||
|
||||
// TODO: The hpa file needs to be copied somewhere on the system during install and
|
||||
// not use bundle, as it only works if the tool was built on the users system.
|
||||
if case .toml = file {
|
||||
// In the case of toml, we copy the internal resource that includes
|
||||
// usage comments in the file.
|
||||
guard let resourceFile = Bundle.module.url(
|
||||
forResource: HPAKey.resourceFileName,
|
||||
withExtension: HPAKey.resourceFileExtension
|
||||
) else {
|
||||
throw ConfigurationError.resourceNotFound
|
||||
}
|
||||
|
||||
try await fileManager.copy(resourceFile, fileUrl)
|
||||
// Copy the file using curl, because when installed as a pre-built binary we
|
||||
// don't have access to bundled resources.
|
||||
try await commandClient.run(
|
||||
quiet: true,
|
||||
["curl", HPAKey.tomlConfigUrl, "--output", fileUrl.path]
|
||||
)
|
||||
} else {
|
||||
// Json does not allow comments, so we write the mock configuration
|
||||
// to the file path.
|
||||
|
||||
Reference in New Issue
Block a user