summaryrefslogtreecommitdiff
path: root/maintenance/resources/update-oojs-ui.sh
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/resources/update-oojs-ui.sh')
-rw-r--r--maintenance/resources/update-oojs-ui.sh55
1 files changed, 32 insertions, 23 deletions
diff --git a/maintenance/resources/update-oojs-ui.sh b/maintenance/resources/update-oojs-ui.sh
index f6245f27..831e2dca 100644
--- a/maintenance/resources/update-oojs-ui.sh
+++ b/maintenance/resources/update-oojs-ui.sh
@@ -1,8 +1,8 @@
-#!/usr/bin/env bash
+#!/bin/bash -eu
# This script generates a commit that updates our copy of OOjs UI
-if [ -n "$2" ]
+if [ -n "${2:-}" ]
then
# Too many parameters
echo >&2 "Usage: $0 [<version>]"
@@ -14,18 +14,21 @@ TARGET_DIR="resources/lib/oojs-ui" # Destination relative to the root of the rep
NPM_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-oojs-ui') # e.g. /tmp/update-oojs-ui.rI0I5Vir
# Prepare working tree
-cd "$REPO_DIR" &&
-git reset composer.json && git checkout composer.json &&
-git reset $TARGET_DIR && git checkout $TARGET_DIR && git fetch origin &&
-git checkout -B upstream-oojs-ui origin/master || exit 1
+cd "$REPO_DIR"
+git reset composer.json
+git checkout composer.json
+git reset -- $TARGET_DIR
+git checkout -- $TARGET_DIR
+git fetch origin
+git checkout -B upstream-oojs-ui origin/master
# Fetch upstream version
cd $NPM_DIR
-if [ -n "$1" ]
+if [ -n "${1:-}" ]
then
- npm install "oojs-ui@$1" || exit 1
+ npm install "oojs-ui@$1"
else
- npm install oojs-ui || exit 1
+ npm install oojs-ui
fi
OOJSUI_VERSION=$(node -e 'console.log(require("./node_modules/oojs-ui/package.json").version);')
@@ -35,24 +38,27 @@ then
exit 1
fi
-# Copy files, excluding:
-# * the Apex theme files,
-# * the minimised distribution files, and
-# * the RTL sheets for non-CSSJanus environments
-# * the raster- and vector-only distribution sheets
-rsync --force --recursive --delete \
- --exclude '*apex*' \
- --exclude 'oojs-ui*.min.*' \
- --exclude 'oojs-ui*.rtl.css' \
- --exclude 'oojs-ui*.raster.css' \
- --exclude 'oojs-ui*.vector.css' \
- ./node_modules/oojs-ui/dist/ "$REPO_DIR/$TARGET_DIR" || exit 1
+# Copy files, picking the necessary ones from source and distribution
+rm -r "$REPO_DIR/$TARGET_DIR"
+mkdir -p "$REPO_DIR/$TARGET_DIR/i18n"
+mkdir -p "$REPO_DIR/$TARGET_DIR/images"
+mkdir -p "$REPO_DIR/$TARGET_DIR/themes/mediawiki/images"
+mkdir -p "$REPO_DIR/$TARGET_DIR/themes/apex/images"
+cp ./node_modules/oojs-ui/dist/oojs-ui.js "$REPO_DIR/$TARGET_DIR"
+cp ./node_modules/oojs-ui/dist/{oojs-ui-mediawiki-noimages.css,oojs-ui-mediawiki.js} "$REPO_DIR/$TARGET_DIR"
+cp ./node_modules/oojs-ui/dist/{oojs-ui-apex-noimages.css,oojs-ui-apex.js} "$REPO_DIR/$TARGET_DIR"
+cp -R ./node_modules/oojs-ui/dist/i18n "$REPO_DIR/$TARGET_DIR"
+cp -R ./node_modules/oojs-ui/dist/images "$REPO_DIR/$TARGET_DIR"
+cp -R ./node_modules/oojs-ui/dist/themes/mediawiki/images "$REPO_DIR/$TARGET_DIR/themes/mediawiki"
+cp ./node_modules/oojs-ui/src/themes/mediawiki/*.json "$REPO_DIR/$TARGET_DIR/themes/mediawiki"
+cp -R ./node_modules/oojs-ui/dist/themes/apex/images "$REPO_DIR/$TARGET_DIR/themes/apex"
+cp ./node_modules/oojs-ui/src/themes/apex/*.json "$REPO_DIR/$TARGET_DIR/themes/apex"
# Clean up temporary area
rm -rf "$NPM_DIR"
# Generate commit
-cd $REPO_DIR || exit 1
+cd $REPO_DIR
COMMITMSG=$(cat <<END
Update OOjs UI to v$OOJSUI_VERSION
@@ -66,4 +72,7 @@ END
composer require oojs/oojs-ui $OOJSUI_VERSION --no-update
# Stage deletion, modification and creation of files. Then commit.
-git add --update $TARGET_DIR && git add $TARGET_DIR && git add composer.json && git commit -m "$COMMITMSG" || exit 1
+git add --update $TARGET_DIR
+git add $TARGET_DIR
+git add composer.json
+git commit -m "$COMMITMSG"