Skip to content

Commit

Permalink
🚀 Version 5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoverbruggen committed Jul 8, 2022
2 parents 1066bdc + 2fc7130 commit 58fd045
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 9 deletions.
8 changes: 4 additions & 4 deletions PHP Monitor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 911;
CURRENT_PROJECT_VERSION = 912;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1603,7 +1603,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 5.4;
MARKETING_VERSION = 5.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1620,7 +1620,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 911;
CURRENT_PROJECT_VERSION = 912;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1630,7 +1630,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 5.4;
MARKETING_VERSION = 5.4.1;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ Super convenient!
<details>
<summary><strong>I want to set up PHP Monitor from scratch! I don't have Homebrew installed either, where do I begin?</strong></summary>

If you want to set up your computer for the very first time with PHP Monitor, here's how I do it:
If you want to set up your computer for the very first time with PHP Monitor, here's how I do it.

**I have also created [a video tutorial](https://www.youtube.com/watch?v=fO3hVhkvm3w) which may be easier to follow. If you just want the terminal commands, keep reading.**

Install [Homebrew](https://brew.sh) first. Follow the instructions there first!

Expand Down Expand Up @@ -146,6 +148,26 @@ Make sure PHP is linked correctly:
should return: `/usr/local/bin/php` (or `/opt/homebrew/bin/php` if you are on Apple Silicon)

composer global require laravel/valet

For optimal results, you should lock your PHP platform for global dependencies to the oldest version of PHP you intend to run. If that version is PHP 7.0, your `~/.composer/composer.json` file could look like this (please adjust the version accordingly!):

```
{
"require": {
"laravel/valet": "^3.0",
},
"config": {
"platform": {
"php": "7.0"
}
}
}
```

Run `composer global update` again. This ensures that when you switch to a different global PHP version, [Valet won't break](https://github.com/nicoverbruggen/phpmon/issues/178). If it does, PHP Monitor will let you know what you can do about this.

Then, install Valet:

valet install

This should install `dnsmasq` and set up Valet. Great, almost there!
Expand Down
14 changes: 14 additions & 0 deletions phpmon/Common/Extensions/NSWindowExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import Cocoa

extension NSWindow {

/**
Centers a window. Taken from: https://stackoverflow.com/a/66140320
*/
public func setCenterPosition(offsetY: CGFloat = 0) {
if let screenSize = screen?.visibleFrame.size {
self.setFrameOrigin(
NSPoint(
x: (screenSize.width - frame.size.width) / 2,
y: (screenSize.height - frame.size.height) / 2 + offsetY
)
)
}
}

/**
Shakes a window. Inspired by: http://blog.ericd.net/2016/09/30/shaking-a-macos-window/
*/
Expand Down
18 changes: 16 additions & 2 deletions phpmon/Domain/App/Startup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,26 @@ class Startup {
descriptionText: "startup.errors.which_alias_issue.desc".localized
),
// =================================================================================
// Determine that Valet works correctly (no issues in platform detected)
// =================================================================================
EnvironmentCheck(
command: {
return valet("--version", sudo: false)
.contains("Composer detected issues in your platform")
},
name: "`no global composer issues",
titleText: "startup.errors.global_composer_platform_issues.title".localized,
subtitleText: "startup.errors.global_composer_platform_issues.subtitle".localized,
descriptionText: "startup.errors.global_composer_platform_issues.desc".localized
),
// =================================================================================
// Determine the Valet version and ensure it isn't unknown.
// =================================================================================
EnvironmentCheck(
command: {
Valet.shared.version = VersionExtractor.from(valet("--version", sudo: false))
return Valet.shared.version == nil
let output = valet("--version", sudo: false)
Valet.shared.version = VersionExtractor.from(output)
return Valet.shared.version == nil && output.contains("Laravel Valet")
},
name: "`valet --version` was loaded",
titleText: "startup.errors.valet_version_unknown.title".localized,
Expand Down
5 changes: 5 additions & 0 deletions phpmon/Domain/Integrations/Valet/Valet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ class Valet {
}
}

public func hasPlatformIssues() -> Bool {
return valet("--version", sudo: false)
.contains("Composer detected issues in your platform")
}

/**
Returns a count of how many sites are linked and parked.
*/
Expand Down
37 changes: 36 additions & 1 deletion phpmon/Domain/Menu/MainMenu+Switcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,26 @@ extension MainMenu {
self.notifyAboutVersionChange(to: version)
}
)

} else {
self.notifyAboutVersionChange(to: version)
}

// Check if Valet still works correctly
self.checkForPlatformIssues()

// Update stats
Stats.incrementSuccessfulSwitchCount()
Stats.evaluateSponsorMessageShouldBeDisplayed()
}
}

private func checkForPlatformIssues() {
if Valet.shared.hasPlatformIssues() {
Log.info("Composer platform issue(s) detected.")
self.suggestFixMyComposer()
}
}

private func suggestFixMyValet(failed version: String) {
let outcome = BetterAlert()
.withInformation(
Expand All @@ -65,6 +74,32 @@ extension MainMenu {
}
}

private func suggestFixMyComposer() {
BetterAlert().withInformation(
title: "alert.global_composer_platform_issues.title".localized,
subtitle: "alert.global_composer_platform_issues.subtitle".localized,
description: "alert.global_composer_platform_issues.desc".localized
)
.withPrimary(text: "alert.global_composer_platform_issues.buttons.update".localized, action: { alert in
alert.close(with: .OK)
Log.info("The user has chosen to update global dependencies.")
ComposerWindow().updateGlobalDependencies(
notify: true,
completion: { success in
Log.info("Dependencies updated successfully: \(success)")
Log.info("Re-checking for platform issue(s)...")
self.checkForPlatformIssues()
}
)
})
.withSecondary(text: "", action: nil)
.withTertiary(text: "alert.global_composer_platform_issues.buttons.quit".localized, action: { alert in
alert.close(with: .OK)
self.terminateApp()
})
.show()
}

private func reloadDomainListData() {
if let window = App.shared.domainListWindowController {
DispatchQueue.main.async {
Expand Down
1 change: 1 addition & 0 deletions phpmon/Domain/Notice/BetterAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class BetterAlert {

NSApp.activate(ignoringOtherApps: true)
windowController.window?.makeKeyAndOrderFront(nil)
windowController.window?.setCenterPosition(offsetY: 70)
return NSApplication.shared.runModal(for: windowController.window!)
}

Expand Down
14 changes: 13 additions & 1 deletion phpmon/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"prefs.notify_about_secure_status_desc" = "Displays a notification when a domain has been secured or unsecured.";
"prefs.notify_about_secure_status" = "Notify about secure/unsecure status";

"prefs.notify_about_composer_success_desc" = "Displays a notification when the global composer configuration was successfully updated.";
"prefs.notify_about_composer_success_desc" = "Displays a notification when the global Composer configuration was successfully updated.";
"prefs.notify_about_composer_success" = "Notify about global composer update";

// NOTIFICATIONS
Expand Down Expand Up @@ -388,6 +388,13 @@ You can do this by running `composer global update` in your terminal. After that
"alert.php_switch_unavailable.info" = "Please make sure PHP %@ is installed and you can switch to it in the dropdown. Currently supported versions include PHP: %@.";
"alert.php_switch_unavailable.ok" = "OK";

// Composer issues
"alert.global_composer_platform_issues.title" = "Composer detected issues in your platform";
"alert.global_composer_platform_issues.subtitle" = "The version of PHP you switched to is too old for the global Composer dependencies you have installed. These dependencies will need to be updated.";
"alert.global_composer_platform_issues.desc" = "The easiest way to prevent this issue from occurring in the future is to switch to the oldest PHP version you have installed and to run `composer global update` again. \n\nAlternatively, you can choose the 'Automatically update global dependencies' option in Preferences to avoid this issue as well.\n\nIf you keep seeing this message even after attempting to update those global dependencies, you may wish to look at your global composer configuration file, located in `~/.composer/composer.json`.";
"alert.global_composer_platform_issues.buttons.update" = "Update Global Dependencies";
"alert.global_composer_platform_issues.buttons.quit" = "Quit PHP Monitor";

// Revert
"alert.revert_description.title" = "Revert Configuration?";
"alert.revert_description.subtitle" = "PHP Monitor can revert to the previous configuration that was active. Here's what will be applied: \n\n%@";
Expand Down Expand Up @@ -438,6 +445,11 @@ You can do this by running `composer global update` in your terminal. After that
"startup.errors.sudoers_valet.subtitle" = "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue. If you did this before, please run `sudo valet trust` again.";
"startup.errors.sudoers_valet.desc" = "If you keep seeing this error, it is possible that there is a permission issue where PHP Monitor cannot validate the file, which can usually be resolved by running: `sudo chmod +r /private/etc/sudoers.d/valet`";

/// Platform issue detected
"startup.errors.global_composer_platform_issues.title" = "PHP Monitor and Valet cannot work correctly: Composer is reporting an issue with your platform";
"startup.errors.global_composer_platform_issues.subtitle" = "Please follow these recommended steps to avoid seeing this issue in the future:\n\n1. Run `composer global update`.\n2. Restart PHP Monitor. (It should work again.)\n3. Switch to the oldest PHP version you have installed.\n4. Run `composer global update` again.";
"startup.errors.global_composer_platform_issues.desc" = "You can go to Preferences and check the 'Automatically update global dependencies' option. This will update your global Composer dependencies whenever you change PHP versions, so this may not be ideal if you may not have constant access to the internet.\n\nTo find out exactly what's going wrong, try running `valet --version`. Valet is currently not functional with the installed dependencies. Usually this is caused by a version mismatch: i.e. installed dependencies for a newer version of PHP than the version that is currently active.";

/// Cannot retrieve services
"startup.errors.services_json_error.title" = "Cannot determine services status";
"startup.errors.services_json_error.subtitle" = "PHP Monitor usually queries `brew` using the following command to test if the services can be retrieved: `sudo brew services info nginx --json`.\n\nPHP Monitor could not interpret this response.";
Expand Down

0 comments on commit 58fd045

Please sign in to comment.