Skip to content
Merged
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
87 changes: 51 additions & 36 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
Write-Host "=== Installing Mint CLI ===" -ForegroundColor Green

# Check for Cargo
if ((Get-Command "cargo" -ErrorAction SilentlyContinue) -eq $null) {
Write-Error "Rust/Cargo is not installed. Please install Rust first: https://www.rust-lang.org/tools/install"
exit 1
Write-Host "=== Installing Mint CLI via npm ===" -ForegroundColor Green

# Check for Node.js / npm
if ((Get-Command "npm" -ErrorAction SilentlyContinue) -eq $null) {
Write-Host "Node.js and npm are not installed. They are required to install Mint CLI." -ForegroundColor Yellow
$response = Read-Host "Would you like to install Node.js and npm automatically? [Y/n]"
if ($response -eq "" -or $response -like "y*" -or $response -like "Y*") {
if ((Get-Command "winget" -ErrorAction SilentlyContinue) -ne $null) {
Write-Host "Installing Node.js via winget..." -ForegroundColor Cyan
winget install --id OpenJS.NodeJS --exact --silent --accept-package-agreements --accept-source-agreements
} else {
Write-Host "winget is not available. Downloading official Node.js MSI installer..." -ForegroundColor Cyan
$NodeMsi = Join-Path $env:TEMP "node-install.msi"
Invoke-WebRequest -Uri "https://nodejs.org/dist/v20.11.0/node-v20.11.0-x64.msi" -OutFile $NodeMsi
Write-Host "Running installer silently. Please wait..." -ForegroundColor Cyan
Start-Process msiexec.exe -ArgumentList "/i `"$NodeMsi`" /qn /norestart" -Wait
}
# Refresh environment PATH for current session
$env:Path = [Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [Environment]::GetEnvironmentVariable("Path", "User")
} else {
Write-Error "Installation aborted. Node.js/npm is required."
exit 1
}
}

# Create temp dir
$TempDir = Join-Path $env:TEMP "Mint-Build-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $TempDir | Out-Null

Write-Host "Cloning Mint repository..." -ForegroundColor Cyan
git clone https://github.com/Pheem49/Mint.git $TempDir

Push-Location $TempDir

Write-Host "Building Mint CLI in release mode..." -ForegroundColor Cyan
cargo build --release -p mint-cli

# Target binary path
$InstallDir = "$env:USERPROFILE\.mint\bin"
if (!(Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir | Out-Null
# Check for Rust/Cargo (since the npm package compiles from source on postinstall)
if ((Get-Command "cargo" -ErrorAction SilentlyContinue) -eq $null) {
Write-Host "Rust/Cargo is not installed. It is required to compile Mint CLI." -ForegroundColor Yellow
$response = Read-Host "Would you like to install Rust/Cargo automatically? [Y/n]"
if ($response -eq "" -or $response -like "y*" -or $response -like "Y*") {
Write-Host "Downloading rustup-init.exe..." -ForegroundColor Cyan
$RustupInit = Join-Path $env:TEMP "rustup-init.exe"
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile $RustupInit
Write-Host "Installing Rust silently..." -ForegroundColor Cyan
Start-Process $RustupInit -ArgumentList "-y" -Wait
# Refresh environment PATH for current session (specifically adding ~/.cargo/bin)
$CargoBin = Join-Path $env:USERPROFILE ".cargo\bin"
if ($env:Path -notlike "*$CargoBin*") {
$env:Path += ";$CargoBin"
}
} else {
Write-Error "Installation aborted. Rust/Cargo is required."
exit 1
}
}

Write-Host "Installing binary to $InstallDir..." -ForegroundColor Cyan
Copy-Item "target\release\mint.exe" "$InstallDir\mint.exe" -Force
Write-Host "Running npm install -g @pheem49/mint@latest..." -ForegroundColor Cyan
npm install -g @pheem49/mint@latest

# Add to user Path if not present
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
Write-Host "Adding $InstallDir to user Path..." -ForegroundColor Yellow
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
$env:Path += ";$InstallDir"
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "=== Mint CLI Installed Successfully! ===" -ForegroundColor Green
Write-Host "Type 'mint' to get started." -ForegroundColor Green
} else {
Write-Error "npm installation failed."
exit 1
}

Pop-Location
Remove-Item -Recurse -Force $TempDir

Write-Host "=== Mint CLI Installed Successfully! ===" -ForegroundColor Green
Write-Host "Please restart your terminal/PowerShell session, then type 'mint' to get started." -ForegroundColor Yellow
95 changes: 69 additions & 26 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,79 @@
#!/bin/bash
set -e

echo "=== Installing Mint CLI ==="
echo "=== Installing Mint CLI via npm ==="

# Check for Rust/Cargo
if ! command -v cargo &> /dev/null; then
echo "Error: Rust/Cargo is not installed."
echo "Please install Rust first: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
exit 1
fi
# Detect OS
OS="$(uname -s)"

# Create a temporary directory
TEMP_DIR=$(mktemp -d)
echo "Cloning Mint repository to temporary directory..."
git clone https://github.com/Pheem49/Mint.git "$TEMP_DIR"
# Check for Node.js / npm
if ! command -v npm &> /dev/null; then
echo "Node.js / npm is not installed. It is required to run and manage Mint CLI."
read -p "Would you like to install Node.js and npm automatically? (Requires sudo on Linux) [Y/n]: " install_node
install_node=${install_node:-Y}

if [[ "$install_node" =~ ^([yY][eE][sS]|[yY])$ ]]; then
if [ "$OS" = "Darwin" ]; then
if command -v brew &> /dev/null; then
echo "Installing Node.js via Homebrew..."
brew install node
else
echo "Error: Homebrew is not installed. Please install Node.js manually from https://nodejs.org"
exit 1
fi
elif [ "$OS" = "Linux" ]; then
if command -v apt-get &> /dev/null; then
echo "Installing Node.js and npm via apt-get..."
sudo apt-get update
sudo apt-get install -y nodejs npm
elif command -v pacman &> /dev/null; then
echo "Installing Node.js and npm via pacman..."
sudo pacman -S --noconfirm nodejs npm
elif command -v dnf &> /dev/null; then
echo "Installing Node.js and npm via dnf..."
sudo dnf install -y nodejs npm
else
echo "Error: Could not detect your package manager. Please install Node.js manually from https://nodejs.org"
exit 1
fi
else
echo "Error: OS not supported for automatic Node.js installation. Please install Node.js manually from https://nodejs.org"
exit 1
fi
else
echo "Installation aborted. Node.js/npm is required."
exit 1
fi
fi

cd "$TEMP_DIR"
# Check for Rust/Cargo (since the npm package compiles from source on postinstall)
if ! command -v cargo &> /dev/null; then
echo "Rust/Cargo is not installed. It is required to compile Mint CLI."
read -p "Would you like to install Rust/Cargo automatically via rustup? [Y/n]: " install_rust
install_rust=${install_rust:-Y}

if [[ "$install_rust" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Installing Rust via rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Load cargo environment in the current shell session
source "$HOME/.cargo/env"
else
echo "Installation aborted. Rust/Cargo is required."
exit 1
fi
fi

echo "Building Mint CLI in release mode..."
cargo build --release -p mint-cli
echo "Running npm install -g @pheem49/mint@latest..."

echo "Installing binary to /usr/local/bin..."
# Try copying to /usr/local/bin (may require sudo)
if [ -w /usr/local/bin ]; then
cp target/release/mint /usr/local/bin/mint
# Try to install globally
if npm install -g @pheem49/mint@latest; then
echo ""
echo "=== Mint CLI Installed Successfully! ==="
echo "Type 'mint' to get started."
else
echo "Permission denied for /usr/local/bin. Requesting sudo permission..."
sudo cp target/release/mint /usr/local/bin/mint
echo ""
echo "Error: npm installation failed."
echo "If you encountered permission errors (EACCES), please try running:"
echo " sudo npm install -g @pheem49/mint@latest --unsafe-perm"
exit 1
fi

echo "Cleaning up..."
rm -rf "$TEMP_DIR"

echo "=== Mint CLI Installed Successfully! ==="
echo "Type 'mint' to get started."
Loading