diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7f6da996..7ca61526 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,6 +3,7 @@ "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "ghcr.io/devcontainers-extra/features/homebrew-package:1": {}, + "ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {}, "./features/common": {}, "ghcr.io/itsmechlark/features/1password:1": {}, "ghcr.io/devcontainers/features/github-cli:1": {}, diff --git a/.devcontainer/features/common/devcontainer-feature.json b/.devcontainer/features/common/devcontainer-feature.json index 00222e45..7e56ee3a 100644 --- a/.devcontainer/features/common/devcontainer-feature.json +++ b/.devcontainer/features/common/devcontainer-feature.json @@ -4,10 +4,9 @@ "name": "Common Development Setup", "description": "Installs common development functions and configures development environment scripts", "installsAfter": [ - "ghcr.io/meaningful-ooo/devcontainer-features/homebrew" + "ghcr.io/meaningful-ooo/devcontainer-features/homebrew", + "ghcr.io/devcontainers-extra/features/zsh-plugins:0", + "ghcr.io/eitsupi/devcontainer-features/jq-likes:2" ], - "options": {}, - "init": true, - "entrypoint": "/bin/sh", - "args": ["-c", "sh .devcontainer/features/common/install.sh"] + "options": {} } diff --git a/.devcontainer/features/common/install.sh b/.devcontainer/features/common/install.sh old mode 100755 new mode 100644 index fecefcc1..dd1b5689 --- a/.devcontainer/features/common/install.sh +++ b/.devcontainer/features/common/install.sh @@ -1,14 +1,43 @@ -#!/bin/sh -set -e - -# npm/global.jsonからパッケージを読み込んでインストール -if [ -f "npm/global.json" ]; then - echo "Installing global npm packages from npm/global.json..." - jq -r '.dependencies | keys[]' npm/global.json | while read package; do - version=$(jq -r ".dependencies[\"$package\"].version" npm/global.json) - echo "Installing $package@$version..." - npm install -g "$package@$version" - done +#!/usr/bin/env bash +[ -n "${ZSH_VERSION-}" ] && emulate -L sh +set -eu +if (set -o 2>/dev/null | grep -q pipefail); then + set -o pipefail fi +echo "Starting common feature installation..." +echo "Current working directory: $(pwd)" +echo "User: $(whoami)" +echo "Home directory: $HOME" + +GLOBAL_JSON_PATHS=( + "npm/global.json" + "/workspace/npm/global.json" + "/workspaces/*/npm/global.json" + "$HOME/npm/global.json" + "/tmp/build/npm/global.json" +) + +GLOBAL_JSON_FILE="" +for path in ${GLOBAL_JSON_PATHS[@]}; do + for file in $path; do + if [ -f "$file" ]; then + GLOBAL_JSON_FILE="$file" + echo "Found npm/global.json at: $GLOBAL_JSON_FILE" + break 2 + fi + done +done + +if [ -z "$GLOBAL_JSON_FILE" ]; then + echo "Warning: npm/global.json not found in any of the expected locations:" + for path in ${GLOBAL_JSON_PATHS[@]}; do + echo " - $path" + done + echo "Skipping npm package installation." + exit 0 +fi + +npm install -g $(jq -r '.dependencies | keys[]' "$GLOBAL_JSON_FILE") + echo "Feature installation completed. Configuration will be applied by postCreateCommand."