feat: Adds install-dependencies command.
This commit is contained in:
@@ -40,6 +40,9 @@ let package = Package(
|
|||||||
.product(name: "Dependencies", package: "swift-dependencies"),
|
.product(name: "Dependencies", package: "swift-dependencies"),
|
||||||
.product(name: "DependenciesMacros", package: "swift-dependencies"),
|
.product(name: "DependenciesMacros", package: "swift-dependencies"),
|
||||||
.product(name: "ShellClient", package: "swift-shell-client")
|
.product(name: "ShellClient", package: "swift-shell-client")
|
||||||
|
],
|
||||||
|
resources: [
|
||||||
|
.copy("Resources/Brewfile")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ public extension CliClient {
|
|||||||
try await runCommand(quiet: quiet, shell: shell, args)
|
try await runCommand(quiet: quiet, shell: shell, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func installDependencies() async throws {
|
||||||
|
guard let url = Bundle.module.url(forResource: "Brewfile", withExtension: nil) else {
|
||||||
|
throw CliClientError.brewfileNotFound
|
||||||
|
}
|
||||||
|
try await runCommand(
|
||||||
|
quiet: false,
|
||||||
|
shell: .zsh(useDashC: true),
|
||||||
|
"brew", "bundle", "--file", url.cleanFilePath
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func runPlaybookCommand(
|
func runPlaybookCommand(
|
||||||
_ options: PlaybookOptions,
|
_ options: PlaybookOptions,
|
||||||
logging loggingOptions: LoggingOptions
|
logging loggingOptions: LoggingOptions
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public enum CliClientError: Error {
|
public enum CliClientError: Error {
|
||||||
|
case brewfileNotFound
|
||||||
case encodingError
|
case encodingError
|
||||||
case playbookDirectoryNotFound
|
case playbookDirectoryNotFound
|
||||||
case templateDirectoryNotFound
|
case templateDirectoryNotFound
|
||||||
|
|||||||
4
Sources/CliClient/Resources/Brewfile
Normal file
4
Sources/CliClient/Resources/Brewfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
brew "ansible"
|
||||||
|
brew "imagemagick"
|
||||||
|
cask "mactex-no-gui"
|
||||||
|
brew "pandoc"
|
||||||
23
Sources/hpa/UtilsCommands/InstallDependenciesCommand.swift
Normal file
23
Sources/hpa/UtilsCommands/InstallDependenciesCommand.swift
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import ArgumentParser
|
||||||
|
import CliClient
|
||||||
|
import CliDoc
|
||||||
|
import Dependencies
|
||||||
|
|
||||||
|
struct InstallDependenciesCommand: AsyncParsableCommand {
|
||||||
|
static let commandName: String = "install-dependencies"
|
||||||
|
|
||||||
|
static let configuration = CommandConfiguration(
|
||||||
|
commandName: commandName,
|
||||||
|
abstract: createAbstract("Ensure required dependencies are installed"),
|
||||||
|
discussion: Discussion {
|
||||||
|
Note {
|
||||||
|
"Homebrew is required to install dependencies."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func run() async throws {
|
||||||
|
@Dependency(\.cliClient) var cliClient
|
||||||
|
try await cliClient.installDependencies()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,8 @@ struct UtilsCommand: AsyncParsableCommand {
|
|||||||
""",
|
""",
|
||||||
subcommands: [
|
subcommands: [
|
||||||
GenerateProjectTemplateCommand.self,
|
GenerateProjectTemplateCommand.self,
|
||||||
GenerateConfigurationCommand.self
|
GenerateConfigurationCommand.self,
|
||||||
|
InstallDependenciesCommand.self
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ struct DecryptCommand: AsyncParsableCommand {
|
|||||||
)
|
)
|
||||||
var output: String?
|
var output: String?
|
||||||
|
|
||||||
// FIX:
|
|
||||||
mutating func run() async throws {
|
mutating func run() async throws {
|
||||||
@Dependency(\.cliClient) var cliClient
|
@Dependency(\.cliClient) var cliClient
|
||||||
|
|
||||||
@@ -32,11 +31,5 @@ struct DecryptCommand: AsyncParsableCommand {
|
|||||||
options.vaultOptions(arguments: args, configuration: nil),
|
options.vaultOptions(arguments: args, configuration: nil),
|
||||||
logging: options.loggingOptions(commandName: Self.commandName)
|
logging: options.loggingOptions(commandName: Self.commandName)
|
||||||
)
|
)
|
||||||
|
|
||||||
// try await runVault(
|
|
||||||
// commandName: Self.commandName,
|
|
||||||
// options: options,
|
|
||||||
// args
|
|
||||||
// )
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user