-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-pie-elements.sh
More file actions
executable file
·117 lines (103 loc) · 3.06 KB
/
update-pie-elements.sh
File metadata and controls
executable file
·117 lines (103 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
#!/bin/bash
# Script to update pie-elements to use the Git dependency
set -e
echo ""
echo "🔄 Updating pie-elements to use Git dependency"
echo "=============================================="
echo ""
# Check if we're in pie-elements root
if [ ! -f "lerna.json" ]; then
echo "❌ Error: This script must be run from pie-elements root"
echo "Current directory: $(pwd)"
echo "Expected: /Users/patriciaromaniuc/pie-framework/pie-elements"
exit 1
fi
echo "📍 Current directory: $(pwd)"
echo ""
# Backup package.json
echo "💾 Creating backup of package.json..."
cp package.json package.json.backup
echo "✅ Backup created: package.json.backup"
echo ""
# Ask for the version to use
echo "Which version do you want to use?"
echo " 1. Latest (main branch)"
echo " 2. v1.0.0 (stable tag)"
echo " 3. Custom tag/branch"
echo ""
read -p "Enter choice (1, 2, or 3): " version_choice
case $version_choice in
1)
GIT_REF="main"
;;
2)
GIT_REF="v1.0.0"
;;
3)
read -p "Enter tag/branch name: " custom_ref
GIT_REF="$custom_ref"
;;
*)
echo "Invalid choice"
exit 1
;;
esac
echo ""
echo "📝 Updating package.json..."
echo " From: file:./tools/pie-code-health"
echo " To: git+ssh://git@github.com:pie-framework/pie-code-health.git#$GIT_REF"
echo ""
# Update package.json
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.devDependencies['@pie-framework/pie-code-health'] = 'git+ssh://git@github.com:pie-framework/pie-code-health.git#$GIT_REF';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
console.log('✅ package.json updated');
"
echo ""
echo "🗑️ Removing old installation..."
rm -rf node_modules/@pie-framework/pie-code-health
echo "✅ Old installation removed"
echo ""
echo "📦 Installing from Git..."
yarn install
if [ $? -eq 0 ]; then
echo ""
echo "✅ Installation successful!"
echo ""
echo "🧪 Testing installation..."
npm run health:scan
if [ $? -eq 0 ]; then
echo ""
echo "🎉 SUCCESS! Git dependency is working!"
echo ""
echo "You can now:"
echo " - Run: npm run health:check"
echo " - Remove backup: rm package.json.backup"
echo ""
echo "To update to latest later:"
echo " yarn upgrade @pie-framework/pie-code-health"
else
echo ""
echo "⚠️ Installation succeeded but health:scan failed"
echo "You may want to restore the backup:"
echo " mv package.json.backup package.json"
echo " yarn install"
fi
else
echo ""
echo "❌ Installation failed!"
echo ""
echo "Restoring backup..."
mv package.json.backup package.json
yarn install
echo ""
echo "Backup restored. The error might be:"
echo " - Repository doesn't exist yet"
echo " - SSH key not configured"
echo " - Network issues"
echo ""
echo "Try using HTTPS instead:"
echo " git+https://github.com/pie-framework/pie-code-health.git#$GIT_REF"
fi