mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
👌 Detect Drupal and WordPress projects (#112)
This commit is contained in:
@ -51,7 +51,7 @@ struct ComposerJson: Decodable {
|
||||
}
|
||||
|
||||
// Unknown!
|
||||
return ("", "unknown")
|
||||
return ("???", "unknown")
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,4 +45,38 @@ struct PhpFrameworks {
|
||||
// "slim/*": "Slim",
|
||||
]
|
||||
|
||||
public static let FileMapping: [String: [String]] = [
|
||||
"Drupal": [
|
||||
// Legacy installations
|
||||
"/misc/drupal.js",
|
||||
"/core/lib/Drupal.php",
|
||||
// The default (new) installation w/ Composer puts the modules in /web
|
||||
"/web/misc/drupal.js",
|
||||
"/web/core/lib/Drupal.php"
|
||||
],
|
||||
"WordPress": [
|
||||
"/wp-config.php",
|
||||
"/wp-config-sample.php"
|
||||
],
|
||||
]
|
||||
|
||||
/**
|
||||
There are two cases where users are unlikely to use `composer`,
|
||||
when setting up a Drupal or a WordPress project. For performance
|
||||
reasons, we only check that here!
|
||||
*/
|
||||
public static func detectFallbackDependency(_ basePath: String) -> String? {
|
||||
for entry in Self.FileMapping {
|
||||
let found = entry.value
|
||||
.map { path in return Filesystem.fileExists(basePath + path) }
|
||||
.contains(true)
|
||||
|
||||
if found {
|
||||
return entry.key
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -291,6 +291,10 @@ class Valet {
|
||||
*/
|
||||
public func determineDriver() {
|
||||
self.determineDriverViaComposer()
|
||||
|
||||
if self.driver == nil {
|
||||
self.driver = PhpFrameworks.detectFallbackDependency(self.absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +306,6 @@ class Valet {
|
||||
*/
|
||||
private func determineDriverViaComposer() {
|
||||
self.driverDeterminedByComposer = true
|
||||
self.driver = "driver.not_detected".localized
|
||||
|
||||
PhpFrameworks.DependencyList.reversed().forEach { (key: String, value: String) in
|
||||
if self.notableComposerDependencies.keys.contains(key) {
|
||||
|
@ -57,7 +57,7 @@ class SiteListCell: NSTableCellView
|
||||
? "Project Type".uppercased()
|
||||
: "Driver Type".uppercased()
|
||||
|
||||
labelDriver.stringValue = "\(site.driver ?? "???")"
|
||||
labelDriver.stringValue = site.driver ?? "driver.not_detected".localized
|
||||
|
||||
// Determine the Laravel version
|
||||
if site.driver == "Laravel" && site.notableComposerDependencies.keys.contains("laravel/framework") {
|
||||
|
@ -119,7 +119,7 @@
|
||||
|
||||
// DRIVERS
|
||||
|
||||
"driver.not_detected" = "Unknown";
|
||||
"driver.not_detected" = "Other";
|
||||
|
||||
// EDITORS
|
||||
|
||||
|
Reference in New Issue
Block a user