12require_once __DIR__ .
'/Maintenance.php';
28 parent::__construct();
30Manage foreign resources registered with ResourceLoader.
32This helps developers with downloading, verifying, and updating local copies of
33upstream libraries registered as ResourceLoader modules. See
36Use the
"update" action to download urls specified in foreign-resources.yaml,
37and unpack them to the resources directory. This will also verify them against
40Use the
"verify" action to verify the files currently in the resources directory
41match what
"update" would replace them with. This is effectively a dry-run and
42will not change any module resources on disk.
44Use the
"make-sri" action to compute an integrity hash
for upstreams that
do not
45publish one themselves. Add or update the urls foreign-resources.yaml as needed,
46but omit (or leave empty) the
"integrity" key. Then, run the
"make-sri" action
47for the module and copy the integrity into the file. Then, you can use
"verify"
50The
"make-cdx" option generates a CycloneDX SBOM file.
53 $this->
addArg(
'action',
'One of "update", "verify", "make-sri" or "make-cdx"',
true );
54 $this->
addArg(
'module',
'Name of a single module (Default: all)',
false );
55 $this->
addOption(
'extension',
'Manage foreign resources for the given extension, instead of core',
57 $this->
addOption(
'skin',
'Manage foreign resources for the given skin, instead of core',
59 $this->
addOption(
'verbose',
'Be verbose',
false,
false,
'v' );
69 $foreignResourcesDirs = ExtensionRegistry::getInstance()->getAttribute(
'ForeignResourcesDir' )
70 + [
'#core' =>
"{$IP}/resources/lib" ];
71 if ( !array_key_exists( $component, $foreignResourcesDirs ) ) {
72 $this->
fatalError(
"Unknown component: $component\n" );
74 $foreignResourcesFile =
"{$foreignResourcesDirs[$component]}/foreign-resources.yaml";
77 $foreignResourcesFile,
78 dirname( $foreignResourcesFile ),
88 $action = $this->
getArg( 0 );
89 $module = $this->
getArg( 1,
'all' );
92 return $frm->run( $action, $module );
93 }
catch ( Exception $e ) {
94 $this->
fatalError(
"Error: {$e->getMessage()}" );
101require_once RUN_MAINTENANCE_IF_MAIN;
if(!defined('MEDIAWIKI')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Manage foreign resources registered with ResourceLoader.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
output( $out, $channel=null)
Throw some output to the user.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
error( $err, $die=0)
Throw an error to the user.
addDescription( $text)
Set the description text.