3 # This script generates a commit that updates our copy of OOjs UI
8 echo >&2 "Usage: $0 [<version>]"
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
18 git
reset composer.json
19 git checkout composer.json
20 git
reset -- $TARGET_DIR
21 git checkout
-- $TARGET_DIR
23 git checkout
-B upstream-oojs-ui origin
/master
25 # Fetch upstream version
29 npm
install "oojs-ui@$1"
34 OOJSUI_VERSION
=$
(node
-e 'console.log(require("./node_modules/oojs-ui/package.json").version);')
35 if [ "$OOJSUI_VERSION" == "" ]
37 echo 'Could not find OOjs UI version'
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.js
"$REPO_DIR/$TARGET_DIR"
48 cp .
/node_modules
/oojs-ui
/dist
/{oojs-ui-mediawiki-noimages.css
,oojs-ui-mediawiki.js
} "$REPO_DIR/$TARGET_DIR"
49 cp .
/node_modules
/oojs-ui
/dist
/{oojs-ui-apex-noimages.css
,oojs-ui-apex.js
} "$REPO_DIR/$TARGET_DIR"
50 cp -R .
/node_modules
/oojs-ui
/dist
/i18n
"$REPO_DIR/$TARGET_DIR"
51 cp -R .
/node_modules
/oojs-ui
/dist
/images
"$REPO_DIR/$TARGET_DIR"
52 cp -R .
/node_modules
/oojs-ui
/dist
/themes
/mediawiki
/images
"$REPO_DIR/$TARGET_DIR/themes/mediawiki"
53 cp .
/node_modules
/oojs-ui
/src
/themes
/mediawiki
/*.json
"$REPO_DIR/$TARGET_DIR/themes/mediawiki"
54 cp -R .
/node_modules
/oojs-ui
/dist
/themes
/apex
/images
"$REPO_DIR/$TARGET_DIR/themes/apex"
55 cp .
/node_modules
/oojs-ui
/src
/themes
/apex
/*.json
"$REPO_DIR/$TARGET_DIR/themes/apex"
57 # Clean up temporary area
64 Update OOjs UI to v$OOJSUI_VERSION
67 https://git.wikimedia.org/blob/oojs%2Fui.git/v$OOJSUI_VERSION/History.md
71 # Update composer.json as well
72 composer require oojs
/oojs-ui
$OOJSUI_VERSION --no-update
74 # Stage deletion, modification and creation of files. Then commit.
75 git add
--update $TARGET_DIR
78 git commit
-m "$COMMITMSG"