forked from wikimedia/VisualEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-ooui.sh
executable file
·60 lines (48 loc) · 1.48 KB
/
update-ooui.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
#!/bin/bash -eu
# This script generates a commit that updates our copy of OOUI
if [ -n "${2:-}" ]
then
# Too many parameters
echo >&2 "Usage: $0 [<version>]"
exit 1
fi
REPO_DIR=$(cd "$(dirname $0)/.."; pwd) # Root dir of the git repo working tree
TARGET_DIR="lib/oojs-ui" # Destination relative to the root of the repo
NPM_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-ooui') # e.g. /tmp/update-ooui.rI0I5Vir
# Prepare working tree
cd "$REPO_DIR"
git reset -- $TARGET_DIR
git checkout -- $TARGET_DIR
git fetch origin
git checkout -B upstream-ooui origin/master
# Fetch upstream version
cd $NPM_DIR
if [ -n "${1:-}" ]
then
npm install "oojs-ui@$1"
else
npm install oojs-ui
fi
OOUI_VERSION=$(node -e 'console.log(require("./node_modules/oojs-ui/package.json").version);')
if [ "$OOUI_VERSION" == "" ]
then
echo 'Could not find OOUI version'
exit 1
fi
# Copy files
# - Exclude the minimised distribution files and PNG image assets (VE requires SVG support)
rsync --force --recursive --delete --exclude 'oojs-ui*.min.*' --exclude 'oojs-ui.js' --exclude 'themes/**/images/*/*.png' ./node_modules/oojs-ui/dist/ "$REPO_DIR/$TARGET_DIR"
# Clean up temporary area
rm -rf "$NPM_DIR"
# Generate commit
cd $REPO_DIR
COMMITMSG=$(cat <<END
Update OOUI to v$OOUI_VERSION
Release notes:
https://gerrit.wikimedia.org/g/oojs/ui/+/v$OOUI_VERSION/History.md
END
)
# Stage deletion, modification and creation of files. Then commit.
git add --update $TARGET_DIR
git add $TARGET_DIR
git commit -m "$COMMITMSG"