-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-github-repo.sh
More file actions
executable file
·216 lines (191 loc) · 7.12 KB
/
create-github-repo.sh
File metadata and controls
executable file
·216 lines (191 loc) · 7.12 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
# Quick setup script to create and push pie-code-health repository
# This automates all the steps needed to create the GitHub repository
set -e
echo ""
echo "🏥 PIE Code Health - GitHub Repository Creator"
echo "=============================================="
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo -e "${YELLOW}⚠️ GitHub CLI (gh) is not installed.${NC}"
echo ""
echo "Choose an option:"
echo " 1. Install gh CLI (recommended)"
echo " 2. Continue with manual setup"
echo ""
read -p "Enter choice (1 or 2): " choice
if [ "$choice" == "1" ]; then
echo ""
echo "Install gh CLI:"
echo " macOS: brew install gh"
echo " Linux: See https://github.com/cli/cli/blob/trunk/docs/install_linux.md"
echo ""
echo "After installing, run: gh auth login"
exit 1
fi
fi
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
echo -e "${RED}❌ Error: package.json not found${NC}"
echo "Please cd to the pie-code-health directory first:"
echo " cd /Users/patriciaromaniuc/pie-framework/pie-elements/tools/pie-code-health"
exit 1
fi
echo -e "${BLUE}📍 Current directory: $(pwd)${NC}"
echo ""
# Check git status
if [ -d ".git" ]; then
echo -e "${YELLOW}⚠️ Git repository already initialized${NC}"
echo "This directory already has a git repository."
echo "Do you want to:"
echo " 1. Use existing git repo (keep history)"
echo " 2. Start fresh (remove .git and reinitialize)"
echo " 3. Cancel"
echo ""
read -p "Enter choice (1, 2, or 3): " git_choice
if [ "$git_choice" == "2" ]; then
rm -rf .git
echo -e "${GREEN}✅ Removed old git repository${NC}"
elif [ "$git_choice" == "3" ]; then
echo "Cancelled."
exit 0
fi
fi
# Initialize git if needed
if [ ! -d ".git" ]; then
echo -e "${BLUE}🔧 Initializing git repository...${NC}"
git init
echo -e "${GREEN}✅ Git initialized${NC}"
fi
# Configure git
echo ""
echo -e "${BLUE}📝 Configuring git...${NC}"
git config --local core.autocrlf input
git config --local core.eol lf
# Add all files
echo -e "${BLUE}📦 Adding files...${NC}"
git add .
# Create initial commit
if git diff --staged --quiet; then
echo -e "${YELLOW}⚠️ No changes to commit${NC}"
else
echo -e "${BLUE}💾 Creating initial commit...${NC}"
git commit -m "Initial commit: PIE Code Health Analyzer
- Core analyzers (deprecated, risks, complexity, dependencies)
- CLI tools (pie-health, pie-health-scan, pie-health-report, pie-health-dashboard)
- Interactive SPA dashboard with Chart.js visualizations
- HTTP server for dashboard viewing
- Comprehensive documentation and guides
- Flexible configuration system
- GitHub Actions CI/CD workflows
- MIT License"
echo -e "${GREEN}✅ Initial commit created${NC}"
fi
# Rename branch to main if needed
current_branch=$(git branch --show-current)
if [ "$current_branch" != "main" ]; then
echo -e "${BLUE}🔀 Renaming branch to 'main'...${NC}"
git branch -M main
fi
echo ""
echo -e "${GREEN}✅ Local repository ready!${NC}"
echo ""
# Ask if user wants to create GitHub repo now
if command -v gh &> /dev/null; then
echo "Do you want to create the GitHub repository now?"
echo " Repository: pie-framework/pie-code-health"
echo " Visibility: public"
echo ""
read -p "Create now? (y/n): " create_now
if [ "$create_now" == "y" ] || [ "$create_now" == "Y" ]; then
echo ""
echo -e "${BLUE}🚀 Creating GitHub repository...${NC}"
gh repo create pie-framework/pie-code-health \
--public \
--description "AI-Assisted Code Health Analysis Tool for PIE Framework" \
--source=. \
--remote=origin \
--push
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Repository created and pushed!${NC}"
# Create and push tag
echo ""
echo -e "${BLUE}🏷️ Creating v1.0.0 tag...${NC}"
git tag -a v1.0.0 -m "Initial release v1.0.0
Features:
- Complete code health analysis
- Interactive dashboard
- CLI tools
- Comprehensive documentation"
git push origin v1.0.0
echo -e "${GREEN}✅ Tag v1.0.0 created and pushed${NC}"
echo ""
echo -e "${GREEN}🎉 SUCCESS! Repository is ready!${NC}"
echo ""
echo "Repository URL: https://github.com/pie-framework/pie-code-health"
echo ""
echo -e "${BLUE}Next steps:${NC}"
echo "1. Update pie-elements to use the Git dependency:"
echo " cd /Users/patriciaromaniuc/pie-framework/pie-elements"
echo " # Edit package.json and change the dependency to:"
echo " \"@pie-framework/pie-code-health\": \"git+ssh://git@github.com:pie-framework/pie-code-health.git#v1.0.0\""
echo ""
echo "2. Reinstall in pie-elements:"
echo " rm -rf node_modules/@pie-framework/pie-code-health"
echo " yarn install"
echo ""
echo "3. Test it works:"
echo " npm run health:check"
echo ""
else
echo -e "${RED}❌ Failed to create repository${NC}"
echo "You may need to:"
echo "1. Check gh auth status: gh auth status"
echo "2. Login again: gh auth login"
echo "3. Or create manually and push"
fi
else
echo ""
echo -e "${YELLOW}Manual setup required:${NC}"
echo ""
echo "1. Create repository on GitHub:"
echo " https://github.com/organizations/pie-framework/repositories/new"
echo " Name: pie-code-health"
echo " Description: AI-Assisted Code Health Analysis Tool for PIE Framework"
echo " Public repository"
echo " Do NOT initialize with README, .gitignore, or license"
echo ""
echo "2. Add remote and push:"
echo " git remote add origin git@github.com:pie-framework/pie-code-health.git"
echo " git push -u origin main"
echo ""
echo "3. Create and push tag:"
echo " git tag -a v1.0.0 -m \"Initial release v1.0.0\""
echo " git push origin v1.0.0"
fi
else
echo -e "${YELLOW}Manual setup required (gh CLI not available):${NC}"
echo ""
echo "1. Create repository on GitHub:"
echo " https://github.com/organizations/pie-framework/repositories/new"
echo " Name: pie-code-health"
echo " Description: AI-Assisted Code Health Analysis Tool for PIE Framework"
echo " Public repository"
echo " Do NOT initialize with README, .gitignore, or license"
echo ""
echo "2. Add remote and push:"
echo " git remote add origin git@github.com:pie-framework/pie-code-health.git"
echo " git push -u origin main"
echo ""
echo "3. Create and push tag:"
echo " git tag -a v1.0.0 -m \"Initial release v1.0.0\""
echo " git push origin v1.0.0"
fi
echo ""