MediaWiki REL1_33
checkComposerLockUpToDate.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/Maintenance.php';
4
6
15 public function __construct() {
16 parent::__construct();
17 $this->addDescription(
18 'Checks whether your composer.lock file is up to date with the current composer.json' );
19 }
20
21 public function execute() {
22 global $IP;
23 $lockLocation = "$IP/composer.lock";
24 $jsonLocation = "$IP/composer.json";
25 if ( !file_exists( $lockLocation ) ) {
26 // Maybe they're using mediawiki/vendor?
27 $lockLocation = "$IP/vendor/composer.lock";
28 if ( !file_exists( $lockLocation ) ) {
29 $this->fatalError(
30 'Could not find composer.lock file. Have you run "composer install --no-dev"?'
31 );
32 }
33 }
34
35 $lock = new ComposerLock( $lockLocation );
36 $json = new ComposerJson( $jsonLocation );
37
38 // Check all the dependencies to see if any are old
39 $found = false;
40 $installed = $lock->getInstalledDependencies();
41 foreach ( $json->getRequiredDependencies() as $name => $version ) {
42 if ( isset( $installed[$name] ) ) {
43 if ( !SemVer::satisfies( $installed[$name]['version'], $version ) ) {
44 $this->output(
45 "$name: {$installed[$name]['version']} installed, $version required.\n"
46 );
47 $found = true;
48 }
49 } else {
50 $this->output( "$name: not installed, $version required.\n" );
51 $found = true;
52 }
53 }
54 if ( $found ) {
55 $this->fatalError(
56 'Error: your composer.lock file is not up to date. ' .
57 'Run "composer update --no-dev" to install newer dependencies'
58 );
59 } else {
60 // We couldn't find any out-of-date dependencies, so assume everything is ok!
61 $this->output( "Your composer.lock file is up to date with current dependencies!\n" );
62 }
63 }
64}
65
66$maintClass = CheckComposerLockUpToDate::class;
67require_once RUN_MAINTENANCE_IF_MAIN;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Checks whether your composer-installed dependencies 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.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
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.
$IP
Definition update.php:3
require_once RUN_MAINTENANCE_IF_MAIN