Skip to content

Commit

Permalink
script to install clj-kondo
Browse files Browse the repository at this point in the history
  • Loading branch information
cgore committed Aug 25, 2023
1 parent e3fe57a commit 5fc8702
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
1 change: 1 addition & 0 deletions abbrev_defs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
;;-*-coding: utf-8;-*-
5 changes: 4 additions & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
;; /usr/local/opt/ncurses/bin:
;; /usr/local/opt/gettext/bin:

(setenv "GOPATH" "/usr/local/Cellar/go/1.18.5/")
(setenv "PAGER" "cat")
(setq exec-path
(append `(,(expand-file-name "~/bin")
,(expand-file-name "~/.cargo/bin")
"/usr/local/share/dotnet"
,(expand-file-name "~/.dotnet/tools")
"/usr/local/bin"
"/usr/local/opt/[email protected]/libexec/bin"
"/usr/local/Cellar/go/1.18.5/bin"
"/usr/local/sbin"
"/usr/bin"
"/usr/sbin"
Expand Down Expand Up @@ -95,7 +98,7 @@
'(inhibit-startup-screen t)
'(magit-log-arguments '("--graph" "--color" "--decorate" "-n256"))
'(package-selected-packages
'(flycheck-clj-kondo ejc-sql wgrep-ack ag soft-morning-theme tide typescript-mode slime ac-cider ac-slime ace-jump-mode ack-and-a-half afternoon-theme aggressive-indent all-the-icons all-the-icons-dired auto-complete auto-highlight-symbol base16-theme beacon cloc clojure-mode clojure-test-mode coffee-mode color-theme color-theme-sanityinc-solarized color-theme-sanityinc-tomorrow color-theme-solarized conda csharp-mode cyberpunk-theme dash dash-docs dash-functional dired-rainbow dirtree django-theme doom-themes ein elisp-slime-nav elpy emamux ensime erlang eshell-autojump espresso-theme ewal-doom-themes fennel-mode find-file-in-project flycheck flycheck-clojure flycheck-pos-tip flymake-go flymd fuzzy geiser go-mode gorepl-mode green-is-the-new-black-theme haml-mode helm-w3m highlight-indentation ht idle-highlight-mode ido-ubiquitous indium inf-clojure inf-ruby ipython jq-format jq-mode js2-refactor json-mode kibit-helper kotlin-mode kubernetes leuven-theme logview lua-mode magit markdown-mode markdown-preview-mode mc-extras minimap multi-term multiple-cursors neotree nodejs-repl ob-restclient omnisharp package+ paper-theme paredit php-mode pixie-mode plantuml-mode popup-complete projectile puppet-mode python-mode queue rainbow-blocks rainbow-delimiters rainbow-identifiers rainbow-mode reverse-theme rjsx-mode robe rspec-mode ruby-electric rust-mode s sass-mode scss-mode seti-theme shen-lisp slime-annot smex solarized-theme solidity-mode soothe-theme starter-kit-eshell string-inflection tabulated-list terraform-doc terraform-mode uuidgen w3m which-key wsd-mode xref-js2 yafolding yaml-mode))
'(organic-green-theme restclient flycheck-clj-kondo ejc-sql wgrep-ack ag soft-morning-theme tide typescript-mode slime ac-cider ac-slime ace-jump-mode ack-and-a-half afternoon-theme aggressive-indent all-the-icons all-the-icons-dired auto-complete auto-highlight-symbol base16-theme beacon cloc clojure-mode clojure-test-mode coffee-mode color-theme color-theme-sanityinc-solarized color-theme-sanityinc-tomorrow color-theme-solarized conda csharp-mode cyberpunk-theme dash dash-docs dash-functional dired-rainbow dirtree django-theme doom-themes ein elisp-slime-nav elpy emamux ensime erlang eshell-autojump espresso-theme ewal-doom-themes fennel-mode find-file-in-project flycheck flycheck-clojure flycheck-pos-tip flymake-go flymd fuzzy geiser go-mode gorepl-mode green-is-the-new-black-theme haml-mode helm-w3m highlight-indentation ht idle-highlight-mode ido-ubiquitous indium inf-clojure inf-ruby ipython jq-format jq-mode js2-refactor json-mode kibit-helper kotlin-mode kubernetes leuven-theme logview lua-mode magit markdown-mode markdown-preview-mode mc-extras minimap multi-term multiple-cursors neotree nodejs-repl ob-restclient omnisharp package+ paper-theme paredit php-mode pixie-mode plantuml-mode popup-complete projectile puppet-mode python-mode queue rainbow-blocks rainbow-delimiters rainbow-identifiers rainbow-mode reverse-theme rjsx-mode robe rspec-mode ruby-electric rust-mode s sass-mode scss-mode seti-theme shen-lisp slime-annot smex solarized-theme solidity-mode soothe-theme starter-kit-eshell string-inflection tabulated-list terraform-doc terraform-mode uuidgen w3m which-key wsd-mode xref-js2 yafolding yaml-mode))
'(py-shell-name "/usr/local/bin/python")
'(safe-local-variable-values
'((url-max-redirections . 0)
Expand Down
90 changes: 90 additions & 0 deletions install-clj-kondo
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env bash

# install script inspired by scripts for clojure and CircleCI CLI tool
# install latest version of clj-kondo or upgrades existing one

set -euo pipefail

default_install_dir="/usr/local/bin"
install_dir=$default_install_dir
default_download_dir="/tmp"
download_dir=$default_download_dir
version=""

print_help() {
echo "Installs latest version of clj-kondo."
echo -e
echo "Usage:"
echo "install [--dir <dir>] [--download-dir <download-dir>] [--version <version>]"
echo -e
echo "Defaults:"
echo " * Installation directory: ${default_install_dir}"
echo " * Download directory: ${default_download_dir}"
echo " * Version: <Latest release on github>"
exit 1
}

while [[ $# -gt 0 ]]
do
key="$1"
if [[ -z "${2:-}" ]]; then
print_help
fi

case $key in
--dir)
install_dir="$2"
shift
shift
;;
--download-dir)
download_dir="$2"
shift
shift
;;
--version|--release-version)
version="$2"
shift
shift
;;
*) # unknown option
print_help
shift
;;
esac
done

if [[ "$version" == "" ]]; then
version="$(curl -s https://raw.githubusercontent.com/clj-kondo/clj-kondo/master/resources/CLJ_KONDO_RELEASED_VERSION)"
fi

case "$(uname -s)" in
Linux*) platform=linux;;
Darwin*) platform=macos;;
esac

download_url="https://github.com/clj-kondo/clj-kondo/releases/download/v$version/clj-kondo-$version-$platform-amd64.zip"

mkdir -p "$download_dir"
pushd "$download_dir" > /dev/null
echo -e "Downloading $download_url to $download_dir"
rm -rf "clj-kondo-$version-$platform-amd64.zip"
rm -rf "clj-kondo"
curl -o "clj-kondo-$version-$platform-amd64.zip" -sL "https://github.com/clj-kondo/clj-kondo/releases/download/v$version/clj-kondo-$version-$platform-amd64.zip"
unzip -qqo "clj-kondo-$version-$platform-amd64.zip"
rm "clj-kondo-$version-$platform-amd64.zip"
popd > /dev/null

if [ "$download_dir" != "$install_dir" ]
then
mkdir -p "$install_dir"
pushd "$install_dir" > /dev/null
if [ -f clj-kondo ]; then
echo -e "Moving $install_dir/clj-kondo to $install_dir/clj-kondo.old"
mv -f "clj-kondo" "clj-kondo.old"
fi
pushd > /dev/null
mv -f "$download_dir/clj-kondo" "$install_dir/clj-kondo"
fi

echo -e "Successfully installed clj-kondo in $install_dir"

0 comments on commit 5fc8702

Please sign in to comment.