Skip to content

Commit

Permalink
Windows 1.9.0
Browse files Browse the repository at this point in the history
- Switch from cargo ripgrep to winget ripgrep install
- Add mingw64 install via msys2
- Disable Powertoys Run from running in fullscreen applications
- Remove grep aliased to findstr, instead rely on msys2 grep.exe
  • Loading branch information
codyduong committed Nov 28, 2023
1 parent 22380a2 commit 8810da0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 12 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion windows/aliases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Set-Alias unmute Set-SoundUnmute
Set-Alias update System-Update

Set-Alias vim nvim
Set-Alias grep findstr
# Set-Alias grep findstr
Set-Alias _ sudo
Set-Alias procexp procexp64
2 changes: 1 addition & 1 deletion windows/profile.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# version 1.8.1
# version 1.9.0

Push-Location (Split-Path -parent "$profile")
"components",
Expand Down
52 changes: 47 additions & 5 deletions windows/scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ else {
InstallerPromptUpdateOutdated
}

$script:currentPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::User)

### Update Help for Modules
# Write-Host "Updating Help..." -ForegroundColor "Yellow"
# Update-Help -Force


### Package Providers
# Write-Host "`nInstalling Package Providers" -ForegroundColor "Yellow"
# Get-PackageProvider NuGet -Force | Out-Null
Expand Down Expand Up @@ -91,13 +92,12 @@ Install-Winget jftuga.less
# Install-Powershell GoogleCloud -Scope CurrentUser
# Todo enable once we configure a gcloud init prompt (see https://cloud.google.com/tools/powershell/docs/quickstart)
Install-Winget Microsoft.Sysinternals.ProcessExplorer
Install-Winget BurntSushi.ripgrep.MSVC

Write-Host "`nInstalling Languages..." -ForegroundColor "Yellow"
Write-Host "NodeJS" -ForegroundColor "Cyan"
### NodeJS
# TODO fix nodejs install
# Install-Winget OpenJS.NodeJS.LTS
# Install-Winget OpenJS.NodeJS
Install-Winget OpenJS.NodeJS.LTS
Install-Winget CoreyButler.NVMforWindows
npm install -g npm@latest
npm install -g yarn
Expand Down Expand Up @@ -128,7 +128,49 @@ Install-Winget Rustlang.Rustup -GetCurrent {
[version]"0.0.0"
}
}
cargo install ripgrep

Write-Host "`nC/C++" -ForegroundColor "Cyan"
$script:msys2Path = "C:\msys64\usr\bin"
$script:mingwPath = "C:\msys64\ucrt64\bin"
# This has an superfluous call but idgaf. We really only care when the gcc version is updated, so use that as our baseline lib for when to upgrade
$script:msys2Remote = Invoke-RestMethod https://api.github.com/repos/msys2/msys2-installer/releases/latest
$script:msys2PackagesAsset = $msys2Remote.assets | Where-Object { $_.name -match "msys2-base-x86_64-latest.packages.txt" }
$script:msys2PackagesTxt = Join-Path $env:TEMP "Github" $msys2PackagesAsset.name
Invoke-WebRequest -Uri $msys2PackagesAsset.browser_download_url -OutFile $msys2PackagesTxt
$script:msys2RemoteVersion = if (Get-Content -Path $msys2PackagesTxt | Where-Object { $_ -match "(?<=gcc-libs )(\d+\.\d+\.\d+)" }) { $matches[0] } else { "0.0.0" }
# We use head instead of cat because there is some fuckery going on with Neovim/bin/cat.exe being on PATH that sometimes blows up msys2 bash cat
$script:msys2LocalVersion = "0.0.0"
try {
$script:msys2LocalVersion = if (
$(& $msys2Path\bash.exe -c "head /proc/version") -match "(?<=gcc version )\d+\.\d+\.\d+"
) { $matches[0] } else { "0.0.0" }
}
catch { Write-Warning $_ }
Install-GitHubRelease msys2 msys2/msys2-installer "msys2-x86_64-latest\.exe$" -version $msys2LocalVersion -remoteVersion $msys2RemoteVersion

# install mingw
Write-Verbose $(& $msys2Path\bash.exe -c "pacman -Syu base-devel mingw-w64-ucrt-x86_64-toolchain --noconfirm")

# Check if the path is already in the PATH variable
if ($currentPath -notlike "*$msys2Path*") {
# Add the MSYS2 path to the PATH variable
$newPath = $currentPath + ";" + $msys2Path
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::User)
Write-Host "$msys2Path added to the PATH" -ForegroundColor "Green"
}
else {
Write-Verbose "$msys2Path is already in the PATH"
}

if ($currentPath -notlike "*$mingwPath*") {
# Add the MSYS2 path to the PATH variable
$newPath = $currentPath + ";" + $mingwPath
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::User)
Write-Host "$mingwPath added to the PATH" -ForegroundColor "Green"
}
else {
Write-Verbose "$mingwPath is already in the PATH"
}

##############
# Desktop Apps
Expand Down
24 changes: 20 additions & 4 deletions windows/scripts/utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ function Install-GitHubRelease {
[semver]
${Version},

[Parameter(ValueFromPipelineByPropertyName)]
[semver]
${RemoteVersion},

[Parameter(ValueFromPipelineByPropertyName)]
[switch]
${WhatIf}
Expand Down Expand Up @@ -376,19 +380,23 @@ function Update-GitHubRelease {
[string]
${Match},

[Parameter(ValueFromPipelineByPropertyName)]
[semver]
${RemoteVersion},

[Parameter(ValueFromPipelineByPropertyName)]
[switch]
${WhatIf}
)

# get remote version
$Remote = Invoke-RestMethod https://api.github.com/repos/$Repository/releases/latest
$LatestVersion = [semver]$($Remote.tag_name.TrimStart("v"))
$LatestVersion = $RemoteVersion ?? [semver]$($Remote.tag_name.TrimStart("v"))

Write-Verbose "Local $Name version: v$Version"
Write-Verbose "Latest $Name version: v$LatestVersion"

if ($LatestVersion -eq $Version) {
if ($LatestVersion -eq $Version -or $Version -ge $LatestVersion) {
Write-Host "$Name $Version found, skipping..." -ForegroundColor $InstallationIndicatorColorFound
return $null
}
Expand All @@ -400,15 +408,23 @@ function Update-GitHubRelease {
New-Item $Temp -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null
Invoke-WebRequest -Uri $Url -OutFile $File

if ($LatestVersion -eq [semver]"0.0.0") {
if ($Version -eq [semver]"0.0.0") {
Write-Host "Installing $Name..." -ForegroundColor $InstallationIndicatorColorInstalling
}
elseif ($LatestVersion -gt $Version) {
Write-Host "Updating $Name from $Version to $LatestVersion..." -ForegroundColor $InstallationIndicatorColorUpdating
}

# Handle zipped files
if ($File -match ".*\.zip") {
$Destination = ($File -replace "\.zip$", "")
Expand-Archive -LiteralPath $File -DestinationPath $Temp
$File = $Destination
# Todo iterate over inside files to find msixbundle or exe. If the .exe is an installer specify with installer flag
# otherwise add binary to path
}
# Handle .msixbundle with AppX
if ($File -match ".*\.msixbundle$") {
elseif ($File -match ".*\.msixbundle$") {
Add-AppxPackage -Path $File -WhatIf:$WhatIf
}
# Handle .exe
Expand Down

0 comments on commit 8810da0

Please sign in to comment.