canasta extension add

From Canasta Wiki

canasta > extension > add

canasta extension add

Add an extension, cloning it from its git repository if needed

Synopsis

Add a MediaWiki extension to the instance and enable it. Each name is matched case-insensitively and handled in this order:

  1. Already in the instance's extensions/ directory: the existing checkout is kept and its branch is verified.
  2. Bundled with Canasta (shipped in the image): nothing is cloned; the extension is only enabled. --repository and --branch are refused, since the image sets its version, unless --override is given.
  3. Otherwise it is cloned into extensions/, which requires --clone (or an explicit --repository). Without it the command fails before changing anything and names the URL it would clone and where that URL came from.

When cloning, the git URL is taken from --repository, else from ExtensionJson.json (the extjsonuploader Toolforge dataset), else from Wikimedia Gerrit (mediawiki/extensions/<Name>). URLs from ExtensionJson.json and Gerrit must be https. When Gerrit does not answer, its GitHub mirror (github.com/wikimedia/mediawiki-extensions-<Name>) is used instead. The URL and its source are printed for every clone, flagged when the repository is not hosted on Wikimedia Gerrit. Pass --branch to pin a specific branch. The branch is chosen automatically as REL1_YY matching the instance's MediaWiki version (e.g. MediaWiki 1.43 -> REL1_43), tried on every remote (GitHub and GitLab mirrors carry the same REL branches); if the REL branch does not exist there, the default branch is used unless --branch is given. Override the detected version with --mw-version.

If the extension ships a composer.json, its non-dev requirements are installed: it is registered in config/composer.local.json (committed in gitops) and composer update --no-dev runs in the web container. A composer.json whose autoload.files names a file the extension does not ship is not registered, and the command fails; so does a composer update after which the autoloader requires a missing file, with the registration rolled back so the wikis keep loading.

With --override, a bundled extension is cloned like any other, at the branch --branch names (or the automatic one), from --repository or the usual lookup, and --clone is not needed. The copy in extensions/ overrides the bundled one: the command warns, naming both versions, and restarts the instance so the copy is loaded. canasta extension list marks it, canasta upgrade warns while its version differs from the bundled one, and canasta extension remove deletes the copy, so the bundled extension is used again, still enabled.

On a gitops instance the extension is added as a submodule and committed (run canasta gitops push to distribute it). The extension is then enabled automatically (write settings + run update.php); use --skip-enable to add the code only.

Requires a Compose (including gitops) instance; Kubernetes is not supported.

canasta extension add [flags] NAMES

Examples

canasta extension add ParserFunctions
canasta extension add DarkMode --clone
canasta extension add DarkMode --clone --mw-version 1.43.2
canasta extension add MyExtension --repository https://example.org/MyExtension.git --branch main
canasta extension add SemanticMediaWiki --override --branch 7.2.1

Arguments

Argument Description Default Required Orchestrator
NAMES Comma-separated extension names ✓ Both

Flags

Flag Shorthand Description Default Required Orchestrator
--branch Branch to check out (overrides auto branch selection); only with a single name Both
--clone Allow cloning extensions that are neither bundled nor already in extensions/ Both
--id -i Canasta instance ID * Both
--mw-version MediaWiki version (e.g. 1.43.2); overrides auto-detection for REL1_YY branch selection Both
--override Clone a bundled extension into extensions/, where the copy overrides the bundled one Both
--repository Git URL to clone (overrides the name lookup); only with a single name Both
--skip-enable Add the code only; do not enable the extension Both
--skip-update Skip running update.php after enabling Both
--wiki -w Wiki ID to enable the extension for (passed to enable) Both

* Defaults to the Canasta instance matching the current directory, if any.

Global flags

Flag Shorthand Description Default Required Orchestrator
--help -h Show help message and exit Both
--verbose -v Enable verbose output Both