Skip to content
This repository was archived by the owner on Sep 23, 2023. It is now read-only.

Commit 0a6be04

Browse files
authored
Build Codex from source if repo is included (#435)
Similar to OOUI, except it's JS only, no PHP. Also add support for 'main' as an alias for the 'master' branch. Without this, installing Codex fails, because it doesn't have a branch named 'master'.
1 parent 6007566 commit 0a6be04

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

new.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,22 @@ function set_progress( float $pc, string $label ) {
343343
}
344344
}
345345

346+
$repoSpecificBranches = [];
346347
foreach ( array_keys( $repos ) as $repo ) {
347348
// Unchecked the checkbox
348349
if ( $repo !== 'mediawiki/core' && !in_array( $repo, $allowedRepos, true ) ) {
349350
unset( $repos[$repo] );
350351
}
352+
353+
$repoBranches = get_branches( $repo );
351354
// This branch doesn't exist for this repo
352-
if ( !in_array( $branch, get_branches( $repo ), true ) ) {
353-
unset( $repos[$repo] );
355+
if ( !in_array( $branch, $repoBranches, true ) ) {
356+
if ( $branch === 'origin/master' && in_array( 'origin/main', $repoBranches, true ) ) {
357+
// master doesn't exist but main does; use main
358+
$repoSpecificBranches[$repo] = 'origin/main';
359+
} else {
360+
unset( $repos[$repo] );
361+
}
354362
}
355363
}
356364

@@ -443,7 +451,7 @@ function set_progress( float $pc, string $label ) {
443451
check_connection();
444452
$error = shell_echo( __DIR__ . '/new/checkout.sh',
445453
$baseEnv + [
446-
'BRANCH' => $branch,
454+
'BRANCH' => $repoSpecificBranches[$source] ?? $branch,
447455
'REPO_SOURCE' => $source,
448456
'REPO_TARGET' => $target,
449457
]

new/postinstall.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ done
3232
# OOUI build
3333
if [ -d $PATCHDEMO/wikis/$NAME/w/build/ooui ]; then
3434
cd $PATCHDEMO/wikis/$NAME/w/build/ooui
35-
npm install
35+
npm ci
3636
npm x grunt build
3737
cd $PATCHDEMO
3838
# JS & CSS
@@ -48,6 +48,17 @@ if [ -d $PATCHDEMO/wikis/$NAME/w/build/ooui ]; then
4848
COMPOSER_CACHE_DIR=/dev/null composer require "oojs/oojs-ui @dev" --update-no-dev
4949
fi
5050

51+
# Codex build
52+
# TODO test
53+
if [ -d $PATCHDEMO/wikis/$NAME/w/build/codex ]; then
54+
cd $PATCHDEMO/wikis/$NAME/w/build/codex
55+
npm ci
56+
npm run build-all
57+
cd $PATCHDEMO
58+
cp -r $PATCHDEMO/wikis/$NAME/w/build/codex/packages/codex/dist/* $PATCHDEMO/wikis/$NAME/w/resources/lib/codex/
59+
cp -r $PATCHDEMO/wikis/$NAME/w/build/codex/packages/codex-icons/dist/codex-icons.json $PATCHDEMO/wikis/$NAME/w/resources/lib/codex-icons/
60+
fi
61+
5162
# grant FlaggedRevs editor rights to the default account
5263
if [ -d $PATCHDEMO/wikis/$NAME/w/extensions/FlaggedRevs ]; then
5364
php $PATCHDEMO/wikis/$NAME/w/maintenance/createAndPromote.php "Patch Demo" --force --custom-groups editor

repository-lists/all.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ mediawiki/extensions/Wikisource w/extensions/Wikisource
7979
mediawiki/extensions/Wikistories w/extensions/Wikistories
8080
mediawiki/extensions/Disambiguator w/extensions/Disambiguator
8181
oojs/ui w/build/ooui
82+
design/codex w/build/codex

repository-lists/wikimedia.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
- mediawiki/skins/Vector
131131
- mediawiki/services/parsoid
132132
- VisualEditor/VisualEditor
133-
# Including OOUI source requires a build which is fairly slow,
133+
# Including OOUI or Codex source requires a build which is fairly slow,
134134
# so should only be done if the user explicitly requests it.
135135
# - oojs/ui
136+
# - design/codex

0 commit comments

Comments
 (0)