Skip to content

Commit

Permalink
Update MongoDB CLI scripts to use environment variable for package name
Browse files Browse the repository at this point in the history
  • Loading branch information
Utesgui authored Apr 30, 2024
1 parent 813f3ef commit 6411ad6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Scripts/Update-MongoDB.MongoDBAtlasCLI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ else {
exit 1
}

#$wingetPackage = ${Env:PackageName}
$wingetPackage = ${Env:PackageName}
$url = ${Env:WebsiteURL}
$PackageFilter = ${Env:PackageFilter}


Write-Host "Try to update MongoDB Tools"
Write-Host "Try to update $wingetPackage"

# Download the webpage
$website = Invoke-WebRequest -Uri $url
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Update-MongoDB.MongoDBCLI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ else {
exit 1
}

#$wingetPackage = ${Env:PackageName}
$wingetPackage = ${Env:PackageName}
$url = ${Env:WebsiteURL}
$PackageFilter = ${Env:PackageFilter}

Write-Host "Try to update MongoDB Tools"
Write-Host "Try to update wingetPackage"

# Download the webpage
$website = Invoke-WebRequest -Uri $url
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Update-MongoDB.Shell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $content = $website.Content

# Find all strings that look like links and end with .msi
$links = $content | Select-String -Pattern 'https?://[^"]+' -AllMatches | % { $_.Matches } | % { $_.Value }
$mongoshlinks = $links | Select-String -Pattern 'https?://[^\s]*mongosh[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
$Packagelinks = $links | Select-String -Pattern 'https?://[^\s]*mongosh[^\s]*\.msi' -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
# Extract versions from the links
$versions = $Packagelinks | ForEach-Object { $_ -match '(\d+\.\d+\.\d+(-rc\d*|-beta\d*)?)' | Out-Null; $matches[1] }

Expand All @@ -29,7 +29,7 @@ $stableVersions = $versions | Where-Object { $_ -notmatch '(-rc|beta)' }

# Sort the versions and get the latest one
$latestVersion = $stableVersions | Sort-Object {[Version]$_} | Select-Object -Last 1
$latestVersionUrl = $mongoshlinks | Where-Object { $_ -match $latestVersion }
$latestVersionUrl = $Packagelinks | Where-Object { $_ -match $latestVersion }


Write-Host "Version found: $latestVersion"
Expand Down

0 comments on commit 6411ad6

Please sign in to comment.