restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
@@ -0,0 +1,25 @@
import Foundation
extension HelderConfig {
/// Folder in the project root that holds Helder's per-project state.
public static let folderName = ".helder"
public static let overridesFileName = "config.json"
public static let defaultsFileName = "config.default.json"
/// The whole `.helder` folder is machine-local state, so it ignores itself.
public static let gitignoreBody = "# Helder — local, machine-specific state (do not commit).\n*\n"
/// The effective config for a sparse `config.json`; nil, empty or invalid JSON yields the defaults.
public static func resolved(overrides data: Data?) -> HelderConfig {
guard let data, !data.isEmpty else { return .defaults }
return (try? JSONDecoder().decode(HelderConfig.self, from: data)) ?? .defaults
}
/// Pretty JSON of every default, rewritten to `config.default.json` on each launch as documentation.
public static func defaultsJSON() -> Data {
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
var data = (try? encoder.encode(HelderConfig.defaults)) ?? Data()
data.append(0x0A)
return data
}
}