read version from composer.json

This commit is contained in:
tracer 2023-09-17 12:36:14 +02:00
parent 3cfcb1e847
commit 0f9e66bf90
3 changed files with 20 additions and 7 deletions

View File

@ -40,6 +40,20 @@ $longOpts = [
$options = getopt(short_options: $shortOpts, long_options: $longOpts, rest_index: $restIndex);
if (array_key_exists(key: 'v', array: $options) || array_key_exists(key: 'version', array: $options)) {
$composerJson = json_decode(json: file_get_contents(filename: dirname(path: __DIR__) . '/composer.json'), associative: true);
$name = $composerJson['name'];
$decription = $composerJson['decription'];
$version = $composerJson['version'];
$build_number = $composerJson['build_number'];
$authorName = $composerJson['authors'][0]['name'];
$authorEmail = $composerJson['authors'][0]['email'];
echo "Name: $name\n";
echo "Description: $decription\n";
echo "Version: $version\n";
echo "Build Number: $build_number\n";
echo "Author: $authorName ($authorEmail)\n";
print("bindAPI version: $version" . PHP_EOL);
exit(0);
}

View File

@ -1,8 +1,8 @@
{
"name": "tracer/bindapi",
"name": "24unix/bindapi",
"decription": "fo",
"version": "2023.0.1",
"build_number": "320",
"build_number": "1",
"authors": [
{
"name": "Micha Espey",

View File

@ -267,16 +267,15 @@ class CLIController
function runCheckSetup(): void
{
if (!$this->domainController->checkPermissions(disableVerbose: false)) {
echo 'You need to setup the bindAPI first.' . PHP_EOL;
exit(1);
echo COLOR_RED . 'You need to setup the bindAPI first.' . COLOR_DEFAULT .PHP_EOL;
}
$self = $this->panelRepository->findSelf();
$c = count($self);
$panelCount = count($self);
if ($c != 1) {
if ($c == 0) {
if ($panelCount != 1) {
if ($panelCount == 0) {
echo 'No panel marked as this server.' . PHP_EOL;
echo 'Use ' . COLOR_YELLOW . 'panels:update <ID> self=1 ' . COLOR_DEFAULT . 'to mark this panel.' . PHP_EOL;
} else {