Previously, logic to validate extension.json files was in two places: validateRegistrationFile.php maintenance script, and the ExtensionJsonValidationTest.php structure test. This caused duplication as validation became more complex (e.g. usage of spdx-licenses library). A generic ExtensionJsonValidator class now handles most of the validation work, while the maintenance script and test case just wrap around it for their output formats. Change-Id: I47062a4ae19c58ee1b1f2bb4877913259bf19c8b
26 lines
712 B
PHP
26 lines
712 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
|
|
|
class ValidateRegistrationFile extends Maintenance {
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->addArg( 'path', 'Path to extension.json/skin.json file.', true );
|
|
}
|
|
public function execute() {
|
|
$validator = new ExtensionJsonValidator( function( $msg ) {
|
|
$this->error( $msg, 1 );
|
|
} );
|
|
$validator->checkDependencies();
|
|
$path = $this->getArg( 0 );
|
|
try {
|
|
$validator->validate( $path );
|
|
$this->output( "$path validates against the schema!\n" );
|
|
} catch ( ExtensionJsonValidationError $e ) {
|
|
$this->error( $e->getMessage(), 1 );
|
|
}
|
|
}
|
|
}
|
|
|
|
$maintClass = 'ValidateRegistrationFile';
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|