diff --git a/src/claude-code/install.sh b/src/claude-code/install.sh index b115c9e..7f14164 100755 --- a/src/claude-code/install.sh +++ b/src/claude-code/install.sh @@ -90,7 +90,14 @@ install_nodejs() { # Function to install Claude Code CLI install_claude_code() { echo "Installing Claude Code CLI..." - npm install -g @anthropic-ai/claude-code + local npm_version npm_major_version + npm_version="$(npm --version)" + npm_major_version="${npm_version%%.*}" + if [ "$npm_major_version" -ge 12 ] 2>/dev/null; then + npm install -g @anthropic-ai/claude-code --allow-scripts=@anthropic-ai/claude-code + else + npm install -g @anthropic-ai/claude-code + fi if command -v claude >/dev/null; then echo "Claude Code CLI installed successfully!" @@ -137,4 +144,4 @@ main() { } # Execute main function -main \ No newline at end of file +main diff --git a/test/claude-code/auto-install-node.sh b/test/claude-code/auto-install-node.sh new file mode 100755 index 0000000..8f3aeed --- /dev/null +++ b/test/claude-code/auto-install-node.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Validate the auto-install path installed Node.js 18 from NodeSource. +if ! node --version | grep -q "^v18\."; then + echo "expected Node.js 18.x from auto-install path" + exit 1 +fi + +if [ ! -f /etc/apt/sources.list.d/nodesource.list ]; then + echo "expected NodeSource apt source list to exist" + exit 1 +fi + +echo "Auto-install Node.js scenario checks passed!" +exit 0 diff --git a/test/claude-code/scenarios.json b/test/claude-code/scenarios.json index 0c894f0..0dcd99e 100644 --- a/test/claude-code/scenarios.json +++ b/test/claude-code/scenarios.json @@ -5,5 +5,11 @@ "ghcr.io/devcontainers/features/node:1": {}, "claude-code": {} } + }, + "auto-install-node": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "claude-code": {} + } } } \ No newline at end of file