Improve docs for Title::getInternalURL/getCanonicalURL
[lhc/web/wiklou.git] / maintenance / resources / manageForeignResources.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Maintenance
20 */
21
22 require_once __DIR__ . '/../Maintenance.php';
23
24 /**
25 * Manage foreign resources registered with ResourceLoader.
26 *
27 * @ingroup Maintenance
28 * @since 1.32
29 */
30 class ManageForeignResources extends Maintenance {
31 public function __construct() {
32 parent::__construct();
33 $this->addDescription( <<<TEXT
34 Manage foreign resources registered with ResourceLoader.
35
36 This helps developers to download, verify and update local copies of upstream
37 libraries registered as ResourceLoader modules. See also foreign-resources.yaml.
38
39 For sources that don't publish an integrity hash, omit "integrity" (or leave empty)
40 and run the "make-sri" action to compute the missing hashes.
41
42 This script runs in dry-run mode by default. Use --update to actually change,
43 remove, or add files to resources/lib/.
44 TEXT
45 );
46 $this->addArg( 'action', 'One of "update", "verify" or "make-sri"', true );
47 $this->addArg( 'module', 'Name of a single module (Default: all)', false );
48 $this->addOption( 'verbose', 'Be verbose', false, false, 'v' );
49 }
50
51 /**
52 * @return bool
53 * @throws Exception
54 */
55 public function execute() {
56 global $IP;
57 $frm = new ForeignResourceManager(
58 __DIR__ . '/foreign-resources.yaml',
59 "{$IP}/resources/lib",
60 function ( $text ) {
61 $this->output( $text );
62 },
63 function ( $text ) {
64 $this->error( $text );
65 },
66 function ( $text ) {
67 if ( $this->hasOption( 'verbose' ) ) {
68 $this->output( $text );
69 }
70 }
71 );
72
73 $action = $this->getArg( 0 );
74 $module = $this->getArg( 1, 'all' );
75 return $frm->run( $action, $module );
76 }
77 }
78
79 $maintClass = ManageForeignResources::class;
80 require_once RUN_MAINTENANCE_IF_MAIN;