Merge "Rename Skin::getUsableSkins() to Skin::getAllowedSkins()"
[lhc/web/wiklou.git] / maintenance / resources / update-oojs.sh
1 #!/usr/bin/env bash
2
3 if [ "$2" != "" ]
4 then
5 echo >&2 "Usage: $0 [<version>]"
6 exit 1
7 fi
8
9 MW_DIR=$(cd $(dirname $0)/../..; pwd) # e.g. mediawiki-core/
10 NPM_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mw-update-oojs'` # e.g. /tmp/mw-update-oojs.rI0I5Vir
11
12 # Prepare MediaWiki working copy
13 cd $MW_DIR
14 git reset resources/lib/oojs/ && git checkout resources/lib/oojs/ && git fetch origin || exit 1
15
16 git checkout -B upstream-oojs origin/master || exit 1
17
18 # Fetch upstream version
19 cd $NPM_DIR
20 if [ "$1" != "" ]
21 then
22 npm install oojs@$1 || exit 1
23 else
24 npm install oojs || exit 1
25 fi
26
27 OOJS_VERSION=$(node -e 'console.log(JSON.parse(require("fs").readFileSync("./node_modules/oojs/package.json")).version);')
28 if [ "$OOJS_VERSION" == "" ]
29 then
30 echo 'Could not find OOjs version'
31 exit 1
32 fi
33
34 # Copy file(s)
35 mv ./node_modules/oojs/dist/* $MW_DIR/resources/lib/oojs/ || exit 1
36
37 # Generate commit
38 cd $MW_DIR || exit 1
39
40 # Clean up temporary area
41 rm -rf $NPM_DIR
42
43 COMMITMSG=$(cat <<END
44 Update OOjs to v$OOJS_VERSION
45
46 Release notes:
47 https://git.wikimedia.org/blob/oojs%2Fcore.git/v$OOJS_VERSION/History.md
48 END
49 )
50
51 git commit resources/lib/oojs/ -m "$COMMITMSG" || exit 1