From a4dcd0cd3d7d9445e94ddab9a76880a6c3593124 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Tue, 15 Oct 2019 10:39:42 +0200 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=93=9D=20Update=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 25c9983..36e0abd 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,16 @@ For me, it comes in handy when running multiple versions of PHP with Homebrew an ## System requirements -Minimal system requirements are: +**Minimal system requirements** * macOS 10.14 or higher * PHP 7.3 installed via Homebrew * Laravel Valet 2.3 or higher installed -## Recommended setup - -This means that this configuration is recommended and supported: +**Recommended system** * macOS 10.15 Catalina -* PHP 7.3.x installed with Homebrew 2 +* PHP 7.3 installed with Homebrew 2.x - other versions of PHP are optional - includes support for PHP 5.6 and PHP 7.0 [as well](https://github.com/eXolnet/homebrew-deprecated) * Laravel Valet 2.5.x installed @@ -58,3 +56,27 @@ The utility runs the following commands: If you want to know more about how this works, I recommend you check out the source code. This app isn't very complicated after all. In the end, this just (conveniently) executes some shell commands. + +## Troubleshooting + +### Reasons for alerts at startup + +PHP Monitor performs some integrity checks to ensure a good experience when using the app. You'll get a message telling you that PHP Monitor won't work correctly in the following scenarios: + +- The PHP binary is not located in `/usr/local/bin/php` +- PHP 7.3 is missing in `/usr/local/opt` +- Laravel Valet is missing in `/usr/local/bin/valet` +- Brew has not been added to sudoers in `/private/etc/sudoers.d/brew` +- Valet has not been added to sudoers in `/private/etc/sudoers.d/valet` + +Follow instructions as specified in the alert in order to resolve any issues. + +### Still seeing another PHP version (from before switching versions)? + +If you're still seeing an old version of PHP in your scripts — e.g. when running `phpinfo()` — I recommend you shut down the PHP service by running: + + sudo brew services stop php + +Please note that PHP Monitor will not be able to stop this service (it doesn't run as an administrator), so you'll need to handle this yourself. + +You should only have to do this **once**, and then PHP Monitor should work as usual. From 3e898d435bc912a98390ef3516ce52af27d4d0b1 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 17 Oct 2019 19:04:49 +0200 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=9A=A7=20WIP:=20Add=20toggle=20to=20e?= =?UTF-8?q?nable=20or=20disable=20Xdebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 14 +++++-- phpmon/Classes/Commands/Actions.swift | 31 ++++++++++++++- phpmon/Classes/Helpers/PhpVersion.swift | 10 +++++ phpmon/Info.plist | 2 +- phpmon/Singletons/Command.swift | 50 +++++++++++++++++++++++++ phpmon/Singletons/MainMenu.swift | 37 +++++++++++++++++- phpmon/Singletons/Shell.swift | 12 ++++-- 7 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 phpmon/Singletons/Command.swift diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 43876ce..3f14729 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */; }; C41C1B4B22B019FF00E7CF16 /* PhpVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4A22B019FF00E7CF16 /* PhpVersion.swift */; }; C41C1B4D22B0215A00E7CF16 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4C22B0215A00E7CF16 /* Actions.swift */; }; + C42295DD2358D02000E263B2 /* Command.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42295DC2358D02000E263B2 /* Command.swift */; }; C476FF9822B0DD830098105B /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C476FF9722B0DD830098105B /* Alert.swift */; }; C4811D2422D70A4700B5F6B3 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4811D2322D70A4700B5F6B3 /* App.swift */; }; C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */; }; @@ -35,6 +36,7 @@ C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarImageGenerator.swift; sourceTree = ""; }; C41C1B4A22B019FF00E7CF16 /* PhpVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpVersion.swift; sourceTree = ""; }; C41C1B4C22B0215A00E7CF16 /* Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Actions.swift; sourceTree = ""; }; + C42295DC2358D02000E263B2 /* Command.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Command.swift; sourceTree = ""; }; C476FF9722B0DD830098105B /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = ""; }; C4811D2322D70A4700B5F6B3 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = ""; }; @@ -112,6 +114,7 @@ C41C1B4622B009A400E7CF16 /* Shell.swift */, C4811D2322D70A4700B5F6B3 /* App.swift */, C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */, + C42295DC2358D02000E263B2 /* Command.swift */, ); path = Singletons; sourceTree = ""; @@ -170,7 +173,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1020; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1110; ORGANIZATIONNAME = "Nico Verbruggen"; TargetAttributes = { C41C1B3222B0097F00E7CF16 = { @@ -217,6 +220,7 @@ C4F8C0A422D4F12C002EFE61 /* DateExtension.swift in Sources */, C41C1B4722B009A400E7CF16 /* Shell.swift in Sources */, C41C1B4D22B0215A00E7CF16 /* Actions.swift in Sources */, + C42295DD2358D02000E263B2 /* Command.swift in Sources */, C4811D2422D70A4700B5F6B3 /* App.swift in Sources */, C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */, C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */, @@ -362,15 +366,17 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 12; + CURRENT_PROJECT_VERSION = 15; DEVELOPMENT_TEAM = 8M54J5J787; INFOPLIST_FILE = phpmon/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MARKETING_VERSION = 1.5; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -382,15 +388,17 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 12; + CURRENT_PROJECT_VERSION = 15; DEVELOPMENT_TEAM = 8M54J5J787; INFOPLIST_FILE = phpmon/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MARKETING_VERSION = 1.5; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/phpmon/Classes/Commands/Actions.swift b/phpmon/Classes/Commands/Actions.swift index bcc2a62..87e54b4 100644 --- a/phpmon/Classes/Commands/Actions.swift +++ b/phpmon/Classes/Commands/Actions.swift @@ -42,6 +42,35 @@ class Actions { public static func openPhpConfigFolder(version: String) { let files = [NSURL(fileURLWithPath: "/usr/local/etc/php/\(version)/php.ini")]; - NSWorkspace.shared.activateFileViewerSelecting(files as [URL]); + NSWorkspace.shared.activateFileViewerSelecting(files as [URL]) + } + + public static func XdebugFound(_ version: String) -> Bool { + let command = """ + grep -q 'zend_extension="xdebug.so"' /usr/local/etc/php/\(version)/php.ini; [ $? -eq 0 ] && echo "YES" || echo "NO" + """ + let output = Shell.user.pipe(command).trimmingCharacters(in: .whitespacesAndNewlines) + return (output == "YES") + } + + public static func XdebugEnabled(_ version: String) -> Bool { + let command = """ + grep -q '; zend_extension="xdebug.so"' /usr/local/etc/php/\(version)/php.ini; [ $? -eq 0 ] && echo "YES" || echo "NO" + """ + let output = Shell.user.pipe(command).trimmingCharacters(in: .whitespacesAndNewlines) + return (output == "NO") + } + + public static func toggleXdebug() { + let version = App.shared.currentVersion?.short + var command = """ + sed -i '' 's/; zend_extension="xdebug.so"/zend_extension="xdebug.so"/g' /usr/local/etc/php/\(version!)/php.ini + """ + if (self.XdebugEnabled(version!)) { + command = """ + sed -i '' 's/zend_extension="xdebug.so"/; zend_extension="xdebug.so"/g' /usr/local/etc/php/\(version!)/php.ini + """ + } + Shell.user.run(command) } } diff --git a/phpmon/Classes/Helpers/PhpVersion.swift b/phpmon/Classes/Helpers/PhpVersion.swift index 3ecda9c..bd42ca9 100644 --- a/phpmon/Classes/Helpers/PhpVersion.swift +++ b/phpmon/Classes/Helpers/PhpVersion.swift @@ -13,6 +13,9 @@ class PhpVersion { var short : String = "???" var long : String = "???" + var xdebugFound: Bool = false + var xdebugEnabled : Bool = false + init() { let version = Shell.user // Get the version directly from PHP @@ -23,7 +26,14 @@ class PhpVersion { // Next up, let's strip away the minor version number let segments = long.components(separatedBy: ".") + // Get the first two elements self.short = segments[0...1].joined(separator: ".") + + // Load xdebug support + self.xdebugFound = Actions.XdebugFound(self.short) + if (self.xdebugFound) { + self.xdebugEnabled = Actions.XdebugEnabled(self.short) + } } } diff --git a/phpmon/Info.plist b/phpmon/Info.plist index e505c2a..556ab4e 100644 --- a/phpmon/Info.plist +++ b/phpmon/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) LSApplicationCategoryType diff --git a/phpmon/Singletons/Command.swift b/phpmon/Singletons/Command.swift new file mode 100644 index 0000000..7c1e4d6 --- /dev/null +++ b/phpmon/Singletons/Command.swift @@ -0,0 +1,50 @@ +// +// Command.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 17/10/2019. +// Copyright © 2019 Nico Verbruggen. All rights reserved. +// + +import Cocoa + +class Command { + + public static func execute(path: String, arguments: [String]) -> String { + let task = Process() + task.launchPath = path + task.arguments = arguments + + let pipe = Pipe() + task.standardOutput = pipe + task.launch() + + let data = pipe.fileHandleForReading.readDataToEndOfFile() + let output: String = String.init(data: data, encoding: String.Encoding.utf8)! + return output; + } + + public static func experiment() { + /* + print("Running '/usr/local/bin/php -v' directly...") + print("========================================") + var start = DispatchTime.now() + print(Command.execute(path: "/usr/local/bin/php", arguments: ["-v"])) + var end = DispatchTime.now() + var nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds + var timeInterval = Double(nanoTime) / 1_000_000_000 + print("Time to run command directly: \(timeInterval) seconds") + + print("") + print("Running 'bash -> php -v'...") + print("========================================") + start = DispatchTime.now() + print(Shell.user.pipe("php -v")) + end = DispatchTime.now() + nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds + timeInterval = Double(nanoTime) / 1_000_000_000 + print("Time to run command via bash: \(timeInterval) seconds") + */ + } + +} diff --git a/phpmon/Singletons/MainMenu.swift b/phpmon/Singletons/MainMenu.swift index c5f933b..631ef14 100644 --- a/phpmon/Singletons/MainMenu.swift +++ b/phpmon/Singletons/MainMenu.swift @@ -63,9 +63,29 @@ class MainMenu: NSObject, NSWindowDelegate { menu.addItem(NSMenuItem.separator()) } if (App.shared.currentVersion != nil) { - menu.addItem(NSMenuItem(title: "PHP configuration file (php.ini)", action: #selector(self.openActiveConfigFolder), keyEquivalent: "")) + menu.addItem(NSMenuItem(title: "PHP configuration file (php.ini)", action: #selector(self.openActiveConfigFolder), keyEquivalent: "c")) + let xdebugFound = App.shared.currentVersion!.xdebugFound + if (xdebugFound) { + let xdebugOn = App.shared.currentVersion!.xdebugEnabled + let xdebugToggleMenuItem = NSMenuItem( + title: "Xdebug", + action: #selector(self.toggleXdebug), keyEquivalent: "x" + ) + if (xdebugOn) { + xdebugToggleMenuItem.state = .on + } + menu.addItem(xdebugToggleMenuItem) + } else { + let disabledItem = NSMenuItem( + title: "xdebug.so missing", + action: nil, keyEquivalent: "x" + ) + disabledItem.isEnabled = false + menu.addItem(disabledItem) + } } - menu.addItem(NSMenuItem(title: "View shell output", action: #selector(self.openOutput), keyEquivalent: "")) + menu.addItem(NSMenuItem.separator()) + menu.addItem(NSMenuItem(title: "View shell output...", action: #selector(self.openOutput), keyEquivalent: "o")) menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem(title: "About PHP Monitor", action: #selector(self.openAbout), keyEquivalent: "")) menu.items.forEach({ (item) in @@ -147,6 +167,19 @@ class MainMenu: NSObject, NSWindowDelegate { } } + @objc public func toggleXdebug() { + DispatchQueue.global(qos: .userInitiated).async { [unowned self] in + DispatchQueue.main.async { + self.setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!) + } + Actions.toggleXdebug() + DispatchQueue.main.async { + self.updatePhpVersionInStatusBar() + self.update() + } + } + } + func windowWillClose(_ notification: Notification) { App.shared.windowController = nil Shell.user.delegate = nil diff --git a/phpmon/Singletons/Shell.swift b/phpmon/Singletons/Shell.swift index 204be91..5db6269 100644 --- a/phpmon/Singletons/Shell.swift +++ b/phpmon/Singletons/Shell.swift @@ -60,11 +60,15 @@ class Shell { ) as String let historyItem = ShellHistoryItem(command: command, output: output) - history.append(historyItem) - // Keep the last 100 items - history = history.suffix(100) - delegate?.didCompleteCommand(historyItem: historyItem) + DispatchQueue.global(qos: .userInitiated).async { [unowned self] in + self.history.append(historyItem) + // Keep the last 100 items + self.history = self.history.suffix(100) + } + + delegate?.didCompleteCommand(historyItem: historyItem) + return output } } From 69c3386088aac0c08ad81102fd2f132510ab8910 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Wed, 20 Nov 2019 08:43:09 +0100 Subject: [PATCH 3/6] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Use=20Command.execute?= =?UTF-8?q?=20to=20retrieve=20PHP=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Classes/Helpers/PhpVersion.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpmon/Classes/Helpers/PhpVersion.swift b/phpmon/Classes/Helpers/PhpVersion.swift index bd42ca9..690e1f2 100644 --- a/phpmon/Classes/Helpers/PhpVersion.swift +++ b/phpmon/Classes/Helpers/PhpVersion.swift @@ -17,9 +17,7 @@ class PhpVersion { var xdebugEnabled : Bool = false init() { - let version = Shell.user - // Get the version directly from PHP - .pipe("php -r 'print phpversion();'") + let version = Command.execute(path: "/usr/local/bin/php", arguments: ["-r", "print phpversion();"]) // That's the long version self.long = version From ea60626c47097e44e9a5c4e106f8661788d8c0d4 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 28 Nov 2019 12:45:24 +0100 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=9A=A7=20WIP:=20Adds=20support=20to?= =?UTF-8?q?=20PHP=207.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (PHP 7.4 isn't out for Homebrew just yet.) --- README.md | 10 +++++----- phpmon/Classes/Commands/Actions.swift | 4 ++-- phpmon/Classes/Commands/Startup.swift | 6 +++--- phpmon/Constants.swift | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 36e0abd..cce4ee8 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ For me, it comes in handy when running multiple versions of PHP with Homebrew an **Minimal system requirements** * macOS 10.14 or higher -* PHP 7.3 installed via Homebrew +* PHP 7.4 installed via Homebrew * Laravel Valet 2.3 or higher installed **Recommended system** * macOS 10.15 Catalina -* PHP 7.3 installed with Homebrew 2.x +* PHP 7.4 installed with Homebrew 2.2 - other versions of PHP are optional - includes support for PHP 5.6 and PHP 7.0 [as well](https://github.com/eXolnet/homebrew-deprecated) * Laravel Valet 2.5.x installed @@ -40,14 +40,14 @@ This utility will detect which PHP versions you have installed via Homebrew, and This means: -- You have at least the latest version of PHP installed (`php@7.3`) +- You have at least the latest version of PHP installed (`php@7.4`) - You have installed Laravel Valet (`which valet` returns `/usr/local/bin/valet`) - You ran `valet trust`, which means Valet commands can be run without using sudo The utility runs the following commands: - Unlink all detected PHP versions -- Switch to PHP 7.3 (this is done in order to ensure that Valet works, even when attempting to use PHP 5.6) +- Switch to PHP 7.4 (this is done in order to ensure that Valet works, even when attempting to use PHP 5.6) - Tell Valet to switch to a specific PHP version - Link the desired version of PHP @@ -64,7 +64,7 @@ This app isn't very complicated after all. In the end, this just (conveniently) PHP Monitor performs some integrity checks to ensure a good experience when using the app. You'll get a message telling you that PHP Monitor won't work correctly in the following scenarios: - The PHP binary is not located in `/usr/local/bin/php` -- PHP 7.3 is missing in `/usr/local/opt` +- PHP 7.4 is missing in `/usr/local/opt` - Laravel Valet is missing in `/usr/local/bin/valet` - Brew has not been added to sudoers in `/private/etc/sudoers.d/brew` - Valet has not been added to sudoers in `/private/etc/sudoers.d/valet` diff --git a/phpmon/Classes/Commands/Actions.swift b/phpmon/Classes/Commands/Actions.swift index 87e54b4..60c0c81 100644 --- a/phpmon/Classes/Commands/Actions.swift +++ b/phpmon/Classes/Commands/Actions.swift @@ -30,8 +30,8 @@ class Actions { availableVersions.forEach { (version) in Shell.user.run("brew unlink php@\(version)") } - if (availableVersions.contains("7.3")) { - Shell.user.run("brew link php@7.3") + if (availableVersions.contains("7.4")) { + Shell.user.run("brew link php@7.4") if (version == Constants.LatestPhpVersion) { Shell.user.run("valet use php") } else { diff --git a/phpmon/Classes/Commands/Startup.swift b/phpmon/Classes/Commands/Startup.swift index aa87687..1a81514 100644 --- a/phpmon/Classes/Commands/Startup.swift +++ b/phpmon/Classes/Commands/Startup.swift @@ -19,9 +19,9 @@ class Startup { ) self.presentAlertOnMainThreadIf( - !Shell.user.pipe("ls /usr/local/opt | grep php@7.3").contains("php@7.3"), - messageText: "PHP 7.3 is not correctly installed", - informativeText: "PHP 7.3 alias was not found in `/usr/local/opt`. The app will not work correctly until you resolve this issue." + !Shell.user.pipe("ls /usr/local/opt | grep php@7.4").contains("php@7.4"), + messageText: "PHP 7.4 is not correctly installed", + informativeText: "PHP 7.4 alias was not found in `/usr/local/opt`. The app will not work correctly until you resolve this issue." ) self.presentAlertOnMainThreadIf( diff --git a/phpmon/Constants.swift b/phpmon/Constants.swift index 2b638c2..66aa848 100644 --- a/phpmon/Constants.swift +++ b/phpmon/Constants.swift @@ -14,13 +14,13 @@ class Constants { * The PHP versions supported by this application. */ static let SupportedPhpVersions = [ - "5.6", "7.0", "7.1", "7.2", "7.3" + "5.6", "7.0", "7.1", "7.2", "7.3", "7.4" ] /** Which php version is aliased as `php` to brew? This is usually the latest PHP version. */ - static let LatestPhpVersion = "7.3" + static let LatestPhpVersion = "7.4" } From e176d6fa2d1ac26f950f85649f15a2f8079c7555 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 20 Dec 2019 11:48:20 +0100 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=94=A7=20Version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 3f14729..d302ebb 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -369,14 +369,14 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 15; + CURRENT_PROJECT_VERSION = 16; DEVELOPMENT_TEAM = 8M54J5J787; INFOPLIST_FILE = phpmon/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 1.6; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -391,14 +391,14 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 15; + CURRENT_PROJECT_VERSION = 16; DEVELOPMENT_TEAM = 8M54J5J787; INFOPLIST_FILE = phpmon/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 1.6; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; From 1c62a100afb9b37b751ec2ef1bc1d36129430c0a Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 20 Dec 2019 11:54:15 +0100 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=94=A5=20Remove=20broken=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Will just log this in a file - the right way) --- PHP Monitor.xcodeproj/project.pbxproj | 4 -- phpmon/Singletons/MainMenu.swift | 6 -- .../Base.lproj/Main.storyboard | 69 +----------------- .../View Controllers/LogViewController.swift | 72 ------------------- 4 files changed, 3 insertions(+), 148 deletions(-) delete mode 100644 phpmon/View Controllers/LogViewController.swift diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index d302ebb..e3ef540 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */; }; - C41C1B3922B0097F00E7CF16 /* LogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B3822B0097F00E7CF16 /* LogViewController.swift */; }; C41C1B3B22B0098000E7CF16 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; }; C41C1B3E22B0098000E7CF16 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3C22B0098000E7CF16 /* Main.storyboard */; }; C41C1B4722B009A400E7CF16 /* Shell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4622B009A400E7CF16 /* Shell.swift */; }; @@ -27,7 +26,6 @@ /* Begin PBXFileReference section */ C41C1B3322B0097F00E7CF16 /* PHP Monitor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PHP Monitor.app"; sourceTree = BUILT_PRODUCTS_DIR; }; C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - C41C1B3822B0097F00E7CF16 /* LogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogViewController.swift; sourceTree = ""; }; C41C1B3A22B0098000E7CF16 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; C41C1B3D22B0098000E7CF16 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; C41C1B3F22B0098000E7CF16 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -103,7 +101,6 @@ isa = PBXGroup; children = ( C41C1B3C22B0098000E7CF16 /* Main.storyboard */, - C41C1B3822B0097F00E7CF16 /* LogViewController.swift */, ); path = "View Controllers"; sourceTree = ""; @@ -224,7 +221,6 @@ C4811D2422D70A4700B5F6B3 /* App.swift in Sources */, C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */, C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */, - C41C1B3922B0097F00E7CF16 /* LogViewController.swift in Sources */, C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */, C41C1B4B22B019FF00E7CF16 /* PhpVersion.swift in Sources */, C476FF9822B0DD830098105B /* Alert.swift in Sources */, diff --git a/phpmon/Singletons/MainMenu.swift b/phpmon/Singletons/MainMenu.swift index 631ef14..097e9cb 100644 --- a/phpmon/Singletons/MainMenu.swift +++ b/phpmon/Singletons/MainMenu.swift @@ -85,8 +85,6 @@ class MainMenu: NSObject, NSWindowDelegate { } } menu.addItem(NSMenuItem.separator()) - menu.addItem(NSMenuItem(title: "View shell output...", action: #selector(self.openOutput), keyEquivalent: "o")) - menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem(title: "About PHP Monitor", action: #selector(self.openAbout), keyEquivalent: "")) menu.items.forEach({ (item) in item.target = self @@ -115,10 +113,6 @@ class MainMenu: NSObject, NSWindowDelegate { // MARK: - Callable via Obj-C (#selector) - @objc func openOutput() { - LogViewController.show(delegate: self) - } - @objc func updatePhpVersionInStatusBar() { App.shared.currentVersion = PhpVersion() if (App.shared.busy) { diff --git a/phpmon/View Controllers/Base.lproj/Main.storyboard b/phpmon/View Controllers/Base.lproj/Main.storyboard index 244c8b5..bda1e5a 100644 --- a/phpmon/View Controllers/Base.lproj/Main.storyboard +++ b/phpmon/View Controllers/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - - + + @@ -54,68 +54,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/phpmon/View Controllers/LogViewController.swift b/phpmon/View Controllers/LogViewController.swift deleted file mode 100644 index 2cd3f08..0000000 --- a/phpmon/View Controllers/LogViewController.swift +++ /dev/null @@ -1,72 +0,0 @@ -// -// ViewController.swift -// PHP Monitor -// -// Created by Nico Verbruggen on 11/06/2019. -// Copyright © 2019 Nico Verbruggen. All rights reserved. -// - -import Cocoa - -class LogViewController: NSViewController, ShellDelegate { - - public static func show(delegate: NSWindowDelegate? = nil) { - if (App.shared.windowController == nil) { - let vc = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "logWindow") as! LogViewController - Shell.user.delegate = vc - let window = NSWindow(contentViewController: vc) - window.title = "Shell output (/bin/bash --login)" - window.delegate = delegate - App.shared.windowController = NSWindowController(window: window) - } - App.shared.windowController!.showWindow(self) - NSApp.activate(ignoringOtherApps: true) - } - - @IBOutlet var textView: NSTextView! - - public func appendHistoryItem(_ historyItem: ShellHistoryItem) { - self.append( - """ - ====== - @ \(historyItem.date.toString()) - ------ - $ \(historyItem.command) - ------ - > \(historyItem.output) - - """ - ) - } - - public func append(_ text : String) { - self.textView.textStorage?.append( - NSAttributedString( - string: text, - attributes: [ - NSAttributedString.Key.font: NSFont(name: "Menlo", size: 12.0)! - ] - ) - ) - self.textView.scrollToEndOfDocument(nil) - } - - override func viewDidLoad() { - self.textView.isEditable = false - for entry in Shell.user.history { - self.appendHistoryItem(entry) - } - } - - func didCompleteCommand(historyItem: ShellHistoryItem) { - self.appendHistoryItem(historyItem) - } - - @IBAction func pressed(_ sender: Any) { - self.view.window?.windowController?.close() - } - - deinit { - print("VC deallocated") - } -}