Jforrester has uploaded a new change for review.
https://gerrit.wikimedia.org/r/175645
Change subject: build: Update update-oojs.sh and update-oojs-ui.sh scripts
......................................................................
build: Update update-oojs.sh and update-oojs-ui.sh scripts
Change-Id: I5f35387ce2ac1d1e00a864cb59a5c9cf1245b689
---
M bin/update-oojs-ui.sh
M bin/update-oojs.sh
2 files changed, 36 insertions(+), 73 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/45/175645/1
diff --git a/bin/update-oojs-ui.sh b/bin/update-oojs-ui.sh
index 0eceb50..69151cb 100755
--- a/bin/update-oojs-ui.sh
+++ b/bin/update-oojs-ui.sh
@@ -1,95 +1,56 @@
#!/usr/bin/env bash
-# This script generates a commit that updates our distribution copy of OOjs UI
+# This script generates a commit that updates our copy of OOjs UI
-if [ -z "$1" ]
+if [ -n "$2" ]
then
- # Missing required parameter
- echo >&2 "Usage: $0 path/to/repo/for/oojs-ui"
+ # Too many parameters
+ echo >&2 "Usage: $0 [<version>]"
exit 1
fi
-TARGET_REPO=$(cd $(dirname $0)/..; pwd)
-TARGET_DIR=lib/oojs-ui
-UI_REPO=$1
-
-function oojsuihash() {
- grep "OOjs UI v" $TARGET_REPO/$TARGET_DIR/oojs-ui.js \
- | head -n 1 \
- | grep -Eo '\([a-z0-9]+\)' \
- | sed 's/^(//' \
- | sed 's/)$//'
-}
-
-function oojsuitag() {
- grep "OOjs UI v" $TARGET_REPO/$TARGET_DIR/oojs-ui.js \
- | head -n 1 \
- | grep -Eo '\bv[0-9a-z.-]+\b'
-}
-
-function oojsuiversion() {
- grep "OOjs UI v" $TARGET_REPO/$TARGET_DIR/oojs-ui.js \
- | head -n 1 \
- | grep -Eo '\bv[0-9a-z.-]+\b.*$'
-}
+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-oojs-ui') # e.g.
/tmp/update-oojs-ui.rI0I5Vir
# Prepare working tree
-cd $TARGET_REPO &&
+cd "$REPO_DIR" &&
git reset $TARGET_DIR && git checkout $TARGET_DIR && git fetch origin &&
-git checkout -B upstream-oojsui origin/master || exit 1
+git checkout -B upstream-oojs-ui origin/master || exit 1
-cd $UI_REPO || exit 1
-
-# Read the old version and check for changes
-OLDHASH=$(oojsuihash)
-if [ -z "$OLDHASH" ]
+# Fetch upstream version
+cd $NPM_DIR
+if [ -n "$1" ]
then
- OLDTAG=$(oojsuitag)
-fi
-if [ "$OLDHASH" == "" ]
-then
- OLDHASH=$(git rev-parse $OLDTAG)
- if [ $? != 0 ]
- then
- echo Could not find OOjs UI version
- cd -
- exit 1
- fi
-fi
-if [ "$(git rev-parse $OLDHASH)" == "$(git rev-parse HEAD)" ]
-then
- echo "No changes (already at $OLDHASH)"
- cd -
- exit 0
+ npm install "oojs-ui@$1" || exit 1
+else
+ npm install oojs-ui || exit 1
fi
-# Build the distribution
-npm install && grunt git-build || exit 1
-
-# Get the list of changes
-NEWCHANGES=$(git log $OLDHASH.. --oneline --no-merges --reverse --color=never)
-NEWCHANGESDISPLAY=$(git log $OLDHASH.. --oneline --no-merges --reverse
--color=always)
+OOJSUI_VERSION=$(node -e
'console.log(JSON.parse(require("./node_modules/oojs-ui/package.json").version);'))
+if [ "$OOJSUI_VERSION" == "" ]
+then
+ echo 'Could not find OOjs UI version'
+ exit 1
+fi
# Copy files
-# - Exclude the minimised distribution files and raster images
-rsync --recursive --delete --force --exclude 'oojs-ui*.min.*' --exclude
'images/*/*.png' ./dist/ $TARGET_REPO/$TARGET_DIR || exit 1
+# - Exclude the minimised distribution files and RTL sheets for non-CSSJanus
environments
+rsync --force --recursive --delete --exclude 'oojs-ui*.min.*' --exclude
'images/*/*.png' ./node_modules/oojs-ui/dist/ "$REPO_DIR/$TARGET_DIR" || exit 1
-# Read the new version
-NEWVERSION=$(oojsuiversion)
+# Clean up temporary area
+rm -rf "$NPM_DIR"
# Generate commit
-cd $TARGET_REPO
-COMMITMSG=$(cat <<END
-Update OOjs UI to $NEWVERSION
+cd $REPO_DIR || exit 1
-New changes:
-$NEWCHANGES
+COMMITMSG=$(cat <<END
+Update OOjs UI to v$OOJSUI_VERSION
+
+Release notes:
+ https://git.wikimedia.org/blob/oojs%2Fui.git/v$OOJSUI_VERSION/History.md
END
)
-git add -u $TARGET_DIR && git add $TARGET_DIR && git commit -m "$COMMITMSG"
-cat >&2 <<END
-
-Created commit with changes:
-$NEWCHANGESDISPLAY
-END
+# Stage deletion, modification and creation of files. Then commit.
+git add --update $TARGET_DIR && git add $TARGET_DIR && git commit -m
"$COMMITMSG" || exit 1
diff --git a/bin/update-oojs.sh b/bin/update-oojs.sh
index 6787da3..0c4ec3e 100755
--- a/bin/update-oojs.sh
+++ b/bin/update-oojs.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+# This script generates a commit that updates our copy of OOjs
+
if [ -n "$2" ]
then
# Too many parameters
@@ -25,7 +27,7 @@
npm install oojs || exit 1
fi
-OOJS_VERSION=$(node -e
'console.log(JSON.parse(require("fs").readFileSync("./node_modules/oojs/package.json")).version);')
+OOJS_VERSION=$(node -e
'console.log(JSON.parse(require("./node_modules/oojs/package.json").version);'))
if [ "$OOJS_VERSION" == "" ]
then
echo 'Could not find OOjs version'
--
To view, visit https://gerrit.wikimedia.org/r/175645
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f35387ce2ac1d1e00a864cb59a5c9cf1245b689
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits