mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-21 23:48:08 +00:00
added new variable "platforms"
This commit is contained in:
parent
98a2ba591d
commit
ec4381bf05
2 changed files with 24 additions and 11 deletions
|
@ -3,7 +3,8 @@
|
||||||
"identifier": "example-script",
|
"identifier": "example-script",
|
||||||
"script": "example-script.qml",
|
"script": "example-script.qml",
|
||||||
"authors": ["@pbek"],
|
"authors": ["@pbek"],
|
||||||
"version": "0.0.1",
|
"platforms": ["linux", "macos", "windows"],
|
||||||
"minAppVersion": "17.05.6",
|
"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 <i>example-script</i> folder from the git-repository on GitHub and rename both the folder and <i>example-script.qml</i>."
|
"description" : "Use this script to start a new script you want to submit to the script repository.\n\nJust copy the whole <i>example-script</i> folder from the git-repository on GitHub and rename both the folder and <i>example-script.qml</i>."
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,12 @@ $errors = $testHelper->errors;
|
||||||
if (count($errors) > 0) {
|
if (count($errors) > 0) {
|
||||||
foreach($errors as $dir => $scriptErrors) {
|
foreach($errors as $dir => $scriptErrors) {
|
||||||
print "Directory '$dir'\n";
|
print "Directory '$dir'\n";
|
||||||
|
|
||||||
foreach($scriptErrors as $error) {
|
foreach($scriptErrors as $error) {
|
||||||
print " $error\n";
|
print " $error\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ exit(0);
|
||||||
|
|
||||||
class TestHelper {
|
class TestHelper {
|
||||||
public $errors = array();
|
public $errors = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the files in a directory
|
* Tests the files in a directory
|
||||||
*/
|
*/
|
||||||
|
@ -34,33 +34,45 @@ class TestHelper {
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$jsonData = file_get_contents($dir . "/info.json");
|
$jsonData = file_get_contents($dir . "/info.json");
|
||||||
$data = json_decode($jsonData, true);
|
$data = json_decode($jsonData, true);
|
||||||
|
|
||||||
if ($data["name"] == "") {
|
if ($data["name"] == "") {
|
||||||
$errors[] = "No name was entered!";
|
$errors[] = "No name was entered!";
|
||||||
}
|
}
|
||||||
|
|
||||||
$identifier = $data["identifier"];
|
$identifier = $data["identifier"];
|
||||||
if ($identifier == "") {
|
if ($identifier == "") {
|
||||||
$errors[] = "No identifier was entered!";
|
$errors[] = "No identifier was entered!";
|
||||||
} elseif (preg_match('/[^a-z0-9\-_]/', $identifier)) {
|
} elseif (preg_match('/[^a-z0-9\-_]/', $identifier)) {
|
||||||
$errors[] = "Invalid charactes were found in identifier '$identifier'!";
|
$errors[] = "Invalid charactes were found in identifier '$identifier'!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data["description"] == "") {
|
if ($data["description"] == "") {
|
||||||
$errors[] = "No description was entered!";
|
$errors[] = "No description was entered!";
|
||||||
}
|
}
|
||||||
|
|
||||||
$script = $data["script"];
|
$script = $data["script"];
|
||||||
if ($script == "") {
|
if ($script == "") {
|
||||||
$errors[] = "No script was entered!";
|
$errors[] = "No script was entered!";
|
||||||
} elseif (!file_exists($dir . "/" . $script)) {
|
} elseif (!file_exists($dir . "/" . $script)) {
|
||||||
$errors[] = "Script '$script' doesn't exist!";
|
$errors[] = "Script '$script' doesn't exist!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data["version"] == "") {
|
if ($data["version"] == "") {
|
||||||
$errors[] = "No version was entered!";
|
$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) {
|
if (count($errors) > 0) {
|
||||||
$this->errors[$dir] = $errors;
|
$this->errors[$dir] = $errors;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue