41 lines
919 B
Swift
41 lines
919 B
Swift
import Foundation
|
|
|
|
|
|
let configUrl = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace/CHGenerator/config.json")
|
|
|
|
let configuration: Configuration
|
|
do {
|
|
let data = try Data(contentsOf: configUrl)
|
|
configuration = try JSONDecoder().decode(from: data)
|
|
} catch {
|
|
print("Failed to read configuration: \(error)")
|
|
exit(1)
|
|
}
|
|
|
|
let log = ValidationLog()
|
|
let files = FileSystem(
|
|
in: configuration.contentDirectory,
|
|
to: configuration.outputDirectory)
|
|
|
|
guard let siteData = Element(atRoot: configuration.contentDirectory) else {
|
|
exit(0)
|
|
}
|
|
|
|
do {
|
|
let siteGenerator = try SiteGenerator()
|
|
siteGenerator.generate(site: siteData)
|
|
} catch {
|
|
print("Failed to generate website: \(error)")
|
|
exit(2)
|
|
}
|
|
|
|
files.printGeneratedPages()
|
|
files.printEmptyPages()
|
|
files.printDraftPages()
|
|
|
|
files.createImages()
|
|
print("Images generated")
|
|
files.copyRequiredFiles()
|
|
files.printExternalFiles()
|
|
files.writeHashes()
|