-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvalidate-dependency-chain.sh
More file actions
executable file
Β·171 lines (142 loc) Β· 5.21 KB
/
Copy pathvalidate-dependency-chain.sh
File metadata and controls
executable file
Β·171 lines (142 loc) Β· 5.21 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
#!/bin/bash
# Script to validate the dependency chain for DIGIT UI packages
# This helps ensure the publish order is correct
set -e
echo "π Validating DIGIT UI Package Dependency Chain..."
echo "=================================================="
# Define package paths
WEBPACK_DIR="webpack"
# Function to get package info
get_package_info() {
local package_dir=$1
local package_json="$WEBPACK_DIR/$package_dir/package.json"
if [ ! -f "$package_json" ]; then
echo "β Package.json not found: $package_json"
return 1
fi
local name=$(node -p "require('./$package_json').name" 2>/dev/null)
local version=$(node -p "require('./$package_json').version" 2>/dev/null)
echo "$name@$version"
}
# Function to get dependencies
get_internal_deps() {
local package_dir=$1
local package_json="$WEBPACK_DIR/$package_dir/package.json"
if [ ! -f "$package_json" ]; then
return 0
fi
# Get dependencies and peerDependencies that are internal DIGIT packages
node -e "
const pkg = require('./$package_json');
const deps = {...(pkg.dependencies || {}), ...(pkg.peerDependencies || {})};
const internalDeps = Object.keys(deps).filter(dep => dep.startsWith('@egovernments/digit-ui-'));
if (internalDeps.length > 0) {
console.log(internalDeps.join(' '));
}
" 2>/dev/null || true
}
echo "π¦ Package Analysis:"
echo "==================="
# Analyze each package
echo "π libraries: $(get_package_info 'libraries')"
LIBS_DEPS=$(get_internal_deps 'libraries')
if [ -n "$LIBS_DEPS" ]; then
echo " π Internal dependencies: $LIBS_DEPS"
else
echo " π No internal dependencies β
"
fi
echo ""
echo "π svg-components: $(get_package_info 'svg-components')"
SVG_DEPS=$(get_internal_deps 'svg-components')
if [ -n "$SVG_DEPS" ]; then
echo " π Internal dependencies: $SVG_DEPS"
else
echo " π No internal dependencies β
"
fi
echo ""
echo "π ui-components: $(get_package_info 'ui-components')"
UI_DEPS=$(get_internal_deps 'ui-components')
if [ -n "$UI_DEPS" ]; then
echo " π Internal dependencies: $UI_DEPS"
else
echo " π No internal dependencies"
fi
echo ""
echo "π react-components: $(get_package_info 'react-components')"
REACT_DEPS=$(get_internal_deps 'react-components')
if [ -n "$REACT_DEPS" ]; then
echo " π Internal dependencies: $REACT_DEPS"
else
echo " π No internal dependencies"
fi
echo ""
echo "ποΈ Recommended Publish Order:"
echo "============================="
echo "1. π’ Stage 1 - Base packages (can publish in parallel):"
if [ -z "$LIBS_DEPS" ]; then
echo " β
libraries - $(get_package_info 'libraries')"
fi
if [ -z "$SVG_DEPS" ]; then
echo " β
svg-components - $(get_package_info 'svg-components')"
fi
echo ""
echo "2. π‘ Stage 2 - Packages with base dependencies:"
if [ -n "$UI_DEPS" ]; then
echo " β
ui-components - $(get_package_info 'ui-components')"
echo " π Wait for: $UI_DEPS"
fi
echo ""
echo "3. π΄ Stage 3 - Packages with complex dependencies:"
if [ -n "$REACT_DEPS" ]; then
echo " β
react-components - $(get_package_info 'react-components')"
echo " π Wait for: $REACT_DEPS"
fi
echo ""
echo "β οΈ GitHub Actions Workflow Validation:"
echo "======================================"
# Check if workflow file exists and analyze it
WORKFLOW_FILE=".github/workflows/publishComponents.yml"
if [ -f "$WORKFLOW_FILE" ]; then
echo "β
Workflow file exists: $WORKFLOW_FILE"
# Check for dependency management
if grep -q "needs:" "$WORKFLOW_FILE"; then
echo "β
Workflow uses job dependencies (needs:)"
else
echo "β Workflow missing job dependencies - all jobs will run in parallel!"
fi
if grep -q "npm view.*version" "$WORKFLOW_FILE"; then
echo "β
Workflow includes package availability checks"
else
echo "β οΈ Workflow missing package availability checks"
fi
if grep -q "sleep" "$WORKFLOW_FILE"; then
echo "β
Workflow includes wait/retry logic"
else
echo "β οΈ Workflow missing wait/retry logic"
fi
# Count stages in workflow
STAGE_COUNT=$(grep -c "publish-.*:" "$WORKFLOW_FILE" | head -1)
echo "π Workflow stages found: $STAGE_COUNT"
else
echo "β Workflow file not found: $WORKFLOW_FILE"
fi
echo ""
echo "π‘ Summary & Recommendations:"
echo "============================"
echo "β
Publish Order: libraries & svg-components β ui-components β react-components"
echo "β° Wait Strategy: Check npm availability with 30s intervals, 15min timeout"
echo "π Retry Logic: Essential for npm registry propagation delays"
echo "π¦ Tag Strategy: Use consistent tags across all packages"
echo ""
# Generate quick publish commands
echo "π Manual Publish Commands (for testing):"
echo "=========================================="
echo "# Stage 1 (parallel)"
echo "cd webpack/libraries && npm publish --tag beta"
echo "cd webpack/svg-components && npm publish --tag beta"
echo ""
echo "# Stage 2 (wait for Stage 1)"
echo "cd webpack/ui-components && npm publish --tag beta"
echo ""
echo "# Stage 3 (wait for Stage 2)"
echo "cd webpack/react-components && npm publish --tag beta"