From: Timo Tijhof Date: Mon, 7 Apr 2014 22:15:06 +0000 (-0700) Subject: update-oojs.sh: Rewrite to fetch from npm repo instead of building from git X-Git-Tag: 1.31.0-rc.0~16331^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=9fdef0e25b1d4d813625e3796221469ef4a4a463;p=lhc%2Fweb%2Fwiklou.git update-oojs.sh: Rewrite to fetch from npm repo instead of building from git * Fetch upstream build from npm repository instead of building it locally from git (to avoid different timestamps and checksums not matching, no need for MediaWiki code to know how to build a oojs distribution). * Ran it which changed the oojs.js file slightly (it now contains the file as released on npmjs.org instead of the local build by the person who last updated it in mediawiki). Follows-up: * 648667a - Split up resources/ into resources/lib/ and resources/src/ * c68b967 - Add scripts to generate update builds of OOjs Change-Id: I63f79293e21781c1db3d7c43658c22f58ba9102d --- diff --git a/maintenance/resources/update-oojs.sh b/maintenance/resources/update-oojs.sh new file mode 100755 index 0000000000..f26350f848 --- /dev/null +++ b/maintenance/resources/update-oojs.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +if [ "$2" != "" ] +then + echo >&2 "Usage: $0 []" + exit 1 +fi + +MW_DIR=$(cd $(dirname $0)/../..; pwd) # e.g. mediawiki-core/ +NPM_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mw-update-oojs'` # e.g. /tmp/mw-update-oojs.rI0I5Vir + +# Prepare MediaWiki working copy +cd $MW_DIR +git reset resources/lib/oojs/ && git checkout resources/lib/oojs/ && git fetch origin || exit 1 + +git checkout -B upstream-oojs origin/master || exit 1 + +# Fetch upstream version +cd $NPM_DIR +if [ "$1" != "" ] +then + npm install oojs@$1 || exit 1 +else + npm install oojs || exit 1 +fi + +OOJS_VERSION=$(node -e 'console.log(JSON.parse(require("fs").readFileSync("./node_modules/oojs/package.json")).version);') +if [ "$OOJS_VERSION" == "" ] +then + echo 'Could not find OOjs version' + exit 1 +fi + +# Copy file(s) +mv ./node_modules/oojs/dist/* $MW_DIR/resources/lib/oojs/ || exit 1 + +# Generate commit +cd $MW_DIR || exit 1 + +# Clean up temporary area +rm -rf $NPM_DIR + +COMMITMSG=$(cat <&2 "Usage: update-oojs.sh path/to/repo/for/oojs" - exit 1 -fi - -# Undo any changes in the oojs directory -git reset resources/oojs/ -git checkout resources/oojs/ - -git fetch origin -# Create a branch of MW if needed, and reset it to master -git checkout -B update-oojs origin/master - -# Get the old oojs version -OLDVERSION=$(oojshash) -if [ "x$OLDVERSION" == "x" ] -then - TAG=$(oojstag) -fi - -# cd to the oojs directory -cd $1 || exit 1 -if [ "x$OLDVERSION" == "x" ] -then - # Try the tag - OLDVERSION=$(git rev-parse $TAG) - if [ $? != 0 ] - then - echo Could not find OOjs version - cd - - exit 1 - fi -fi -if [ "$(git rev-parse $OLDVERSION)" == "$(git rev-parse HEAD)" ] -then - echo "No changes (already at $OLDVERSION)" - cd - - exit 0 -fi -# Build the distribution -npm install || exit 1 -grunt || exit 1 -# Get the list of changes -NEWCHANGES=$(git log $OLDVERSION.. --oneline --no-merges --reverse --color=never) -NEWCHANGESDISPLAY=$(git log $OLDVERSION.. --oneline --no-merges --reverse --color=always) -# cd back to the VisualEditor directory -cd - - -# Copy files from dist/ to resources/oojs/ -cp -a $1/dist/* resources/oojs/ -# Figure out what the new version is -NEWVERSION=$(oojsversion) -# Generate commit summary -COMMITMSG=$(cat <&2 <