-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathupgrade-dependencies.sh
149 lines (128 loc) · 5.43 KB
/
upgrade-dependencies.sh
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
#!/usr/bin/env bash
if [ "$1" == "" ] || [ "$1" == "--help" ]; then
echo "Available flags:"
echo "--help"
echo "--upgrade-expo - run yarn to add latest Expo and npx expo install --fix upgrade to update to latest SDK on all examples"
echo "--fix-dependencies - run npx expo install --fix on all repos"
exit 0
fi
manager="${EXPO_PACKAGE_MANAGER:-yarn}"
if [ "$1" == "--upgrade-expo" ]; then
echo "Upgrading all projects to the latest SDK..."
echo "For each example, this will run `yarn` to add latest Expo and then run `npx expo install --fix`, accepting all defaults."
echo "Upgrade logs will be written to .sdk-upgrade-logs."
# Resolve the "latest" Expo version, avoiding adding `"expo": "latest"` to the package.json files
expoVersion="^$(npm info expo@latest version)"
echo "Resolved latest Expo version: $expoVersion"
mkdir -p ./.sdk-upgrade-logs
for d in */ ; do
DIRNAME=${d%/}
echo "Upgrading $DIRNAME..."
if [ -z ${CI} ]; then
echo "• Run $manager install";
(cd $DIRNAME && $manager install --ignore-scripts &> ../.sdk-upgrade-logs/$DIRNAME-install.txt || echo "FAILURE")
else
echo "::group::• Run $manager install";
(cd $DIRNAME && $manager install --ignore-scripts)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
if [ -z ${CI} ]; then
echo "• Run expo upgrade";
(cd $DIRNAME && $manager add expo@$expoVersion && $manager expo install --fix &> ../.sdk-upgrade-logs/$DIRNAME-upgrade.txt || echo "FAILURE")
else
echo "::group::• Run expo upgrade";
(cd $DIRNAME && $manager add expo@$expoVersion && $manager expo install --fix)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
done
# yarn workspaces has example(s) inside of app folder
echo "• Run expo upgrade on apps inside with-yarn-workspaces"
mkdir -p ./.sdk-upgrade-logs/with-yarn-workspaces
for d in with-yarn-workspaces/apps/*/ ; do
if [ -z ${CI} ]; then
echo "• Run yarn install";
(cd $DIRNAME && yarn install &> ../.sdk-upgrade-logs/with-yarn-workspaces/$DIRNAME-install.txt || echo "FAILURE")
else
echo "::group::• Run yarn install";
(cd $DIRNAME && yarn install)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
if [ -z ${CI} ]; then
echo "• Run expo upgrade";
(cd $DIRNAME && yarn add expo@$expoVersion && yarn expo install --fix &> ../.sdk-upgrade-logs/with-yarn-workspaces/$DIRNAME-upgrade.txt || echo "FAILURE")
else
echo "::group::• Run expo upgrade";
(cd $DIRNAME && yarn add expo@$expoVersion && yarn expo install --fix)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
done
echo "Upgrades complete! Check .sdk-upgrade-logs for results. Be sure to correct any errors or warnings."
echo "WARNING: with-dev-client has native project files that need to be upgraded manually!"
echo "Deleting ios/android folders and running prebuild will regenerate them, applying the proper URL schemes."
echo "https://docs.expo.dev/development/installation/ has more info on how a bare dev client project is setup."
exit 0
fi
if [ "$1" == "--fix-dependencies" ]; then
echo "Fixing dependencies on all examples..."
mkdir -p ./.sdk-fix-logs
for d in */ ; do
DIRNAME=${d%/}
echo "Fixing dependencies on $DIRNAME..."
if [ -z ${CI} ]; then
echo "• Run $manager install";
(cd $DIRNAME && $manager install --ignore-scripts &> ../.sdk-fix-logs/$DIRNAME-install.txt || echo "FAILURE")
else
echo "::group::• Run $manager install";
(cd $DIRNAME && $manager install --ignore-scripts)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
if [ -z ${CI} ]; then
echo "• Run expo upgrade";
(cd $DIRNAME && $manager expo install --fix &> ../.sdk-fix-logs/$DIRNAME-fix.txt || echo "FAILURE")
else
echo "::group::• Run expo fix";
(cd $DIRNAME && $manager expo install --fix)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
done
echo "Fixing dependencies on apps inside with-yarn-workspaces..."
mkdir -p ./.sdk-fix-logs/with-yarn-workspaces
for d in with-yarn-workspaces/apps/*/ ; do
echo "• Fixing dependencies on apps inside with-yarn-workspaces"
if [ -z ${CI} ]; then
echo "• Run yarn install";
(cd $DIRNAME && yarn install --ignore-scripts &> ../.sdk-fix-logs/with-yarn-workspaces/$DIRNAME-install.txt || echo "FAILURE")
else
echo "::group::• Run yarn install";
(cd $DIRNAME && yarn install)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
if [ -z ${CI} ]; then
echo "• Run expo fix";
(cd $DIRNAME && yarn expo install --fix &> ../.sdk-fix-logs/with-yarn-workspaces/$DIRNAME-fix.txt || echo "FAILURE")
else
echo "::group::• Run expo fix";
(cd $DIRNAME && yarn expo install --fix)
exitCode=$?
echo "::endgroup::"
if [ $exitCode -ne 0 ]; then echo -e "\033[0;31mFAILURE\033[0m"; fi
fi
done
echo "Dependency fixes complete!"
exit 0
fi
echo "Error: flag not recognized"