-
Notifications
You must be signed in to change notification settings - Fork 13
/
versions.sh
executable file
·47 lines (40 loc) · 1.08 KB
/
versions.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
#!/bin/bash
###########################################################################################
# This scripts extracts the Gutenberg package versions from a Gutenberg release directory #
###########################################################################################
GUTENBERG_DIR=$1
PACKAGES_DIR="$GUTENBERG_DIR/packages"
PACKAGES=(
"api-fetch"
"base-styles"
"block-editor"
"block-library"
"blocks"
"components"
"data"
"element"
"format-library"
"hooks"
"keyboard-shortcuts"
"server-side-render"
)
if [[ ! -d $PACKAGES_DIR ]]; then
echo 'Directory does not exist';
exit 1
fi
cd $PACKAGES_DIR
MISSING_PACKAGES=()
for PACKAGE in ${PACKAGES[@]}; do
FILE="$PACKAGE/package.json"
if [[ -f $FILE ]]; then
VERSION=$(cat $FILE | egrep -o '"version": (".*")' | egrep -o '\d+\.\d+\.\d+')
PACKAGE_VERSION="\"@wordpress/$PACKAGE\": \"~$VERSION\","
echo $PACKAGE_VERSION
else
MISSING_PACKAGES+=($PACKAGE)
fi
done
for PACKAGE in ${MISSING_PACKAGES[@]}; do
echo "Package '$PACKAGE' was not found."
done
exit 0