Skip to content

Commit ab7aaf9

Browse files
committed
Use github api when downloding things
1 parent 96faf9e commit ab7aaf9

1 file changed

Lines changed: 10 additions & 22 deletions

File tree

Executables/STORE-APPS.ps1

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@ $tempDir = Join-Path -Path $(Get-SystemDrive) -ChildPath $([System.Guid]::NewGui
1313
New-Item $tempDir -ItemType Directory -Force | Out-Null
1414
Push-Location $tempDir
1515

16-
function WingetCheck {
17-
Write-Output "Checking for winget"
18-
if (Get-Command winget -ErrorAction SilentlyContinue) {
19-
Write-Output "Winget Found"
20-
return true
21-
}
22-
Write-Output "Winget not found, trying to install"
23-
$packageUrl = "https://aka.ms/getwinget"
24-
$packagePath = Join-Path -Path $tempDir -ChildPath "AppInstaller.msixbundle"
25-
& curl.exe -L $packageUrl -o $packagePath
26-
Write-Output "Installing Winget"
27-
Add-AppxPackage -Path $packagePath
28-
Remove-TempDirectory
29-
}
30-
3116
if ($Files) {
3217
Write-Output "Downloading Files..."
3318
$packagePath = Join-Path $tempDir "Files.Package_3.9.1.0_x64_arm64.msixbundle"
@@ -39,8 +24,10 @@ if ($Files) {
3924

4025
if ($Notepads) {
4126
Write-Output "Downloading Notepads..."
42-
$packagePath = Join-Path $tempDir "Notepads_1.5.6.0_x86_x64_arm64.msixbundle"
43-
& curl.exe -L "https://github.com/0x7c13/Notepads/releases/download/v1.5.6.0/Notepads_1.5.6.0_x86_x64_arm64.msixbundle" -o $packagePath
27+
$githubApi = Invoke-RestMethod "https://api.github.com/repos/0x7c13/Notepads/releases/latest" -EA 0
28+
$packageUrl = $githubApi.assets.browser_download_url | Where-Object { $_ -like "*.msixbundle" } | Select-Object -First 1
29+
$packagePath = Join-Path $tempDir "Notepads_x86_x64_arm64.msixbundle"
30+
& curl.exe -L $packageUrl -o $packagePath
4431
Add-AppxPackage -Path $packagePath
4532
Write-Host "Notepads installed."
4633
Remove-TempDirectory
@@ -72,11 +59,10 @@ if ($AppFetch) {
7259

7360
if ($UniGetUI) {
7461
Write-Output "Downloading UniGetUI..."
75-
# Winget is silent for some reason AND UNRELIABLE
76-
# WingetCheck
77-
# winget install --id=MartiCliment.UniGetUI -e --silent
62+
$githubApi = Invoke-RestMethod "https://api.github.com/repos/marticliment/UniGetUI/releases/latest" -EA 0
63+
$exeUrl = $githubApi.assets.browser_download_url | Where-Object { $_ -like "*.exe" } | Select-Object -First 1
7864
$exePath = Join-Path $tempDir "UniGetUI.Installer.exe"
79-
& curl.exe -L "https://github.com/marticliment/UniGetUI/releases/download/3.2.0/UniGetUI.Installer.exe" -o $exePath
65+
& curl.exe -L $exeUrl -o $exePath
8066
Start-Process -FilePath $exePath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /NoAutoStart"
8167
Start-Sleep -Seconds 100
8268
Stop-Process -Name "UniGetUI.exe" -Force
@@ -86,8 +72,10 @@ if ($UniGetUI) {
8672

8773
if ($FluentTerminal) {
8874
Write-Output "Downloading Fluent Terminal..."
75+
$githubApi = Invoke-RestMethod "https://api.github.com/repos/felixse/FluentTerminal/releases/latest" -EA 0
76+
$zipUrl = $githubApi.assets.browser_download_url | Where-Object { $_ -like "*.zip" } | Select-Object -First 1
8977
$zipPath = Join-Path $tempDir "FluentTerminal.Package_0.7.7.0.zip"
90-
& curl.exe -L "https://github.com/felixse/FluentTerminal/releases/download/0.7.7.0/FluentTerminal.Package_0.7.7.0.zip" -o $zipPath
78+
& curl.exe -L $zipUrl -o $zipPath
9179
Expand-Archive -Path $zipPath -DestinationPath $tempDir
9280
Add-AppxPackage -Path "$tempDir\FluentTerminal.Package_0.7.7.0_x86_x64.msixbundle"
9381
Write-Output "Fluent Terminal Installed."

0 commit comments

Comments
 (0)