Last active
October 23, 2015 19:55
-
-
Save guillermooo/f579fdb84aab4bc488da to your computer and use it in GitHub Desktop.
Update Dart manifest for Scoop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO(guillermooo): add dartium manifest | |
function getManifest { | |
param($url) | |
invoke-restmethod $url | |
} | |
function getLatestVersion { | |
param($manifest) | |
invoke-restmethod $manifest.checkver.url | select -expandproperty version | |
} | |
function getCheckSum { | |
param($manifest, $arch) | |
$type = "$($arch)bit" | |
[void] ((invoke-restmethod "$($manifest.architecture.$type.url).sha256sum") -match "^(.+?)\s") | |
$matches.1 | |
} | |
function buildUrl { | |
param($manifest, $arch, $latestVersion) | |
$url = [System.Uri] $manifest.architecture."$($arch)bit".url | |
$segments = $url.segments | |
$segments[5] = "$latestVersion/" | |
[System.UriBuilder]::new($url.scheme, $url.host, -1, $($segments -join '')).ToString() | |
} | |
function updateManifest { | |
param($url) | |
$manifest = getManifest $url | |
$latestVersion = getLatestVersion $manifest | |
if ($latestVersion -eq $manifest.version) { | |
return | |
} | |
$manifest.version = $latestVersion | |
$manifest.architecture."64bit".url = buildUrl $manifest 64 $latestVersion | |
$manifest.architecture."32bit".url = buildUrl $manifest 32 $latestVersion | |
$manifest.architecture."64bit".hash = getCheckSum $manifest 64 | |
$manifest.architecture."32bit".hash = getCheckSum $manifest 32 | |
$manifest | |
} | |
function writeManifest { | |
param($manifest, $fileName) | |
if ($manifest -eq $null) { | |
write-output "Dart manifest is up to date: $fileName." | |
return | |
} | |
$manifest | convertto-json | out-file $fileName -encoding ascii | |
write-output "Updated manifest: $fileName." | |
} | |
$stableManifest = "https://raw.githubusercontent.com/lukesampson/scoop/master/bucket/dart.json" | |
$devManifest = "https://raw.githubusercontent.com/lukesampson/scoop-extras/master/dart-dev.json" | |
writeManifest (updateManifest $stableManifest) "dart.json" | |
writeManifest (updateManifest $devManifest) "dart-dev.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment