-
Notifications
You must be signed in to change notification settings - Fork 0
feat: enhance package auto-update with Claude Code focus #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Update Claude Code | ||
|
|
||
| Claude Code の最新バージョンをチェックして更新します。 | ||
|
|
||
| ## 実行内容 | ||
|
|
||
| 1. npm/global.json から現在の `@anthropic-ai/claude-code` のバージョンを取得 | ||
| 2. npm registry から最新バージョンを取得 | ||
| 3. バージョンを比較して、更新が必要な場合は global.json を更新 | ||
| 4. リリースノートのURLを表示 | ||
|
|
||
| ## 使用方法 | ||
|
|
||
| ```bash | ||
| /update-claude-code | ||
| ``` | ||
|
|
||
| ## 実装 | ||
|
|
||
| ```bash | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # スクリプトのディレクトリを取得 | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" | ||
|
|
||
| # 環境変数を設定して自動更新を有効化 | ||
| export AUTO_UPDATE=true | ||
| export CI=true | ||
|
|
||
| # Claude Code更新スクリプトを実行 | ||
| if [[ -f "${PROJECT_ROOT}/script/update-claude-code.sh" ]]; then | ||
| bash "${PROJECT_ROOT}/script/update-claude-code.sh" | ||
| else | ||
| echo "Error: update-claude-code.sh が見つかりません" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 更新があった場合の後処理 | ||
| if git diff --quiet npm/global.json; then | ||
| echo "✓ Claude Code は既に最新です" | ||
| else | ||
| echo "" | ||
| echo "更新が完了しました。変更をコミットしてください:" | ||
| echo " git add npm/global.json" | ||
| echo " git commit -m 'chore: update Claude Code to latest version'" | ||
| echo "" | ||
| git diff npm/global.json | ||
| fi | ||
| ``` | ||
|
|
||
| ## 注意事項 | ||
|
|
||
| - このコマンドは config リポジトリ内で実行する必要があります | ||
| - 更新後は手動でコミットとプッシュが必要です | ||
| - CI環境では自動的に更新されます(確認プロンプトなし) |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/usr/bin/env bash | ||
| # ============================================================================ | ||
| # Claude Code Version Update Script | ||
| # @anthropic-ai/claude-code の最新バージョンをチェックして更新します | ||
| # ============================================================================ | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # カラー出力 | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| RED='\033[0;31m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } | ||
| log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; } | ||
| log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } | ||
| log_error() { echo -e "${RED}[ERROR]${NC} $1"; } | ||
|
|
||
| # スクリプトのディレクトリを取得 | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" | ||
|
|
||
| GLOBAL_FILE="${PROJECT_ROOT}/npm/global.json" | ||
| PACKAGE="@anthropic-ai/claude-code" | ||
|
|
||
| log_info "Claude Code バージョン更新を開始します..." | ||
|
|
||
| # jqの存在確認 | ||
| if ! command -v jq &> /dev/null; then | ||
| log_error "jq が必要です。インストールしてください: brew install jq" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # npmの存在確認 | ||
| if ! command -v npm &> /dev/null; then | ||
| log_error "npm が必要です。" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # global.jsonの存在確認 | ||
| if [[ ! -f "$GLOBAL_FILE" ]]; then | ||
| log_error "global.json が見つかりません: ${GLOBAL_FILE}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 現在のバージョンを取得 | ||
| current_version=$(jq -r ".dependencies[\"${PACKAGE}\"].version" "$GLOBAL_FILE") | ||
| log_info "現在のバージョン: ${current_version}" | ||
|
|
||
| # 最新バージョンを取得 | ||
| log_info "最新バージョンを確認中..." | ||
| latest_version=$(npm view "$PACKAGE" version 2>/dev/null) | ||
|
|
||
| if [[ -z "$latest_version" ]]; then | ||
| log_error "最新バージョンの取得に失敗しました" | ||
| exit 1 | ||
| fi | ||
|
|
||
| log_info "最新バージョン: ${latest_version}" | ||
|
|
||
| # バージョン比較 | ||
| if [[ "$current_version" == "$latest_version" ]]; then | ||
| log_success "Claude Code は既に最新バージョンです (${current_version})" | ||
| exit 0 | ||
| fi | ||
|
|
||
| log_warn "バージョンが異なります: ${current_version} → ${latest_version}" | ||
|
|
||
| # 更新するかどうかを確認(CI環境では自動的に更新) | ||
| if [[ "${CI:-false}" != "true" ]] && [[ "${AUTO_UPDATE:-false}" != "true" ]]; then | ||
| read -p "更新しますか? (y/N): " -n 1 -r | ||
| echo | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
| log_info "更新をキャンセルしました" | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| # global.jsonを更新 | ||
| log_info "global.json を更新中..." | ||
| tmp_file=$(mktemp) | ||
| jq --arg version "$latest_version" \ | ||
| ".dependencies[\"${PACKAGE}\"].version = \$version" "$GLOBAL_FILE" > "$tmp_file" | ||
| mv "$tmp_file" "$GLOBAL_FILE" | ||
|
|
||
| log_success "Claude Code を ${current_version} → ${latest_version} に更新しました" | ||
|
|
||
| # リリースノートのURLを表示 | ||
| log_info "リリースノート: https://github.com/anthropics/claude-code/releases" | ||
|
|
||
| log_success "更新完了!" |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:32:6: Double quote to prevent globbing and word splitting [shellcheck]