Browse Source

feat(requirements): extensions with logical operators

fix-api
JamesRezo 1 year ago
parent
commit
e7506bec69
  1. 1
      CHANGELOG
  2. 40
      data/releases.json
  3. 37
      modeles/supportedversions_spiploaderlist_2.html
  4. 19
      supportedversions_fonctions.php
  5. 25
      tests/SupportedVersionsTest.php

1
CHANGELOG

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- releases upgrades (SPIP 4.0.1, SPIP 3.2.12)
- add last eol release to `spip_loader.api`
- logical operators for php extensions
## [0.6.0] - 2021-08-14

40
data/releases.json

@ -2159,7 +2159,14 @@
],
"php-ext": {
"xml": "*",
"gd": "2"
"gd": "2",
"or": {
"mysqli": "*",
"and": {
"pdo": "*",
"pdo_sqlite": "*"
}
}
}
},
"suggest": {
@ -2464,7 +2471,14 @@
],
"php-ext": {
"xml": "*",
"gd": "2"
"gd": "2",
"or": {
"mysqli": "*",
"and": {
"pdo": "*",
"pdo_sqlite": "*"
}
}
}
},
"suggest": {
@ -2716,7 +2730,14 @@
],
"php-ext": {
"xml": "*",
"gd": "2"
"gd": "2",
"or": {
"mysqli": "*",
"and": {
"pdo": "*",
"pdo_sqlite": "*"
}
}
}
},
"suggest": {
@ -2800,7 +2821,18 @@
"7.4",
"8.0",
"8.1"
]
],
"php-ext": {
"xml": "*",
"gd": "2",
"or": {
"mysqli": "*",
"and": {
"pdo": "*",
"pdo_sqlite": "*"
}
}
}
}
},
"releases": null

37
modeles/supportedversions_spiploaderlist_2.html

@ -1,8 +1,17 @@
#SET{list, #ARRAY{dev, #ARRAY{url, https://files.spip.net/spip/dev/spip-master.zip, php, #LISTE{7.4,8.0,8.1}}}
#SET{list, #ARRAY{dev, #ARRAY{
url, https://files.spip.net/spip/dev/spip-master.zip,
php, #LISTE{7.4,8.0,8.1}
}}
<BOUCLE_pre_releases(DATA){source json, #CHEMIN{data/pre_releases.json}}{branch=#VAL{future}|SupportedVersions::getBranchesFromState|table_valeur{0/branch}}>
<BOUCLE_releases(DATA){source table, #PRE_RELEASES}{par released_at}{inverse}{0,1}>
<BOUCLE_download(DATA){source table, #DOWNLOAD}>
#SET{release, #ARRAY{url, #URL, php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php}}}
#SET{release, #ARRAY{
url, #URL,
php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php},
extensions, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php-ext},
ram, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/ram},
freespace, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/freespace}
}}
</BOUCLE_download>
#SET{list, #GET{list}|array_merge{#ARRAY{#VERSION, #GET{release}}}}
</BOUCLE_releases>
@ -10,7 +19,13 @@
<BOUCLE_stable(DATA){source table, #VAL{stable}|SupportedVersions::getBranchesFromState}{par last_date_release}{inverse}{0,1}>
<BOUCLE_release_stable(DATA){source table, #RELEASES}{version=#LAST_VERSION_RELEASE}>
<BOUCLE_download_stable(DATA){source table, #DOWNLOAD}>
#SET{release, #ARRAY{url, #URL, php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php}}}
#SET{release, #ARRAY{
url, #URL,
php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php},
extensions, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php-ext},
ram, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/ram},
freespace, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/freespace}
}}
</BOUCLE_download_stable>
#SET{list, #GET{list}|array_merge{#ARRAY{#VERSION, #GET{release}}}}
</BOUCLE_release_stable>
@ -18,7 +33,13 @@
<BOUCLE_security(DATA){source table, #VAL{security}|SupportedVersions::getBranchesFromState}{par last_date_release}{inverse}{0,1}>
<BOUCLE_release_security(DATA){source table, #RELEASES}{version=#LAST_VERSION_RELEASE}>
<BOUCLE_download_security(DATA){source table, #DOWNLOAD}>
#SET{release, #ARRAY{url, #URL, php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php}}}
#SET{release, #ARRAY{
url, #URL,
php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php},
extensions, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php-ext},
ram, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/ram},
freespace, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/freespace}
}}
</BOUCLE_download_security>
#SET{list, #GET{list}|array_merge{#ARRAY{#VERSION, #GET{release}}}}
</BOUCLE_release_security>
@ -26,7 +47,13 @@
<BOUCLE_eol(DATA){source table, #VAL{eol}|SupportedVersions::getBranchesFromState}{par last_date_release}{inverse}{0,1}>
<BOUCLE_release_eol(DATA){source table, #RELEASES}{version=#LAST_VERSION_RELEASE}>
<BOUCLE_download_eol(DATA){source table, #DOWNLOAD}>
#SET{release, #ARRAY{url, #URL, php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php}}}
#SET{release, #ARRAY{
url, #URL,
php, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php},
extensions, #VERSION|SupportedVersions::getBranchValues|table_valeur{technologies/require/php-ext},
ram, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/ram},
freespace, #VERSION|SupportedVersions::getBranchValues|table_valeur{system/freespace}
}}
</BOUCLE_download_eol>
#SET{list, #GET{list}|array_merge{#ARRAY{#VERSION, #GET{release}}}}
</BOUCLE_release_eol>

19
supportedversions_fonctions.php

@ -775,14 +775,25 @@ class SupportedVersions
* Transforme un tableau en chaine.
*
* @param array<mixed> $extensions liste des extensions et de leurs versions
* @param string $versionMarker
* @param string $logicalOperation
* @return string
*/
public static function configuration(array $extensions, string $versionMarker = ''): string {
$strExtensions = '';
public static function configuration(
array $extensions,
string $versionMarker = '',
string $logicalOperation = 'and'
): string {
$tmpExtensions =[];
foreach ($extensions as $extension => $version) {
$strExtensions .= $extension . ($version == '*' ? '' : $versionMarker . $version) . ', ';
if (is_array($version)) {
$tmpExtensions[] = '(' . self::configuration($version, $versionMarker, $extension) . ')';
} else {
$tmpExtensions[] = $extension . ($version == '*' ? '' : $versionMarker . $version);
}
}
return preg_replace('/, $/', '', $strExtensions) ?? '';
return implode($logicalOperation !== 'or' ? ', ' : ' | ', $tmpExtensions);
}
}

25
tests/SupportedVersionsTest.php

@ -603,15 +603,32 @@ class SupportedVersionsTest extends TestCase
$this->assertEquals($expected, $actual);
}
public function testConfiguration()
public function dataConfiguration()
{
//Given
$configuration = ['test' => '*', 'othertest' => '1'];
return [
[
'test, othertestv1',
['test' => '*', 'othertest' => '1'],
],
[
'test, (one way | another)',
['test' => '*', 'or' => ['one way' => '*', 'another' => '*']],
],
];
}
/**
* @group filtres
* @dataProvider dataConfiguration
*/
public function testConfiguration($expected, $configuration)
{
//Given a $configuration
//When
$actual = SupportedVersions::configuration($configuration, 'v');
//Then
$this->assertEquals('test, othertestv1', $actual);
$this->assertEquals($expected, $actual);
}
}

Loading…
Cancel
Save