install.ps1 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env pwsh
  2. $ErrorActionPreference = 'Stop'
  3. if ($v) {
  4. $Version = "v${v}"
  5. }
  6. if ($Args.Length -eq 1) {
  7. $Version = $Args.Get(0)
  8. }
  9. $DxInstall = $env:DX_INSTALL
  10. $BinDir = if ($DxInstall) {
  11. "${DxInstall}\bin"
  12. } else {
  13. "${Home}\.dx\bin"
  14. }
  15. $DxZip = "$BinDir\dx.zip"
  16. $DxExe = "$BinDir\dx.exe"
  17. $Target = 'x86_64-pc-windows-msvc'
  18. $DownloadUrl = if (!$Version) {
  19. "https://github.com/dioxuslabs/dioxus/releases/latest/download/dx-${target}.zip"
  20. } else {
  21. "https://github.com/dioxuslabs/dioxus/releases/download/${Version}/dx-${target}.zip"
  22. }
  23. if (!(Test-Path $BinDir)) {
  24. New-Item $BinDir -ItemType Directory | Out-Null
  25. }
  26. curl.exe --ssl-revoke-best-effort -Lo $DxZip $DownloadUrl
  27. tar.exe xf $DxZip -C $BinDir
  28. Remove-Item $DxZip
  29. $CargoBin = "${Home}\.cargo\bin"
  30. if (!(Test-Path $CargoBin)) {
  31. New-Item $CargoBin -ItemType Directory | Out-Null
  32. }
  33. Copy-Item $DxExe "$CargoBin\dx.exe" -Force
  34. # $User = [System.EnvironmentVariableTarget]::User
  35. # $Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
  36. # if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
  37. # [System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User)
  38. # $Env:Path += ";${BinDir}"
  39. # }
  40. Write-Output "dx was installed successfully! 💫"
  41. Write-Output "Run 'dx --help' to get started"