@schandlergarcia/sf-web-components 1.9.43 → 1.9.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.a4drules/RULES.md +456 -0
- package/ARCHITECTURE.md +112 -0
- package/CHANGELOG.md +401 -0
- package/CONTRIBUTING.md +247 -0
- package/QUICK-REFERENCE.md +212 -0
- package/README.md +76 -14
- package/package.json +8 -2
- package/scripts/pre-publish-check.sh +180 -0
- package/scripts/verify-consistency.sh +238 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Verification script to ensure consistency between:
|
|
4
|
+
# 1. .a4drules documentation
|
|
5
|
+
# 2. Component implementations
|
|
6
|
+
# 3. Template imports
|
|
7
|
+
# 4. Barrel exports
|
|
8
|
+
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
+
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
13
|
+
|
|
14
|
+
echo "🔍 Verifying sf-web-components consistency..."
|
|
15
|
+
echo ""
|
|
16
|
+
|
|
17
|
+
ERRORS=0
|
|
18
|
+
|
|
19
|
+
# Color codes
|
|
20
|
+
RED='\033[0;31m'
|
|
21
|
+
GREEN='\033[0;32m'
|
|
22
|
+
YELLOW='\033[1;33m'
|
|
23
|
+
NC='\033[0m' # No Color
|
|
24
|
+
|
|
25
|
+
# Check 1: UIButton and UIInput must exist as .tsx files
|
|
26
|
+
echo "📦 Checking UI component files..."
|
|
27
|
+
if [ -f "$ROOT/src/components/library/ui/UIButton.tsx" ]; then
|
|
28
|
+
echo -e " ${GREEN}✓${NC} UIButton.tsx exists"
|
|
29
|
+
else
|
|
30
|
+
echo -e " ${RED}✗${NC} UIButton.tsx missing (required by documentation)"
|
|
31
|
+
ERRORS=$((ERRORS + 1))
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
if [ -f "$ROOT/src/components/library/ui/UIInput.tsx" ]; then
|
|
35
|
+
echo -e " ${GREEN}✓${NC} UIInput.tsx exists"
|
|
36
|
+
else
|
|
37
|
+
echo -e " ${RED}✗${NC} UIInput.tsx missing (required by documentation)"
|
|
38
|
+
ERRORS=$((ERRORS + 1))
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Check 2: Button.jsx and Input.jsx should NOT exist in ui/
|
|
42
|
+
if [ -f "$ROOT/src/components/library/ui/Button.jsx" ] || [ -f "$ROOT/src/components/library/ui/Button.tsx" ]; then
|
|
43
|
+
echo -e " ${RED}✗${NC} Button.jsx/tsx exists in ui/ (should be UIButton.tsx)"
|
|
44
|
+
ERRORS=$((ERRORS + 1))
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
if [ -f "$ROOT/src/components/library/ui/Input.jsx" ] || [ -f "$ROOT/src/components/library/ui/Input.tsx" ]; then
|
|
48
|
+
echo -e " ${RED}✗${NC} Input.jsx/tsx exists in ui/ (should be UIInput.tsx)"
|
|
49
|
+
ERRORS=$((ERRORS + 1))
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
echo ""
|
|
53
|
+
|
|
54
|
+
# Check 3: Barrel export consistency
|
|
55
|
+
echo "📚 Checking barrel export (index.jsx)..."
|
|
56
|
+
if grep -q 'from "./ui/UIButton"' "$ROOT/src/components/library/index.jsx"; then
|
|
57
|
+
echo -e " ${GREEN}✓${NC} UIButton exported correctly"
|
|
58
|
+
else
|
|
59
|
+
echo -e " ${RED}✗${NC} UIButton export incorrect or missing"
|
|
60
|
+
ERRORS=$((ERRORS + 1))
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
if grep -q 'from "./ui/UIInput"' "$ROOT/src/components/library/index.jsx"; then
|
|
64
|
+
echo -e " ${GREEN}✓${NC} UIInput exported correctly"
|
|
65
|
+
else
|
|
66
|
+
echo -e " ${RED}✗${NC} UIInput export incorrect or missing"
|
|
67
|
+
ERRORS=$((ERRORS + 1))
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Check for wrong paths
|
|
71
|
+
if grep -q 'from "./ui/Button"' "$ROOT/src/components/library/index.jsx"; then
|
|
72
|
+
echo -e " ${RED}✗${NC} Incorrect export path: ./ui/Button (should be ./ui/UIButton)"
|
|
73
|
+
ERRORS=$((ERRORS + 1))
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
if grep -q 'from "./ui/Input"' "$ROOT/src/components/library/index.jsx"; then
|
|
77
|
+
echo -e " ${RED}✗${NC} Incorrect export path: ./ui/Input (should be ./ui/UIInput)"
|
|
78
|
+
ERRORS=$((ERRORS + 1))
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
echo ""
|
|
82
|
+
|
|
83
|
+
# Check 4: Template imports
|
|
84
|
+
echo "📄 Checking template imports..."
|
|
85
|
+
TEMPLATE_ERRORS=0
|
|
86
|
+
|
|
87
|
+
# Check NotFound.tsx.template
|
|
88
|
+
if [ -f "$ROOT/src/templates/pages/NotFound.tsx.template" ]; then
|
|
89
|
+
if grep -q "from '@/components/library/ui/UIButton'" "$ROOT/src/templates/pages/NotFound.tsx.template"; then
|
|
90
|
+
echo -e " ${GREEN}✓${NC} NotFound.tsx.template imports UIButton correctly"
|
|
91
|
+
else
|
|
92
|
+
echo -e " ${RED}✗${NC} NotFound.tsx.template does not import UIButton correctly"
|
|
93
|
+
TEMPLATE_ERRORS=$((TEMPLATE_ERRORS + 1))
|
|
94
|
+
fi
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Check Home.tsx.template
|
|
98
|
+
if [ -f "$ROOT/src/templates/pages/Home.tsx.template" ]; then
|
|
99
|
+
if grep -q "from '@/components/library/ui/UIInput'" "$ROOT/src/templates/pages/Home.tsx.template"; then
|
|
100
|
+
echo -e " ${GREEN}✓${NC} Home.tsx.template imports UIInput correctly"
|
|
101
|
+
else
|
|
102
|
+
echo -e " ${RED}✗${NC} Home.tsx.template does not import UIInput correctly"
|
|
103
|
+
TEMPLATE_ERRORS=$((TEMPLATE_ERRORS + 1))
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
if grep -q "from '@/components/library/ui/UIButton'" "$ROOT/src/templates/pages/Home.tsx.template"; then
|
|
107
|
+
echo -e " ${GREEN}✓${NC} Home.tsx.template imports UIButton correctly"
|
|
108
|
+
else
|
|
109
|
+
echo -e " ${RED}✗${NC} Home.tsx.template does not import UIButton correctly"
|
|
110
|
+
TEMPLATE_ERRORS=$((TEMPLATE_ERRORS + 1))
|
|
111
|
+
fi
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
# Check Search.tsx.template
|
|
115
|
+
if [ -f "$ROOT/src/templates/pages/Search.tsx.template" ]; then
|
|
116
|
+
if grep -q "from '@/components/library/ui/UIInput'" "$ROOT/src/templates/pages/Search.tsx.template"; then
|
|
117
|
+
echo -e " ${GREEN}✓${NC} Search.tsx.template imports UIInput correctly"
|
|
118
|
+
else
|
|
119
|
+
echo -e " ${YELLOW}⚠${NC} Search.tsx.template does not import UIInput (may not need it)"
|
|
120
|
+
fi
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
# Check for wrong imports in templates
|
|
124
|
+
WRONG_IMPORTS=$(grep -r "from '@/components/library/ui/Button'" "$ROOT/src/templates/" 2>/dev/null || true)
|
|
125
|
+
if [ -n "$WRONG_IMPORTS" ]; then
|
|
126
|
+
echo -e " ${RED}✗${NC} Templates importing Button instead of UIButton:"
|
|
127
|
+
echo "$WRONG_IMPORTS" | sed 's/^/ /'
|
|
128
|
+
TEMPLATE_ERRORS=$((TEMPLATE_ERRORS + 1))
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
WRONG_IMPORTS=$(grep -r "from '@/components/library/ui/Input'" "$ROOT/src/templates/" 2>/dev/null || true)
|
|
132
|
+
if [ -n "$WRONG_IMPORTS" ]; then
|
|
133
|
+
echo -e " ${RED}✗${NC} Templates importing Input instead of UIInput:"
|
|
134
|
+
echo "$WRONG_IMPORTS" | sed 's/^/ /'
|
|
135
|
+
TEMPLATE_ERRORS=$((TEMPLATE_ERRORS + 1))
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
ERRORS=$((ERRORS + TEMPLATE_ERRORS))
|
|
139
|
+
|
|
140
|
+
echo ""
|
|
141
|
+
|
|
142
|
+
# Check 5: Internal library imports
|
|
143
|
+
echo "🔗 Checking internal library imports..."
|
|
144
|
+
INTERNAL_ERRORS=0
|
|
145
|
+
|
|
146
|
+
# Check cards/ for wrong imports
|
|
147
|
+
WRONG_CARDS=$(grep -r 'from "../ui/Button"' "$ROOT/src/components/library/cards/" 2>/dev/null || true)
|
|
148
|
+
if [ -n "$WRONG_CARDS" ]; then
|
|
149
|
+
echo -e " ${RED}✗${NC} Card components importing Button instead of UIButton:"
|
|
150
|
+
echo "$WRONG_CARDS" | sed 's/^/ /'
|
|
151
|
+
INTERNAL_ERRORS=$((INTERNAL_ERRORS + 1))
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
WRONG_CARDS=$(grep -r 'from "../ui/Input"' "$ROOT/src/components/library/cards/" 2>/dev/null || true)
|
|
155
|
+
if [ -n "$WRONG_CARDS" ]; then
|
|
156
|
+
echo -e " ${RED}✗${NC} Card components importing Input instead of UIInput:"
|
|
157
|
+
echo "$WRONG_CARDS" | sed 's/^/ /'
|
|
158
|
+
INTERNAL_ERRORS=$((INTERNAL_ERRORS + 1))
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# Check if UIButton/UIInput are imported correctly
|
|
162
|
+
CORRECT_IMPORTS=$(grep -r 'from "../ui/UIButton"' "$ROOT/src/components/library/cards/" 2>/dev/null | wc -l)
|
|
163
|
+
if [ "$CORRECT_IMPORTS" -gt 0 ]; then
|
|
164
|
+
echo -e " ${GREEN}✓${NC} Found $CORRECT_IMPORTS correct UIButton imports in cards/"
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
CORRECT_IMPORTS=$(grep -r 'from "../ui/UIInput"' "$ROOT/src/components/library/cards/" 2>/dev/null | wc -l)
|
|
168
|
+
if [ "$CORRECT_IMPORTS" -gt 0 ]; then
|
|
169
|
+
echo -e " ${GREEN}✓${NC} Found $CORRECT_IMPORTS correct UIInput imports in cards/"
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
ERRORS=$((ERRORS + INTERNAL_ERRORS))
|
|
173
|
+
|
|
174
|
+
echo ""
|
|
175
|
+
|
|
176
|
+
# Check 6: Documentation exists
|
|
177
|
+
echo "📖 Checking documentation..."
|
|
178
|
+
if [ -f "$ROOT/.a4drules/skills/component-library/ui-primitives.md" ]; then
|
|
179
|
+
# Check if UIButton is documented
|
|
180
|
+
if grep -q "UIButton" "$ROOT/.a4drules/skills/component-library/ui-primitives.md"; then
|
|
181
|
+
echo -e " ${GREEN}✓${NC} UIButton documented in ui-primitives.md"
|
|
182
|
+
else
|
|
183
|
+
echo -e " ${RED}✗${NC} UIButton not found in ui-primitives.md"
|
|
184
|
+
ERRORS=$((ERRORS + 1))
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
# Check if UIInput is documented
|
|
188
|
+
if grep -q "UIInput" "$ROOT/.a4drules/skills/component-library/ui-primitives.md"; then
|
|
189
|
+
echo -e " ${GREEN}✓${NC} UIInput documented in ui-primitives.md"
|
|
190
|
+
else
|
|
191
|
+
echo -e " ${RED}✗${NC} UIInput not found in ui-primitives.md"
|
|
192
|
+
ERRORS=$((ERRORS + 1))
|
|
193
|
+
fi
|
|
194
|
+
else
|
|
195
|
+
echo -e " ${RED}✗${NC} Documentation file missing: .a4drules/skills/component-library/ui-primitives.md"
|
|
196
|
+
ERRORS=$((ERRORS + 1))
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
echo ""
|
|
200
|
+
|
|
201
|
+
# Check 7: Package.json files array includes necessary directories
|
|
202
|
+
echo "📦 Checking package.json files array..."
|
|
203
|
+
if grep -q '"src/templates"' "$ROOT/package.json"; then
|
|
204
|
+
echo -e " ${GREEN}✓${NC} src/templates included in package.json files"
|
|
205
|
+
else
|
|
206
|
+
echo -e " ${RED}✗${NC} src/templates missing from package.json files array"
|
|
207
|
+
ERRORS=$((ERRORS + 1))
|
|
208
|
+
fi
|
|
209
|
+
|
|
210
|
+
if grep -q '"src/components"' "$ROOT/package.json"; then
|
|
211
|
+
echo -e " ${GREEN}✓${NC} src/components included in package.json files"
|
|
212
|
+
else
|
|
213
|
+
echo -e " ${RED}✗${NC} src/components missing from package.json files array"
|
|
214
|
+
ERRORS=$((ERRORS + 1))
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
if grep -q '".a4drules"' "$ROOT/package.json"; then
|
|
218
|
+
echo -e " ${GREEN}✓${NC} .a4drules included in package.json files"
|
|
219
|
+
else
|
|
220
|
+
echo -e " ${RED}✗${NC} .a4drules missing from package.json files array"
|
|
221
|
+
ERRORS=$((ERRORS + 1))
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
echo ""
|
|
225
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
226
|
+
|
|
227
|
+
if [ $ERRORS -eq 0 ]; then
|
|
228
|
+
echo -e "${GREEN}✅ All consistency checks passed!${NC}"
|
|
229
|
+
echo ""
|
|
230
|
+
echo "Safe to publish."
|
|
231
|
+
exit 0
|
|
232
|
+
else
|
|
233
|
+
echo -e "${RED}❌ Found $ERRORS error(s)${NC}"
|
|
234
|
+
echo ""
|
|
235
|
+
echo "Fix these errors before publishing."
|
|
236
|
+
echo "See CONTRIBUTING.md for guidance."
|
|
237
|
+
exit 1
|
|
238
|
+
fi
|