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
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Iae45fa269363be8ee05c598ea6926514ce817762
CODEX_MODULE_DIR is always the /modules subdirectory of
CODEX_LIBRARY_DIR, so remove it and derive it that way instead.
- Update tests accordingly
- Rename test data files accordingly
- Use CODEX_LIBRARY_DIR in one place where we had neglected to use a
constant
Change-Id: Ieb347c2d128f3addfb11f6aca79d63969434f342
Leave class aliases behind because they might be being used somewhere,
but we don't normally flag these kinds of things in the release notes,
do we?
Bug: T357823
Change-Id: I7fc7f34494d5c4df81f6746d63df1d0f990f8ae9
- Add a getCodexFiles() method that parses the manifest and transforms
it to a more useful format based on actual file names rather than
manifest keys
- Cache the result as a static class property, so that it's reused
between all CodexModule instances
- Use the resulting data structure to simplify the rest of the code
- This also has the side effect of correctly throwing an error when a
nonexistent file is requested (this wasn't the case before). Add a
test case for this.
- Add a test for this new method in CodexModuleTest.php
Change-Id: Id527cef0e19fec7b54af3bf65a1de66f50d5fff0
This patch adds test cases for the following scenarios:
- codexComponents defined as an empty array in the module definition
file
- codexComponents defined as a non-array type in the module definition
file
Bug: T353858
Change-Id: I055f837baab2bfce5ae840a472a9f8a2bf3847df
CodexModule throws an InvalidArgumentException if one of the elements
of the codexComponents array refers to a private chunk rather than a
public entry point file. Add a unit test asserting this behavior.
Also add an `isset()` to the check in CodexModule so that it doesn't
cause a PHP notice about a missing array index.
Bug: T353191
Change-Id: I3e31511aeeb42d825c308f047894f5eba28b0f27
If a generated chunk is listed in the codexComponents array,
an exception will be thrown informing the developer that the
item is not an export of Codex and cannot be required.
Text fixtures and expected values were updated to match
recent changes to the manifest that made composables
explict entries.
Bug: T353191
Change-Id: Ie3e35501993b1ad5d29ebecbcc8203e7f4ea8c81
This patch adds a test case for the scenario where a codex component is
not defined in the module definition file and a user attempts to require
it.
The scenario where the 'codexComponents' key is defined but is an empty
array will be tested separately after 984663 lands.
Bug: T353858
Change-Id: I717ac327848ff6f6baad83110e8d2f10c135e5f1
This requires the path to the Codex modules directory
to be configurable, so we can use static manifest and
component files in tests. This is achieved by changing
the constant storing the Codex modules dir from private
to protected so it can be overridden when creating a
test module.
Bug: T350054
Change-Id: Icd3c6c5d2a82f5a5fb1c38b52e54893034e7375c