Files
fe-common-rules/scripts/install.sh

94 lines
2.6 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
#
# fe-common-rules installer
# 현재 Git 프로젝트의 .claude/common 경로에 fe-common-rules 저장소를
# submodule 로 추가하고 루트 CLAUDE.md 템플릿을 생성합니다.
#
# 사용법:
# bash scripts/install.sh [<repo-url>] [<branch>]
#
# 예:
# bash scripts/install.sh git@github.com:our-team/fe-common-rules.git main
#
set -euo pipefail
REPO_URL="${1:-}"
BRANCH="${2:-main}"
TARGET_PATH=".claude/common"
if [[ -z "$REPO_URL" ]]; then
echo "❌ 사용법: bash scripts/install.sh <repo-url> [branch]" >&2
echo " 예: bash scripts/install.sh git@github.com:our-team/fe-common-rules.git main" >&2
exit 1
fi
# Git 프로젝트인지 확인
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "❌ 현재 디렉토리는 Git 저장소가 아닙니다. 먼저 'git init' 후 실행해주세요." >&2
exit 1
fi
# 이미 submodule 이 존재하는지 확인
if [[ -d "$TARGET_PATH" ]]; then
echo "⚠️ '$TARGET_PATH' 경로가 이미 존재합니다. 설치를 건너뜁니다."
else
echo "📦 fe-common-rules 를 submodule 로 추가합니다..."
git submodule add -b "$BRANCH" "$REPO_URL" "$TARGET_PATH"
git submodule update --init --recursive
echo "✅ submodule 추가 완료: $TARGET_PATH"
fi
# 프로젝트 지침 폴더 생성
mkdir -p .claude/project
# CLAUDE.md 템플릿 생성 (없을 때만)
if [[ ! -f "CLAUDE.md" ]]; then
cat > CLAUDE.md <<'EOF'
# <프로젝트 이름>
## 공통 지침
@.claude/common/CLAUDE.md
## 프로젝트 지침
@.claude/project/overview.md
@.claude/project/conventions.md
EOF
echo "✅ CLAUDE.md 템플릿을 생성했습니다."
else
echo " 기존 CLAUDE.md 가 이미 존재합니다. 아래 블록을 수동으로 추가하세요:"
echo ""
echo " ## 공통 지침"
echo " @.claude/common/CLAUDE.md"
echo ""
fi
# 프로젝트 지침 샘플 파일
if [[ ! -f ".claude/project/overview.md" ]]; then
cat > .claude/project/overview.md <<'EOF'
# 프로젝트 개요
- 서비스명:
- 기술 스택:
- 주요 기능:
- 주의사항:
EOF
fi
if [[ ! -f ".claude/project/conventions.md" ]]; then
cat > .claude/project/conventions.md <<'EOF'
# 프로젝트 전용 컨벤션
공통 지침 외에 이 프로젝트에서만 적용되는 규칙을 작성하세요.
EOF
fi
echo ""
echo "🎉 설치가 완료되었습니다."
echo " - 공통 지침: .claude/common/CLAUDE.md"
echo " - 프로젝트 지침: .claude/project/"
echo " - 엔트리 파일: CLAUDE.md"
echo ""
echo "변경 사항을 커밋해 주세요:"
echo " git add .gitmodules .claude CLAUDE.md"
echo " git commit -m 'chore: add fe-common-rules submodule'"