From ec4381bf05d86a5bce5365bab6b8b537bc2bc8a8 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Sat, 3 Jun 2017 10:35:21 +0200 Subject: [PATCH] added new variable "platforms" --- example-script/info.json | 5 +++-- run-tests.php | 30 +++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/example-script/info.json b/example-script/info.json index 77a7022..0b34ce0 100644 --- a/example-script/info.json +++ b/example-script/info.json @@ -3,7 +3,8 @@ "identifier": "example-script", "script": "example-script.qml", "authors": ["@pbek"], - "version": "0.0.1", - "minAppVersion": "17.05.6", + "platforms": ["linux", "macos", "windows"], + "version": "0.0.2", + "minAppVersion": "17.06.2", "description" : "Use this script to start a new script you want to submit to the script repository.\n\nJust copy the whole example-script folder from the git-repository on GitHub and rename both the folder and example-script.qml." } diff --git a/run-tests.php b/run-tests.php index 102edce..2b08638 100755 --- a/run-tests.php +++ b/run-tests.php @@ -12,12 +12,12 @@ $errors = $testHelper->errors; if (count($errors) > 0) { foreach($errors as $dir => $scriptErrors) { print "Directory '$dir'\n"; - + foreach($scriptErrors as $error) { print " $error\n"; } } - + exit(1); } @@ -26,7 +26,7 @@ exit(0); class TestHelper { public $errors = array(); - + /** * Tests the files in a directory */ @@ -34,33 +34,45 @@ class TestHelper { $errors = array(); $jsonData = file_get_contents($dir . "/info.json"); $data = json_decode($jsonData, true); - + if ($data["name"] == "") { $errors[] = "No name was entered!"; } - + $identifier = $data["identifier"]; if ($identifier == "") { $errors[] = "No identifier was entered!"; } elseif (preg_match('/[^a-z0-9\-_]/', $identifier)) { $errors[] = "Invalid charactes were found in identifier '$identifier'!"; } - + if ($data["description"] == "") { $errors[] = "No description was entered!"; } - + $script = $data["script"]; if ($script == "") { $errors[] = "No script was entered!"; } elseif (!file_exists($dir . "/" . $script)) { $errors[] = "Script '$script' doesn't exist!"; } - + if ($data["version"] == "") { $errors[] = "No version was entered!"; } - + + if (isset($data["platforms"])) { + if (!is_array($data["platforms"])) { + $errors[] = "'platforms' has to be an array!"; + } else { + foreach ($data["platforms"] as $platform) { + if (!in_array($platform, array("linux", "macos", "windows"))) { + $errors[] = "Unsupported platform '$platform', only 'linux', 'macos' and 'windows' are allowed!"; + } + } + } + } + if (count($errors) > 0) { $this->errors[$dir] = $errors; }