1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

Compare commits

..

20 Commits

Author SHA1 Message Date
8b0aeef2e6 🚀 Version 5.8.1 2023-03-29 18:05:03 +02:00
aa406434d0 🔧 Bump build 2023-03-29 18:04:27 +02:00
d320c49092 👌 Avoid force unwrapping try (may crash) 2023-03-23 19:08:39 +01:00
966033e052 🐛 Prevent crash upon parsing invalid Valet directories
This fixes #247, which can be caused when certain folders are not
accessible for some reason. This can occur due to network reasons,
but also because the linked folder in question is iCloud Drive.
2023-03-23 18:00:45 +01:00
7c192730e1 📝 Update SECURITY 2023-03-15 20:09:32 +01:00
13ee618d5c 🚀 Version 5.8.0 2023-03-03 16:49:38 +01:00
e149a2500e 📝 Updated README 2023-03-02 16:27:26 +01:00
aef7d4021c 🔧 Bump build 2023-03-01 19:22:26 +01:00
050c489158 🐛 Prevent upgrade file removal from crashing the app 2023-03-01 19:20:13 +01:00
130bf38dd9 👌 Clean up HOMEBREW_DIR/Caskroom directory
Only when using the self-updater, of course.

Also include a description that reflects this cleanup scenario.
2023-03-01 19:17:18 +01:00
a6c3f0ceba 🍱 Use classic DEV channel icon 2023-02-27 19:16:15 +01:00
f274e9e004 👌 Updated IAP for accessing formulae.brew.sh 2023-02-27 19:08:04 +01:00
a07881a987 👌 Fix copy of missing config check 2023-02-27 19:04:50 +01:00
715b674929 Fix tests 2023-02-26 15:02:43 +01:00
3f14754177 📝 Update README to reflect #239 2023-02-21 18:18:23 +01:00
b0de0c04c6 🚀 Version 5.7.4 2023-02-14 18:53:32 +01:00
f27e07fc78 🔧 Bump build 2023-02-13 17:30:37 +01:00
9fceab3e2e 🐛 Adjusted for new Homebrew JSON output (#235) 2023-02-13 17:30:01 +01:00
03fdf23f0a 🚀 Version 5.7.3 2023-02-06 19:15:25 +01:00
412b7bad5c 🐛 Fix generated script (#231) 2023-02-06 19:13:49 +01:00
35 changed files with 285 additions and 146 deletions

View File

@ -141,6 +141,7 @@
C44CCD4127AFE2FC00CE40E5 /* AlertableError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44CCD3F27AFE2FC00CE40E5 /* AlertableError.swift */; };
C44CCD4927AFF3B700CE40E5 /* MainMenu+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44CCD4827AFF3B700CE40E5 /* MainMenu+Async.swift */; };
C44CCD4A27AFF3BC00CE40E5 /* MainMenu+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44CCD4827AFF3B700CE40E5 /* MainMenu+Async.swift */; };
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44E985E29B23EBF0059F773 /* UpdateCheckTest.swift */; };
C44F868E2835BD8D005C353A /* phpmon-config.json in Resources */ = {isa = PBXBuildFile; fileRef = C44F868D2835BD8D005C353A /* phpmon-config.json */; };
C450C8C628C919EC002A2B4B /* PreferenceName.swift in Sources */ = {isa = PBXBuildFile; fileRef = C450C8C528C919EC002A2B4B /* PreferenceName.swift */; };
C450C8C728C919EC002A2B4B /* PreferenceName.swift in Sources */ = {isa = PBXBuildFile; fileRef = C450C8C528C919EC002A2B4B /* PreferenceName.swift */; };
@ -710,6 +711,9 @@
C4FACE83288F1F9700FC478F /* OnboardingWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FACE82288F1F9700FC478F /* OnboardingWindowController.swift */; };
C4FBFC532616485F00CDB8E1 /* PhpVersionDetectionTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FBFC512616485F00CDB8E1 /* PhpVersionDetectionTest.swift */; };
C4FC21B128391F8E00D368BB /* MainMenu+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F361602836BFD9003598CC /* MainMenu+Actions.swift */; };
C4FD87A529AB98720002D701 /* PhpConfigChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */; };
C4FD87A629AB98730002D701 /* PhpConfigChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */; };
C4FD87A729AB98730002D701 /* PhpConfigChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */; };
C4FE011128084FC200D1DE6D /* SelectionVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FE011028084FC200D1DE6D /* SelectionVC.swift */; };
C4FE011228084FC200D1DE6D /* SelectionVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4FE011028084FC200D1DE6D /* SelectionVC.swift */; };
/* End PBXBuildFile section */
@ -827,6 +831,7 @@
C44C1990276E44CB0072762D /* ProgressWindow.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = ProgressWindow.storyboard; sourceTree = "<group>"; };
C44CCD3F27AFE2FC00CE40E5 /* AlertableError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertableError.swift; sourceTree = "<group>"; };
C44CCD4827AFF3B700CE40E5 /* MainMenu+Async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MainMenu+Async.swift"; sourceTree = "<group>"; };
C44E985E29B23EBF0059F773 /* UpdateCheckTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateCheckTest.swift; sourceTree = "<group>"; };
C44F868D2835BD8D005C353A /* phpmon-config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "phpmon-config.json"; sourceTree = "<group>"; };
C450C8C528C919EC002A2B4B /* PreferenceName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceName.swift; sourceTree = "<group>"; };
C451AFF52969E40F0078E617 /* HelpButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpButton.swift; sourceTree = "<group>"; };
@ -1425,6 +1430,7 @@
children = (
C471E7BE28F9B90F0021E251 /* StartupTest.swift */,
C469E702294CFDF700A82AB2 /* DomainsListTest.swift */,
C44E985E29B23EBF0059F773 /* UpdateCheckTest.swift */,
C4181F1028FAF9330042EA28 /* UITestCase.swift */,
);
path = ui;
@ -2221,6 +2227,7 @@
C471E84328F9BB650021E251 /* App.swift in Sources */,
C4E2E85E28FC282B003B070C /* TestableConfiguration.swift in Sources */,
C491997D29901DF7001F3A21 /* CaskFile.swift in Sources */,
C4FD87A629AB98730002D701 /* PhpConfigChecker.swift in Sources */,
C45E2A7529199248005C7CFD /* InternalSwitcherTest.swift in Sources */,
C471E84428F9BB650021E251 /* App+ActivationPolicy.swift in Sources */,
C471E84528F9BB650021E251 /* App+GlobalHotkey.swift in Sources */,
@ -2370,6 +2377,7 @@
C471E89028F9BB8F0021E251 /* AlertableError.swift in Sources */,
C471E89128F9BB8F0021E251 /* Errors.swift in Sources */,
C471E89228F9BB8F0021E251 /* Alert.swift in Sources */,
C4FD87A529AB98720002D701 /* PhpConfigChecker.swift in Sources */,
C471E89328F9BB8F0021E251 /* Application.swift in Sources */,
C471E89428F9BB8F0021E251 /* LocalNotification.swift in Sources */,
C471E89528F9BB8F0021E251 /* MenuBarImageGenerator.swift in Sources */,
@ -2499,6 +2507,7 @@
C471E82C28F9BB340021E251 /* ValetListable.swift in Sources */,
C471E82828F9BB310021E251 /* HomebrewDiagnostics.swift in Sources */,
C471E81E28F9BB260021E251 /* BetterAlert.swift in Sources */,
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */,
C471E7D228F9BA630021E251 /* ActiveFileSystem.swift in Sources */,
C471E80028F9BAD10021E251 /* Xdebug.swift in Sources */,
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */,
@ -2618,6 +2627,7 @@
C4D936CB27E3EE4A00BD69FE /* DomainListCellProtocol.swift in Sources */,
C4B97B76275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */,
C4F780CD25D80B75000DBC97 /* Alert.swift in Sources */,
C4FD87A729AB98730002D701 /* PhpConfigChecker.swift in Sources */,
C485706D28BF450900539B36 /* NSMenuItemExtension.swift in Sources */,
C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */,
C495F5B028A42E080087F70A /* EnvironmentCheck.swift in Sources */,
@ -2879,7 +2889,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1074;
CURRENT_PROJECT_VERSION = 1079;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -2892,7 +2902,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 5.8;
MARKETING_VERSION = 5.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -2909,7 +2919,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1074;
CURRENT_PROJECT_VERSION = 1079;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
@ -2922,7 +2932,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 5.8;
MARKETING_VERSION = 5.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3132,13 +3142,13 @@
C4975D0828CD190C00FFB4E8 /* Release.Dev */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconEA;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDev;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AppColor;
CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1074;
CURRENT_PROJECT_VERSION = 1079;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
@ -3150,7 +3160,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 5.8;
MARKETING_VERSION = 5.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_NAME = "$(TARGET_NAME) DEV";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -3243,13 +3253,13 @@
C4975D0B28CD193A00FFB4E8 /* Debug.Dev */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconEA;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDev;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AppColor;
CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1074;
CURRENT_PROJECT_VERSION = 1079;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
@ -3261,7 +3271,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.4;
MARKETING_VERSION = 5.8;
MARKETING_VERSION = 5.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -5,15 +5,13 @@
**PHP Monitor** (or *phpmon*) is a lightweight macOS utility app that runs on your Mac and displays the active PHP version in your status bar. It's tightly integrated with [Laravel Valet](https://github.com/laravel/valet), so <u>you need to have it set up before you can use this app</u> (consult the FAQ below with info about how to set up your environment).
<img src="./docs/screenshot.jpg#gh-light-mode-only" width="1280px" alt="phpmon screenshot (menu bar app)"/>
<img src="./docs/screenshot-dark.jpg#gh-dark-mode-only" width="1280px" alt="phpmon screenshot (menu bar app)"/>
<img src="./docs/screenshot.jpg" width="1280px" alt="phpmon screenshot (menu bar app)"/>
<small><i>Screenshot: Showing the key functionality of PHP Monitor.</i></small>
It's super convenient to switch between different versions of PHP. You'll even get notifications (only if you choose to opt-in, of course)!
<img src="./docs/notification.png#gh-light-mode-only" width="370px" alt="phpmon screenshot (notification)"/>
<img src="./docs/notification-dark.png#gh-dark-mode-only" width="370px" alt="phpmon screenshot (notification)"/>
<img src="./docs/notification.png" width="370px" alt="phpmon screenshot (notification)"/>
PHP Monitor also gives you quick access to various useful functionality (like accessing configuration files, restarting services, and more).
@ -43,13 +41,15 @@ valet install
valet trust
```
#### Manual installation (first time only)
#### Manual installation (recommended, first time only)
Once that's done, you can [download the latest release](https://github.com/nicoverbruggen/phpmon/releases/latest), unzip it and place it in `/Applications`.
#### Installation via Homebrew
If you prefer to install the app via Homebrew, you can also do this:
*Prior to version 5.8, this was the recommended way of installing PHP Monitor.*
If you prefer to install the app via Homebrew, you can also run the following:
```sh
brew tap nicoverbruggen/homebrew-cask
@ -58,9 +58,11 @@ brew install --cask phpmon
## ⬆️ How to update
The recommended method of updating your app to the latest version is to use **the built-in updater**.
The recommended method of updating the app to the latest version is to use **the built-in updater**.
If that doesn't work or you prefer Homebrew, you can also upgrade via those methods.
If you have a very slow internet connection, the updater may report that the download has timed out. In that case, you may wish to manually update by [downloading the latest release](https://github.com/nicoverbruggen/phpmon/releases/latest) and placing the app in `/Applications`.
(You may also use Homebrew to update PHP Monitor, but this will require you to approve the app every time an update is installed. If you use the built-in updater, this won't be necessary.)
## ⚡️ Launchers (Alfred, Raycast)
@ -276,6 +278,8 @@ This problem is usually resolved by upgrading Valet and running `valet install`
composer global update
valet install
If you are seeing a 502 (Bad Gateway) error after about 30 seconds or so, your request is likely timing out. You may need to solve a performance issue with your own code.
</details>
<details>

View File

@ -6,9 +6,7 @@ Generally speaking, only the latest version of **PHP Monitor** is supported, exc
| Version | Apple Silicon | Supported | Supported macOS | Deployment Target | Detected PHP Versions | Recommended Valet Version |
| ------- | ------------- | ------------------ | ----- | ----- | ----- | ----
| 5.8 | ✅ Universal binary | ✅ Yes | Monterey (12.4+)<br/>Ventura (13.0+) | macOS 12.4 | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x)<br/>PHP 7.1-PHP 8.2 (w/ Valet 4.x*) | 3.0 or higher recommended<br/> 2.16.2 minimum |
(*) Preliminary listing. Valet 4 hasn't been released yet and the versions of PHP Valet can work with might still change.
| 5.8 | ✅ Universal binary | ✅ Yes | Monterey (12.4+)<br/>Ventura (13.0+) | macOS 12.4 | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x)<br/>PHP 7.1-PHP 8.2 (w/ Valet 4.x) | 3.0 or higher recommended<br/> 2.16.2 minimum |
## Legacy versions
@ -16,8 +14,8 @@ These versions of PHP Monitor are no longer supported, but if youre using an
| Version | Apple Silicon | Supported | Supported macOS | Deployment Target | Detected PHP Versions | Minimum Required Valet Version |
| ------- | ------------- | ------------------ | ----- | ----- | ----- | ----
| 5.7 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0)* | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum |
| 5.6 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0)* | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum |
| 5.7 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0) | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum |
| 5.6 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0) | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum |
| 4.1 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0) | macOS 11+ | PHP 5.6—PHP 8.2 | 2.16.2 |
| 4.0 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0) | macOS 10.14+ | PHP 5.6—PHP 8.2 | 2.13 |
| 3.5 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0) | macOS 10.14+ | PHP 5.6—PHP 8.2 | 2.13 |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 524 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 KiB

After

Width:  |  Height:  |  Size: 627 KiB

View File

@ -1,68 +0,0 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "icon_16x16@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "icon_32x32@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "icon_128x128@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "icon_256x256@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "icon_512x512@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

View File

@ -86,6 +86,11 @@ public class Paths {
return "\(shared.baseDir.rawValue)/etc"
}
public static var caskroomPath: String {
return "\(shared.baseDir.rawValue)/Caskroom/"
+ (App.identifier.contains(".dev") ? "phpmon-dev" : "phpmon")
}
// MARK: - Flexible Binaries
// (these can be in multiple locations, so we scan common places because)
// (PHP Monitor will not use the user's own PATH)

View File

@ -13,6 +13,7 @@ public struct TestableConfiguration: Codable {
var filesystem: [String: FakeFile]
var shellOutput: [String: BatchFakeShellOutput]
var commandOutput: [String: String]
var preferenceOverrides: [PreferenceName: Bool]
func apply() {
Log.separator()
@ -31,6 +32,10 @@ public struct TestableConfiguration: Codable {
ServicesManager.useFake()
Log.info("Applying fake Valet domain interactor...")
ValetInteractor.useFake()
Log.info("Applying temporary preference overrides...")
preferenceOverrides.forEach { (key: PreferenceName, value: Any?) in
Preferences.shared.cachedPreferences[key] = value
}
}
func toJson(pretty: Bool = false) -> String {

View File

@ -14,10 +14,10 @@ class AppUpdater {
var latestVersionOnline: AppVersion!
var interactive: Bool = false
public func checkForUpdates(interactive: Bool) async {
self.interactive = interactive
public func checkForUpdates(userInitiated: Bool) async {
self.interactive = userInitiated
if interactive && !Preferences.isEnabled(.automaticBackgroundUpdateCheck) {
if !interactive && !Preferences.isEnabled(.automaticBackgroundUpdateCheck) {
Log.info("Skipping automatic update check due to user preference.")
return
}
@ -80,6 +80,7 @@ class AppUpdater {
.withPrimary(
text: "updater.alerts.buttons.install".localized,
action: { vc in
self.cleanupCaskroom()
self.prepareForDownload()
vc.close(with: .OK)
}
@ -158,6 +159,20 @@ class AppUpdater {
}
}
private func cleanupCaskroom() {
let path = Paths.caskroomPath
if FileSystem.directoryExists(path) {
Log.info("Removing the Caskroom directory for PHP Monitor...")
do {
try FileSystem.remove(path)
Log.info("Removed the Caskroom directory at `\(path)`.")
} catch {
Log.err("Automatically removing the Caskroom directory at `\(path)` failed.")
}
}
}
// MARK: - Checking if Self-Updater Worked
public static func checkIfUpdateWasPerformed() {
@ -172,7 +187,7 @@ class AppUpdater {
}
Log.info("The `upgrade.success` file was found! An update was installed. Cleaning up...")
try! FileSystem.remove("~/.config/phpmon/updater/upgrade.success")
try? FileSystem.remove("~/.config/phpmon/updater/upgrade.success")
}
// Cleanup the previous updater

View File

@ -15,7 +15,7 @@ class AppVersion: Comparable {
init(version: String, build: String?, suffix: String? = nil) {
self.version = version
self.build = Int(build ?? "0")
self.build = build == nil ? nil : Int(build!)
self.suffix = suffix
}

View File

@ -39,6 +39,9 @@ struct CaskFile {
}
let lines = string.split(separator: "\n")
.map { line in
return line.trimmingCharacters(in: .whitespacesAndNewlines)
}
.filter { $0 != "" }
if lines.count < 4 {

View File

@ -32,6 +32,7 @@ class HomebrewDiagnostics {
*/
public static var customCaskInstalled: Bool = {
return installedTaps.contains("nicoverbruggen/cask")
&& FileSystem.directoryExists(Paths.caskroomPath)
}()
/**

View File

@ -14,14 +14,18 @@ class ValetDomainScanner: DomainScanner {
func resolveSiteCount(paths: [String]) -> Int {
return paths.map { path in
do {
let entries = try FileSystem
.getShallowContentsOfDirectory(path)
let entries = try! FileSystem
.getShallowContentsOfDirectory(path)
return entries
.map { self.isSite($0, forPath: path) }
.filter { $0 == true}
.count
return entries
.map { self.isSite($0, forPath: path) }
.filter { $0 == true}
.count
} catch {
Log.err("Unexpected error getting contents of \(path): \(error).")
return 0
}
}.reduce(0, +)
}
@ -30,13 +34,17 @@ class ValetDomainScanner: DomainScanner {
var sites: [ValetSite] = []
paths.forEach { path in
let entries = try! FileSystem
.getShallowContentsOfDirectory(path)
do {
let entries = try FileSystem
.getShallowContentsOfDirectory(path)
return entries.forEach {
if let site = self.resolveSite(path: "\(path)/\($0)") {
sites.append(site)
return entries.forEach {
if let site = self.resolveSite(path: "\(path)/\($0)") {
sites.append(site)
}
}
} catch {
Log.err("Unexpected error getting contents of \(path): \(error).")
}
}

View File

@ -39,8 +39,8 @@ extension MainMenu {
// Determine install method
Log.info(HomebrewDiagnostics.customCaskInstalled
? "[BREW] The app has probably been installed via Homebrew Cask."
: "[BREW] The app has probably been installed directly."
? "[BREW] The app has been installed via Homebrew Cask."
: "[BREW] The app has been installed directly (optimal)."
)
Log.info(HomebrewDiagnostics.usesNginxFullFormula
@ -111,7 +111,7 @@ extension MainMenu {
OnboardingWindowController.show()
}
} else {
await AppUpdater().checkForUpdates(interactive: false)
await AppUpdater().checkForUpdates(userInitiated: false)
}
}

View File

@ -193,7 +193,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
}
@objc func checkForUpdates() {
Task { await AppUpdater().checkForUpdates(interactive: true) }
Task { await AppUpdater().checkForUpdates(userInitiated: true) }
}
// MARK: - Menu Delegate

View File

@ -48,7 +48,7 @@ class OnboardingWindowController: PMWindowController {
// Search for updates after closing the window
if Stats.successfulLaunchCount == 1 {
Task { await AppUpdater().checkForUpdates(interactive: false) }
Task { await AppUpdater().checkForUpdates(userInitiated: false) }
}
}
}

View File

@ -9,7 +9,7 @@
/**
These are the keys used for every preference in the app.
*/
enum PreferenceName: String {
enum PreferenceName: String, Codable {
// FIRST-TIME LAUNCH
case wasLaunchedBefore = "launched_before"

View File

@ -10,6 +10,22 @@
<string>https://github.com/nicoverbruggen/phpmon</string>
<key>Connections</key>
<array>
<dict>
<key>IsIncoming</key>
<false/>
<key>Host</key>
<string>github.com, api.github.com</string>
<key>NetworkProtocol</key>
<string>TCP</string>
<key>Port</key>
<string>443</string>
<key>Relevance</key>
<string>Essential</string>
<key>Purpose</key>
<string>PHP Monitor directly invokes Homebrew which contacts GitHub. This happens when PHP Monitor asks for more information about the PHP formula to determine which version of PHP you&apos;ve got running.</string>
<key>DenyConsequences</key>
<string>If you deny these connections, PHP Monitor might not be able to complete its preset set of instructions, causing version switching to fail.</string>
</dict>
<dict>
<key>IsIncoming</key>
<false/>
@ -46,15 +62,15 @@
<key>IsIncoming</key>
<false/>
<key>Host</key>
<string>github.com, api.github.com</string>
<string>formulae.brew.sh</string>
<key>NetworkProtocol</key>
<string>TCP</string>
<key>Port</key>
<string>443</string>
<string>80, 443</string>
<key>Relevance</key>
<string>Essential</string>
<key>Purpose</key>
<string>PHP Monitor directly invokes Homebrew which contacts GitHub. This happens when PHP Monitor asks for more information about the PHP formula to determine which version of PHP you&apos;ve got running.</string>
<string>PHP Monitor directly invokes Homebrew which contacts the Homebrew API. This happens when PHP Monitor asks for more information about the PHP formula to determine which version of PHP you&apos;ve got running.</string>
<key>DenyConsequences</key>
<string>If you deny these connections, PHP Monitor might not be able to complete its preset set of instructions, causing version switching to fail.</string>
</dict>

View File

@ -624,8 +624,8 @@ COMMON TROUBLESHOOTING TIPS
"updater.alerts.newer_version_available.title" = "PHP Monitor v%@ is now available!";
"updater.alerts.newer_version_available.subtitle" = "Keeping PHP Monitor up-to-date is highly recommended, since newer versions usually fix bugs and include fixes to support the latest versions of Valet and PHP.";
"updater.installation_source.brew" = "The recommended method of installing updates to PHP Monitor is to simply press 'Install Update'.\n\n(You may also upgrade via the terminal by running `%@`, but this is not recommended.)";
"updater.installation_source.direct" = "The recommended method of installing updates to PHP Monitor is to simply press 'Install Update'.";
"updater.installation_source.brew" = "The recommended method of installing updates to PHP Monitor is to simply press Install Update.\n\nSince you used Homebrew to install the app, you can also upgrade via the terminal by running `%@`, but this is not recommended.\n\n(Please note that installing via this built-in updater will remove PHP Monitor from Homebrew's Caskroom directory, to prevent duplicate updates from being downloaded and causing potential issues later.)";
"updater.installation_source.direct" = "The recommended method of installing updates to PHP Monitor is to simply press Install Update.";
"updater.alerts.buttons.release_notes" = "View Release Notes";
"updater.alerts.is_latest_version.title" = "PHP Monitor is up-to-date!";
@ -661,8 +661,8 @@ COMMON TROUBLESHOOTING TIPS
"warnings.arm_compatibility.title" = "You are running PHP Monitor using Rosetta on Apple Silicon, which means your PHP environment is also running via Rosetta.";
"warnings.arm_compatibility.description" = "You appear to be running an ARM-compatible version of macOS, but you are currently running PHP Monitor using Rosetta. While this will work correctly, it is recommended that you use the native version of Homebrew.";
"warnings.files_missing.title" = "Your PHP installation is lacking required configuration files";
"warnings.files_missing.description" = "The following files normally exist on a functional system:
"warnings.files_missing.title" = "Your PHP installation is missing important required configuration files.";
"warnings.files_missing.description" = "The following key configuration files should exist after installing PHP:
• %@

View File

@ -138,8 +138,22 @@ class TestableConfigurations {
: .instant(ShellStrings.shared.brewServicesAsRoot),
"/opt/homebrew/bin/brew services info --all --json"
: .instant(ShellStrings.shared.brewServicesAsUser),
"curl -s --max-time 5 '\(Constants.Urls.StableBuildCaskFile.absoluteString)' | grep version"
: .instant("version '5.6.2_976'"),
"curl -s --max-time 10 '\(Constants.Urls.DevBuildCaskFile.absoluteString)'"
: .delayed(0.5, """
cask 'phpmon-dev' do
depends_on formula: 'gnu-sed'
version '\(App.shortVersion)_\(App.bundleVersion)'
sha256 '1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a'
url 'https://github.com/nicoverbruggen/phpmon/releases/download/v\(App.shortVersion)/phpmon-dev.zip'
appcast 'https://github.com/nicoverbruggen/phpmon/releases.atom'
name 'PHP Monitor DEV'
homepage 'https://phpmon.app'
app 'PHP Monitor DEV.app', target: "PHP Monitor DEV.app"
end
"""),
"/opt/homebrew/bin/brew unlink php"
: .delayed(0.2, "OK"),
"/opt/homebrew/bin/brew unlink php@8.2"
@ -170,7 +184,8 @@ class TestableConfigurations {
: """
/opt/homebrew/etc/php/8.2/conf.d/php-memory-limits.ini,
"""
]
],
preferenceOverrides: [:]
)
}
}

View File

@ -16,26 +16,14 @@ final class DomainsListTest: UITestCase {
override func tearDownWithError() throws {}
private func openMenu() -> XCPMApplication {
let app = XCPMApplication()
app.withConfiguration(TestableConfigurations.working)
app.launch()
// Note: If this fails here, make sure the menu bar item can be displayed
// If you use Bartender or something like this, this item may be hidden and tests will fail
app.statusItems.firstMatch.click()
return app
}
final func test_can_always_open_domains_list() throws {
let app = openMenu()
let app = launch(openMenu: true)
app.menuItems["mi_domain_list".localized].click()
}
final func test_can_filter_domains_list() throws {
let app = openMenu()
let app = launch(openMenu: true)
app.menuItems["mi_domain_list".localized].click()
@ -58,7 +46,7 @@ final class DomainsListTest: UITestCase {
}
final func test_can_tap_add_domain_button() throws {
let app = openMenu()
let app = launch(openMenu: true)
app.menuItems["mi_domain_list".localized].click()

View File

@ -10,9 +10,33 @@ import XCTest
class UITestCase: XCTestCase {
/** Launches the app and opens the menu. */
public func launch(
openMenu: Bool = false,
with configuration: TestableConfiguration? = nil
) -> XCPMApplication {
let app = XCPMApplication()
let config = configuration ?? TestableConfigurations.working
app.withConfiguration(config)
app.launch()
// Note: If this fails here, make sure the menu bar item can be displayed
// If you use Bartender or something like this, this item may be hidden and tests will fail
if openMenu {
app.statusItems.firstMatch.click()
}
return app
}
/** Checks if a single element exists. */
public func assertExists(_ element: XCUIElement, _ timeout: TimeInterval = 0.05) {
XCTAssert(element.waitForExistence(timeout: timeout))
XCTAssertTrue(element.waitForExistence(timeout: timeout))
}
/** Checks if a single element fails to exist. */
public func assertNotExists(_ element: XCUIElement, _ timeout: TimeInterval = 0.05) {
XCTAssertFalse(element.waitForExistence(timeout: timeout))
}
/** Checks if all elements exist. */

View File

@ -0,0 +1,121 @@
//
// UpdateCheckTest.swift
// UI Tests
//
// Created by Nico Verbruggen on 13/03/2023.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import XCTest
final class UpdateCheckTest: UITestCase {
override func setUpWithError() throws {
continueAfterFailure = false
}
override func tearDownWithError() throws {}
final func test_can_check_for_updates_with_no_new_update() throws {
let app = launch(openMenu: true)
app.menuItems["mi_check_for_updates".localized].click()
assertExists(app.staticTexts["updater.alerts.is_latest_version.title".localized], 1.0)
assertExists(app.buttons["generic.ok".localized])
}
final func test_will_prompt_at_launch_new_version_available() throws {
var configuration = TestableConfigurations.working
// Ensure automatic check is enabled
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = true
// Ensure an update is available
configuration.shellOutput[
"curl -s --max-time 10 '\(Constants.Urls.DevBuildCaskFile.absoluteString)'"
] = .delayed(0.5, """
cask 'phpmon-dev' do
depends_on formula: 'gnu-sed'
version '99.0.0_9999'
sha256 '1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a'
url 'https://github.com/nicoverbruggen/phpmon/releases/download/v99.0/phpmon-dev.zip'
appcast 'https://github.com/nicoverbruggen/phpmon/releases.atom'
name 'PHP Monitor DEV'
homepage 'https://phpmon.app'
app 'PHP Monitor DEV.app', target: "PHP Monitor DEV.app"
end
""")
let app = launch(openMenu: false, with: configuration)
// Expect to see the content of the appropriate alert box
assertExists(app.staticTexts["updater.alerts.newer_version_available.title".localized("99.0.0 (9999)")], 2)
assertExists(app.buttons["updater.alerts.buttons.install".localized])
assertExists(app.buttons["updater.alerts.buttons.dismiss".localized])
}
final func test_will_require_manual_search_for_update() throws {
var configuration = TestableConfigurations.working
// Ensure automatic check is disabled
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = false
// Ensure an update is available
configuration.shellOutput[
"curl -s --max-time 10 '\(Constants.Urls.DevBuildCaskFile.absoluteString)'"
] = .delayed(0.5, """
cask 'phpmon-dev' do
depends_on formula: 'gnu-sed'
version '99.0.0_9999'
sha256 '1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a'
url 'https://github.com/nicoverbruggen/phpmon/releases/download/v99.0/phpmon-dev.zip'
appcast 'https://github.com/nicoverbruggen/phpmon/releases.atom'
name 'PHP Monitor DEV'
homepage 'https://phpmon.app'
app 'PHP Monitor DEV.app', target: "PHP Monitor DEV.app"
end
""")
// Wait for the menu to open and search for updates
let app = launch(openMenu: false, with: configuration)
// The check should not happen if the preference is disabled
assertNotExists(app.staticTexts["updater.alerts.newer_version_available.title".localized("99.0.0 (9999)")], 2)
// Open the menu and check manually
app.statusItems.firstMatch.click()
app.menuItems["mi_check_for_updates".localized].click()
// Expect to see the content of the appropriate alert box
assertExists(app.staticTexts["updater.alerts.newer_version_available.title".localized("99.0.0 (9999)")], 2)
assertExists(app.buttons["updater.alerts.buttons.install".localized])
assertExists(app.buttons["updater.alerts.buttons.dismiss".localized])
}
final func test_could_not_parse_version() throws {
var configuration = TestableConfigurations.working
// Ensure automatic check is disabled
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = false
// Ensure an update is available
configuration.shellOutput[
"curl -s --max-time 10 '\(Constants.Urls.DevBuildCaskFile.absoluteString)'"
] = .delayed(0.5, "404 PAGE NOT FOUND")
// Wait for the menu to open and search for updates
let app = launch(openMenu: true, with: configuration)
app.menuItems["mi_check_for_updates".localized].click()
// Expect to see the content of the appropriate alert box
assertExists(app.staticTexts["updater.alerts.cannot_check_for_update.title".localized], 2)
assertExists(app.buttons["generic.ok".localized])
assertExists(app.buttons["updater.alerts.buttons.releases_on_github".localized])
}
}

View File

@ -37,10 +37,4 @@ class ValetVersionExtractorTest: XCTestCase {
XCTAssertEqual(version.major, 3)
}
func test_can_determine_valet_version() async {
let version = await valet("--version", sudo: false)
XCTAssert(version.contains("Laravel Valet 2") || version.contains("Laravel Valet 3"))
}
}