From 0b62570f161a54702870414d27f9a706816cc094 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 8 Sep 2024 17:41:30 +0200 Subject: [PATCH] Improve performance --- scripts/Common/Scripts/Config.ps1 | 15 ----------- scripts/Common/Software/git/Manage.ps1 | 23 ++++------------- scripts/Windows/Scripts/Deployment.ps1 | 35 ++++++++++++++------------ 3 files changed, 24 insertions(+), 49 deletions(-) diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index f6f67328..279592ca 100644 --- a/scripts/Common/Scripts/Config.ps1 +++ b/scripts/Common/Scripts/Config.ps1 @@ -458,21 +458,6 @@ $null = New-Module { Set-SetupOption $finishedOption $true; } - <# - .SYNOPSIS - Checks whether the specified software collection is enabled. - - .PARAMETER Name - The name of the collection to check. - #> - function Test-Collection { - param( - [string] $Name - ) - - Get-Config "$(Get-ConfigRootName).software.$Name"; - } - <# .SYNOPSIS Checks whether the running system is a QEMU virtual machine. diff --git a/scripts/Common/Software/git/Manage.ps1 b/scripts/Common/Software/git/Manage.ps1 index 45313ced..59e2cc27 100644 --- a/scripts/Common/Software/git/Manage.ps1 +++ b/scripts/Common/Software/git/Manage.ps1 @@ -28,20 +28,7 @@ $null = New-Module { $configArgs = @("--system"); } - <# - .SYNOPSIS - Gets the specified git configuration. - - .PARAMETER Name - THe name of the configuration to get. - #> - function Get-GitConfig { - param( - [string] $Name - ) - - Get-Config "$root.git.$Name"; - } + $config = Get-Config "$root.git"; <# .SYNOPSIS @@ -52,7 +39,7 @@ $null = New-Module { } if ((-not $IsWindows) -or $User) { - $branch = Get-GitConfig "defaultBranch"; + $branch = $config.defaultBranch; if ($branch) { Set-GitConfig "init.defaultBranch" $branch; @@ -76,8 +63,8 @@ $null = New-Module { . { $dir = New-TemporaryDirectory; $key = "flow"; - $mainBranch = Get-GitConfig "$key.mainBranch"; - $devBranch = Get-GitConfig "$key.devBranch"; + $mainBranch = $config."$key".mainBranch; + $devBranch = $config."$key".devBranch; & { git -C "$dir" init; @@ -103,7 +90,7 @@ $null = New-Module { }; # Aliases - [PSCustomObject] $aliases = Get-GitConfig "aliases"; + [PSCustomObject] $aliases = $config.aliases; if ($aliases) { foreach ($alias in ($aliases | Get-Member -MemberType Properties)) { diff --git a/scripts/Windows/Scripts/Deployment.ps1 b/scripts/Windows/Scripts/Deployment.ps1 index 72b625bb..0c6089cb 100644 --- a/scripts/Windows/Scripts/Deployment.ps1 +++ b/scripts/Windows/Scripts/Deployment.ps1 @@ -24,13 +24,16 @@ function Deploy-SoftwareAction { $install = $true; } + $hardware = Get-Config "valhalla.hardware"; + $collections = Get-Config "valhalla.windows.software"; + # Drivers & { $driverPath = "$PSScriptRoot/../Drivers"; $mbPath = "$driverPath/ROG Zenith Extreme Alpha"; if ($install) { - if (Get-Config "valhalla.hardware.elgatoWave") { + if ($hardware.elgatoWave) { if (-not (Test-ChocoPackage wavelink)) { Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"'; Remove-DesktopIcon "*Wave Link*"; @@ -40,7 +43,7 @@ function Deploy-SoftwareAction { } } - foreach ($component in (Get-Config "valhalla.hardware.components")) { + foreach ($component in $hardware.components) { switcH ($component) { ("ROG Zenith Extreme Alpha") { & "$mbPath/MarvellEthernet/Manage.ps1" @arguments; @@ -56,22 +59,22 @@ function Deploy-SoftwareAction { } if ($install) { - if (Get-Config "valhalla.hardware.amdCPU") { + if ($hardware.amdCPU) { Install-ChocoPackage amd-ryzen-master; # ToDo: backup Ryzen energy saving plan } - if (Get-Config "valhalla.hardware.nvidiaGPU") { + if ($hardware.nvidiaGPU) { Install-ChocoPackage geforce-game-ready-driver; Remove-DesktopIcon "*Geforce*"; } - if (Get-Config "valhalla.hardware.corsairDevice") { + if ($hardware.corsairDevice) { Install-ChocoPackage icue; } } - if (Get-Config "valhalla.hardware.eyeX") { + if ($hardware.eyeX) { & "$driverPath/Tobii EyeX/Manage.ps1" @arguments; } }; @@ -83,12 +86,12 @@ function Deploy-SoftwareAction { # Windows Config & "$softwarePath/Windows/Manage.ps1" @arguments; - if (Get-Config "valhalla.hardware.logitechG") { + if ($hardware.logitechG) { & "$softwarePath/LGHub/Manage.ps1" @arguments; } # Essentials - if (Test-Collection "essential") { + if ($collections.essential) { & "$softwarePath/aliae/Main.ps1" @arguments; & "$softwarePath/OpenSSH/Manage.ps1" @arguments; & "$softwarePath/PowerShell/Manage.ps1" @arguments; @@ -115,7 +118,7 @@ function Deploy-SoftwareAction { } # Common Software - if (Test-Collection "common") { + if ($collections.common) { & "$softwarePath/WinSCP/Manage.ps1" @arguments; & "$softwarePath/Thunderbird/Manage.ps1" @arguments; & "$softwarePath/PuTTY/Manage.ps1" @arguments; @@ -137,7 +140,7 @@ function Deploy-SoftwareAction { } } - if (Test-Collection "desktopExperience") { + if ($collections.desktopExperience) { if ($install) { # Fonts Install-ChocoPackage nerd-fonts-CascadiaCode; @@ -170,7 +173,7 @@ function Deploy-SoftwareAction { Remove-DesktopIcon "GIMP*"; Remove-DesktopIcon "GPU-Z*"; Remove-DesktopIcon "WinDirStat*"; - Remove-DesktopIcon "*HWMonior*"; + Remove-DesktopIcon "*HWMonitor*"; Remove-DesktopIcon "ImgBurn*"; Remove-DesktopIcon "InkScape*"; Remove-DesktopIcon "Krita*"; @@ -192,12 +195,12 @@ function Deploy-SoftwareAction { & "$softwarePath/Firefox/Manage.ps1" @arguments; & "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments; - if (Test-Collection "fileSync") { + if ($collections.fileSync) { & "$softwarePath/Nextcloud/Main.ps1" @arguments; } } - if (Test-Collection "socialMedia") { + if ($collections.socialMedia) { if ($install) { Install-ChocoPackage ` signal ` @@ -214,7 +217,7 @@ function Deploy-SoftwareAction { } } - if (Test-Collection "media") { + if ($collections.media) { if ($install) { Install-ChocoPackage ` k-litecodecpackmega ` @@ -230,7 +233,7 @@ function Deploy-SoftwareAction { } } - if (Test-Collection "coding") { + if ($collections.coding) { if ($install) { & "$softwarePath/vscode/Main.ps1" @arguments; @@ -256,7 +259,7 @@ function Deploy-SoftwareAction { } # Gaming - if (Test-Collection "gaming") { + if ($collections.gaming) { if ($install) { Install-ChocoPackage ` goggalaxy `