Created
May 18, 2026 10:00
-
-
Save jiskanulo/a4582af98ad44377fbe520ca06b43503 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Takumi Guard の registry 設定ファイルを pip / uv / npm / pnpm / bundle 用に配置する。既に存在するファイルは触らない | |
| set -euo pipefail | |
| # ---------------------------------------------------------------------- | |
| # 実行前の注意書き | |
| # ---------------------------------------------------------------------- | |
| read -r -d '' NOTICE <<'EOF' || true | |
| 実行前にこのスクリプトの内容は確認しましたか? | |
| 内容を理解せず実行しようとしていませんか? | |
| 不安な場合は実行前にこのスクリプトについての解説をお手元のAIで確認してください! | |
| EOF | |
| confirm() { | |
| printf '%s\n\n' "$NOTICE" | |
| printf '実行しますか? [y/N]: ' | |
| local ans | |
| read -r ans | |
| case "$ans" in | |
| y|Y|yes|YES) return 0 ;; | |
| *) echo "aborted."; exit 1 ;; | |
| esac | |
| } | |
| log() { printf '[takumi-guard:file] %s\n' "$*"; } | |
| skip() { printf '[takumi-guard:file] skip: %s\n' "$*"; } | |
| place_pip() { | |
| local file="$HOME/.config/pip/pip.conf" | |
| if [[ -e "$file" ]]; then | |
| skip "pip: $file already exists" | |
| return | |
| fi | |
| mkdir -p "$(dirname "$file")" | |
| cat > "$file" <<'EOF' | |
| [global] | |
| index-url = https://pypi.flatt.tech/simple/ | |
| EOF | |
| log "pip: created $file" | |
| } | |
| place_uv() { | |
| local file="$HOME/.config/uv/uv.toml" | |
| if [[ -e "$file" ]]; then | |
| skip "uv: $file already exists" | |
| return | |
| fi | |
| mkdir -p "$(dirname "$file")" | |
| cat > "$file" <<'EOF' | |
| [[index]] | |
| url = "https://pypi.flatt.tech/simple/" | |
| default = true | |
| EOF | |
| log "uv: created $file" | |
| } | |
| place_npm() { | |
| local file="$HOME/.npmrc" | |
| if [[ -e "$file" ]]; then | |
| skip "npm/pnpm: $file already exists" | |
| return | |
| fi | |
| echo 'registry=https://npm.flatt.tech' > "$file" | |
| chmod 600 "$file" | |
| log "npm/pnpm: created $file" | |
| } | |
| place_bundle() { | |
| local file="$HOME/.bundle/config" | |
| if [[ -e "$file" ]]; then | |
| skip "bundle: $file already exists" | |
| return | |
| fi | |
| mkdir -p "$(dirname "$file")" | |
| cat > "$file" <<'EOF' | |
| --- | |
| BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/: "https://rubygems.flatt.tech" | |
| EOF | |
| log "bundle: created $file" | |
| } | |
| main() { | |
| confirm | |
| place_pip | |
| place_uv | |
| place_npm | |
| place_bundle | |
| log "done" | |
| } | |
| main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment