1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 12:29:54 +02:00

👌 Load notable dependencies (incl. laravel, #80)

This commit is contained in:
2022-01-22 21:35:32 +01:00
parent 03a409281a
commit 46005a3c68
5 changed files with 36 additions and 48 deletions

View File

@@ -473,7 +473,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Lock" id="aJ0-ia-YrZ"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jKi-Ls-7FZ">
<rect key="frame" x="449" y="28" width="64" height="11"/>
<rect key="frame" x="424" y="28" width="64" height="11"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="DRIVER TYPE" id="fjd-eb-itv">
<font key="font" metaFont="miniSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -481,7 +481,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TbX-e2-3QL">
<rect key="frame" x="449" y="15" width="36" height="14"/>
<rect key="frame" x="424" y="15" width="36" height="14"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Driver" id="GMt-SG-vFl">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -492,7 +492,7 @@
<rect key="frame" x="0.0" y="-2" width="531" height="5"/>
</box>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0NQ-ZD-CqD">
<rect key="frame" x="425" y="18" width="18" height="18"/>
<rect key="frame" x="400" y="18" width="18" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="18" id="Suw-gm-AEi"/>
<constraint firstAttribute="height" constant="18" id="qO6-vg-5nC"/>
@@ -500,46 +500,25 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="IconLinked" id="2ng-pK-kvv"/>
<color key="contentTintColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
</imageView>
<button translatesAutoresizingMaskIntoConstraints="NO" id="ypa-iv-wLD">
<rect key="frame" x="211" y="18" width="18" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="18" id="jKJ-Xn-BPA"/>
<constraint firstAttribute="height" constant="18" id="lSH-of-WzD"/>
</constraints>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSCaution" catalog="system" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="9XB-KO-aSI">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="150" translatesAutoresizingMaskIntoConstraints="NO" id="MD8-ef-Ht8">
<rect key="frame" x="235" y="5" width="112" height="44"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Warning: This is a warning message. Please take this into account." id="iub-KH-clf">
<font key="font" metaFont="miniSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3xt-wC-hUJ">
<rect key="frame" x="352" y="18" width="59" height="18"/>
<rect key="frame" x="329" y="19" width="59" height="16"/>
<buttonCell key="cell" type="inline" title=" PHP X.X" bezelStyle="inline" alignment="center" borderStyle="border" inset="2" id="anZ-hP-G0R">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystemBold"/>
</buttonCell>
<color key="contentTintColor" name="systemGreenColor" catalog="System" colorSpace="catalog"/>
<color key="contentTintColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<connections>
<action selector="pressedPhpVersion:" target="5GY-nN-BWd" id="mB5-WD-aZy"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="0NQ-ZD-CqD" firstAttribute="leading" secondItem="MD8-ef-Ht8" secondAttribute="trailing" constant="80" id="1Rb-Or-Nnn"/>
<constraint firstItem="0NQ-ZD-CqD" firstAttribute="leading" secondItem="3xt-wC-hUJ" secondAttribute="trailing" constant="12" id="2G8-Ow-FTu"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="TbX-e2-3QL" secondAttribute="trailing" constant="20" symbolic="YES" id="3vE-LR-S7N"/>
<constraint firstItem="TbX-e2-3QL" firstAttribute="leading" secondItem="0NQ-ZD-CqD" secondAttribute="trailing" constant="8" symbolic="YES" id="4cb-D9-8d1"/>
<constraint firstItem="XJL-Uw-frD" firstAttribute="leading" secondItem="QPX-eu-eV8" secondAttribute="trailing" constant="10" id="55y-3V-RYt"/>
<constraint firstItem="syz-LF-l6P" firstAttribute="leading" secondItem="5GY-nN-BWd" secondAttribute="leading" id="8QK-nf-Fiw"/>
<constraint firstItem="QPX-eu-eV8" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="top" id="9QB-jZ-k1V"/>
<constraint firstItem="ypa-iv-wLD" firstAttribute="centerY" secondItem="5GY-nN-BWd" secondAttribute="centerY" id="9d8-P2-iSk"/>
<constraint firstItem="MD8-ef-Ht8" firstAttribute="leading" secondItem="ypa-iv-wLD" secondAttribute="trailing" constant="8" symbolic="YES" id="C90-wQ-3Gf"/>
<constraint firstItem="QPX-eu-eV8" firstAttribute="leading" secondItem="5GY-nN-BWd" secondAttribute="leading" constant="10" id="GOj-sw-ZlZ"/>
<constraint firstItem="TbX-e2-3QL" firstAttribute="top" secondItem="jKi-Ls-7FZ" secondAttribute="bottom" constant="-1" id="J29-wT-Uex"/>
<constraint firstItem="CXK-Q9-CpO" firstAttribute="leading" secondItem="XJL-Uw-frD" secondAttribute="leading" id="Ojw-VZ-3EG"/>
@@ -547,26 +526,21 @@
<constraint firstItem="XJL-Uw-frD" firstAttribute="top" secondItem="5GY-nN-BWd" secondAttribute="top" constant="12" id="QeE-c7-I9U"/>
<constraint firstItem="0NQ-ZD-CqD" firstAttribute="centerY" secondItem="5GY-nN-BWd" secondAttribute="centerY" id="Utr-aa-tqX"/>
<constraint firstItem="CXK-Q9-CpO" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="bottom" id="VKg-Vq-sYa"/>
<constraint firstAttribute="trailing" secondItem="3xt-wC-hUJ" secondAttribute="trailing" constant="120" id="W5B-63-qmy"/>
<constraint firstItem="TbX-e2-3QL" firstAttribute="centerY" secondItem="5GY-nN-BWd" secondAttribute="centerY" constant="5" id="cN8-zO-fnc"/>
<constraint firstAttribute="bottom" secondItem="syz-LF-l6P" secondAttribute="bottom" id="gj7-cJ-Lle"/>
<constraint firstItem="0NQ-ZD-CqD" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="CXK-Q9-CpO" secondAttribute="trailing" constant="8" symbolic="YES" id="iEd-Y3-zhp"/>
<constraint firstItem="ypa-iv-wLD" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="XJL-Uw-frD" secondAttribute="trailing" constant="30" id="koV-Sj-tO8"/>
<constraint firstItem="MD8-ef-Ht8" firstAttribute="centerY" secondItem="ypa-iv-wLD" secondAttribute="centerY" id="lIN-pm-mCo"/>
<constraint firstItem="0NQ-ZD-CqD" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="XJL-Uw-frD" secondAttribute="trailing" constant="8" symbolic="YES" id="lLA-Jx-Q4W"/>
<constraint firstItem="3xt-wC-hUJ" firstAttribute="centerY" secondItem="5GY-nN-BWd" secondAttribute="centerY" id="vhb-WC-3NC"/>
<constraint firstAttribute="trailing" secondItem="jKi-Ls-7FZ" secondAttribute="trailing" constant="20" id="vwD-Sg-Lzc"/>
<constraint firstAttribute="trailing" secondItem="jKi-Ls-7FZ" secondAttribute="trailing" constant="45" id="vwD-Sg-Lzc"/>
<constraint firstItem="jKi-Ls-7FZ" firstAttribute="leading" secondItem="TbX-e2-3QL" secondAttribute="leading" id="zjN-s3-2Ww"/>
</constraints>
<connections>
<outlet property="buttonPhpVersion" destination="3xt-wC-hUJ" id="LpB-7n-qUr"/>
<outlet property="buttonWarning" destination="ypa-iv-wLD" id="NwX-H3-8um"/>
<outlet property="imageViewLock" destination="QPX-eu-eV8" id="Nnh-kB-adG"/>
<outlet property="imageViewType" destination="0NQ-ZD-CqD" id="Cph-FN-LaY"/>
<outlet property="labelDriver" destination="TbX-e2-3QL" id="qJh-Ak-Dge"/>
<outlet property="labelPathName" destination="CXK-Q9-CpO" id="iVZ-cL-azB"/>
<outlet property="labelSiteName" destination="XJL-Uw-frD" id="f0t-vd-W68"/>
<outlet property="labelWarning" destination="MD8-ef-Ht8" id="Faw-CY-9R5"/>
</connections>
</tableCellView>
</prototypeCellViews>
@@ -616,13 +590,12 @@
</viewController>
<customObject id="HgD-aB-bQb" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="288" y="764.5"/>
<point key="canvasLocation" x="251" y="751"/>
</scene>
</scenes>
<resources>
<image name="IconLinked" width="512" height="512"/>
<image name="Lock" width="30" height="30"/>
<image name="NSCaution" catalog="system" width="32" height="32"/>
<image name="arrow.clockwise" catalog="system" width="14" height="16"/>
</resources>
</document>

View File

@@ -28,6 +28,19 @@ struct ComposerJson: Decodable {
return ("", "unknown")
}
public func getNotableDependencies() -> [String: String] {
var notable: [String: String] = [:]
let scan = ["php", "laravel/framework"]
scan.forEach { dependency in
if dependencies?[dependency] != nil {
notable[dependency] = dependencies![dependency]
}
}
return notable
}
private enum CodingKeys: String, CodingKey {
case dependencies = "require"
case devDependencies = "require-dev"

View File

@@ -162,10 +162,13 @@ class Valet {
/// What driver is currently in use. If not detected, defaults to nil.
var driver: String? = nil
/// The PHP version as discovered in composer.json
/// A list of notable Composer dependencies.
var notableComposerDependencies: [String: String] = [:]
/// The PHP version as discovered in composer.json.
var composerPhp: String = "???"
/// How the PHP version was determined
/// How the PHP version was determined.
var composerPhpSource: String = "unknown"
init() {}
@@ -210,10 +213,13 @@ class Valet {
let path = "\(absolutePath!)/composer.json"
do {
if Filesystem.fileExists(path) {
(self.composerPhp, self.composerPhpSource) = try JSONDecoder().decode(
let decoded = try JSONDecoder().decode(
ComposerJson.self,
from: String(contentsOf: URL(fileURLWithPath: path), encoding: .utf8).data(using: .utf8)!
).getPhpVersion()
)
(self.composerPhp, self.composerPhpSource) = decoded.getPhpVersion()
self.notableComposerDependencies = decoded.getNotableDependencies()
}
} catch {
Log.err("Something went wrong reading the composer JSON file.")

View File

@@ -21,9 +21,6 @@ class SiteListCell: NSTableCellView
@IBOutlet weak var labelDriver: NSTextField!
@IBOutlet weak var buttonWarning: NSButton!
@IBOutlet weak var labelWarning: NSTextField!
@IBOutlet weak var buttonPhpVersion: NSButton!
override func draw(_ dirtyRect: NSRect) {
@@ -36,11 +33,6 @@ class SiteListCell: NSTableCellView
// Make sure to show the TLD
labelSiteName.stringValue = "\(site.name!).\(Valet.shared.config.tld)"
let isProblematic = site.name.contains(" ")
buttonWarning.isHidden = !isProblematic
labelWarning.isHidden = !isProblematic
labelWarning.stringValue = "site_list.warning.spaces".localized
// Show the absolute path, except make sure to replace the /Users/username segment with ~ for readability
labelPathName.stringValue = site.absolutePath
.replacingOccurrences(of: "/Users/\(Paths.whoami)", with: "~")
@@ -62,6 +54,11 @@ class SiteListCell: NSTableCellView
// Show the current driver
labelDriver.stringValue = "\(site.driver ?? "???")"
if site.driver == "Laravel" && site.notableComposerDependencies.keys.contains("laravel/framework") {
let constraint = site.notableComposerDependencies["laravel/framework"]!
labelDriver.stringValue = "Laravel (\(constraint))"
}
// Show the PHP version
buttonPhpVersion.title = " PHP \(site.composerPhp) "
buttonPhpVersion.isHidden = (site.composerPhp == "???")

View File

@@ -186,7 +186,6 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
// MARK: - Deinitialization