-
-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathupdate-package-json.sh
executable file
·42 lines (39 loc) · 1.2 KB
/
update-package-json.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
# expects `$repo`, `$tagPrefix` and `$packages` (array) variables to be defined, see e.g. update-javascript.sh
# Since Corepack is not going to be distributed with Node.js v25+ in the future we need to install Corepack globally.
# See: https://github.com/getsentry/sentry-react-native/pull/4741
corepack enable # This repository uses Yarn v3 which requires corepack to be enabled
monorepoRoot="$(dirname "$0")/.."
case $1 in
get-version)
file="$(dirname "$0")/../packages/core/package.json"
content=$(cat $file)
regex='"'${packages[0]}'": *"([0-9.]+)"'
if ! [[ $content =~ $regex ]]; then
echo "Failed to find plugin '${packages[0]}' version in $file"
exit 1
fi
echo $tagPrefix${BASH_REMATCH[1]}
;;
get-repo)
echo $repo
;;
set-version)
list=""
version="$2"
# remove $tagPrefix from the $version by skipping the first `strlen($tagPrefix)` characters
if [[ "$version" == "$tagPrefix"* ]]; then
version="${version:${#tagPrefix}}"
fi
for i in ${!packages[@]}; do
list+="${packages[$i]}@$version "
done
(
cd "${monorepoRoot}"
yarn up $list
)
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac