Implement extension registration from an extension.json file
[mediawiki.git] / maintenance / resources / update-oojs.sh
blob1d5c2b17096f833490472f37f34c11c6e059e974
1 #!/usr/bin/env bash
3 # This script generates a commit that updates our copy of OOjs
5 if [ -n "$2" ]
6 then
7 # Too many parameters
8 echo >&2 "Usage: $0 [<version>]"
9 exit 1
12 REPO_DIR=$(cd "$(dirname $0)/../.."; pwd) # Root dir of the git repo working tree
13 TARGET_DIR="resources/lib/oojs" # Destination relative to the root of the repo
14 NPM_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-oojs') # e.g. /tmp/update-oojs.rI0I5Vir
16 # Prepare working tree
17 cd "$REPO_DIR" &&
18 git reset $TARGET_DIR && git checkout $TARGET_DIR && git fetch origin &&
19 git checkout -B upstream-oojs origin/master || exit 1
21 # Fetch upstream version
22 cd $NPM_DIR
23 if [ -n "$1" ]
24 then
25 npm install "oojs@$1" || exit 1
26 else
27 npm install oojs || exit 1
30 OOJS_VERSION=$(node -e 'console.log(require("./node_modules/oojs/package.json").version);')
31 if [ "$OOJS_VERSION" == "" ]
32 then
33 echo 'Could not find OOjs version'
34 exit 1
37 # Copy file(s)
38 rsync --force ./node_modules/oojs/dist/oojs.jquery.js "$REPO_DIR/$TARGET_DIR" || exit 1
40 # Clean up temporary area
41 rm -rf "$NPM_DIR"
43 # Generate commit
44 cd $REPO_DIR || exit 1
46 COMMITMSG=$(cat <<END
47 Update OOjs to v$OOJS_VERSION
49 Release notes:
50 https://git.wikimedia.org/blob/oojs%2Fcore.git/v$OOJS_VERSION/History.md
51 END
54 # Stage deletion, modification and creation of files. Then commit.
55 git add --update $TARGET_DIR && git add $TARGET_DIR && git commit -m "$COMMITMSG" || exit 1