mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-23 22:16:48 +00:00
feat(redis-commander): add PowerShell installer + update POSIX installer
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
###########################
|
||||
# Install redis-commander #
|
||||
###########################
|
||||
|
||||
function command-v-silent($cmdname) {
|
||||
$my_cmd = Get-Command $command -ErrorAction SilentlyContinue
|
||||
# $my_path = $my_cmd | Select-Object -ExpandProperty Definition
|
||||
|
||||
if ($my_cmd) {
|
||||
return True
|
||||
}
|
||||
return False
|
||||
}
|
||||
|
||||
function mktemp-d-t() {
|
||||
# create random suffix for dirname
|
||||
$my_bytes = New-Object byte[] 4
|
||||
$my_rng = [Security.Cryptography.RNGCryptoServiceProvider]::Create()
|
||||
$my_rng.GetBytes($bytes)
|
||||
$my_hex_delimited = [BitConverter]::ToString($bytes)
|
||||
$my_hex = $my_hex_delimited -replace "-", ""
|
||||
|
||||
# create random directory
|
||||
$my_systmpdir = [System.IO.Path]::GetTempPath()
|
||||
$my_tmpdir = Join-Path "$my_systmpdir" "$my_hex"
|
||||
New-Item -ItemType Directory -Path "$my_tmpdir"
|
||||
|
||||
return "$my_tmpdir"
|
||||
}
|
||||
|
||||
function npm-install-global($pkgname) {
|
||||
# Fetch npm package manager
|
||||
Write-Output "Checking for npm..."
|
||||
if (-Not (command-v-silent("npm"))) {
|
||||
& "$Env:USERPROFILE\.local\bin\webi-pwsh.ps1" node
|
||||
}
|
||||
|
||||
if (command-v-silent($pkgname)) {
|
||||
$my_cmd = Get-Command $pkgname
|
||||
$my_cmd Select-Object -ExpandProperty Definition
|
||||
Write-Host "Found '$my_cmd'"
|
||||
return
|
||||
}
|
||||
|
||||
$my_tmpdir = mktemp-d-t()
|
||||
|
||||
# npm install works best from a directory with no package.json
|
||||
Push-Location "$my_tmpdir"
|
||||
if (command-v-silent("npm")) {
|
||||
& npm --location-golbal redis-commander
|
||||
}
|
||||
else {
|
||||
& "$Env:USERPROFILE\.local\opt\node\npm" --location-golbal "$pkgname"
|
||||
}
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
npm-install-global redis-commander
|
||||
@@ -3,11 +3,19 @@ set -e
|
||||
set -u
|
||||
|
||||
__init_redis_commander() {
|
||||
if [ -z "$(npm --version 2> /dev/null)" ]; then
|
||||
"$HOME/.local/bin/webi" node
|
||||
if test -z "$(npm --version 2> /dev/null)"; then
|
||||
~/.local/bin/webi node
|
||||
export PATH="$HOME/.local/opt/node/bin:$PATH"
|
||||
fi
|
||||
npm install -g redis-commander@latest
|
||||
|
||||
# In recent versions of node (~v18+), npm:
|
||||
# - requires '--location=global' rather than '-g'
|
||||
# - will modify 'package.json' when it shouldn't
|
||||
my_tmpdir="$(mktemp -d -t "webi-npm-tmp.XXXXXXXXXX")"
|
||||
(
|
||||
cd "${my_tmpdir}" || exit 1
|
||||
npm install --location=global redis-commander@latest
|
||||
)
|
||||
}
|
||||
|
||||
__init_redis_commander
|
||||
|
||||
Reference in New Issue
Block a user