Fix installers and tests

This commit is contained in:
thePR0M3TH3AN
2025-06-19 19:22:27 -04:00
parent 572f078445
commit 0cbd5ef607
5 changed files with 119 additions and 42 deletions

View File

@@ -17,10 +17,10 @@ See [docs/usage.md](docs/usage.md) for detailed usage instructions.
Run the installer to set up the core dependencies and install the `voxvera` CLI. Run the installer to set up the core dependencies and install the `voxvera` CLI.
The script installs Tor, OnionShare, `jq`, `qrencode`, and ImageMagick before The script installs Tor, OnionShare, `jq`, `qrencode`, and ImageMagick before
fetching the latest release of the CLI. Other prerequisites like Node.js, fetching the latest release of the CLI. Run `setup.sh` to install additional
`javascript-obfuscator`, `html-minifier-terser`, and the Python packages dependencies such as Node.js, `javascript-obfuscator`, `html-minifier-terser`,
`InquirerPy` and `rich` are not installed automatically. Run `setup.sh` or and the Python packages `InquirerPy` and `rich` if they are not already
install those packages manually if they are missing. available.
If you already have the prerequisites you can install the package directly from If you already have the prerequisites you can install the package directly from
PyPI: PyPI:
@@ -95,14 +95,14 @@ globally:
npm install -g javascript-obfuscator html-minifier-terser npm install -g javascript-obfuscator html-minifier-terser
``` ```
Install the Python dependencies: `setup.sh` also installs the required Python packages automatically. If you
prefer to install them manually, run:
```bash ```bash
pip install --user InquirerPy rich pip install --user InquirerPy rich
``` ```
A helper script `setup.sh` is provided to check for these dependencies and The script checks for these dependencies and installs anything that is missing.
install anything that is missing.
### Windows ### Windows

View File

@@ -5,25 +5,33 @@ LOG_DIR="$(pwd)/ci-logs"
mkdir -p "$LOG_DIR" mkdir -p "$LOG_DIR"
exec >"$LOG_DIR/run.log" 2>&1 exec >"$LOG_DIR/run.log" 2>&1
# Install VoxVera from the local repository and time it # Install VoxVera
{ time pip install -e .; } 2>&1 if [ -n "${VOXVERA_BIN:-}" ]; then
voxvera_cmd="$VOXVERA_BIN"
echo "Using provided VoxVera binary: $voxvera_cmd" >&2
else
{ time pip install -e .; } 2>&1
voxvera_cmd="$(command -v voxvera)"
fi
# Generate demo flyer # Generate demo flyer
voxvera init --template voxvera <<EOI "$voxvera_cmd" init --template voxvera <<EOI
DemoUser DemoUser
demosite demosite
EOI EOI
voxvera build "$voxvera_cmd" build
ls -R dist >>"$LOG_DIR/tree.txt" ls -R dist >>"$LOG_DIR/tree.txt"
# Start Tor # Optional network tests
tor >"$LOG_DIR/tor.log" 2>&1 & if [ "${VOXVERA_E2E_OFFLINE:-}" != "1" ]; then
TOR_PID=$! # Start Tor
sleep 10 tor >"$LOG_DIR/tor.log" 2>&1 &
TOR_PID=$!
sleep 10
# Start OnionShare # Start OnionShare
onionshare-cli --website --public --persistent dist/demosite/.onionshare-session dist/demosite >"$LOG_DIR/onionshare.log" 2>&1 & onionshare-cli --website --public --persistent dist/demosite/.onionshare-session dist/demosite >"$LOG_DIR/onionshare.log" 2>&1 &
OS_PID=$! OS_PID=$!
# Wait for URL # Wait for URL
URL="" URL=""
@@ -52,7 +60,11 @@ curl --socks5-hostname 127.0.0.1:9050 "$URL" | grep -q '<title>'
# Clean up # Clean up
kill $OS_PID kill $OS_PID
kill $TOR_PID kill $TOR_PID
wait $OS_PID 2>/dev/null || true wait $OS_PID 2>/dev/null || true
wait $TOR_PID 2>/dev/null || true wait $TOR_PID 2>/dev/null || true
else
echo "Skipping network-dependent tests" >&2
exit 0
fi
exit 0 exit 0

View File

@@ -39,13 +39,32 @@ function Install-PipFallback {
} }
} }
function Install-PipRepoFallback {
if (Get-Command pip -ErrorAction SilentlyContinue) {
try {
pip install --user git+https://github.com/PR0M3TH3AN/VoxVera
Write-Host 'VoxVera installed successfully from repository.'
exit 0
} catch {
Write-Error 'pip installation from repository failed.'
exit 1
}
} else {
Write-Error 'pip not found for fallback installation.'
exit 1
}
}
function Download-Binary { function Download-Binary {
param([string]$Url, [string]$Dest) param([string]$Url, [string]$Dest)
try { try {
Invoke-WebRequest -Uri $Url -OutFile $Dest -ErrorAction Stop $response = Invoke-WebRequest -Uri $Url -OutFile $Dest -ErrorAction Stop
return $true return $response.StatusCode
} catch { } catch {
return $false if ($_.Exception.Response) {
return $_.Exception.Response.StatusCode.value__
}
return 0
} }
} }
@@ -66,11 +85,15 @@ if (Get-Command pipx -ErrorAction SilentlyContinue) {
$dest = Join-Path $home '.local\bin' $dest = Join-Path $home '.local\bin'
New-Item -ItemType Directory -Path $dest -Force | Out-Null New-Item -ItemType Directory -Path $dest -Force | Out-Null
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe' $url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
if (-not (Download-Binary $url "$dest/voxvera.exe")) { $status = Download-Binary $url "$dest/voxvera.exe"
if ($status -eq 200) {
Check-LocalBin
} elseif ($status -eq 404) {
Write-Host 'Release asset not found, installing from repository'
Install-PipRepoFallback
} else {
Write-Host 'Binary download failed, falling back to pip' Write-Host 'Binary download failed, falling back to pip'
Install-PipFallback Install-PipFallback
} else {
Check-LocalBin
} }
} }
} else { } else {
@@ -78,11 +101,15 @@ if (Get-Command pipx -ErrorAction SilentlyContinue) {
$dest = Join-Path $home '.local\bin' $dest = Join-Path $home '.local\bin'
New-Item -ItemType Directory -Path $dest -Force | Out-Null New-Item -ItemType Directory -Path $dest -Force | Out-Null
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe' $url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
if (-not (Download-Binary $url "$dest/voxvera.exe")) { $status = Download-Binary $url "$dest/voxvera.exe"
if ($status -eq 200) {
Check-LocalBin
} elseif ($status -eq 404) {
Write-Host 'Release asset not found, installing from repository'
Install-PipRepoFallback
} else {
Write-Host 'Binary download failed, falling back to pip' Write-Host 'Binary download failed, falling back to pip'
Install-PipFallback Install-PipFallback
} else {
Check-LocalBin
} }
} }

View File

@@ -65,12 +65,24 @@ download_binary() {
local url=$1 local url=$1
local dest=$2 local dest=$2
if command_exists curl; then if command_exists curl; then
curl -fsSL "$url" -o "$dest" || return 1 local status
status=$(curl -w "%{http_code}" -fsSL "$url" -o "$dest" || true)
if [ "$status" = "404" ]; then
return 2
elif [ "$status" != "200" ]; then
return 1
fi
elif command_exists wget; then elif command_exists wget; then
wget -q "$url" -O "$dest" || return 1 local out
out=$(wget --server-response -q "$url" -O "$dest" 2>&1 || true)
if echo "$out" | grep -q "404 Not Found"; then
return 2
elif ! echo "$out" | grep -q "200 OK"; then
return 1
fi
else else
echo "Install curl or wget to download voxvera" >&2 echo "Install curl or wget to download voxvera" >&2
return 2 return 1
fi fi
chmod +x "$dest" chmod +x "$dest"
} }
@@ -95,6 +107,20 @@ pip_fallback() {
exit 1 exit 1
} }
pip_repo_fallback() {
if command_exists pip; then
echo "Attempting pip install from repository as fallback..."
if pip install --user git+https://github.com/PR0M3TH3AN/VoxVera; then
echo "VoxVera installed successfully from repository."
exit 0
fi
echo "pip installation from repository failed." >&2
else
echo "pip not found for fallback installation" >&2
fi
exit 1
}
if command_exists pipx; then if command_exists pipx; then
if ! pipx install --force voxvera; then if ! pipx install --force voxvera; then
echo "pipx install failed, downloading binary" echo "pipx install failed, downloading binary"
@@ -102,11 +128,17 @@ if command_exists pipx; then
mkdir -p "$install_dir" mkdir -p "$install_dir"
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera" url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
dest="$install_dir/voxvera" dest="$install_dir/voxvera"
if ! download_binary "$url" "$dest"; then if download_binary "$url" "$dest"; then
echo "Binary download failed, falling back to pip." >&2
pip_fallback
else
check_local_bin check_local_bin
else
rc=$?
echo "Binary download failed." >&2
if [ $rc -eq 2 ]; then
echo "Release asset not found, installing from repository." >&2
pip_repo_fallback
else
pip_fallback
fi
fi fi
fi fi
else else
@@ -114,11 +146,17 @@ else
mkdir -p "$install_dir" mkdir -p "$install_dir"
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera" url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
dest="$install_dir/voxvera" dest="$install_dir/voxvera"
if ! download_binary "$url" "$dest"; then if download_binary "$url" "$dest"; then
echo "Binary download failed, falling back to pip." >&2
pip_fallback
else
check_local_bin check_local_bin
else
rc=$?
echo "Binary download failed." >&2
if [ $rc -eq 2 ]; then
echo "Release asset not found, installing from repository." >&2
pip_repo_fallback
else
pip_fallback
fi
fi fi
fi fi

View File

@@ -41,11 +41,11 @@ done
# ensure Python packages used by the CLI are available # ensure Python packages used by the CLI are available
for py in InquirerPy rich; do for py in InquirerPy rich; do
python3 - <<EOF >/dev/null 2>&1 if ! python3 - <<EOF >/dev/null 2>&1
import importlib.util, sys import importlib.util, sys
sys.exit(0 if importlib.util.find_spec('$py') else 1) sys.exit(0 if importlib.util.find_spec('$py') else 1)
EOF EOF
if [ $? -ne 0 ]; then then
pip install --user "$py" pip install --user "$py"
fi fi
done done