MediaWiki master
checkComposerLockUpToDate.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/Maintenance.php';
4
8
17 public function __construct() {
18 parent::__construct();
19 $this->addDescription(
20 'Checks whether your composer.lock file is up to date with the current composer.json' );
21 }
22
23 public function execute() {
24 global $IP;
25 $lockLocation = "$IP/composer.lock";
26 $jsonLocation = "$IP/composer.json";
27 if ( !file_exists( $lockLocation ) ) {
28 // Maybe they're using mediawiki/vendor?
29 $lockLocation = "$IP/vendor/composer.lock";
30 if ( !file_exists( $lockLocation ) ) {
31 $this->fatalError(
32 'Could not find composer.lock file. Have you run "composer install --no-dev"?'
33 );
34 }
35 }
36
37 $lock = new ComposerLock( $lockLocation );
38 $json = new ComposerJson( $jsonLocation );
39
40 // Check all the dependencies to see if any are old
41 $checker = new LockFileChecker( $json, $lock );
42 $result = $checker->check();
43 if ( $result->isGood() ) {
44 // We couldn't find any out-of-date dependencies, so assume everything is ok!
45 $this->output( "Your composer.lock file is up to date with current dependencies!\n" );
46 } else {
47 foreach ( $result->getErrors() as $error ) {
48 $this->error(
49 wfMessage( $error['message'], ...$error['params'] )->inLanguage( 'en' )->plain() . "\n"
50 );
51 }
52 $this->fatalError(
53 'Error: your composer.lock file is not up to date. ' .
54 'Run "composer update --no-dev" to install newer dependencies'
55 );
56 }
57 }
58}
59
60$maintClass = CheckComposerLockUpToDate::class;
61require_once RUN_MAINTENANCE_IF_MAIN;
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:98
Checks whether your composer-installed dependencies are up to date.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Used to check whether composer-installed dependencies (no-dev) are up-to-date.
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
Reads a composer.lock file and provides accessors to get its hash and what is installed.