mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Add --include-python and --ci args
This commit is contained in:
parent
eddb4f3f75
commit
b60cb63fdb
2 changed files with 92 additions and 9 deletions
|
|
@ -1,6 +1,23 @@
|
||||||
# Downloads and installs safe-chain for Windows
|
# Downloads and installs safe-chain for Windows
|
||||||
# Usage: iex (iwr "https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.ps1" -UseBasicParsing)
|
#
|
||||||
|
# Usage examples:
|
||||||
|
#
|
||||||
|
# Default (JavaScript packages only):
|
||||||
|
# iex (iwr "https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.ps1" -UseBasicParsing)
|
||||||
|
#
|
||||||
|
# CI setup (JavaScript packages only):
|
||||||
|
# iex "& { $(iwr 'https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.ps1' -UseBasicParsing) } -ci"
|
||||||
|
#
|
||||||
|
# Include Python packages:
|
||||||
|
# iex "& { $(iwr 'https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.ps1' -UseBasicParsing) } -includepython"
|
||||||
|
#
|
||||||
|
# CI setup with Python packages:
|
||||||
|
# iex "& { $(iwr 'https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.ps1' -UseBasicParsing) } -ci -includepython"
|
||||||
|
|
||||||
|
param(
|
||||||
|
[switch]$ci,
|
||||||
|
[switch]$includepython
|
||||||
|
)
|
||||||
|
|
||||||
$Version = "v0.0.4-binaries-beta"
|
$Version = "v0.0.4-binaries-beta"
|
||||||
$InstallDir = Join-Path $env:USERPROFILE ".safe-chain\bin"
|
$InstallDir = Join-Path $env:USERPROFILE ".safe-chain\bin"
|
||||||
|
|
@ -139,19 +156,32 @@ function Install-SafeChain {
|
||||||
|
|
||||||
Write-Info "Binary installed to: $finalFile"
|
Write-Info "Binary installed to: $finalFile"
|
||||||
|
|
||||||
|
# Build setup command based on parameters
|
||||||
|
$setupCmd = if ($ci) { "setup-ci" } else { "setup" }
|
||||||
|
$setupArgs = @()
|
||||||
|
if ($includepython) {
|
||||||
|
$setupArgs += "--include-python"
|
||||||
|
}
|
||||||
|
|
||||||
# Execute safe-chain setup
|
# Execute safe-chain setup
|
||||||
|
Write-Info "Running safe-chain $setupCmd $(if ($setupArgs) { $setupArgs -join ' ' })..."
|
||||||
try {
|
try {
|
||||||
$env:Path = "$env:Path;$InstallDir"
|
$env:Path = "$env:Path;$InstallDir"
|
||||||
& $finalFile setup
|
|
||||||
|
if ($setupArgs) {
|
||||||
|
& $finalFile $setupCmd $setupArgs
|
||||||
|
} else {
|
||||||
|
& $finalFile $setupCmd
|
||||||
|
}
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Warn "safe-chain was installed but setup encountered issues."
|
Write-Warn "safe-chain was installed but setup encountered issues."
|
||||||
Write-Warn "You can run 'safe-chain setup' manually later."
|
Write-Warn "You can run 'safe-chain $setupCmd $(if ($setupArgs) { $setupArgs -join ' ' })' manually later."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Warn "safe-chain was installed but setup encountered issues: $_"
|
Write-Warn "safe-chain was installed but setup encountered issues: $_"
|
||||||
Write-Warn "You can run 'safe-chain setup' manually later."
|
Write-Warn "You can run 'safe-chain $setupCmd $(if ($setupArgs) { $setupArgs -join ' ' })' manually later."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,24 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Downloads and installs safe-chain, depending on the operating system and architecture
|
# Downloads and installs safe-chain, depending on the operating system and architecture
|
||||||
# Usage: curl -fsSL https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh
|
#
|
||||||
# or: wget -qO- https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh
|
# Usage examples:
|
||||||
|
#
|
||||||
|
# Default (JavaScript packages only):
|
||||||
|
# curl -fsSL https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh
|
||||||
|
# wget -qO- https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh
|
||||||
|
#
|
||||||
|
# CI setup (JavaScript packages only):
|
||||||
|
# curl -fsSL https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh -s -- --ci
|
||||||
|
# wget -qO- https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh -s -- --ci
|
||||||
|
#
|
||||||
|
# Include Python packages:
|
||||||
|
# curl -fsSL https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh -s -- --include-python
|
||||||
|
# wget -qO- https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh -s -- --include-python
|
||||||
|
#
|
||||||
|
# CI setup with Python packages:
|
||||||
|
# curl -fsSL https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh -s -- --ci --include-python
|
||||||
|
# wget -qO- https://raw.githubusercontent.com/AikidoSec/safe-chain/main/install-scripts/install-safe-chain.sh | sh -s -- --ci --include-python
|
||||||
|
|
||||||
set -e # Exit on error
|
set -e # Exit on error
|
||||||
|
|
||||||
|
|
@ -109,8 +125,32 @@ check_volta_installation() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse command-line arguments
|
||||||
|
parse_arguments() {
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--ci)
|
||||||
|
USE_CI_SETUP=true
|
||||||
|
;;
|
||||||
|
--include-python)
|
||||||
|
INCLUDE_PYTHON=true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "Unknown argument: $arg"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Main installation
|
# Main installation
|
||||||
main() {
|
main() {
|
||||||
|
# Initialize argument flags
|
||||||
|
USE_CI_SETUP=false
|
||||||
|
INCLUDE_PYTHON=false
|
||||||
|
|
||||||
|
# Parse command-line arguments
|
||||||
|
parse_arguments "$@"
|
||||||
|
|
||||||
info "Installing safe-chain ${VERSION}..."
|
info "Installing safe-chain ${VERSION}..."
|
||||||
|
|
||||||
# Check for existing npm installation
|
# Check for existing npm installation
|
||||||
|
|
@ -146,11 +186,24 @@ main() {
|
||||||
|
|
||||||
info "Binary installed to: $FINAL_FILE"
|
info "Binary installed to: $FINAL_FILE"
|
||||||
|
|
||||||
|
# Build setup command based on arguments
|
||||||
|
SETUP_CMD="setup"
|
||||||
|
SETUP_ARGS=""
|
||||||
|
|
||||||
|
if [ "$USE_CI_SETUP" = "true" ]; then
|
||||||
|
SETUP_CMD="setup-ci"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$INCLUDE_PYTHON" = "true" ]; then
|
||||||
|
SETUP_ARGS="--include-python"
|
||||||
|
fi
|
||||||
|
|
||||||
# Execute safe-chain setup
|
# Execute safe-chain setup
|
||||||
if ! "$FINAL_FILE" setup; then
|
info "Running safe-chain $SETUP_CMD $SETUP_ARGS..."
|
||||||
|
if ! "$FINAL_FILE" $SETUP_CMD $SETUP_ARGS; then
|
||||||
warn "safe-chain was installed but setup encountered issues."
|
warn "safe-chain was installed but setup encountered issues."
|
||||||
warn "You can run 'safe-chain setup' manually later."
|
warn "You can run 'safe-chain $SETUP_CMD $SETUP_ARGS' manually later."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue