Skip to content

Commit

Permalink
refactor: use enum instead of string values to acces platform archive…
Browse files Browse the repository at this point in the history
… map in setup more safely
  • Loading branch information
ttytm committed May 28, 2024
1 parent f24d8b1 commit 39eb6b3
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions setup.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ import os
import v.pref
import net.http

// Latest tag that should is tested with the wrapper.
// Other versions might include breaking changes.
// Last WebUI tag that is known to work with the wrapper. Other versions may contain breaking changes.
// It must be available in webui's repository e.g., `https://github.com/webui-dev/webui/releases/tag/2.4.2/`
const webui_version = '2.4.2'
const platform = pref.get_host_os()
const arch = pref.get_host_arch()
const base_url = 'https://github.com/webui-dev/webui/releases'
const archives = {
'Linux': {
'amd64': 'webui-linux-gcc-x64.zip'
'aarch64': 'webui-linux-gcc-arm64.zip'
'arm64': 'webui-linux-gcc-arm64.zip'
'arm32': 'webui-linux-gcc-arm.zip'
pref.OS.linux: {
pref.Arch.amd64: 'webui-linux-gcc-x64.zip'
.arm64: 'webui-linux-gcc-arm64.zip'
.arm32: 'webui-linux-gcc-arm.zip'
}
'MacOS': {
'amd64': 'webui-macos-clang-x64.zip'
'arm64': 'webui-macos-clang-arm64.zip'
.macos: {
pref.Arch.amd64: 'webui-macos-clang-x64.zip'
.arm64: 'webui-macos-clang-arm64.zip'
}
'Windows': {
'amd64': 'webui-windows-gcc-x64.zip'
.windows: {
pref.Arch.amd64: 'webui-windows-gcc-x64.zip'
}
}

Expand All @@ -41,9 +40,9 @@ fn run(cmd cli.Command) ! {
rmdir_all(out_dir) or {}
}

archive := archives[platform.str()] or {
archive := archives[platform] or {
return error('The setup script currently does not support `${platform}`.')
}[arch.str()] or {
}[arch] or {
return error('The setup script currently does not support `${arch}` architectures on `${platform}`.')
}

Expand Down

0 comments on commit 39eb6b3

Please sign in to comment.