Skip to content

Commit 5c834c0

Browse files
authored
Merge pull request #32 from dev-satoshi/fix/asdf
ASDF周りの修正
2 parents 0e0f709 + 69e703e commit 5c834c0

6 files changed

Lines changed: 79 additions & 10 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
```
55
$ curl -sL https://github.com/dev-satoshi/dotfiles/install.sh | sh
66
```
7+
8+
## Update
9+
```
10+
$ curl -sL https://github.com/dev-satoshi/dotfiles/update.sh | sh
11+
```

asdf/.tool-versions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
ruby 3.3.4
21
awscli 2.16.5
32
flutter 3.29.2-stable
43
gradle 8.4
54
java openjdk-17.0.2
5+
kotlin 2.1.10
66
nodejs 20.12.2
77
pre-commit 3.7.1
8-
yarn 1.22.22
9-
kotlin 2.1.10
8+
ruby 3.3.4
109
rust 1.85.1
10+
yarn 1.22.22

scripts/asdf_setup.sh

100644100755
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@ set -euo pipefail
33

44
echo "「ASDF」のセットアップを開始しました"
55

6-
# プラグインを出力
7-
asdf plugin list --urls > ~/dotfiles/asdf/plugins.txt
8-
96
# プラグインをインストール
10-
while read -r name url; do
11-
asdf plugin add "$name" "$url" || true
7+
while IFS=$' \t' read -r name url; do
8+
asdf plugin add "$name" "$url" >/dev/null 2>&1 || true
129
done < ~/dotfiles/asdf/plugins.txt
1310

14-
# 一括インストール
15-
asdf install
11+
# .tool-versionsに書いてある全てのバージョンをインストール
12+
while IFS= read -r line; do
13+
# 空行スキップ
14+
[[ -z "$line" ]] && continue
15+
16+
# 先頭の単語がプラグイン名、残りがバージョン一覧
17+
set -- "$line"
18+
plugin=$1
19+
shift
20+
for version in "$@"; do
21+
echo "→ Installing $plugin $version"
22+
asdf install "$plugin" "$version"
23+
done
24+
done < ~/dotfiles/asdf/.tool-versions
1625

1726
echo "「ASDF」のセットアップが完了しました"

scripts/update/asdf_update.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「ASDF」のアップデートを開始しました"
5+
6+
# プラグインを出力
7+
asdf plugin list --urls > "$HOME/dotfiles/asdf/plugins.txt"
8+
9+
# 出力先ディレクトリがなければ作成
10+
mkdir -p "$HOME/dotfiles/asdf"
11+
12+
# .tool-versionsを初期化
13+
: > "$HOME/dotfiles/asdf/.tool-versions"
14+
15+
# 各プラグインの全バージョンを取得して出力
16+
for plugin in $(asdf plugin list); do
17+
# 空行はスキップ
18+
[[ -z "$plugin" ]] && continue
19+
20+
# バージョンリスト取得&整形(行頭の空白、*、空行を削除)
21+
versions=$(asdf list "$plugin" 2>/dev/null \
22+
| sed -e 's/^[[:space:]]*\*\?[[:space:]]*//' -e '/^$/d')
23+
24+
# それぞれのバージョンを.tool-versionsに出力
25+
for version in $versions; do
26+
echo "$plugin $version" >> "$HOME/dotfiles/asdf/.tool-versions"
27+
done
28+
done
29+
30+
echo "「ASDF」のアップデートが完了しました"

scripts/update/update.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「dotfiles」のアップデートを開始しました"
5+
6+
INSTALL_DIR="$HOME/dotfiles"
7+
8+
sh "$INSTALL_DIR/scripts/update/asdf_update.sh"
9+
10+
echo "「dotfiles」のアップデートが完了しました"

update.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
INSTALL_DIR="$HOME/dotfiles"
5+
6+
if [ ! -d "$INSTALL_DIR" ]; then
7+
echo "dotfiles not found in $INSTALL_DIR"
8+
echo "Please run 'install.sh' first."
9+
exit 1
10+
fi
11+
12+
echo "Updating dotfiles..."
13+
git -C "$INSTALL_DIR" pull
14+
15+
sh "$INSTALL_DIR/scripts/update/update.sh"

0 commit comments

Comments
 (0)