26require_once __DIR__ .
'/Maintenance.php';
42 parent::__construct();
44Manage foreign resources registered with ResourceLoader.
46This helps developers with downloading, verifying, and updating local copies of
47upstream libraries registered as ResourceLoader modules. See
50Use the
"update" action to download urls specified in foreign-resources.yaml,
51and unpack them to the resources directory. This will also verify them against
54Use the
"verify" action to verify the files currently in the resources directory
55match what
"update" would replace them with. This is effectively a dry-run and
56will not change any module resources on disk.
58Use the
"make-sri" action to compute an integrity hash
for upstreams that
do not
59publish one themselves. Add or update the urls foreign-resources.yaml as needed,
60but omit (or leave empty) the
"integrity" key. Then, run the
"make-sri" action
61for the module and copy the integrity into the file. Then, you can use
"verify"
64The
"make-cdx" option generates a CycloneDX SBOM file.
67 $this->
addArg(
'action',
'One of "update", "verify", "make-sri" or "make-cdx"',
true );
68 $this->
addArg(
'module',
'Name of a single module (Default: all)',
false );
69 $this->
addOption(
'extension',
'Manage foreign resources for the given extension, instead of core',
71 $this->
addOption(
'skin',
'Manage foreign resources for the given skin, instead of core',
73 $this->
addOption(
'verbose',
'Be verbose',
false,
false,
'v' );
83 $foreignResourcesDirs = ExtensionRegistry::getInstance()->getAttribute(
'ForeignResourcesDir' )
84 + [
'#core' =>
"{$IP}/resources/lib" ];
85 if ( !array_key_exists( $component, $foreignResourcesDirs ) ) {
86 $this->
fatalError(
"Unknown component: $component\n" );
88 $foreignResourcesFile =
"{$foreignResourcesDirs[$component]}/foreign-resources.yaml";
91 $foreignResourcesFile,
92 dirname( $foreignResourcesFile ),
97 $this->
error( $text );
106 $action = $this->
getArg( 0 );
107 $module = $this->
getArg( 1,
'all' );
110 return $frm->run( $action, $module );
111 }
catch ( Exception $e ) {
112 $this->
fatalError(
"Error: {$e->getMessage()}" );
119require_once RUN_MAINTENANCE_IF_MAIN;
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) 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.