-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
1,128 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// LoginItemManager.swift | ||
// PHP Monitor | ||
// | ||
// Created by Nico Verbruggen on 15/02/2023. | ||
// Copyright © 2023 Nico Verbruggen. All rights reserved. | ||
// | ||
|
||
import AppKit | ||
import ServiceManagement | ||
|
||
@available(macOS 13.0, *) | ||
class LoginItemManager { | ||
func loginItemIsEnabled() -> Bool { | ||
return SMAppService.mainApp.status == .enabled | ||
} | ||
|
||
func disableLoginItem() { | ||
try? SMAppService.mainApp.unregister() | ||
} | ||
|
||
func enableLoginItem() { | ||
try? SMAppService.mainApp.register() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ public struct PhpVersionNumberCollection: Equatable { | |
- Parameter strict: Whether the patch version check is strict. See more below. | ||
|
||
The strict mode does not matter if a patch version is provided for all versions in the collection. | ||
It also does not matter for certain comparisons (e.g. when dealing with wildcards). | ||
|
||
Strict mode assumes that any PHP version lacking precise patch information, e.g. inferred | ||
from Homebrew corresponds to the .0 patch version of that version. The default, which is imprecise, | ||
|
@@ -45,18 +46,34 @@ public struct PhpVersionNumberCollection: Equatable { | |
|
||
Given versions 8.0.? and 8.1.?, but the requirement is ^8.0.1, in strict mode only 8.1.? will | ||
be considered valid (8.0 translates to 8.0.0 and as such is older than 8.0.1, 8.1.0 is OK). | ||
|
||
When checking against actual PHP versions installed by the user (with patch precision), use | ||
strict mode. | ||
|
||
**NON-STRICT MODE (= patch precision off)** | ||
|
||
Given versions 8.0.? and 8.1.?, but the requirement is ^8.0.1, in non-strict mode version 8.0 | ||
is assumed to be equal to version 8.0.999, which is actually fine if 8.0.1 is the required version. | ||
|
||
In non-strict mode, the patch version is ignored for regular version checks (no caret / tilde). | ||
If checking compatibility with general Homebrew versions of PHP, do NOT use strict mode, since | ||
the patch version there is not used. (The formula [email protected] suffices for ^8.0.1.) | ||
*/ | ||
public func matching(constraint: String, strict: Bool = false) -> [VersionNumber] { | ||
if constraint == "*" { | ||
return self.versions | ||
} | ||
|
||
if let version = VersionNumber.make(from: constraint, type: .wildCardPatch) { | ||
// Wildcard for patch (e.g. "7.4.*") must match major and minor (any patch) | ||
return self.versions.filter { $0.hasSameMajorAndMinor(version) } | ||
} | ||
|
||
if let version = VersionNumber.make(from: constraint, type: .wildCardMinor) { | ||
// Strict constraint (e.g. "7.*") -> must only match major (any patch, minor) | ||
return self.versions.filter { $0.isSameMajorVersionAs(version) } | ||
} | ||
|
||
if let version = VersionNumber.make(from: constraint, type: .versionOnly) { | ||
// Strict constraint (e.g. "7.0") -> returns specific version | ||
return self.versions.filter { $0.isSameAs(version, strict) } | ||
|
Oops, something went wrong.