mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Change where scanners are initialized
This commit is contained in:
@ -561,6 +561,14 @@
|
||||
C4CE3BBA27B31F670086CA49 /* ComposerWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CE3BB927B31F670086CA49 /* ComposerWindow.swift */; };
|
||||
C4CE3BBB27B324230086CA49 /* MainMenu+Switcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CE3BB727B31F2E0086CA49 /* MainMenu+Switcher.swift */; };
|
||||
C4CE3BBC27B324250086CA49 /* ComposerWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CE3BB927B31F670086CA49 /* ComposerWindow.swift */; };
|
||||
C4D36601291132B7006BD146 /* ValetScanners.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D36600291132B7006BD146 /* ValetScanners.swift */; };
|
||||
C4D36602291132B7006BD146 /* ValetScanners.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D36600291132B7006BD146 /* ValetScanners.swift */; };
|
||||
C4D36603291132B7006BD146 /* ValetScanners.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D36600291132B7006BD146 /* ValetScanners.swift */; };
|
||||
C4D36604291132B7006BD146 /* ValetScanners.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D36600291132B7006BD146 /* ValetScanners.swift */; };
|
||||
C4D366062911331E006BD146 /* EmptyProxyScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D366052911331E006BD146 /* EmptyProxyScanner.swift */; };
|
||||
C4D366072911331E006BD146 /* EmptyProxyScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D366052911331E006BD146 /* EmptyProxyScanner.swift */; };
|
||||
C4D366082911331E006BD146 /* EmptyProxyScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D366052911331E006BD146 /* EmptyProxyScanner.swift */; };
|
||||
C4D366092911331E006BD146 /* EmptyProxyScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D366052911331E006BD146 /* EmptyProxyScanner.swift */; };
|
||||
C4D5CFCA27E0F9CD00035329 /* NginxConfigurationFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D5CFC927E0F9CD00035329 /* NginxConfigurationFile.swift */; };
|
||||
C4D5CFCB27E0F9CD00035329 /* NginxConfigurationFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D5CFC927E0F9CD00035329 /* NginxConfigurationFile.swift */; };
|
||||
C4D8016622B1584700C6DA1B /* Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D8016522B1584700C6DA1B /* Startup.swift */; };
|
||||
@ -841,6 +849,8 @@
|
||||
C4CDA892288F1A71007CE25F /* Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keys.swift; sourceTree = "<group>"; };
|
||||
C4CE3BB727B31F2E0086CA49 /* MainMenu+Switcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MainMenu+Switcher.swift"; sourceTree = "<group>"; };
|
||||
C4CE3BB927B31F670086CA49 /* ComposerWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposerWindow.swift; sourceTree = "<group>"; };
|
||||
C4D36600291132B7006BD146 /* ValetScanners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValetScanners.swift; sourceTree = "<group>"; };
|
||||
C4D366052911331E006BD146 /* EmptyProxyScanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyProxyScanner.swift; sourceTree = "<group>"; };
|
||||
C4D5CFC927E0F9CD00035329 /* NginxConfigurationFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NginxConfigurationFile.swift; sourceTree = "<group>"; };
|
||||
C4D8016522B1584700C6DA1B /* Startup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Startup.swift; sourceTree = "<group>"; };
|
||||
C4D89BC52783C99400A02B68 /* ComposerJson.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposerJson.swift; sourceTree = "<group>"; };
|
||||
@ -1363,6 +1373,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C4AF9F792754499000D44ED0 /* Valet.swift */,
|
||||
C4D36600291132B7006BD146 /* ValetScanners.swift */,
|
||||
C40175B629030F7A00763A68 /* Domains */,
|
||||
C4C0E8D927F887BD002D32A9 /* Proxies */,
|
||||
C4C0E8D827F887A5002D32A9 /* Sites */,
|
||||
@ -1499,6 +1510,7 @@
|
||||
children = (
|
||||
C4C0E8E627F88B41002D32A9 /* ProxyScanner.swift */,
|
||||
C484437A2804BB560041A78A /* ValetProxyScanner.swift */,
|
||||
C4D366052911331E006BD146 /* EmptyProxyScanner.swift */,
|
||||
);
|
||||
path = ProxyScanner;
|
||||
sourceTree = "<group>";
|
||||
@ -1918,6 +1930,7 @@
|
||||
C48D6C70279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */,
|
||||
C4998F0A2617633900B2526E /* PreferencesWindowController.swift in Sources */,
|
||||
C46FA9882822EFDC00D78807 /* PhpConfigurationFile.swift in Sources */,
|
||||
C4D366062911331E006BD146 /* EmptyProxyScanner.swift in Sources */,
|
||||
C4F8C0A422D4F12C002EFE61 /* DateExtension.swift in Sources */,
|
||||
C4AF9F7A2754499000D44ED0 /* Valet.swift in Sources */,
|
||||
C4C0E8EA27F88B80002D32A9 /* ValetProxy+Fake.swift in Sources */,
|
||||
@ -2025,6 +2038,7 @@
|
||||
C4B6091D2853AB9700C95265 /* ServicesView.swift in Sources */,
|
||||
C40508B128ADAB44008FAC1F /* NSMenuItemExtension.swift in Sources */,
|
||||
C4B97B7B275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */,
|
||||
C4D36601291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||
C4EED88927A48778006D7272 /* InterAppHandler.swift in Sources */,
|
||||
C40C7F1E2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
||||
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
|
||||
@ -2082,6 +2096,7 @@
|
||||
C471E83D28F9BB650021E251 /* FakeSiteScanner.swift in Sources */,
|
||||
C471E83F28F9BB650021E251 /* AppDelegate.swift in Sources */,
|
||||
C471E84028F9BB650021E251 /* AppDelegate+MenuOutlets.swift in Sources */,
|
||||
C4D36603291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||
C471E84128F9BB650021E251 /* AppDelegate+Notifications.swift in Sources */,
|
||||
C471E84228F9BB650021E251 /* AppDelegate+InterApp.swift in Sources */,
|
||||
C471E84328F9BB650021E251 /* App.swift in Sources */,
|
||||
@ -2106,6 +2121,7 @@
|
||||
C471E85528F9BB650021E251 /* StatusMenu+Items.swift in Sources */,
|
||||
C471E85628F9BB650021E251 /* DomainListCellProtocol.swift in Sources */,
|
||||
C471E85728F9BB650021E251 /* DomainListTLSCell.swift in Sources */,
|
||||
C4D366082911331E006BD146 /* EmptyProxyScanner.swift in Sources */,
|
||||
C471E85828F9BB650021E251 /* DomainListNameCell.swift in Sources */,
|
||||
C471E85928F9BB650021E251 /* DomainListPhpCell.swift in Sources */,
|
||||
C471E85A28F9BB650021E251 /* DomainListTypeCell.swift in Sources */,
|
||||
@ -2228,6 +2244,7 @@
|
||||
C471E89528F9BB8F0021E251 /* MenuBarImageGenerator.swift in Sources */,
|
||||
C471E89628F9BB8F0021E251 /* PMWindowController.swift in Sources */,
|
||||
C471E89728F9BB8F0021E251 /* VersionExtractor.swift in Sources */,
|
||||
C4D366092911331E006BD146 /* EmptyProxyScanner.swift in Sources */,
|
||||
C4E2E86728FC2F1B003B070C /* XCPMApplication.swift in Sources */,
|
||||
C471E89828F9BB8F0021E251 /* ValetProxy.swift in Sources */,
|
||||
C471E89928F9BB8F0021E251 /* ValetProxy+Fake.swift in Sources */,
|
||||
@ -2310,6 +2327,7 @@
|
||||
C4E2E85F28FC282B003B070C /* TestableConfiguration.swift in Sources */,
|
||||
C471E8E928F9BB8F0021E251 /* StatsView.swift in Sources */,
|
||||
C471E8EA28F9BB8F0021E251 /* SectionHeaderView.swift in Sources */,
|
||||
C4D36604291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||
C471E8EB28F9BB8F0021E251 /* HeaderView.swift in Sources */,
|
||||
C471E8EC28F9BB8F0021E251 /* SwiftUIHelper.swift in Sources */,
|
||||
C471E8EE28F9BB8F0021E251 /* HotKey.swift in Sources */,
|
||||
@ -2413,6 +2431,7 @@
|
||||
C485707A28BF457800539B36 /* WarningListView.swift in Sources */,
|
||||
C4C0E8E827F88B41002D32A9 /* ProxyScanner.swift in Sources */,
|
||||
C449B4F027EE7FB800C47E8A /* DomainListTLSCell.swift in Sources */,
|
||||
C4D366072911331E006BD146 /* EmptyProxyScanner.swift in Sources */,
|
||||
C4FBFC532616485F00CDB8E1 /* PhpVersionDetectionTest.swift in Sources */,
|
||||
C43A8A2425D9D20D00591B77 /* HomebrewPackageTest.swift in Sources */,
|
||||
C485707928BF456C00539B36 /* ArrayExtension.swift in Sources */,
|
||||
@ -2532,6 +2551,7 @@
|
||||
C4E0F7EE27BEBDA9007475F2 /* NSWindowExtension.swift in Sources */,
|
||||
C4A81CA528C67101008DD9D1 /* PMTableView.swift in Sources */,
|
||||
C45E76152854A65300B4FE0C /* ServicesManager.swift in Sources */,
|
||||
C4D36602291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||
C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
||||
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
||||
C464ADB0275A7A6A003FCD53 /* DomainListVC.swift in Sources */,
|
||||
|
@ -80,7 +80,7 @@
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--configuration:~/.phpmon_fconf_working.json"
|
||||
isEnabled = "NO">
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--configuration:~/.phpmon_fconf_broken.json"
|
||||
|
@ -15,9 +15,18 @@ public struct TestableConfiguration: Codable {
|
||||
var commandOutput: [String: String]
|
||||
|
||||
func apply() {
|
||||
Log.separator()
|
||||
Log.info("USING TESTABLE CONFIGURATION...")
|
||||
Log.separator()
|
||||
Log.info("Applying fake shell...")
|
||||
ActiveShell.useTestable(shellOutput)
|
||||
Log.info("Applying fake filesystem...")
|
||||
ActiveFileSystem.useTestable(filesystem)
|
||||
Log.info("Applying fake commands...")
|
||||
ActiveCommand.useTestable(commandOutput)
|
||||
Log.info("Applying fake scanner...")
|
||||
ValetScanners.useFake()
|
||||
Log.separator()
|
||||
}
|
||||
|
||||
func toJson(pretty: Bool = false) -> String {
|
||||
|
@ -60,7 +60,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
|
||||
#if DEBUG
|
||||
logger.verbosity = .performance
|
||||
|
||||
if let profile = CommandLine.arguments.first(where: { $0.matches(pattern: "--configuration:*") }) {
|
||||
Self.initializeTestingProfile(profile.replacingOccurrences(of: "--configuration:", with: ""))
|
||||
}
|
||||
@ -89,9 +88,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
|
||||
static func initializeTestingProfile(_ path: String) {
|
||||
Log.info("The configuration with path `\(path)` is being requested...")
|
||||
TestableConfiguration
|
||||
.loadFrom(path: path)
|
||||
.apply()
|
||||
TestableConfiguration.loadFrom(path: path).apply()
|
||||
}
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// EmptyProxyScanner.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 01/11/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class EmptyProxyScanner: ProxyScanner {
|
||||
func resolveProxies(directoryPath: String) -> [ValetProxy] {
|
||||
return []
|
||||
}
|
||||
}
|
@ -35,6 +35,8 @@ class FakeValetSite: ValetSite {
|
||||
self.isolatedPhpVersion = PhpInstallation(isolated)
|
||||
}
|
||||
|
||||
// TODO: Resolve this at a later time
|
||||
/*
|
||||
self.composerPhpCompatibleWithLinked = self.composerPhp.split(separator: "|")
|
||||
.map { string in
|
||||
let origin = self.isolatedPhpVersion?.versionNumber.short ?? PhpEnv.phpInstall.version.long
|
||||
@ -42,5 +44,6 @@ class FakeValetSite: ValetSite {
|
||||
.matching(constraint: string.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||
.isEmpty
|
||||
}.contains(true)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -41,23 +41,16 @@ class Valet {
|
||||
self.version = nil
|
||||
self.sites = []
|
||||
self.proxies = []
|
||||
self.checkForMarketingMode()
|
||||
}
|
||||
|
||||
/**
|
||||
If marketing mode is enabled, show a list of sites that are used for promotional screenshots.
|
||||
This can be done by swapping out the real Valet scanner with one that always returns a fixed
|
||||
list of fake sites. You should not interact with these sites!
|
||||
*/
|
||||
static var siteScanner: SiteScanner {
|
||||
/// If marketing mode is enabled, you can tinker around with the site list
|
||||
/// without actually modifying items on your local system.
|
||||
public func checkForMarketingMode() {
|
||||
if ProcessInfo.processInfo.environment["PHPMON_MARKETING_MODE"] != nil {
|
||||
return FakeSiteScanner()
|
||||
Log.info("Using a fake list of sites for Marketing Mode!")
|
||||
ValetScanners.useFake()
|
||||
}
|
||||
|
||||
return ValetSiteScanner()
|
||||
}
|
||||
|
||||
static var proxyScanner: ProxyScanner {
|
||||
return ValetProxyScanner()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +191,7 @@ class Valet {
|
||||
Returns a count of how many sites are linked and parked.
|
||||
*/
|
||||
private func countPaths() -> Int {
|
||||
return Self.siteScanner
|
||||
return ValetScanners.siteScanner
|
||||
.resolveSiteCount(paths: config.paths)
|
||||
}
|
||||
|
||||
@ -208,13 +201,13 @@ class Valet {
|
||||
private func resolvePaths() {
|
||||
isBusy = true
|
||||
|
||||
sites = Self.siteScanner
|
||||
sites = ValetScanners.siteScanner
|
||||
.resolveSitesFrom(paths: config.paths)
|
||||
.sorted {
|
||||
$0.absolutePath < $1.absolutePath
|
||||
}
|
||||
|
||||
proxies = Self.proxyScanner
|
||||
proxies = ValetScanners.proxyScanner
|
||||
.resolveProxies(
|
||||
directoryPath: FileManager.default
|
||||
.homeDirectoryForCurrentUser
|
||||
|
21
phpmon/Domain/Integrations/Valet/ValetScanners.swift
Normal file
21
phpmon/Domain/Integrations/Valet/ValetScanners.swift
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// Valet+Scanners.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 01/11/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class ValetScanners {
|
||||
|
||||
static var siteScanner: SiteScanner = ValetSiteScanner()
|
||||
static var proxyScanner: ProxyScanner = ValetProxyScanner()
|
||||
|
||||
public static func useFake() {
|
||||
ValetScanners.siteScanner = FakeSiteScanner()
|
||||
ValetScanners.proxyScanner = EmptyProxyScanner()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user