CorkEdit sectionCopy link
Cork is a macOS application that provides a user-friendly interface for managing Homebrew packages, taps, and services. The application offers a comprehensive set of features, including package installation, removal, and updating, as well as maintenance tasks like cache cleanup and orphan package uninstallation.
The most important functionality of the Cork application is centered around the …/Views
, …/Logic
, and …/Models
directories. These directories contain the core implementation of the application's user interface, business logic, and data models, respectively.
The …/Views
directory houses the SwiftUI views that make up the application's user interface. This includes the main views for package management, such as the Package Details view, the Installation view, and the Removal view. Additionally, the views for Tap Management, Service Management, and Maintenance Tasks are also located in this directory.
The …/Logic
directory contains the core business logic of the application, including functionality for Brewfile management, Discoverability, File System interactions, Package Installation and Removal, JSON processing, Maintenance tasks, Networking, Notifications, Package Loading, and Package Searching.
The …/Models
directory defines the data models and observable objects used throughout the application, covering areas such as Discoverability, Outdated Packages, Package Installation, Package Uninstallation, Package Management, Searching, Services, and Updating.
The Cork application relies on several key technologies and design choices:
- SwiftUI: The entire user interface is built using the SwiftUI framework, which provides a declarative approach to building user interfaces.
- Homebrew Integration: The application integrates closely with the Homebrew package manager, using its command-line interface to perform various package-related operations.
- Asynchronous Operations: Many of the application's tasks, such as package installation and maintenance, are performed asynchronously to provide a responsive user experience.
- State Management: The application uses various
ObservableObject
types to manage the state of the application, including the package list, outdated packages, and service status. - Modular Design: The codebase is organized into several directories and files, each focusing on a specific aspect of the application's functionality, promoting modularity and maintainability.
For more details on the specific functionality and implementation of the Cork application, please refer to the following sections of the wiki:
Package ManagementEdit sectionCopy link
References: Cork/Views/Installation
, Cork/Views/Packages
, Cork/Logic/Installation & Removal
, Cork/Models/Packages
The functionality related to installing, removing, and updating Homebrew packages is primarily implemented in the following directories and files:
Read morePackage InstallationEdit sectionCopy link
References: Cork/Views/Installation
, Cork/Views/Installation/Sub-Views
, Cork/Models/Packages
The …/Installation
directory contains the implementation of various views and components related to the package installation process in the Cork application. This includes the initial view for displaying top packages, the view for searching and selecting packages, the view for displaying the installation progress, and the views for handling specific scenarios like when sudo access is required or when the package architecture is incompatible.
Initial Package SelectionEdit sectionCopy link
References: Cork/Views/Installation/Sub-Views/Initial
The TopPackagesSection
view in the …/Initial
directory is responsible for displaying the initial view that shows the top Homebrew packages (both formulae and casks) that the user can install.
Package Search and SelectionEdit sectionCopy link
References: Cork
The …/Search for Package.swift
file contains the core functionality for searching for Homebrew packages in the Cork application.
Installation Progress and HandlingEdit sectionCopy link
References: Cork
The InstallationProgressTracker
class in …/Installation Progress Tracker.swift
is responsible for managing the installation process of Homebrew packages in the Cork application. This class tracks the progress of the installation and provides a way to display the progress to the user.
Package RemovalEdit sectionCopy link
References: Cork/Logic/Installation & Removal/Removal
The uninstallSelectedPackage()
function in the …/Uninstall Packages.swift
file is responsible for the core functionality of uninstalling a selected Homebrew package from the user's system. This function plays a crucial role in the package removal process within the Cork application.
Package SynchronizationEdit sectionCopy link
References: Cork
The …/Synchnorize Installed Packages.swift
file contains the synchronizeInstalledPackages()
function, which is responsible for synchronizing the list of installed Homebrew packages with the application's state.
Package Details and DiscoverabilityEdit sectionCopy link
References: Cork/Views/Packages
, Cork/Views/Packages/Package Details
, Cork/Models/Packages/Discoverability
The …/Package Details
directory contains the main components responsible for displaying detailed information about a specific Homebrew package in the Cork application. This includes various subviews that handle different aspects of the package details, such as caveats, dependencies, system information, and modification actions.
Tap ManagementEdit sectionCopy link
References: Cork/Views/Taps
, Cork/Logic/JSON
The Tap Management section covers the functionality related to managing Homebrew taps, including adding, removing, and displaying tap details.
Read moreAdding TapsEdit sectionCopy link
References: Cork/Views/Taps/Sub-Views
, Cork/Views/Taps/Add Tap View.swift
The AddTapView
struct in the …/Add Tap View.swift
file is responsible for handling the process of adding a new Homebrew tap to the application.
Removing TapsEdit sectionCopy link
References: Cork/Views/Taps/Tap Details/Tap Details.swift
The TapDetailView
struct in the file …/Tap Details.swift
provides the functionality for removing a Homebrew tap from the system.
Displaying Tap DetailsEdit sectionCopy link
References: Cork/Views/Taps/Tap Details
, Cork/Views/Taps/Tap Details/Sub-Views
The TapDetailView
struct in the …/Tap Details.swift
file is responsible for displaying detailed information about a specific Homebrew tap. It fetches the tap information asynchronously and parses the retrieved JSON data to extract relevant details, such as the tap's homepage, official status, included formulae and casks, and the total number of packages.
Extracting Tap Information from JSONEdit sectionCopy link
References: Cork/Logic/JSON/Get Various Tap Info from JSON
The …/
directory contains several Swift files that are responsible for extracting various information about Homebrew taps from a JSON data source. The key functionality includes:
Service ManagementEdit sectionCopy link
References: Cork/Views/Services
, Cork/Logic/Services
, Cork/Models/Services
The Service Management section covers the functionality related to managing Homebrew services, including displaying service status and details.
Read moreService Status and DetailsEdit sectionCopy link
References: Cork/Views/Services/Service Detail
, Cork/Logic/Services/Service Details
The …/Service Detail
directory contains the main view responsible for displaying detailed information about a HomebrewService
object. This view handles the loading and display of the service details, as well as error handling when the details fail to load.
Service State ManagementEdit sectionCopy link
References: Cork/Views/Services/Services State.swift
, Cork/Models/Services
The ServicesState
class is an ObservableObject
that manages the state related to services in the Cork application. It has two main properties:
Maintenance TasksEdit sectionCopy link
References: Cork/Views/Menu Bar
, Cork/Logic/Maintenance
The Maintenance Tasks section covers the functionality related to performing various maintenance tasks in the Cork application, such as cleaning up the Homebrew cache, deleting cached downloads, and uninstalling orphaned packages.
Read moreCache CleanupEdit sectionCopy link
References: Cork/Views/Menu Bar/Sub-Views/Menu Bar - Cache Cleanup.swift
, Cork/Logic/Maintenance/Utility Functions/Purge Cache Utility.swift
The Purge Cache Utility.swift
file in the …/
directory contains a utility function purgeHomebrewCacheUtility()
that is responsible for purging the Homebrew cache on the system. This function is designed to handle any errors that may occur during the cache purging process and provide information about any packages that are holding back the cache purge.
Cached Downloads CleanupEdit sectionCopy link
References: Cork/Views/Menu Bar/Sub-Views/Menu Bar - Cached Downloads Cleanup.swift
, Cork/Logic/Maintenance/Steps/Delete Cached Downloads.swift
The Menu Bar - Cached Downloads Cleanup.swift
file contains the implementation of the MenuBar_CachedDownloadsCleanup
view, which is responsible for managing the cleanup of cached downloads in the Cork application. This view is part of the application's menu bar and provides functionality to delete the cached downloads and display the amount of space reclaimed after the cleanup process.
Orphan CleanupEdit sectionCopy link
References: Cork/Views/Menu Bar/Sub-Views/Menu Bar - Orphan Cleanup.swift
, Cork/Logic/Maintenance/Steps/Uninstall Orphaned Packages.swift
, Cork/Logic/Maintenance/Utility Functions/Uninstall Orphans - Utility.swift
The MenuBar_OrphanCleanup
view in the …/Menu Bar - Orphan Cleanup.swift
file is responsible for handling the functionality related to uninstalling orphaned packages in the Cork application. This view provides a button that, when clicked, initiates a task to uninstall any orphaned packages and sends a notification with the results of the operation.
Homebrew Health CheckEdit sectionCopy link
References: Cork/Logic/Maintenance/Steps/Perform Brew Health Check.swift
The performBrewHealthCheck()
function in …/Perform Brew Health Check.swift
is responsible for running the Homebrew "doctor" command and handling any errors that are reported.
Maintenance UtilitiesEdit sectionCopy link
References: Cork/Logic/Maintenance/Utility Functions/Purge Cache Utility.swift
, Cork/Logic/Maintenance/Utility Functions/Uninstall Orphans - Utility.swift
The Purge Cache Utility.swift
file in the …/
directory contains a utility function purgeHomebrewCacheUtility()
that is responsible for purging the Homebrew cache on the system. This function is designed to handle any errors that may occur during the cache purging process and provide information about any packages that are holding back the cache purge.
Discoverability and AnalyticsEdit sectionCopy link
References: Cork/Views/Start Page
, Cork/Logic/Discoverability
, Cork/Models/Discoverability
The Cork
application provides functionality for discovering top Homebrew packages and managing the user's analytics settings.
Top PackagesEdit sectionCopy link
References: Cork/Models/Discoverability
, Cork/Logic/Discoverability
The TopPackagesTracker
class in …/Top Packages Tracker.swift
is responsible for tracking and publishing the top Homebrew packages and casks. This class has two published properties:
Analytics ManagementEdit sectionCopy link
References: Cork/Views/Start Page/Sub-Views/Analytics Status Box.swift
, Cork/Views/Start Page/Sub-Views/Analytics Status Box 2.swift
The AnalyticsStatusBox
view in the …/Analytics Status Box 2.swift
file is responsible for displaying the user's analytics settings in the Cork application. This view uses the @AppStorage
property wrapper to access the allowBrewAnalytics
boolean value, which determines whether analytics are enabled or disabled for the application.
Settings and PreferencesEdit sectionCopy link
References: Cork/Views/Settings
, Cork/Models/Misc
The Settings and Preferences section covers the functionality related to configuring the application's settings and preferences, including advanced options, Homebrew-related settings, and notification preferences.
Read moreAdvanced SettingsEdit sectionCopy link
References: Cork/Views/Settings/Panes/Advanced Pane.swift
, Cork/Views/Settings/Panes/Brew Pane.swift
The AdvancedPane
in the …/Advanced Pane.swift
file provides access to advanced settings for the Cork application. This subsection covers the key functionality related to these advanced settings.
General PreferencesEdit sectionCopy link
References: Cork/Views/Settings/Panes/General Pane.swift
The GeneralPane
struct in the …/General Pane.swift
file defines the user interface and functionality for the general settings pane in the Cork application. This pane allows users to configure various settings related to package management, search, and application behavior.
Installation and UninstallationEdit sectionCopy link
References: Cork/Views/Settings/Panes/Installation Pane.swift
The InstallationAndUninstallationPane
in …/Installation Pane.swift
provides settings related to the installation and uninstallation of Homebrew packages in the Cork application.
Maintenance TasksEdit sectionCopy link
References: Cork/Views/Settings/Panes/Maintenance Pane.swift
The MaintenancePane
struct in the file …/Maintenance Pane.swift
provides a settings pane for configuring default settings related to various maintenance tasks in the Cork application. This pane allows users to customize the behavior of operations such as uninstalling orphaned packages, purging the Homebrew cache, deleting cached downloads, and performing a Homebrew health check.
Notification PreferencesEdit sectionCopy link
References: Cork/Views/Settings/Panes/Notifications Pane.swift
The NotificationsPane
struct in the …/Notifications Pane.swift
file provides the user interface for managing notification settings in the Cork application.
Discoverability SettingsEdit sectionCopy link
References: Cork/Views/Settings/Panes/Discoverability Pane.swift
The DiscoverabilityPane
struct in the file …/Discoverability Pane.swift
is responsible for rendering the Discoverability settings pane in the Cork application. This pane allows users to configure various settings related to package discoverability.
Onboarding and LicensingEdit sectionCopy link
References: Cork/Views/Onboarding
, Cork/Views/Licensing
The …/Onboarding
directory and the …/Licensing
directory contain the core functionality for the onboarding experience and licensing management in the Cork application.
Onboarding ExperienceEdit sectionCopy link
References: Cork/Views/Onboarding
, Cork/Views/Onboarding/Sub-Views
The OnboardingView
struct in the …/Onboarding.swift
file is responsible for the application's onboarding experience. This view allows users to configure various settings and preferences related to the app's functionality, such as real-time terminal output, uninstallation options, dependency display, search features, notifications, and more.
Licensing ManagementEdit sectionCopy link
References: Cork/Views/Licensing
, Cork/Views/Licensing/Sub-Views
The Licensing_BoughtView
struct is responsible for displaying a screen that indicates the user has successfully purchased a license. This view interacts with the AppState
environment object and updates several AppStorage
values related to the licensing workflow.
Utility Functions and HelpersEdit sectionCopy link
References: Cork/Logic/Helpers
, Cork/Logic/JSON
, Cork/Logic/Networking
, Cork/Logic/Notifications
, Cork/Logic/Tagging
This section covers the various utility functions and helper classes used throughout the application.
Read moreApplication LifecycleEdit sectionCopy link
References: Cork/Logic/Helpers/Restart App.swift
, Cork/Logic/Helpers/Switch Cork to Foreground.swift
The Cork
application provides utility functions to handle the application's lifecycle, including restarting the application and bringing it to the foreground.
Start PageEdit sectionCopy link
References: Cork/Views/Start Page
, Cork/Views/Start Page/Sub-Views
, Cork/Views/Start Page/Sub-Views/Outdated Packages
The start page is the main entry point for the Cork application, displaying an overview of the user's installed packages, taps, analytics status, cached downloads, and outdated packages.
Read more