Skip to content

Commit a1a74f4

Browse files
authored
feat(installer): Add asdf install formula (#96)
close #91
1 parent 1dff7f9 commit a1a74f4

19 files changed

+129
-178
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ tmux/.config/tmux/plugins/tpm/
77
node_modules/
88
zsh/.config/zsh/envs/
99
zshrc
10+
nvim/.config/nvim/lazy-lock.json

asdf/.config/asdf/.asdfrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use_release_candidates = no
2323
# * ASDF_DEFAULT_TOOL_VERSIONS_FILENAME - The name of the file storing the tool names and versions.
2424
# Defaults to .tool-versions. Can be any valid file name.
2525

26-
# Mac OS X
26+
# Mac OS X
2727
# ---------
2828
# Some applications in macOS use `/usr/libexec/java_home` to set java home.
2929
# Setting java_macos_integration_enable to yes on .asdfrc file enables this integration.

asdf/.config/asdf/default-ctags

Lines changed: 0 additions & 165 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// allows comments
22
github.com/Dreamacro/clash
3-
github.com/jesseduffield/lazygit
3+
//github.com/jesseduffield/lazygit

asdf/.config/asdf/default-npm-packages

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ request
1212
ts-node
1313
typescript
1414
typescript-language-server
15-

git/.config/git/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
defaultBranch = main
2121

2222
[core]
23-
excludesfile = ~/.gitignore_global
23+
excludesfile = ~/.config/git/gitignore_global
2424
editor = nvim
2525

2626
[github]

installer/1password_formula.bash

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
# -----------------------------------------------------------------------------
88
function install_1password() {
99

10+
echo "+----------------------------------------------------------+"
11+
echo "| *** 🗝️ Instalador do 1Password *** |"
12+
echo "+----------------------------------------------------------+"
13+
1014
if [ -f /opt/1Password/op-ssh-sign ]; then
1115
echo "✔️ 1Password já instalado."
1216
return
1317
fi
1418

15-
echo "🗝️ Instalando 1Password..."
16-
1719
case $PLATFORM_OS in
1820
Fedora)
1921
install_1password_fedora
@@ -62,7 +64,7 @@ function install_1password() {
6264
function install_1password_debian_or_ubuntu() {
6365
_add_key_for_the_1Password_apt_repository_and_add_apt_repo
6466
sudo apt-get update -qq
65-
sudo apt-get install -y 1password
67+
sudo apt-get install -qq -y 1password
6668
}
6769

6870
function _add_key_for_the_1Password_apt_repository_and_add_apt_repo() {
@@ -96,7 +98,7 @@ function _add_key_for_the_1Password_apt_repository_and_add_apt_repo() {
9698
# -----------------------------------------------------------------------------
9799
function install_1password_fedora() {
98100
_add_key_for_the_1Password_yum_repository
99-
sudo dnf install -y 1password
101+
sudo dnf install -q -y 1password
100102
}
101103

102104
function _add_key_for_the_1Password_yum_repository() {

installer/asdf_formula.bash

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
function install_asdf() {
4+
5+
echo "+----------------------------------------------------------+"
6+
echo "| *** 🧩 Instalador do ASDF *** |"
7+
echo "+----------------------------------------------------------+"
8+
9+
if command -v asdf >/dev/null 2>&1; then
10+
echo "ASDF-VM já está instalado."
11+
return
12+
fi
13+
REPO="asdf-vm/asdf"
14+
INSTALL_DIR="/usr/local/bin"
15+
16+
export ASDF_DIR="$HOME/.local/share/asdf"
17+
mkdir -p "$ASDF_DIR"
18+
19+
20+
# Obtém a última versão do release via GitHub API
21+
LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep -oP '"tag_name": "\K(.*)(?=")')
22+
VERSION="${LATEST_TAG#v}" # Remove o 'v' inicial, se presente
23+
case $PLATFORM_OS in
24+
Fedora)
25+
ARCHIVE_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/asdf-$LATEST_TAG-linux-amd64.tar.gz"
26+
;;
27+
Ubuntu)
28+
ARCHIVE_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/asdf-$LATEST_TAG-linux-amd64.tar.gz"
29+
;;
30+
MacOS)
31+
ARCHIVE_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/asdf-$LATEST_TAG-darwin-arm64.tar.gz"
32+
;;
33+
*)
34+
echo "Invalid option $PLATFORM_ARCH"
35+
esac
36+
37+
#ARCHIVE_URL="https://github.com/$REPO/archive/refs/tags/$LATEST_TAG.tar.gz"
38+
39+
echo "Baixando $ARCHIVE_URL..."
40+
curl -L "$ARCHIVE_URL" -o "/tmp/asdf-$LATEST_TAG.tar.gz"
41+
42+
# Extrai para /usr/local/bin
43+
echo "Extraindo para $INSTALL_DIR..."
44+
sudo tar -xzf "/tmp/asdf-$LATEST_TAG.tar.gz" -C "$INSTALL_DIR"
45+
46+
# Opcional: mostra conteúdo extraído
47+
echo "Conteúdo extraído:"
48+
# ln -sf "$INSTALL_DIR/asdf-$VERSION" "$INSTALL_DIR/asdf"
49+
ls -l "$INSTALL_DIR/" | grep -i asdf
50+
51+
# Limpeza
52+
rm "/tmp/asdf-$LATEST_TAG.tar.gz"
53+
54+
$INSTALL_DIR/asdf --version
55+
echo "Instalação do asdf $VERSION concluída."
56+
echo "Adicione o seguinte ao seu arquivo de configuração do shell (ex: ~/.zshrc ou ~/.bashrc):"
57+
echo " source /usr/local/bin/asdf-$LATEST_TAG/asdf.sh"
58+
echo " source /usr/local/bin/asdf-$LATEST_TAG/completions/asdf.bash"
59+
}

installer/bootstrap.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source ./installer/lazy_packages.bash
77
source ./installer/zplug_formula.bash
88
source ./installer/tmux_formula.bash
99
source ./installer/1password_formula.bash
10+
source ./installer/asdf_formula.bash
1011

1112
export XDG_CONFIG_HOME=$HOME/.config
1213

@@ -49,6 +50,7 @@ main() {
4950
ensure_zplug_installed
5051
ensure_tmux_tpm_installed
5152
install_1password
53+
install_asdf
5254
echo "🎉 Bootstrap concluído com sucesso!"
5355
}
5456

0 commit comments

Comments
 (0)