@@ -7,30 +7,33 @@ _get_parent_dir_abs_path() {
77# ––––––––––––––––––––––––––– Config –––––––––––––––––––––––––––
88
99TOOL_NAME=" swift-format"
10- TOOL_OWNER=" apple "
10+ TOOL_OWNER=" CaptureContext "
1111TOOL_VERSION=" 0.50600.1"
1212
1313# ––––––––––––––––––––––––– Constants ––––––––––––––––––––––––––
1414
1515SCRIPT_DIR=$( _get_parent_dir_abs_path $0 )
1616TOOLS_INSTALL_PATH=" ${SCRIPT_DIR} /.bin"
1717TOOL_INSTALL_PATH=" ${TOOLS_INSTALL_PATH} /${TOOL_NAME} "
18- TEMP_INSTALL_PATH=" ${TOOLS_INSTALL_PATH} /install-${TOOL_NAME} "
18+ TOOL_DOWNLOAD_DIR=" ${TOOLS_INSTALL_PATH} /_${TOOL_NAME} "
19+
20+ TOOL=${TOOL_INSTALL_PATH}
21+ TOOL_REPO=" https://github.com/${TOOL_OWNER} /${TOOL_NAME} "
22+ ARCHIVE_NAME=" x86_64"
23+ ARCHIVE_URL=" ${TOOL_REPO} /releases/download/0.50600.1/${ARCHIVE_NAME} .zip" # todo: support other archs
1924
2025# ––––––––––––––––––––––––––– Steps ––––––––––––––––––––––––––––
2126
2227tool_fetch () {
23- git clone " https://github.com/${TOOL_OWNER} /${TOOL_NAME} .git"
24- cd " ${TOOL_NAME} "
25- git checkout " tags/${TOOL_VERSION} "
28+ curl -L ${ARCHIVE_URL} -o " ${TOOL_DOWNLOAD_DIR} /${ARCHIVE_NAME} .zip"
2629}
2730
28- tool_build () {
29- swift build --product= " ${TOOL_NAME} " -c release --disable-sandbox --build-path ' .build '
31+ tool_extract () {
32+ unzip " ${TOOL_DOWNLOAD_DIR} / ${ARCHIVE_NAME} .zip " -d ${TOOL_DOWNLOAD_DIR}
3033}
3134
3235tool_install () {
33- install " ${TEMP_INSTALL_PATH } /${TOOL_NAME} /.build/release /${TOOL_NAME} " " ${TOOLS_INSTALL_PATH} "
36+ install " ${TOOL_DOWNLOAD_DIR } /${ARCHIVE_NAME} /${TOOL_NAME} " " ${TOOLS_INSTALL_PATH} "
3437}
3538
3639# ––––––––––––––––––––––––––– Script –––––––––––––––––––––––––––
@@ -42,20 +45,20 @@ log() {
4245 printf " \n$1 ${set_bold} $2 ${set_normal} \n"
4346}
4447
45- _trap_exit () {
46- rm -rf " ${TEMP_INSTALL_PATH } "
48+ clean_up () {
49+ rm -rf " ${TOOL_DOWNLOAD_DIR } "
4750}
4851
4952set -e
50- trap _trap_exit err exit SIGTERM SIGINT
53+ trap clean_up err exit SIGTERM SIGINT
5154
5255if [ -f " ${TOOL_INSTALL_PATH} " ]; then
5356 log " ⚠️" " ${TOOL_NAME} already installed"
5457 exit 0
5558fi
5659
57- if [ ! -d " ${TEMP_INSTALL_PATH } " ]; then
58- mkdir -p " ${TEMP_INSTALL_PATH } "
60+ if [ ! -d " ${TOOL_DOWNLOAD_DIR } " ]; then
61+ mkdir -p " ${TOOL_DOWNLOAD_DIR } "
5962fi
6063
6164cd " ${TEMP_INSTALL_PATH} "
@@ -64,16 +67,16 @@ log "⬇️" " Fetching ${TOOL_NAME}...\n"
6467
6568tool_fetch
6669
67- log " 🔨 " " Building ${TOOL_NAME} ...\n"
70+ log " 📦 " " Extracting ${TOOL_NAME} ...\n"
6871
69- tool_build
72+ tool_extract
7073
7174log " ♻️" " Installing ${TOOL_NAME} ..."
7275
7376tool_install
7477
7578log " 💧" " Performing cleanup..."
76- rm -rf " ${TEMP_INSTALL_PATH} "
79+ clean_up
7780
7881if [ -f " ${TOOL_INSTALL_PATH} " ]; then
7982 log " ✅" " ${TOOL_NAME} successfully installed"
0 commit comments