-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit-cursor.sh
More file actions
135 lines (107 loc) · 3.06 KB
/
init-cursor.sh
File metadata and controls
135 lines (107 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
# init_cursor_rules.sh — create Cursor .mdc rule scaffolds
# Generates .cursor/rules/*.mdc from a canonical list, deduplicating automatically.
set -euo pipefail
#######################################################################
# 1. 원본 항목 정의 -- 필요 시 여기에만 추가하세요
#######################################################################
declare -a RAW_ITEMS=(
"PRD"
"app-flow-doc"
"tech-stack-doc"
"frontend-guidelines"
"backend-structure"
"security-checklist"
"user-flow"
"styling"
"project-structure"
"schema design"
"api-spec"
"design"
"requirements"
"architecture"
"roadmap"
"context"
)
#######################################################################
# 2. 정규화(소문자·공백→하이픈) + Dedup
#######################################################################
for i in "${!RAW_ITEMS[@]}"; do
RAW_ITEMS[$i]=$(echo "${RAW_ITEMS[$i]}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
done
declare -A seen=()
UNIQUE_ITEMS=()
for item in "${RAW_ITEMS[@]}"; do
if [[ -z "${seen[$item]:-}" ]]; then
UNIQUE_ITEMS+=("$item")
seen["$item"]=1
fi
done
#######################################################################
# 3. .mdc 파일 생성
#######################################################################
printf "\n📁 Creating .cursor/rules structure...\n"
mkdir -p .cursor/rules
# slug → Title Case 변환: api-spec → Api Spec
to_title() {
echo "$1" | tr '-' ' ' | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2)}; print}'
}
for slug in "${UNIQUE_ITEMS[@]}"; do
file=".cursor/rules/${slug}.mdc"
if [[ -f "$file" ]]; then
echo "⚠️ $file already exists — skipping"
continue
fi
title="$(to_title "$slug")"
if [[ "$slug" == "prd" ]]; then
cat > "$file" <<EOF
---
title: "PRD"
description: "Product Requirements Document – single source of truth for the project."
alwaysApply: false
---
## 프로젝트 개요 (Project Overview)
<!-- 프로젝트의 비전, 문제 정의, 목표를 서술하세요. -->
## 기술 스택 (Tech Stack)
| Layer | Tech/Tool | Rationale |
|-------|-----------|-----------|
| Frontend | | |
| Backend | | |
| Database | | |
| Infrastructure | | |
## 유저 플로우 (User Flow)
```mermaid
flowchart TD
User["사용자"] -->|Action| System["서비스"]
```
## 핵심 기능 (Core Features)
1. Feature 1
- KPI:
- Priority:
## UI 상세 (UI Details)
<!-- 주요 화면, 컴포넌트, 인터랙션을 설명하거나 링크하세요. -->
## 백엔드 스키마 (Backend Schema)
```sql
-- 예: CREATE TABLE users (...)
```
## 보안 가이드라인 (Security Guidelines)
- 인증/인가
- 데이터 암호화
- 로깅 및 모니터링
## 규제 준수 (Regulations)
- GDPR
- 기타 산업 표준
EOF
else
cat > "$file" <<EOF
---
title: "${title}"
description: "TODO: add description for ${title}"
alwaysApply: false
---
<!-- Write your ${title} content here -->
EOF
fi
echo "✅ Created $file"
done
printf "\n🎉 Done. Customise each .mdc file as needed.\n"