From dea55fdf2c23cc5f6ab8e4dee59310563a78db1e Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Tue, 11 Apr 2023 08:00:01 +0200 Subject: [PATCH 1/2] fetch-configlet: remove scripts Closes: #2260 --- bin/fetch-configlet | 90 ----------------------------------------- bin/fetch-configlet.ps1 | 24 ----------- 2 files changed, 114 deletions(-) delete mode 100755 bin/fetch-configlet delete mode 100755 bin/fetch-configlet.ps1 diff --git a/bin/fetch-configlet b/bin/fetch-configlet deleted file mode 100755 index 4800e15084..0000000000 --- a/bin/fetch-configlet +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash - -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. - -set -eo pipefail - -curlopts=( - --silent - --show-error - --fail - --location - --retry 3 -) - -if [[ -n "${GITHUB_TOKEN}" ]]; then - curlopts+=(--header "authorization: Bearer ${GITHUB_TOKEN}") -fi - -get_download_url() { - local os="$1" - local ext="$2" - local latest='https://api.github.com/repos/exercism/configlet/releases/latest' - local arch - case "$(uname -m)" in - x86_64) arch='x86-64' ;; - *686*) arch='i386' ;; - *386*) arch='i386' ;; - *) arch='x86-64' ;; - esac - local suffix="${os}_${arch}.${ext}" - curl "${curlopts[@]}" --header 'Accept: application/vnd.github.v3+json' "${latest}" | - grep "\"browser_download_url\": \".*/download/.*/configlet.*${suffix}\"$" | - cut -d'"' -f4 -} - -main() { - local output_dir - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - local os - case "$(uname)" in - Darwin*) os='macos' ;; - Linux*) os='linux' ;; - Windows*) os='windows' ;; - MINGW*) os='windows' ;; - MSYS_NT-*) os='windows' ;; - *) os='linux' ;; - esac - - local ext - case "${os}" in - windows*) ext='zip' ;; - *) ext='tar.gz' ;; - esac - - echo "Fetching configlet..." >&2 - local download_url - download_url="$(get_download_url "${os}" "${ext}")" - local output_path="${output_dir}/latest-configlet.${ext}" - curl "${curlopts[@]}" --output "${output_path}" "${download_url}" - - case "${ext}" in - *zip) unzip "${output_path}" -d "${output_dir}" ;; - *) tar xzf "${output_path}" -C "${output_dir}" ;; - esac - - rm -f "${output_path}" - - local executable_ext - case "${os}" in - windows*) executable_ext='.exe' ;; - *) executable_ext='' ;; - esac - - local configlet_path="${output_dir}/configlet${executable_ext}" - local configlet_version - configlet_version="$(${configlet_path} --version)" - echo "Downloaded configlet ${configlet_version} to ${configlet_path}" -} - -main diff --git a/bin/fetch-configlet.ps1 b/bin/fetch-configlet.ps1 deleted file mode 100755 index f89ed4ecb6..0000000000 --- a/bin/fetch-configlet.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -Function DownloadUrl ([string] $FileName, $Headers) { - $latestUrl = "https://api.github.com/repos/exercism/configlet/releases/latest" - $json = Invoke-RestMethod -Headers $Headers -Uri $latestUrl - $json.assets | Where-Object { $_.browser_download_url -match $FileName } | Select-Object -ExpandProperty browser_download_url -} - -Function Headers { - If ($GITHUB_TOKEN) { @{ Authorization = "Bearer ${GITHUB_TOKEN}" } } Else { @{ } } -} - -Function Arch { - If ([Environment]::Is64BitOperatingSystem) { "64bit" } Else { "32bit" } -} - -$arch = Arch -$headers = Headers -$fileName = "configlet-windows-$arch.zip" -$outputDirectory = "bin" -$outputFile = Join-Path -Path $outputDirectory -ChildPath $fileName -$zipUrl = DownloadUrl -FileName $fileName -Headers $headers - -Invoke-WebRequest -Headers $headers -Uri $zipUrl -OutFile $outputFile -Expand-Archive $outputFile -DestinationPath $outputDirectory -Force -Remove-Item -Path $outputFile From 860fb235c7c54740418fe82bb18e34939a710ee1 Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Tue, 11 Apr 2023 08:00:02 +0200 Subject: [PATCH 2/2] .gitignore: remove rules for ignoring configlet executables --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index b91eaeb78c..45ff89609a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,6 @@ *.swp .DS_Store -# Platform specific tools (use fetch-configlet) -bin/configlet -bin/configlet.exe - # IDE folders and files .idea