From 8a39d83175cbe47a0a66ef95d765bcf8952e5f77 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 1 May 2024 20:27:22 -0700 Subject: Codex: Allow a local development version to be used Developers can use this to test their local version of Codex with MediaWiki by pointing $wgCodexDevelopmentDir to their local clone of the Codex repo, e.g. $wgCodexDevelopmentDir = '/home/yourname/git/codex'; Setting $wgCodexDevelopmentDir affects where the following things come from: - Codex JS/CSS files for the full library - Codex JS/CSS files for code-split chunks, and the manifest.json file that points to them - Icons retrieved by CodexModule::getIcons() - CSS-only icons imported in Less - Design tokens imported in Less Other changes in this patch: - Add CodexModule::makeFilePath() to centralize the repeated path concatenation. This makes it easier to switch out the regular path for the dev mode path. - Replace all uses of $IP (which is deprecated) and MW_INSTALL_PATH in CodexModule with the BaseDirectory config setting. - Make CodexModule::getIcons() reset its static cache if the path to the icons file changes. Without this, it's impossible to make the unit tests pass. - Move the i18n messages code from the CodexModule constructor to getMessages(). It can't be in the constructor because makeFilePath() doesn't work there (it fails because the Config object hasn't been set up yet). - Add a 'mediawiki.skin.codex' import path so that we can stop hard-coding the path to the Codex mixins file. Without this, we can't make the Codex mixins come from the right place in development mode. - Consider $wgCodexDevelopmentDir in setting the cache key for compiled Less code, since changing this setting can change the output of Less compilation (by changing design tokens, icons or mixins). - Add unit tests for (the non-dev mode behavior of) CodexModule::getIcons() and the i18n message key handling. Bug: T314507 Change-Id: I11c6a81a1ba34fe10f4b1c98bf76f0db40c1ce98 --- tests/phpunit/data/less/import-codex-icons-devmode.css | 3 +++ tests/phpunit/data/less/import-codex-tokens-devmode.css | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 tests/phpunit/data/less/import-codex-icons-devmode.css create mode 100644 tests/phpunit/data/less/import-codex-tokens-devmode.css (limited to 'tests/phpunit/data/less') diff --git a/tests/phpunit/data/less/import-codex-icons-devmode.css b/tests/phpunit/data/less/import-codex-icons-devmode.css new file mode 100644 index 000000000000..0b5b300cc955 --- /dev/null +++ b/tests/phpunit/data/less/import-codex-icons-devmode.css @@ -0,0 +1,3 @@ +.foo:before { + content: 'test add icon'; +} diff --git a/tests/phpunit/data/less/import-codex-tokens-devmode.css b/tests/phpunit/data/less/import-codex-tokens-devmode.css new file mode 100644 index 000000000000..9b5c1c9efddd --- /dev/null +++ b/tests/phpunit/data/less/import-codex-tokens-devmode.css @@ -0,0 +1,3 @@ +.foo { + width: 'test size 100'; +} -- cgit v1.2.3