Version and dependency are now required

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-05-22 09:54:44 +02:00
parent e102923a97
commit eebd2811dc
No known key found for this signature in database
GPG key ID: E166FD8976B3BAC8
11 changed files with 24 additions and 60 deletions

View file

@ -146,11 +146,7 @@ class CheckCode extends Command implements CompletionAwareInterface {
}); });
$infoChecker->listen('InfoChecker', 'missingRequirement', function($minMax) use ($output) { $infoChecker->listen('InfoChecker', 'missingRequirement', function($minMax) use ($output) {
$output->writeln("<comment>Nextcloud $minMax version requirement missing (will be an error in Nextcloud 12 and later)</comment>"); $output->writeln("<error>Nextcloud $minMax version requirement missing</error>");
});
$infoChecker->listen('InfoChecker', 'duplicateRequirement', function($minMax) use ($output) {
$output->writeln("<error>Duplicate $minMax ownCloud version requirement found</error>");
}); });
$infoChecker->listen('InfoChecker', 'differentVersions', function($versionFile, $infoXML) use ($output) { $infoChecker->listen('InfoChecker', 'differentVersions', function($versionFile, $infoXML) use ($output) {
@ -162,7 +158,7 @@ class CheckCode extends Command implements CompletionAwareInterface {
}); });
$infoChecker->listen('InfoChecker', 'migrateVersion', function($version) use ($output) { $infoChecker->listen('InfoChecker', 'migrateVersion', function($version) use ($output) {
$output->writeln("<info>Migrate the app version to appinfo/info.xml (add <version>$version</version> to appinfo/info.xml and remove appinfo/version)</info>"); $output->writeln("<error>Migrate the app version to appinfo/info.xml (add <version>$version</version> to appinfo/info.xml and remove appinfo/version)</error>");
}); });
if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {

View file

@ -34,15 +34,16 @@ class InfoChecker extends BasicEmitter {
private $mandatoryFields = [ private $mandatoryFields = [
'author', 'author',
'description', 'description',
'dependencies',
'id', 'id',
'licence', 'licence',
'name', 'name',
'version',
]; ];
private $optionalFields = [ private $optionalFields = [
'bugs', 'bugs',
'category', 'category',
'default_enable', 'default_enable',
'dependencies', // TODO: Mandatory as of ownCloud 11
'documentation', 'documentation',
'namespace', 'namespace',
'ocsid', 'ocsid',
@ -50,7 +51,6 @@ class InfoChecker extends BasicEmitter {
'remote', 'remote',
'repository', 'repository',
'types', 'types',
'version',
'website', 'website',
]; ];
private $deprecatedFields = [ private $deprecatedFields = [
@ -80,29 +80,19 @@ class InfoChecker extends BasicEmitter {
$info = $this->infoParser->parse($appPath . '/appinfo/info.xml'); $info = $this->infoParser->parse($appPath . '/appinfo/info.xml');
if (isset($info['dependencies']['owncloud']['@attributes']['min-version']) && (isset($info['requiremin']) || isset($info['require']))) { if (!isset($info['dependencies']['nextcloud']['@attributes']['min-version'])) {
$this->emit('InfoChecker', 'duplicateRequirement', ['min']);
$errors[] = [ $errors[] = [
'type' => 'duplicateRequirement', 'type' => 'missingRequirement',
'field' => 'min', 'field' => 'min',
]; ];
} else if (
!isset($info['dependencies']['owncloud']['@attributes']['min-version']) &&
!isset($info['dependencies']['nextcloud']['@attributes']['min-version'])
) {
$this->emit('InfoChecker', 'missingRequirement', ['min']); $this->emit('InfoChecker', 'missingRequirement', ['min']);
} }
if (isset($info['dependencies']['owncloud']['@attributes']['max-version']) && isset($info['requiremax'])) { if (!isset($info['dependencies']['nextcloud']['@attributes']['max-version'])) {
$this->emit('InfoChecker', 'duplicateRequirement', ['max']);
$errors[] = [ $errors[] = [
'type' => 'duplicateRequirement', 'type' => 'missingRequirement',
'field' => 'max', 'field' => 'max',
]; ];
} else if (
!isset($info['dependencies']['owncloud']['@attributes']['max-version']) &&
!isset($info['dependencies']['nextcloud']['@attributes']['max-version'])
) {
$this->emit('InfoChecker', 'missingRequirement', ['max']); $this->emit('InfoChecker', 'missingRequirement', ['max']);
} }
@ -145,21 +135,7 @@ class InfoChecker extends BasicEmitter {
$versionFile = $appPath . '/appinfo/version'; $versionFile = $appPath . '/appinfo/version';
if (is_file($versionFile)) { if (is_file($versionFile)) {
$version = trim(file_get_contents($versionFile)); $version = trim(file_get_contents($versionFile));
if (isset($info['version'])) { $this->emit('InfoChecker', 'migrateVersion', [$version]);
if($info['version'] !== $version) {
$this->emit('InfoChecker', 'differentVersions',
[$version, $info['version']]);
$errors[] = [
'type' => 'differentVersions',
'message' => 'appinfo/version: ' . $version .
' - appinfo/info.xml: ' . $info['version'],
];
} else {
$this->emit('InfoChecker', 'sameVersions', [$versionFile]);
}
} else {
$this->emit('InfoChecker', 'migrateVersion', [$version]);
}
} }
return $errors; return $errors;

View file

@ -1,9 +0,0 @@
<?xml version="1.0"?>
<info>
<id>testapp-infoxml-version</id>
<version>1.2.3</version>
<author>Jane</author>
<description>A b c</description>
<licence>Abc</licence>
<name>Test app</name>
</info>

View file

@ -1 +0,0 @@
1.2.3

View file

@ -6,4 +6,7 @@
<description>A b c</description> <description>A b c</description>
<licence>Abc</licence> <licence>Abc</licence>
<name>Test app</name> <name>Test app</name>
<dependencies>
<nextcloud min-version="12.0" max-version="12.0"/>
</dependencies>
</info> </info>

View file

@ -5,4 +5,7 @@
<author>Jane</author> <author>Jane</author>
<description>A b c</description> <description>A b c</description>
<licence>Abc</licence> <licence>Abc</licence>
<dependencies>
<nextcloud min-version="12.0" max-version="12.0"/>
</dependencies>
</info> </info>

View file

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<info>
<id>testapp-version</id>
<author>Jane</author>
<description>A b c</description>
<licence>Abc</licence>
<name>Test app</name>
</info>

View file

@ -5,4 +5,7 @@
<description>A b c</description> <description>A b c</description>
<licence>Abc</licence> <licence>Abc</licence>
<name>Test app</name> <name>Test app</name>
<dependencies>
<nextcloud min-version="12.0" max-version="12.0"/>
</dependencies>
</info> </info>

View file

@ -50,10 +50,12 @@ class InfoCheckerTest extends TestCase {
public function appInfoData() { public function appInfoData() {
return [ return [
['testapp-infoxml', []], ['testapp-infoxml', []],
['testapp-version', []], ['testapp-version', [['type' => 'mandatoryFieldMissing', 'field' => 'version']]],
['testapp-infoxml-version', []], ['testapp-dependency-missing', [
['testapp-infoxml-version-different', [['type' => 'differentVersions', 'message' => 'appinfo/version: 1.2.4 - appinfo/info.xml: 1.2.3']]], ['type' => 'missingRequirement', 'field' => 'min'],
['testapp-version-missing', []], ['type' => 'missingRequirement', 'field' => 'max'],
['type' => 'mandatoryFieldMissing', 'field' => 'dependencies'],
]],
['testapp-name-missing', [['type' => 'mandatoryFieldMissing', 'field' => 'name']]], ['testapp-name-missing', [['type' => 'mandatoryFieldMissing', 'field' => 'name']]],
]; ];
} }