-
Notifications
You must be signed in to change notification settings - Fork 15
/
get_required_matomo_version.php
41 lines (33 loc) · 1.45 KB
/
get_required_matomo_version.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
$pluginName = $argv[1];
$returnMaxVersion = !empty($argv[2]) && $argv[2] === 'max';
// tiny script to get plugin version from plugin.json from a bash script
require_once __DIR__ . '/../../core/Version.php';
require_once __DIR__ . '/matomo_version_parser.php';
// at this point in travis the plugin to test against is not in the piwik directory. we could move it to piwik
// beforehand, but for plugins that are also stored as submodules, this would erase the plugin or fail when git
// submodule update is called
$pluginJsonPath = __DIR__ . "/../../../$pluginName/plugin.json";
$pluginJsonContents = file_get_contents($pluginJsonPath);
$pluginJsonContents = json_decode($pluginJsonContents, true);
$requiredVersions = getRequiredMatomoVersions($pluginJsonContents);
if ($returnMaxVersion) {
$versionToReturn = getMaxVersion($requiredVersions);
if (empty($versionToReturn)) {
$versionToReturn = trim(file_get_contents('https://api.matomo.org/LATEST_BETA'));
}
} else {
$versionToReturn = getMinVersion($requiredVersions);
}
if (empty($versionToReturn)) {
$requiredVersions = getRequiredMatomoVersions($pluginJsonContents, true);
$versionToReturn = getMinVersion($requiredVersions);
$versionToReturn = !empty($versionToReturn) ? $versionToReturn : '4.x-dev';
}
echo $versionToReturn;