Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/178264

Change subject: Add checkComposerLockUpToDate.php script
......................................................................

Add checkComposerLockUpToDate.php script

Checks whether your composer.lock file is up to date
with the current composer.json file.

Bug: T77388
Change-Id: I528d63172c238cf1ea9bc02e8eb39b93225865de
---
A maintenance/checkComposerLockUpToDate.php
1 file changed, 37 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/64/178264/1

diff --git a/maintenance/checkComposerLockUpToDate.php 
b/maintenance/checkComposerLockUpToDate.php
new file mode 100644
index 0000000..2186327
--- /dev/null
+++ b/maintenance/checkComposerLockUpToDate.php
@@ -0,0 +1,37 @@
+<?php
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * Checks whether your composer-installed dependencies are up to date
+ *
+ * Composer creates a "composer.lock" file which specifies which versions are 
installed
+ * (via `composer install`). It has a hash, which can be compared to the value 
of
+ * the composer.json file to see if dependencies are up to date.
+ */
+class CheckComposerLockUpToDate extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->mDescription = 'Checks whether your composer.lock file 
is up to date with the current composer.json';
+       }
+
+       public function execute() {
+               global $IP;
+               $lock = "$IP/composer.lock";
+               $json = "$IP/composer.json";
+               if ( !file_exists( $lock ) ) {
+                       $this->error( "Could not find composer.lock file at 
$lock", 1 );
+               }
+               // This is the same thing that composer does internally
+               $hash = md5_file( $json );
+               $lockContents = FormatJson::decode( file_get_contents( $lock ) 
);
+               if ( $lockContents->hash === $hash ) {
+                       $this->output( "Your composer.lock file is up to date 
with current dependencies!\n" );
+               } else {
+                       $this->error( 'Error: your composer.lock file is not up 
to date, run "composer update" to install newer dependencies', 1 );
+               }
+       }
+}
+
+$maintClass = 'CheckComposerLockUpToDate';
+require_once RUN_MAINTENANCE_IF_MAIN;
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/178264
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I528d63172c238cf1ea9bc02e8eb39b93225865de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to