Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: more PowerShell cleanup and such #749

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _webi/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var arches = [
// https://git.com/org/foo/releases/v0.7.9/foo-x86_64-linux-musl.tar.gz
//
var archMap = {
armv7l: /(\b|_)(armv?7l?)/i,
armv7l: /(\b|_)(arm32|armv?7l?)/i,
//amd64: /(amd.?64|x64|[_\-]64)/i,
amd64:
/(\b|_|amd|(dar)?win(dows)?|mac(os)?|linux|osx|x)64([_\-]?bit)?(\b|_)/i,
Expand Down
2 changes: 1 addition & 1 deletion _webi/ua-detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getArch(ua) {

if (/aarch64|arm64|arm8|armv8/i.test(ua)) {
return 'arm64';
} else if (/aarch|arm7|armv7/i.test(ua)) {
} else if (/aarch|arm7|armv7|arm32/i.test(ua)) {
return 'armv7l';
} else if (/arm6|armv6/i.test(ua)) {
return 'armv6l';
Expand Down
38 changes: 22 additions & 16 deletions webi/webi-pwsh.ps1
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Set-ExecutionPolicy -Scope Process Bypass
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

$my_version = 'v1.1.16'
$my_version = 'v1.2.0'

IF ($null -eq $Env:WEBI_HOST -or $Env:WEBI_HOST -eq "") {
$Env:WEBI_HOST = "https://webinstall.dev"
Expand Down Expand Up @@ -125,23 +125,25 @@ function Show-HowToUpdateEnv {
Write-Host ""
}

# Switch to userprofile
Push-Location $Env:USERPROFILE
function Install-Webi {
# Make paths if needed
# TODO replace all bin with opt\bin\
$null = New-Item -Path "$HOME\.local\bin\" -ItemType Directory -Force
$null = New-Item -Path "$HOME\.local\opt\" -ItemType Directory -Force

# Make paths if needed
# TODO replace all bin with opt\bin\
New-Item -Path "$HOME\.local\bin\" -ItemType Directory -Force | Out-Null
# See note on Set-ExecutionPolicy above
Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass %USERPROFILE%\.local\bin\webi-pwsh.ps1 %*"

# See note on Set-ExecutionPolicy above
Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass %USERPROFILE%\.local\bin\webi-pwsh.ps1 %*"
# Backwards-compat bugfix: remove old webi-pwsh.ps1 location
Remove-Item -Path "$HOME\.local\bin\webi.ps1" -Recurse -ErrorAction Ignore
if (!(Test-Path -Path "$HOME\.local\opt")) {
New-Item -Path "$HOME\.local\opt" -ItemType Directory -Force | Out-Null
}
# TODO windows version of mktemp -d
if (!(Test-Path -Path "$HOME\.local\tmp")) {
New-Item -Path "$HOME\.local\tmp" -ItemType Directory -Force | Out-Null
# Backwards-compat bugfix: remove old webi-pwsh.ps1 location
Remove-Item -Path "$HOME\.local\bin\webi.ps1" -Recurse -ErrorAction Ignore

# TODO windows version of mktemp -d
IF (Test-Path -Path "$HOME\.local\tmp") {
Write-Host " Found $HOME\.local\tmp\"
} ELSE {
Write-Host " Creating $HOME\.local\tmp\"
$null = New-Item -Path "$HOME\.local\tmp" -ItemType Directory -Force | Out-Null
}
}

## show help if no params given or help flags are used
Expand Down Expand Up @@ -180,11 +182,15 @@ if ($exename -eq "-V" -or $exename -eq "--version" -or $exename -eq "version" -o
exit 0
}

# Switch to userprofile
Push-Location $Env:USERPROFILE

$Env:WEBI_UA = Get-UserAgent

IF ($IsWebiParent) {
Write-Host ""
Write-Host "${TName}Welcome to${TReset} ${TTask}Webi${TReset}${TName}!${TReset} - Instant Installs, Easy to Remember URLs"
Write-Host "${TDim}($Env:WEBI_UA)${TReset}"
Write-Host ""
}

Expand Down
Empty file modified webi/webi.sh
100644 → 100755
Empty file.
Loading