@@ -4,21 +4,57 @@ if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]:
4
4
Write-Host " You cannot install vein-sdk from under the administrator." - ForegroundColor Red
5
5
exit 1
6
6
}
7
+ $env: RUNE_NOVID = " 1" ;
8
+ $env: VEINC_NOVID = " 1" ;
7
9
8
10
$apiUrl = " https://releases.vein-lang.org/api/get-release"
9
11
10
12
$outputDir = " $HOME \.vein"
11
13
12
- function DownloadFile ($url , $outputFile ) {
13
- $webClient = New-Object System.Net.WebClient
14
- $webClient.DownloadFile ($url , $outputFile )
14
+ function DownloadFile {
15
+ param (
16
+ [string ]$url ,
17
+ [string ]$outputFile
18
+ )
19
+
20
+ $fileStream = $null
21
+ $stream = $null
22
+
23
+ try {
24
+ $request = [System.Net.HttpWebRequest ]::Create($url )
25
+ $request.Method = " GET"
26
+ $response = $request.GetResponse ()
27
+ $totalBytes = $response.ContentLength
28
+ $stream = $response.GetResponseStream ()
29
+ $fileStream = [System.IO.File ]::Create($outputFile )
30
+ $buffer = New-Object byte[] 8192
31
+ $totalReadBytes = 0
32
+ while ($true ) {
33
+ $readBytes = $stream.Read ($buffer , 0 , $buffer.Length )
34
+ if ($readBytes -le 0 ) { break }
35
+ $fileStream.Write ($buffer , 0 , $readBytes )
36
+ $totalReadBytes += $readBytes
37
+ $percentComplete = [math ]::Round(($totalReadBytes / $totalBytes ) * 100 , 2 )
38
+ Write-Progress - Activity " Downloading $url " - Status " $percentComplete % Complete" - PercentComplete $percentComplete
39
+ }
40
+ } finally {
41
+ if ($fileStream ) {
42
+ $fileStream.Close ()
43
+ }
44
+ if ($stream ) {
45
+ $stream.Close ()
46
+ }
47
+ Write-Progress - Activity " Downloading $url " - Status " Download Complete" - Completed
48
+ }
15
49
}
16
50
51
+
17
52
try {
18
53
$releaseInfo = Invoke-RestMethod - Uri $apiUrl
19
54
$asset = $releaseInfo.assets | Where-Object { $_.name -eq " rune.$arch .zip" }
20
55
$downloadUrl = $asset.browser_download_url
21
- Write-Output $downloadUrl
56
+ $tagVersion = $releaseInfo.tag_name.Replace (" v" , " " )
57
+ Write-Host $tagVersion
22
58
New-Item - ItemType Directory - Force - Path $outputDir > $null
23
59
$zipFile = " $outputDir \rune.$arch .zip"
24
60
DownloadFile $downloadUrl $zipFile
@@ -30,10 +66,22 @@ try {
30
66
[Environment ]::SetEnvironmentVariable(" Path" , $env: Path , [EnvironmentVariableTarget ]::User)
31
67
}
32
68
69
+ Invoke-Expression " $outputDir \rune.exe telemetry"
70
+
71
+ if ($LASTEXITCODE -ne 0 ) {
72
+ exit $LASTEXITCODE
73
+ }
74
+
33
75
$installWorkloads = Read-Host " Do you want to install vein.runtime and vein.compiler workloads? (y/n)"
34
76
if ($installWorkloads -eq ' y' ) {
35
- Invoke-Expression " $outputDir \rune.exe workload install [email protected] "
36
- Invoke-Expression " $outputDir \rune.exe workload install [email protected] "
77
+ Invoke-Expression " $outputDir \rune.exe workload install vein.runtime@$tagVersion "
78
+ if ($LASTEXITCODE -ne 0 ) {
79
+ exit $LASTEXITCODE
80
+ }
81
+ Invoke-Expression " $outputDir \rune.exe workload install vein.compiler@$tagVersion "
82
+ if ($LASTEXITCODE -ne 0 ) {
83
+ exit $LASTEXITCODE
84
+ }
37
85
Write-Output " Workloads installed."
38
86
} else {
39
87
Write-Output " Workloads installation skipped."
0 commit comments