From 8535c3c03a182abcccfe67f7eb34e1cbaaf95d71 Mon Sep 17 00:00:00 2001 From: Scott McKendry <39483124+scottmckendry@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:24:18 +1300 Subject: [PATCH] setup script improvements & refactors :recycle: --- Setup.ps1 | 80 +++++++++++++++++++++---------------------------------- 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/Setup.ps1 b/Setup.ps1 index 2a3e15c..13aa4a1 100644 --- a/Setup.ps1 +++ b/Setup.ps1 @@ -1,6 +1,4 @@ # Setup script for Windots -# Author: Scott McKendry - #Requires -RunAsAdministrator # Linked Files (Destination => Source) @@ -12,64 +10,48 @@ $symlinks = @{ "$HOME\AppData\Roaming\lazygit" = ".\lazygit" } +# Winget & choco dependencies (cmd => package name) +$wingetDeps = @{ + "pwsh" = "Microsoft.PowerShell" + "git" = "Git.Git" + "starship" = "Starship.Starship" + "npm" = "OpenJS.NodeJS" + "eza" = "eza-community.eza" + "java" = "Microsoft.OpenJDK.21" + "choco" = "Chocolatey.Chocolatey" +} +$chocoDeps = @{ + "zig" = "zig" + "rg" = "ripgrep" + "fd" = "fd" + "sed" = "sed" + "lazygit" = "lazygit" + "nvim" = "neovim" + "bat" = "bat" + "fzf" = "fzf" + "zoxide" = "zoxide" +} + # Set working directory Set-Location $PSScriptRoot [Environment]::CurrentDirectory = $PSScriptRoot Write-Host "Installing missing dependencies..." - -# Install dependencies - Powershell, git, starship, node, eza, choco, zig, rg, fd, sed, lazygit, nvim, bat, fzf, zoxide -if (!(Get-Command "pwsh" -ErrorAction SilentlyContinue)) { - winget install -e --id=Microsoft.PowerShell -} -if (!(Get-Command "git" -ErrorAction SilentlyContinue)) { - winget install -e --id=Git.Git -} -if (!(Get-Command "starship" -ErrorAction SilentlyContinue)) { - winget install -e --id Starship.Starship -} -if (!(Get-Command "npm" -ErrorAction SilentlyContinue)) { - winget install -e --id OpenJS.NodeJS -} -if (!(Get-Command "eza" -ErrorAction SilentlyContinue)) { - winget install -e --id=eza-community.eza -} -if (!(Get-Command "choco" -ErrorAction SilentlyContinue)) { - winget install -e --id=Chocolatey.Chocolatey +foreach ($wingetDep in $wingetDeps.GetEnumerator()) { + if (!(Get-Command $wingetDep.Key -ErrorAction SilentlyContinue)) { + winget install -e --id $wingetDep.Value + } } + # Path Refresh $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") -# Choco Deps -if (!(Get-Command "zig" -ErrorAction SilentlyContinue)) { - choco install -y zig -} -if (!(Get-Command "rg" -ErrorAction SilentlyContinue)) { - choco install -y ripgrep -} -if (!(Get-Command "fd" -ErrorAction SilentlyContinue)) { - choco install -y fd -} -if (!(Get-Command "sed" -ErrorAction SilentlyContinue)) { - choco install -y sed -} -if (!(Get-Command "lazygit" -ErrorAction SilentlyContinue)) { - choco install -y lazygit -} -if (!(Get-Command "nvim" -ErrorAction SilentlyContinue)) { - choco install -y neovim -} -if (!(Get-Command "bat" -ErrorAction SilentlyContinue)) { - choco install -y bat -} -if (!(Get-Command "fzf" -ErrorAction SilentlyContinue)) { - choco install -y fzf -} -if (!(Get-Command "zoxide" -ErrorAction SilentlyContinue)) { - choco install -y zoxide +foreach ($chocoDep in $chocoDeps.GetEnumerator()) { + if (!(Get-Command $chocoDep.Key -ErrorAction SilentlyContinue)) { + choco install -y $chocoDep.Value + } } - # Create Custom NVIM shotcut if (!(Test-Path "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\nvim.lnk")) { $wshShell = New-Object -ComObject WScript.Shell