Read generator configuration from file
This commit is contained in:
parent
81b373fb5a
commit
570cebb5d0
@ -1,6 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct Configuration {
|
struct Configuration: Codable {
|
||||||
|
|
||||||
let pageImageWidth: Int
|
let pageImageWidth: Int
|
||||||
|
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
let configuration = Configuration(
|
let configUrl = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace/CHGenerator/config.json")
|
||||||
pageImageWidth: <#T##Int#>,
|
|
||||||
minifyCSSandJS: <#T##Bool#>,
|
let configuration: Configuration
|
||||||
contentPath: <#T##String#>,
|
do {
|
||||||
outputPath: <#T##String#>)
|
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 log = ValidationLog()
|
||||||
let files = FileSystem(
|
let files = FileSystem(
|
||||||
@ -20,8 +25,8 @@ do {
|
|||||||
let siteGenerator = try SiteGenerator()
|
let siteGenerator = try SiteGenerator()
|
||||||
siteGenerator.generate(site: siteData)
|
siteGenerator.generate(site: siteData)
|
||||||
} catch {
|
} catch {
|
||||||
print(error)
|
print("Failed to generate website: \(error)")
|
||||||
exit(0)
|
exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
files.printGeneratedPages()
|
files.printGeneratedPages()
|
||||||
@ -31,4 +36,5 @@ files.printDraftPages()
|
|||||||
files.createImages()
|
files.createImages()
|
||||||
print("Images generated")
|
print("Images generated")
|
||||||
files.copyRequiredFiles()
|
files.copyRequiredFiles()
|
||||||
|
files.printExternalFiles()
|
||||||
files.writeHashes()
|
files.writeHashes()
|
||||||
|
6
config_example.json
Normal file
6
config_example.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"pageImageWidth" : 748,
|
||||||
|
"minifyCSSandJS" : true,
|
||||||
|
"contentPath" : "/path/to/content/folder",
|
||||||
|
"outputPath" : "/path/to/output/folder")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user