54 lines
1.1 KiB
Swift
54 lines
1.1 KiB
Swift
import Foundation
|
|
|
|
public struct CopyFilesTask {
|
|
|
|
// MARK: Properties
|
|
|
|
private let fileService: FileServicing
|
|
|
|
// MARK: Initialisers
|
|
|
|
public init(fileService: FileServicing) {
|
|
self.fileService = fileService
|
|
}
|
|
|
|
// MARK: Functions
|
|
|
|
public func callAsFunction(to rootFolder: URL) async throws {
|
|
let filesFolder = URL(at: .folderFiles)
|
|
|
|
for fileToCopy in Self.filesToCopy {
|
|
try await fileService.copyItem(
|
|
from: filesFolder.appendingPath(fileToCopy),
|
|
to: rootFolder.appendingPath(fileToCopy)
|
|
)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Helpers
|
|
|
|
extension CopyFilesTask {
|
|
|
|
// MARK: Constants
|
|
|
|
static let filesToCopy: [String] = [
|
|
.fileDockerIgnore,
|
|
.fileGitIgnore,
|
|
.fileLicense,
|
|
.fileReadme
|
|
]
|
|
|
|
}
|
|
|
|
// MARK: - URL+Constants
|
|
|
|
private extension String {
|
|
static let folderFiles = "./Resources/Files"
|
|
static let fileDockerIgnore = ".dockerignore"
|
|
static let fileGitIgnore = ".gitignore"
|
|
static let fileLicense = "LICENSE"
|
|
static let fileReadme = "README.md"
|
|
}
|