From d1c418af3e32dee21d6abd40b6ecdd61684cd68c Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Fri, 2 Sep 2022 23:19:13 +0200 Subject: [PATCH] Improve overview of modified pages --- WebsiteGenerator/Files/FileSystem.swift | 20 +++++++++++++++++++ .../Generators/IndexPageGenerator.swift | 2 +- .../Generators/OverviewPageGenerator.swift | 2 +- .../Generators/PageGenerator.swift | 2 +- WebsiteGenerator/main.swift | 6 +++--- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/WebsiteGenerator/Files/FileSystem.swift b/WebsiteGenerator/Files/FileSystem.swift index 6d350a9..997813b 100644 --- a/WebsiteGenerator/Files/FileSystem.swift +++ b/WebsiteGenerator/Files/FileSystem.swift @@ -76,6 +76,11 @@ final class FileSystem { */ private var imageTasks: [String : ImageOutput] = [:] + /** + The paths to all pages which were changed + */ + private var generatedPages: Set = [] + init(in input: URL, to output: URL) { self.input = input self.output = output @@ -474,6 +479,21 @@ final class FileSystem { pagePaths[id] } + func generated(page: String) { + generatedPages.insert(page) + } + + func printGeneratedPages() { + guard !generatedPages.isEmpty else { + print("No pages modified") + return + } + print("\(generatedPages.count) pages modified") + for page in generatedPages.sorted() { + print(" " + page) + } + } + // MARK: Writing files diff --git a/WebsiteGenerator/Generators/IndexPageGenerator.swift b/WebsiteGenerator/Generators/IndexPageGenerator.swift index b5b79f1..c663810 100644 --- a/WebsiteGenerator/Generators/IndexPageGenerator.swift +++ b/WebsiteGenerator/Generators/IndexPageGenerator.swift @@ -29,7 +29,7 @@ struct IndexPageGenerator { guard factory.page.generate(content, to: pageUrl) else { return } - log.add(info: "Page generated", source: path) + files.generated(page: path) } private func makeHeader(page: Element, metadata: Element.LocalizedMetadata, language: String) -> String { diff --git a/WebsiteGenerator/Generators/OverviewPageGenerator.swift b/WebsiteGenerator/Generators/OverviewPageGenerator.swift index 6dac0c5..955068e 100644 --- a/WebsiteGenerator/Generators/OverviewPageGenerator.swift +++ b/WebsiteGenerator/Generators/OverviewPageGenerator.swift @@ -29,7 +29,7 @@ struct OverviewPageGenerator { guard factory.page.generate(content, to: url) else { return } - log.add(info: "Page generated", source: path) + files.generated(page: path) } private func makeContent(section: Element, language: String) -> String { diff --git a/WebsiteGenerator/Generators/PageGenerator.swift b/WebsiteGenerator/Generators/PageGenerator.swift index 33876da..15a551a 100644 --- a/WebsiteGenerator/Generators/PageGenerator.swift +++ b/WebsiteGenerator/Generators/PageGenerator.swift @@ -57,7 +57,7 @@ struct PageGenerator { guard factory.page.generate(content, to: url) else { return } - log.add(info: "Page generated", source: path) + files.generated(page: path) } private func makeContent(page: Element, language: String, path: String) -> (content: String, includesCode: Bool)? { diff --git a/WebsiteGenerator/main.swift b/WebsiteGenerator/main.swift index 258ae07..f67d54f 100644 --- a/WebsiteGenerator/main.swift +++ b/WebsiteGenerator/main.swift @@ -22,11 +22,11 @@ do { private let siteGenerator = try SiteGenerator() try siteGenerator.generate(site: siteData) -print("Pages generated\n") -files.createImages() +files.printGeneratedPages() files.printEmptyPages() files.printDraftPages() + +files.createImages() print("Images generated") files.copyRequiredFiles() -print("Required files copied") files.writeHashes()