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
|
|
|
|
2022-08-26 17:40:51 +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
|
|
|
|
2022-09-08 09:30:54 +02:00
|
|
|
guard let siteData = Element(atRoot: configuration.contentDirectory) else {
|
|
|
|
exit(0)
|
|
|
|
}
|
2022-09-05 16:08:06 +02:00
|
|
|
|
2022-09-08 09:30:54 +02:00
|
|
|
do {
|
2022-09-05 16:08:06 +02:00
|
|
|
let siteGenerator = try SiteGenerator()
|
2022-09-08 09:30:54 +02:00
|
|
|
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")
|
2022-08-26 17:40:51 +02:00
|
|
|
files.copyRequiredFiles()
|
2022-09-08 09:33:27 +02:00
|
|
|
files.printExternalFiles()
|
2022-08-26 17:40:51 +02:00
|
|
|
files.writeHashes()
|