Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Check the app's words in its tests, not when its window opens
Țugui Dragoș4084fbd51073
diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swiftindex 28b072d8..813cc52a 100644--- a/Peel/PeelApp.swift+++ b/Peel/PeelApp.swift@@ -431,10 +431,6 @@ struct PeelApp: App {.environment(\.notifications, notifications).task {#if DEBUG- Tweak.checkWords()- SpaceItem.checkWords()- AppExtension.checkWords()- FixedSentence.checkWords()await HomeSnapshot.runIfRequested()TerminalExport.runIfRequested()#endifdiff --git a/Peel/Views/Extensions/ExtensionText.swift b/Peel/Views/Extensions/ExtensionText.swiftindex 59b7ed2e..6df07490 100644--- a/Peel/Views/Extensions/ExtensionText.swift+++ b/Peel/Views/Extensions/ExtensionText.swift@@ -72,22 +72,3 @@ private enum ExtensionPoint {}}}--#if DEBUG-extension AppExtension {- /// Checks `pointName`: a known point gets a word, an unknown point keeps its identifier, and an extension- /// with no point gets nil. The app has no test target, so Debug builds run this when the main window opens.- static func checkWords() {- func made(_ point: String?) -> AppExtension {- AppExtension(- identifier: "x", name: "x", kind: .appExtension, point: point, owner: nil,- url: URL(filePath: "/x"), election: .asItCame, teamIdentifier: nil, reportedState: nil- )- }- assert(made("com.apple.FinderSync").pointName?.isEmpty == false, "Finder has no word")- assert(made("com.apple.FinderSync").pointName != "com.apple.FinderSync", "Finder kept its identifier")- assert(made("com.example.unknown").pointName == "com.example.unknown", "an unknown point lost its identifier")- assert(made(nil).pointName == nil, "no point was given a name")- }-}-#endifdiff --git a/Peel/Views/FixedSentenceText.swift b/Peel/Views/FixedSentenceText.swiftindex 2687604a..5d9bd411 100644--- a/Peel/Views/FixedSentenceText.swift+++ b/Peel/Views/FixedSentenceText.swift@@ -54,15 +54,3 @@ extension LocalizedStringResource {return String(localized: String.LocalizationValue(key), table: table, bundle: bundle, locale: locale)}}--#if DEBUG-extension FixedSentence {- /// A sentence is known by its English, so the words here have to read exactly as what is sent. The key is- /// compared rather than the text it resolves to, which a pseudolanguage rewrites.- static func checkWords() {- for sentence in allCases {- assert(sentence.words.key == sentence.english, "the words for \(sentence) no longer read as what is sent")- }- }-}-#endifdiff --git a/Peel/Views/Space/SpaceText.swift b/Peel/Views/Space/SpaceText.swiftindex bbc0c408..a28bc66a 100644--- a/Peel/Views/Space/SpaceText.swift+++ b/Peel/Views/Space/SpaceText.swift@@ -185,27 +185,3 @@ nonisolated extension SpaceItem {),]}--#if DEBUG-extension SpaceItem {- /// Checks that every area PeelCore defines has complete words here. The app has no test target, so a Debug- /// build runs this when its window opens. It reads the keys, not the text they resolve to, so a- /// pseudolanguage can't trip it. `StringCatalogTests` checks the translations.- static func checkWords() {- for id in SpaceInventory.definitionIdentifiers {- guard let found = words[id] else {- assertionFailure("no words for \(id)")- continue- }- assert(!found.title.key.isEmpty, "\(id) has no title")- assert(found.detail.key.hasSuffix("."), "\(id) doesn't explain itself")- if let hint = found.hint {- assert(!hint.key.isEmpty, "\(id) has an empty hint")- }- }- for id in SpaceInventory.managedAreaIdentifiers {- assert(words[id]?.hintWithoutItsApp != nil, "\(id) has no hint for when its app is gone")- }- }-}-#endifdiff --git a/Peel/Views/Tweaks/TweakText.swift b/Peel/Views/Tweaks/TweakText.swiftindex e1b901a8..7eb50dd7 100644--- a/Peel/Views/Tweaks/TweakText.swift+++ b/Peel/Views/Tweaks/TweakText.swift@@ -27,6 +27,10 @@ extension Tweak {return found}+ static func words(for id: String) -> Words? {+ words[id]+ }+private static let words: [String: Words] = ["dock-autohide": Words(title: "Automatically hide and show the Dock",@@ -201,21 +205,3 @@ extension Tweak {),]}--#if DEBUG-extension Tweak {- /// Checks that every tweak has words: a title, and a detail that ends with a period. The app has no test- /// target, so Debug builds run this at launch. It reads the English keys rather than the resolved text, so- /// it also passes in a pseudolanguage. `StringCatalogTests` checks the translations.- static func checkWords() {- for id in TweakCatalog.all.map(\.id) {- guard let found = words[id] else {- assertionFailure("no words for \(id)")- continue- }- assert(!found.title.key.isEmpty, "\(id) has no title")- assert(found.detail.key.hasSuffix("."), "\(id) doesn't explain itself")- }- }-}-#endifdiff --git a/PeelTests/WordsTests.swift b/PeelTests/WordsTests.swiftnew file mode 100644index 00000000..eb341908--- /dev/null+++ b/PeelTests/WordsTests.swift@@ -0,0 +1,50 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++/// Each reads the English keys, not the text they resolve to, so a pseudolanguage can't trip it. `StringCatalogTests`+/// checks the translations.+struct WordsTests {+ @Test func everyTweakHasATitleAndExplainsItself() {+ for id in TweakCatalog.all.map(\.id) {+ let found = Tweak.words(for: id)+ #expect(found != nil, "no words for \(id)")+ #expect(found?.title.key.isEmpty == false, "\(id) has no title")+ #expect(found?.detail.key.hasSuffix(".") == true, "\(id) doesn't explain itself")+ }+ }++ @Test func everyAreaOfTheDiskHasATitleAndExplainsItself() {+ for id in SpaceInventory.definitionIdentifiers {+ let found = SpaceItem.words(for: id)+ #expect(found != nil, "no words for \(id)")+ #expect(found?.title.key.isEmpty == false, "\(id) has no title")+ #expect(found?.detail.key.hasSuffix(".") == true, "\(id) doesn't explain itself")+ #expect(found?.hint?.key.isEmpty != true, "\(id) has an empty hint")+ }+ for id in SpaceInventory.managedAreaIdentifiers {+ #expect(SpaceItem.words(for: id)?.hintWithoutItsApp != nil, "\(id) has no hint for when its app is gone")+ }+ }++ @Test func anExtensionPointIsNamedInWordsOrByItsIdentifier() {+ func made(_ point: String?) -> AppExtension {+ AppExtension(+ identifier: "org.example.part", name: "Part", kind: .appExtension, point: point, owner: nil,+ url: URL(filePath: "/org.example"), election: .asItCame, teamIdentifier: nil, reportedState: nil+ )+ }++ #expect(made("com.apple.FinderSync").pointName?.isEmpty == false, "Finder has no word")+ #expect(made("com.apple.FinderSync").pointName != "com.apple.FinderSync", "Finder kept its identifier")+ #expect(made("com.example.unknown").pointName == "com.example.unknown", "an unknown point lost its identifier")+ #expect(made(nil).pointName == nil, "no point was given a name")+ }++ @Test func everyFixedSentenceReadsAsWhatIsSent() {+ for sentence in FixedSentence.allCases {+ #expect(sentence.words.key == sentence.english, "the words for \(sentence) no longer read as what is sent")+ }+ }+}