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-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
70 Update OOjs UI to v$OOJSUI_VERSION
73 https://phabricator.wikimedia.org/diffusion/GOJU/browse/master/History.md;v$OOJSUI_VERSION
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
84 git commit
-m "$COMMITMSG"