Skip to content

Commit

Permalink
🚀 Version 6.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoverbruggen committed Nov 2, 2023
2 parents e6f1d7e + c42188b commit 8790b30
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 81 deletions.
24 changes: 12 additions & 12 deletions PHP Monitor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3520,7 +3520,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1340;
CURRENT_PROJECT_VERSION = 1346;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -3533,7 +3533,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 6.2;
MARKETING_VERSION = 6.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -3551,7 +3551,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1340;
CURRENT_PROJECT_VERSION = 1346;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -3564,7 +3564,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 6.2;
MARKETING_VERSION = 6.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -3791,7 +3791,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1340;
CURRENT_PROJECT_VERSION = 1346;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -3804,7 +3804,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 6.2;
MARKETING_VERSION = 6.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) DEV";
Expand Down Expand Up @@ -3907,7 +3907,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1340;
CURRENT_PROJECT_VERSION = 1346;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -3920,7 +3920,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 6.2;
MARKETING_VERSION = 6.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) DEV";
Expand Down Expand Up @@ -4023,7 +4023,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1340;
CURRENT_PROJECT_VERSION = 1346;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -4036,7 +4036,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 6.2;
MARKETING_VERSION = 6.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) EAP";
Expand Down Expand Up @@ -4204,7 +4204,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1340;
CURRENT_PROJECT_VERSION = 1346;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -4217,7 +4217,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 6.2;
MARKETING_VERSION = 6.2.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) EAP";
Expand Down
24 changes: 21 additions & 3 deletions phpmon/Common/Core/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,26 @@ struct Constants {

/**
* The PHP versions that are considered pre-release versions.
* Past a certain date, an experimental version "graduates"
* to a release version and is no longer marked as experimental.
*/
static let ExperimentalPhpVersions: Set = [
"8.3", "8.4"
]
static var ExperimentalPhpVersions: Set<String> {
let releaseDates = [
"8.4": Date.fromString("2024-12-01"), // PLACEHOLDER DATE
"8.3": Date.fromString("2023-11-23") // OFFICIAL RELEASE
]

return Set(releaseDates
.filter { (_: String, date: Date?) in
guard let date else {
return false
}

return date > Date.now
}.map { (version: String, _: Date?) in
return version
})
}

/**
* The PHP versions supported by this application.
Expand Down Expand Up @@ -91,6 +107,8 @@ struct Constants {
string: "https://raw.githubusercontent.com/nicoverbruggen/homebrew-cask/master/Casks/phpmon-dev.rb"
)!

// EAP URLs

static let EarlyAccessCaskFile = URL(
string: "https://phpmon.app/builds/early-access/sponsors/phpmon-eap.rb"
)!
Expand Down
6 changes: 6 additions & 0 deletions phpmon/Common/Extensions/DateExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ extension Date {
return dateFormatter.string(from: self)
}

static func fromString(_ string: String) -> Date? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
return dateFormatter.date(from: string)
}

}
10 changes: 4 additions & 6 deletions phpmon/Common/PHP/PHP Version/PhpEnvironments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PhpEnvironments {
// MARK: - Initializer

/**

Loads the currently active PHP installation upon startup. May be empty.
*/
init() {
self.currentInstall = ActivePhpInstallation.load()
Expand Down Expand Up @@ -49,12 +49,10 @@ class PhpEnvironments {
static let shared = PhpEnvironments()

/** Whether the switcher is busy performing any actions. */
var isBusy: Bool = false {
@MainActor var isBusy: Bool = false {
didSet {
Task { @MainActor in
MainMenu.shared.setBusyImage()
MainMenu.shared.rebuild()
}
MainMenu.shared.refreshIcon()
MainMenu.shared.rebuild()
}
}

Expand Down
8 changes: 4 additions & 4 deletions phpmon/Common/PHP/PhpExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PhpExtension {

self.name = String(fullPath.split(separator: "/").last!) // take last segment

self.enabled = !line.contains(";")
self.enabled = !line.starts(with: ";")
self.file = file
}

Expand All @@ -76,22 +76,22 @@ class PhpExtension {
You may need to restart the other services in order for this change to apply.
*/
func toggle() async {
let newLine = enabled
let newLine = !line.starts(with: ";")
// DISABLED: Commented out line
? "; \(line)"
// ENABLED: Line where the comment delimiter (;) is removed
: line.replacingOccurrences(of: "; ", with: "")

await sed(file: file, original: line, replacement: newLine)

enabled.toggle()
self.enabled = !newLine.starts(with: ";")
self.line = newLine

if !isRunningTests {
Task { @MainActor in
MainMenu.shared.rebuild()
}
}

}

// MARK: - Static Methods
Expand Down
7 changes: 1 addition & 6 deletions phpmon/Domain/Integrations/Composer/ComposerWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import Foundation
}

PhpEnvironments.shared.isBusy = true
MainMenu.shared.setBusyImage()
MainMenu.shared.rebuild()

window = TerminalProgressWindowController.display(
title: "alert.composer_progress.title".localized,
Expand Down Expand Up @@ -106,14 +104,11 @@ import Foundation

private func removeBusyStatus() {
PhpEnvironments.shared.isBusy = false
Task { @MainActor in
MainMenu.shared.updatePhpVersionInStatusBar()
}
}

// MARK: Alert

@MainActor private func presentMissingAlert() {
private func presentMissingAlert() {
BetterAlert()
.withInformation(
title: "alert.composer_missing.title".localized,
Expand Down
3 changes: 2 additions & 1 deletion phpmon/Domain/Integrations/Homebrew/Brew.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class Brew {

/// Each formula for each PHP version that can be installed.
public static let phpVersionFormulae = [
"8.3": "shivammathur/php/[email protected]",
"8.4": "shivammathur/php/[email protected]",
"8.3": "shivammathur/php/[email protected]", // TODO: when [email protected] lands in stable, update this
"8.2": "[email protected]",
"8.1": "[email protected]",
"8.0": "[email protected]",
Expand Down
3 changes: 0 additions & 3 deletions phpmon/Domain/Menu/MainMenu+Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ extension MainMenu {
return
}

setBusyImage()
PhpEnvironments.shared.isBusy = true
PhpEnvironments.shared.delegate = self
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
Expand All @@ -298,7 +297,6 @@ extension MainMenu {
}

@objc func switchToPhpVersion(_ version: String) {
setBusyImage()
PhpEnvironments.shared.isBusy = true
PhpEnvironments.shared.delegate = self
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
Expand All @@ -325,7 +323,6 @@ extension MainMenu {
*/
func switchToPhp(_ version: String) async {
Task { @MainActor [self] in
setBusyImage()
PhpEnvironments.shared.isBusy = true
PhpEnvironments.shared.delegate = self
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
Expand Down
19 changes: 8 additions & 11 deletions phpmon/Domain/Menu/MainMenu+Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,16 @@ extension MainMenu {
.broadcastServicesUpdate
]
) {
if behaviours.contains(.reloadsPhpInstallation) {
if behaviours.contains(.reloadsPhpInstallation) || behaviours.contains(.setsBusyUI) {
PhpEnvironments.shared.isBusy = true
}

if behaviours.contains(.setsBusyUI) {
setBusyImage()
}

Task(priority: .userInitiated) { [unowned self] in
var error: Error?

do { try execute() } catch let e { error = e }

if behaviours.contains(.setsBusyUI) {
PhpEnvironments.shared.isBusy = false
do { try execute() } catch let e {
error = e
Log.err(e)
}

Task { @MainActor [self, error] in
Expand All @@ -69,14 +64,16 @@ extension MainMenu {

if behaviours.contains(.updatesMenuBarContents) {
updatePhpVersionInStatusBar()
} else if behaviours.contains(.setsBusyUI) {
refreshIcon()
}

if behaviours.contains(.broadcastServicesUpdate) {
Task { await ServicesManager.shared.reloadServicesStatus() }
}

if behaviours.contains(.setsBusyUI) {
PhpEnvironments.shared.isBusy = false
}

if error != nil {
return failure(error!)
}
Expand Down
3 changes: 3 additions & 0 deletions phpmon/Domain/Menu/MainMenu+Startup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ extension MainMenu {
Valet.shared.notifyAboutUnsupportedTLD()
}

// Keep track of which PHP versions are currently about to release
Log.info("Experimental PHP versions: \(Constants.ExperimentalPhpVersions)")

// Find out which services are active
Log.info("The services manager knows about \(ServicesManager.shared.services.count) services.")

Expand Down
4 changes: 3 additions & 1 deletion phpmon/Domain/Menu/MainMenu+Switcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ extension MainMenu {

nonisolated func switcherDidCompleteSwitch(to version: String) {
// Mark as no longer busy
PhpEnvironments.shared.isBusy = false
Task { @MainActor in
PhpEnvironments.shared.isBusy = false
}

Task { // Things to do after reloading domain list data
if Valet.installed {
Expand Down
13 changes: 5 additions & 8 deletions phpmon/Domain/Menu/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
}

/** Updates the icon (refresh icon) and rebuilds the menu. */
@available(*, deprecated, message: "Use the busy status instead")
@objc func updatePhpVersionInStatusBar() {
refreshIcon()
rebuild()
Expand Down Expand Up @@ -139,7 +140,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
@objc func reloadPhpMonitorMenuInBackground() {
asyncExecution({
// This automatically reloads the menu
Log.info("Reloading information about the PHP installation (in the background)...")
Log.perf("Reloading information about the PHP installation (in the background)...")
}, behaviours: [
.setsBusyUI,
.reloadsPhpInstallation,
Expand All @@ -150,10 +151,13 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate

/** Refreshes the icon with the PHP version. */
@objc func refreshIcon() {

Task { @MainActor [self] in
if PhpEnvironments.shared.isBusy {
Log.perf("Refreshing icon: currently busy")
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
} else {
Log.perf("Refreshing icon: no longer busy")
if Preferences.preferences[.shouldDisplayDynamicIcon] as! Bool == false {
// Static icon has been requested
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIconStatic"))!)
Expand All @@ -172,13 +176,6 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
}
}

/** Updates the icon to be displayed as busy. */
@objc func setBusyImage() {
Task { @MainActor [self] in
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
}
}

// MARK: - Menu Item Functionality

@objc func openAbout() {
Expand Down
Loading

0 comments on commit 8790b30

Please sign in to comment.