Skip to content

Commit c5b92cb

Browse files
committed
refactor: setupスクリプトをscripts/setup配下に移動
1 parent 80491cc commit c5b92cb

File tree

8 files changed

+148
-1
lines changed

8 files changed

+148
-1
lines changed

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ else
1111
git clone https://github.com/dev-satoshi/dotfiles "$INSTALL_DIR"
1212
fi
1313

14-
sh "$INSTALL_DIR/scripts/setup.sh"
14+
sh "$INSTALL_DIR/scripts/setup/setup.sh"

scripts/setup/android_setup.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「Android」のセットアップを開始しました"
5+
6+
SDK_DIR="/opt/homebrew/share/android-commandlinetools"
7+
CMDLINE_TOOLS_DIR="/opt/homebrew/share/android-commandlinetools/cmdline-tools/latest"
8+
9+
if [ -d "$CMDLINE_TOOLS_DIR" ]; then
10+
:
11+
else
12+
# パッケージをインストール
13+
sdkmanager --install "cmdline-tools;latest" \
14+
"platform-tools" \
15+
"platforms;android-34" \
16+
"build-tools;34.0.0" \
17+
"emulator"
18+
fi
19+
20+
# Androidのライセンスに同意
21+
yes | flutter doctor --android-licenses || true
22+
23+
# FlutterにSDKパスを教える
24+
flutter config --android-sdk "$SDK_DIR"
25+
26+
echo "「Android」のセットアップが完了しました"

scripts/setup/asdf_setup.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「ASDF」のセットアップを開始しました"
5+
6+
# プラグインをインストール
7+
while IFS=$'\t ' read -r name url; do
8+
asdf plugin add "$name" "$url" >/dev/null 2>&1 || true
9+
done < ~/dotfiles/asdf/plugins.txt
10+
11+
# .tool-versions に書いてあるバージョンをインストール
12+
while IFS=' ' read -r plugin version; do
13+
[[ -z "$plugin" || -z "$version" ]] && continue
14+
echo "→ Installing $plugin $version"
15+
asdf install "$plugin" "$version"
16+
done < ~/dotfiles/asdf/.tool-versions
17+
18+
echo "「ASDF」のセットアップが完了しました"

scripts/setup/homebrew_setup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「Homebrew」のセットアップを開始しました"
5+
6+
# brewのインストール
7+
if ! command -v brew >/dev/null 2>&1; then
8+
echo "「Homebrew」が見つかりません。インストールを開始します..."
9+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
10+
else
11+
echo "「Homebrew」は既にインストールされています"
12+
fi
13+
14+
# パッケージリストを更新
15+
brew update
16+
17+
# Brewfileを元にインストール
18+
brew bundle --file=~/dotfiles/homebrew/Brewfile
19+
20+
echo "「Homebrew」のセットアップが完了しました"

scripts/setup/link_dotfiles.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「シンボリックリンク」の作成を開始しました"
5+
6+
DOTFILES_DIR="$HOME/dotfiles"
7+
8+
# リンクを作成するファイル一覧(キー:シンボリックリンク先、値:dotfiles内の実ファイル)
9+
LINKS=(
10+
"$DOTFILES_DIR/zsh/.zshrc:$HOME/.zshrc"
11+
"$DOTFILES_DIR/zsh/.zshenv:$HOME/.zshenv"
12+
"$DOTFILES_DIR/git/.gitconfig:$HOME/.gitconfig"
13+
"$DOTFILES_DIR/git/.gitignore:$HOME/.gitignore"
14+
"$DOTFILES_DIR/git/.gitattributes:$HOME/.gitattributes"
15+
"$DOTFILES_DIR/asdf/.tool-versions:$HOME/.tool-versions"
16+
"$DOTFILES_DIR/aws/config:$HOME/.aws/config"
17+
"$DOTFILES_DIR/vscode/settings.json:$HOME/Library/Application Support/Code/User/settings.json"
18+
"$DOTFILES_DIR/android/sdk:$HOME/Library/Android/sdk"
19+
"/opt/homebrew/share/android-commandlinetools/cmdline-tools/latest:$DOTFILES_DIR/android/sdk/cmdline-tools/latest"
20+
)
21+
22+
# すべてのリンクを作成
23+
for link in "${LINKS[@]}"; do
24+
src=$(echo "$link" | cut -d':' -f1)
25+
dest=$(echo "$link" | cut -d':' -f2)
26+
27+
# 親ディレクトリが無ければ作成
28+
mkdir -p "$(dirname "$dest")"
29+
30+
# 既存のファイルやリンクがあればバックアップ
31+
# if [ -e "$dest" ] || [ -L "$dest" ]; then
32+
# echo "$dest をバックアップ: ${dest}.backup"
33+
# mv "$dest" "${dest}.backup"
34+
# fi
35+
36+
# 既存のファイルやリンクを削除(バックアップは取らない)
37+
if [ -e "$dest" ] || [ -L "$dest" ]; then
38+
echo "既存の $dest を削除"
39+
rm -rf "$dest"
40+
fi
41+
42+
# シンボリックリンクを作成
43+
echo "$src$dest"
44+
ln -s "$src" "$dest"
45+
done
46+
47+
echo "「シンボリックリンク」の作成が完了しました"

scripts/setup/setup.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+
echo "「dotfiles」のセットアップを開始しました"
5+
6+
INSTALL_DIR="$HOME/dotfiles"
7+
8+
sh "$INSTALL_DIR/scripts/setup/link_dotfiles.sh"
9+
sh "$INSTALL_DIR/scripts/setup/homebrew_setup.sh"
10+
sh "$INSTALL_DIR/scripts/setup/asdf_setup.sh"
11+
sh "$INSTALL_DIR/scripts/setup/vscode_setup.sh"
12+
sh "$INSTALL_DIR/scripts/setup/xcode_setup.sh"
13+
sh "$INSTALL_DIR/scripts/setup/android_setup.sh"
14+
15+
echo "「dotfiles」のセットアップが完了しました"

scripts/setup/vscode_setup.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「VSCode」のセットアップを開始しました"
5+
6+
# 拡張機能をインストール
7+
xargs -L 1 code --install-extension < ~/dotfiles/vscode/extensions.txt
8+
9+
echo "「VSCode」のセットアップが完了しました"

scripts/setup/xcode_setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env zsh
2+
set -euo pipefail
3+
4+
echo "「Xcode」のセットアップを開始しました"
5+
6+
# podのインストール
7+
gem install cocoapods
8+
9+
# xcodebuildのライセンスを受諾
10+
yes | sudo xcodebuild -license accept || true
11+
12+
echo "「Xcode」のセットアップが完了しました"

0 commit comments

Comments
 (0)