Skip to content

Commit afe1d64

Browse files
committed
add: アップデートスクリプトを追加
1 parent fa8fc1b commit afe1d64

4 files changed

Lines changed: 60 additions & 0 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+
```

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)