Skip to content

Commit

Permalink
🚀 Version 5.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoverbruggen committed Jan 30, 2023
2 parents 2f658ee + 2eda8d6 commit 4568f03
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ If applicable, add screenshots to help explain your problem.
- OS: [e.g. macOS Monterey]
- PHP Monitor version [e.g. v5.0.1]

**Additional log**
You can help me figure out even more information by sending me your verbose log for your latest session of PHP Monitor. Logging is disabled by default.

You can start extra verbose logging by running: `touch ~/.config/phpmon/verbose` and restarting PHP Monitor. You can find the latest log in: `~/.config/phpmon/last_session.log`. Please attach it here!

**Additional context**
Add any other context about the problem here.
16 changes: 8 additions & 8 deletions PHP Monitor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2831,7 +2831,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1031;
CURRENT_PROJECT_VERSION = 1035;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -2843,7 +2843,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 5.7.1;
MARKETING_VERSION = 5.7.2;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -2860,7 +2860,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1031;
CURRENT_PROJECT_VERSION = 1035;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
Expand All @@ -2872,7 +2872,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 5.7.1;
MARKETING_VERSION = 5.7.2;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -3088,7 +3088,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1031;
CURRENT_PROJECT_VERSION = 1035;
DEBUG = NO;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -3099,7 +3099,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 5.7.1;
MARKETING_VERSION = 5.7.2;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_NAME = "$(TARGET_NAME) DEV";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -3198,7 +3198,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1031;
CURRENT_PROJECT_VERSION = 1035;
DEBUG = YES;
DEVELOPMENT_TEAM = 8M54J5J787;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -3209,7 +3209,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 5.7.1;
MARKETING_VERSION = 5.7.2;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
argument = "--v"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--cli"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--configuration:~/.phpmon_fconf_working.json"
isEnabled = "NO">
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ If you would like to report a crash, please include the associated **log files**

To find the logs, take a look in `~/Library/Logs/DiagnosticReports` (in Finder) and see if there's any (log) files that start with "PHP Monitor".

Additionally, you can help me figure out even more information by sending me your verbose log for your latest session of PHP Monitor. Logging is disabled by default.

You can start extra verbose logging by running: `touch ~/.config/phpmon/verbose` and restarting PHP Monitor. You can find the latest log in: `~/.config/phpmon/last_session.log`. Please attach it to the relevant bug report.

</details>

## 📝 Having another issue?
Expand Down
43 changes: 36 additions & 7 deletions phpmon/Common/Core/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,76 @@ class Log {

static var shared = Log()

var logFilePath = "~/.config/phpmon/last_session.log"
var logExists = false

enum Verbosity: Int {
case error = 1,
warning = 2,
info = 3,
performance = 4
performance = 4,
cli = 5

public func isApplicable() -> Bool {
return Log.shared.verbosity.rawValue >= self.rawValue
}
}

var verbosity: Verbosity = .warning
public func prepareLogFile() {
if !isRunningTests && Verbosity.cli.isApplicable() {
_ = system("mkdir -p ~/.config/phpmon 2> /dev/null")
_ = system("rm ~/.config/phpmon/last_session.log 2> /dev/null")
_ = system("touch ~/.config/phpmon/last_session.log 2> /dev/null")
self.logExists = FileSystem.fileExists(self.logFilePath)
}
}

var verbosity: Verbosity = .warning {
didSet {
self.prepareLogFile()
}
}

static func err(_ item: Any) {
if Verbosity.error.isApplicable() {
print("[E] \(item)")
Log.shared.log("[E] \(item)")
}
}

static func warn(_ item: Any) {
if Verbosity.warning.isApplicable() {
print("[W] \(item)")
Log.shared.log("[W] \(item)")
}
}

static func info(_ item: Any) {
if Verbosity.info.isApplicable() {
print("\(item)")
Log.shared.log("\(item)")
}
}

static func perf(_ item: Any) {
if Verbosity.performance.isApplicable() {
print("[P] \(item)")
Log.shared.log("[P] \(item)")
}
}

static func separator(as verbosity: Verbosity = .info) {
if verbosity.isApplicable() {
print("==================================")
Log.shared.log("==================================")
}
}

private func log(_ text: String) {
print(text)

if logExists && Verbosity.cli.isApplicable() {
let logFile = URL(string: self.logFilePath.replacingTildeWithHomeDirectory)!
if let fileHandle = try? FileHandle(forWritingTo: logFile) {
fileHandle.seekToEndOfFile()
fileHandle.write(text.appending("\n").data(using: .utf8).unsafelyUnwrapped)
fileHandle.closeFile()
}
}
}
}
1 change: 0 additions & 1 deletion phpmon/Common/Helpers/VersionExtractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ class VersionExtractor {
return nil
}
}

}
30 changes: 30 additions & 0 deletions phpmon/Common/Shell/RealShell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class RealShell: ShellProtocol {
let task = Process()
task.launchPath = self.launchPath
task.arguments = ["--noprofile", "-norc", "--login", "-c", completeCommand]

return task
}

Expand Down Expand Up @@ -113,6 +114,35 @@ class RealShell: ShellProtocol {
encoding: .utf8
)!

if Log.shared.verbosity == .cli {
var args = task.arguments
let last: String = "\"" + (args?.popLast() ?? "") + "\""
let concat = [self.launchPath] + task.arguments! + [last]
let command = concat.joined(separator: " ")
var log = """
<~~~~~~~~~~~~~~~~~~~~~~~
$ \(command)
[OUT]:
\(stdOut)
"""

if !stdErr.isEmpty {
log.append("""
[ERR]:
\(stdErr)
""")
}

log.append("""
~~~~~~~~~~~~~~~~~~~~~~~~>
""")

Log.info(log)
}

return .out(stdOut, stdErr)
}

Expand Down
13 changes: 11 additions & 2 deletions phpmon/Domain/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
When the application initializes, create all singletons.
*/
override init() {
logger.verbosity = .info

#if DEBUG
logger.verbosity = .performance

if let profile = CommandLine.arguments.first(where: { $0.matches(pattern: "--configuration:*") }) {
Self.initializeTestingProfile(profile.replacingOccurrences(of: "--configuration:", with: ""))
}
Expand All @@ -70,6 +69,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
Log.info("Extra verbose mode has been activated.")
}

if CommandLine.arguments.contains("--cli") {
logger.verbosity = .cli
Log.info("Extra CLI mode has been activated via --cli flag.")
}

if FileSystem.fileExists("~/.config/phpmon/verbose") {
logger.verbosity = .cli
Log.info("Extra CLI mode is on (`~/.config/phpmon/verbose` exists).")
}

Log.separator(as: .info)
Log.info("PHP MONITOR by Nico Verbruggen")
Log.info("Version \(App.version)")
Expand Down
2 changes: 1 addition & 1 deletion phpmon/Domain/App/Startup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Startup {
.components(separatedBy: "Laravel Valet")[1]
.trimmingCharacters(in: .whitespaces)
// Extract the version number
Valet.shared.version = try! VersionNumber.parse(VersionExtractor.from(output)!)
Valet.shared.version = try! VersionNumber.parse(VersionExtractor.from(versionString)!)
// Get the actual version
return Valet.shared.version == nil
},
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/Versions/ValetVersionExtractorTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,34 @@ import XCTest

class ValetVersionExtractorTest: XCTestCase {

func test_can_determine_valet_version_regardless_of_deprecations() async {
let output = """
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1789
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1800
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1812
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1827
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::count() should either be compatible with Countable::count(): int, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1768
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1747
Deprecated: Return type of Tightenco\\Collect\\Support\\Collection::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/dummy/.composer/vendor/tightenco/collect/src/Collect/Support/Collection.php on line 1716
Laravel Valet 3.3.0
"""

let versionString = output
.trimmingCharacters(in: .whitespacesAndNewlines)
.components(separatedBy: "Laravel Valet")[1]
.trimmingCharacters(in: .whitespaces)

let version = try! VersionNumber.parse(VersionExtractor.from(versionString)!)

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"))
Expand Down

0 comments on commit 4568f03

Please sign in to comment.