2025-01-27 23:54:50 +00:00
|
|
|
import ArgumentParser
|
|
|
|
import ColibriLibrary
|
|
|
|
|
|
|
|
extension Colibri {
|
|
|
|
struct Create: AsyncParsableCommand {
|
|
|
|
|
|
|
|
// MARK: Properties
|
|
|
|
|
|
|
|
static let configuration = CommandConfiguration(
|
|
|
|
commandName: "create-project",
|
|
|
|
abstract: "Create a new, tailored Hummingbird app",
|
|
|
|
helpNames: .shortAndLong,
|
|
|
|
aliases: ["create"]
|
|
|
|
)
|
2025-01-28 00:07:24 +00:00
|
|
|
|
2025-01-27 23:54:50 +00:00
|
|
|
@OptionGroup var options: Options
|
|
|
|
|
|
|
|
// MARK: Functions
|
|
|
|
|
|
|
|
mutating func run() async throws {
|
|
|
|
let fileService = FileService()
|
2025-02-17 22:11:05 +00:00
|
|
|
let templateService = try await TemplateService(templateFolder: "Files/Templates")
|
|
|
|
let terminalService = TerminalService()
|
|
|
|
|
2025-01-28 00:07:24 +00:00
|
|
|
let copyFiles = CopyFilesTask(fileService: fileService)
|
|
|
|
let createFolders = CreateFoldersTask(fileService: fileService)
|
2025-01-27 23:54:50 +00:00
|
|
|
let createRootFolder = CreateRootFolderTask(fileService: fileService)
|
2025-02-17 22:11:05 +00:00
|
|
|
let initGitInFolder = InitGitInFolderTask(terminalService: terminalService)
|
|
|
|
let renderFiles = RenderFilesTask(fileService: fileService,
|
|
|
|
templateService: templateService)
|
2025-01-27 23:54:50 +00:00
|
|
|
|
2025-02-17 22:11:05 +00:00
|
|
|
let rootFolder = try await createRootFolder(name: options.name,
|
|
|
|
at: options.locationURL)
|
2025-01-28 00:07:24 +00:00
|
|
|
|
|
|
|
try await createFolders(at: rootFolder)
|
|
|
|
try await copyFiles(to: rootFolder)
|
2025-02-17 22:11:05 +00:00
|
|
|
try await renderFiles(at: rootFolder,
|
|
|
|
with: Project(name: options.name))
|
2025-01-28 00:07:24 +00:00
|
|
|
try await initGitInFolder(at: rootFolder)
|
2025-01-27 23:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|