Skip to content

Instantly share code, notes, and snippets.

@devoncarew
Forked from guillermooo/updateDartManifestForScoop.ps1
Last active October 23, 2015 19:56
Show Gist options
  • Save devoncarew/2e7214073d6a7252936a to your computer and use it in GitHub Desktop.
Save devoncarew/2e7214073d6a7252936a to your computer and use it in GitHub Desktop.
Update Dart manifest for Scoop
{
"version": "1.13.0-dev.7.3",
"license": "BSD",
"homepage": "https://www.dartlang.org/",
"extract_dir": "dart-sdk",
"env_add_path": [
"bin"
],
"architecture": {
"64bit": {
"url": "https://storage.googleapis.com/dart-archive/channels/dev/release/1.13.0-dev.7.3/sdk/dartsdk-windows-x64-release.zip",
"hash": "510cc9037f3d1000990e30b0e83808d2293b24e679bfab0321cce0dba35aed41"
},
"32bit": {
"url": "https://storage.googleapis.com/dart-archive/channels/dev/release/1.13.0-dev.7.3/sdk/dartsdk-windows-ia32-release.zip",
"hash": "da0fc25f9d11bcf2d43fa0f4a0d6bda0d1c9d70fbae2a9ff27465a0d1d9198eb"
}
},
"checkver": {
"url": "http://storage.googleapis.com/dart-archive/channels/dev/release/latest/VERSION",
"re": "\\s*\"version\"\\s*:\\s*(\\d+\\.\\d+\\.\\d+.*)"
}
}
{
"version": "1.12.2",
"license": "BSD",
"homepage": "https://www.dartlang.org/",
"extract_dir": "dart-sdk",
"env_add_path": [
"bin"
],
"architecture": {
"64bit": {
"url": "https://storage.googleapis.com/dart-archive/channels/stable/release/1.12.2/sdk/dartsdk-windows-x64-release.zip",
"hash": "6fba96dbdaa8169e2c6a6ed5ea0f490c1ef41509aa51f88d7ebd6d5a60ef7091"
},
"32bit": {
"url": "https://storage.googleapis.com/dart-archive/channels/stable/release/1.12.2/sdk/dartsdk-windows-ia32-release.zip",
"hash": "fc1ab8d53caf1eaa63273ca10e64e467ca0721bca91e97281f35cd3c4f6d1b9d"
}
},
"checkver": {
"url": "http://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION",
"re": "\\s*\"version\"\\s*:\\s*(\\d+\\.\\d+\\.\\d+.*)"
}
}
# 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