CHGenerator/WebsiteGenerator/main.swift

41 lines
919 B
Swift
Raw Normal View History

2022-08-05 19:03:00 +02:00
import Foundation
2022-08-19 18:05:06 +02:00
2022-09-08 09:33:27 +02:00
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)
}
2022-08-29 18:57:58 +02:00
let log = ValidationLog()
2022-09-05 16:08:06 +02:00
let files = FileSystem(
in: configuration.contentDirectory,
to: configuration.outputDirectory)
2022-08-19 18:05:06 +02:00
guard let siteData = Element(atRoot: configuration.contentDirectory) else {
exit(0)
}
2022-09-05 16:08:06 +02:00
do {
2022-09-05 16:08:06 +02:00
let siteGenerator = try SiteGenerator()
siteGenerator.generate(site: siteData)
2022-08-19 18:05:06 +02:00
} catch {
2022-09-08 09:33:27 +02:00
print("Failed to generate website: \(error)")
exit(2)
2022-08-19 18:05:06 +02:00
}
2022-09-02 23:19:13 +02:00
files.printGeneratedPages()
2022-08-29 19:20:13 +02:00
files.printEmptyPages()
2022-08-31 09:02:40 +02:00
files.printDraftPages()
2022-09-02 23:19:13 +02:00
files.createImages()
2022-08-16 10:39:05 +02:00
print("Images generated")
files.copyRequiredFiles()
2022-09-08 09:33:27 +02:00
files.printExternalFiles()
files.writeHashes()