-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·109 lines (90 loc) · 3.06 KB
/
install.sh
File metadata and controls
executable file
·109 lines (90 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# One-liner installer for IDEasy.
# Usage: bash -c "$(curl -fsSL https://raw.githubusercontent.com/devonfw/IDEasy/main/install.sh)"
#
# What it does:
# 1. Detects your OS (mac/linux) and architecture (x64/arm64)
# 2. Fetches the latest release version from GitHub
# 3. Downloads and extracts the correct archive to a temp directory
# 4. Runs the setup script
# 5. Cleans up the temp directory
#
# On Windows use Git Bash (comes with Git for Windows).
# Prerequisites: git, curl, tar
set -eu
GITHUB_REPO="devonfw/IDEasy"
# colored output helpers
red() { printf '\033[1;31m%s\033[0m\n' "$1"; }
green() { printf '\033[1;32m%s\033[0m\n' "$1"; }
blue() { printf '\033[1;34m%s\033[0m\n' "$1"; }
abort() { red "Error: $1" >&2; exit 1; }
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "mac" ;;
*) abort "Unsupported operating system: $(uname -s). Use the PowerShell installer on Windows." ;;
esac
}
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "x64" ;;
arm64|aarch64) echo "arm64" ;;
*) abort "Unsupported architecture: $(uname -m)" ;;
esac
}
# gets the latest release tag from GitHub API and strips the "release/" prefix
fetch_latest_version() {
local url="https://api.github.com/repos/${GITHUB_REPO}/releases/latest"
local tag
tag=$(curl -fsSL "${url}" | grep '"tag_name"' | cut -d '"' -f 4)
if [ -z "${tag}" ]; then
abort "Failed to determine latest release version."
fi
echo "${tag#release/}"
}
check_prerequisites() {
if ! command -v git >/dev/null 2>&1; then
abort "git is required but not installed. See https://git-scm.com/downloads"
fi
if ! command -v curl >/dev/null 2>&1; then
abort "curl is required but not installed."
fi
if ! command -v tar >/dev/null 2>&1; then
abort "tar is required but not installed."
fi
}
main() {
blue "Installing IDEasy..."
check_prerequisites
local os arch version download_url archive
os=$(detect_os)
arch=$(detect_arch)
version=$(fetch_latest_version)
archive="ide-cli-${version}-${os}-${arch}.tar.gz"
download_url="https://github.com/${GITHUB_REPO}/releases/download/release/${version}/${archive}"
blue "Detected: ${os} ${arch}"
blue "Latest version: ${version}"
# download to a temp dir that gets cleaned up on exit
TMPDIR_CLEANUP=$(mktemp -d)
trap 'rm -rf "${TMPDIR_CLEANUP}"' EXIT
local tmpdir="${TMPDIR_CLEANUP}"
blue "Downloading ${archive}..."
curl -fSL --progress-bar -o "${tmpdir}/${archive}" "${download_url}"
blue "Extracting..."
tar xzf "${tmpdir}/${archive}" -C "${tmpdir}"
# on macOS remove quarantine flag so the binary can run without gatekeeper issues
if [ "${os}" = "mac" ]; then
xattr -r -d com.apple.quarantine "${tmpdir}" 2>/dev/null || true
fi
blue "Running setup..."
cd "${tmpdir}"
bash setup </dev/tty
echo ""
green "IDEasy ${version} installed successfully!"
echo ""
echo " Restart your terminal, then run:"
echo " ide create <project> # set up a new project"
echo " ide --help # see all commands"
echo ""
}
main