Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / maintenance / resources / update-oojs-ui.sh
blobdbce7a7a34c698c87a47abd8467d4421c72b757d
1 #!/bin/bash -eu
3 # This script generates a commit that updates our copy of OOjs UI
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-ui" # Destination relative to the root of the repo
14 NPM_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-oojs-ui') # e.g. /tmp/update-oojs-ui.rI0I5Vir
16 # Prepare working tree
17 cd "$REPO_DIR"
18 git reset composer.json
19 git checkout composer.json
20 git reset -- $TARGET_DIR
21 git checkout -- $TARGET_DIR
22 git fetch origin
23 git checkout -B upstream-oojs-ui origin/master
25 # Fetch upstream version
26 cd $NPM_DIR
27 if [ -n "${1:-}" ]
28 then
29 npm install "oojs-ui@$1"
30 else
31 npm install oojs-ui
34 OOJSUI_VERSION=$(node -e 'console.log(require("./node_modules/oojs-ui/package.json").version);')
35 if [ "$OOJSUI_VERSION" == "" ]
36 then
37 echo 'Could not find OOjs UI version'
38 exit 1
41 # Copy files, picking the necessary ones from source and distribution
42 rm -r "$REPO_DIR/$TARGET_DIR"
43 mkdir -p "$REPO_DIR/$TARGET_DIR/i18n"
44 mkdir -p "$REPO_DIR/$TARGET_DIR/images"
45 mkdir -p "$REPO_DIR/$TARGET_DIR/themes/mediawiki/images"
46 mkdir -p "$REPO_DIR/$TARGET_DIR/themes/apex/images"
47 cp ./node_modules/oojs-ui/dist/oojs-ui-core.js "$REPO_DIR/$TARGET_DIR"
48 cp ./node_modules/oojs-ui/dist/oojs-ui-core-{mediawiki,apex}.css "$REPO_DIR/$TARGET_DIR"
49 cp ./node_modules/oojs-ui/dist/oojs-ui-widgets.js "$REPO_DIR/$TARGET_DIR"
50 cp ./node_modules/oojs-ui/dist/oojs-ui-widgets-{mediawiki,apex}.css "$REPO_DIR/$TARGET_DIR"
51 cp ./node_modules/oojs-ui/dist/oojs-ui-toolbars.js "$REPO_DIR/$TARGET_DIR"
52 cp ./node_modules/oojs-ui/dist/oojs-ui-toolbars-{mediawiki,apex}.css "$REPO_DIR/$TARGET_DIR"
53 cp ./node_modules/oojs-ui/dist/oojs-ui-windows.js "$REPO_DIR/$TARGET_DIR"
54 cp ./node_modules/oojs-ui/dist/oojs-ui-windows-{mediawiki,apex}.css "$REPO_DIR/$TARGET_DIR"
55 cp ./node_modules/oojs-ui/dist/oojs-ui-{mediawiki,apex}.js "$REPO_DIR/$TARGET_DIR"
56 cp -R ./node_modules/oojs-ui/dist/i18n "$REPO_DIR/$TARGET_DIR"
57 cp -R ./node_modules/oojs-ui/dist/images "$REPO_DIR/$TARGET_DIR"
58 cp -R ./node_modules/oojs-ui/dist/themes/mediawiki/images "$REPO_DIR/$TARGET_DIR/themes/mediawiki"
59 cp ./node_modules/oojs-ui/src/themes/mediawiki/*.json "$REPO_DIR/$TARGET_DIR/themes/mediawiki"
60 cp -R ./node_modules/oojs-ui/dist/themes/apex/images "$REPO_DIR/$TARGET_DIR/themes/apex"
61 cp ./node_modules/oojs-ui/src/themes/apex/*.json "$REPO_DIR/$TARGET_DIR/themes/apex"
63 # Clean up temporary area
64 rm -rf "$NPM_DIR"
66 # Generate commit
67 cd $REPO_DIR
69 COMMITMSG=$(cat <<END
70 Update OOjs UI to v$OOJSUI_VERSION
72 Release notes:
73 https://phabricator.wikimedia.org/diffusion/GOJU/browse/master/History.md;v$OOJSUI_VERSION
74 END
77 # Update composer.json as well
78 composer require oojs/oojs-ui $OOJSUI_VERSION --no-update
80 # Stage deletion, modification and creation of files. Then commit.
81 git add --update $TARGET_DIR
82 git add $TARGET_DIR
83 git add composer.json
84 git commit -m "$COMMITMSG"