From 443d646af6d45e8d0bfa3fa8c984b95cf790292d Mon Sep 17 00:00:00 2001 From: Will Browning Date: Mon, 1 Aug 2022 09:16:36 +0100 Subject: [PATCH] Fallback to ANONADDY_VERSION env var if empty --- app/Helpers/GitVersionHelper.php | 4 ++ .../Controllers/Api/AppVersionController.php | 11 ++--- composer.lock | 42 ++++++++++--------- package-lock.json | 12 +++--- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/app/Helpers/GitVersionHelper.php b/app/Helpers/GitVersionHelper.php index 178b3a7..ff8462b 100644 --- a/app/Helpers/GitVersionHelper.php +++ b/app/Helpers/GitVersionHelper.php @@ -60,6 +60,10 @@ class GitVersionHelper chdir($dir); } + if (! $output) { + return str(getenv('ANONADDY_VERSION', true)); + } + return Str::of($output)->after('v')->trim(); } } diff --git a/app/Http/Controllers/Api/AppVersionController.php b/app/Http/Controllers/Api/AppVersionController.php index bbda1f2..108871d 100644 --- a/app/Http/Controllers/Api/AppVersionController.php +++ b/app/Http/Controllers/Api/AppVersionController.php @@ -9,13 +9,14 @@ class AppVersionController extends Controller { public function index() { - $parts = str(Version::version())->explode('.'); + $ver = Version::version(); + $parts = $ver->explode('.'); return response()->json([ - 'version' => Version::version(), - 'major' => (int) isset($parts[0]) ? $parts[0] : null, - 'minor' => (int) isset($parts[1]) ? $parts[1] : null, - 'patch' => (int) isset($parts[2]) ? $parts[2] : null, + 'version' => $ver, + 'major' => isset($parts[0]) && $parts[0] !== '' ? (int) $parts[0] : 0, + 'minor' => isset($parts[1]) ? (int) $parts[1] : 0, + 'patch' => isset($parts[2]) ? (int) $parts[2] : 0, ]); } } diff --git a/composer.lock b/composer.lock index f77ab26..927b7bc 100644 --- a/composer.lock +++ b/composer.lock @@ -1230,24 +1230,24 @@ }, { "name": "graham-campbell/result-type", - "version": "v1.0.4", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "0690bde05318336c7221785f2a932467f98b64ca" + "reference": "a878d45c1914464426dc94da61c9e1d36ae262a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/0690bde05318336c7221785f2a932467f98b64ca", - "reference": "0690bde05318336c7221785f2a932467f98b64ca", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/a878d45c1914464426dc94da61c9e1d36ae262a8", + "reference": "a878d45c1914464426dc94da61c9e1d36ae262a8", "shasum": "" }, "require": { - "php": "^7.0 || ^8.0", - "phpoption/phpoption": "^1.8" + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9" }, "require-dev": { - "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + "phpunit/phpunit": "^8.5.28 || ^9.5.21" }, "type": "library", "autoload": { @@ -1276,7 +1276,7 @@ ], "support": { "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.4" + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.0" }, "funding": [ { @@ -1288,7 +1288,7 @@ "type": "tidelift" } ], - "time": "2021-11-21T21:41:47+00:00" + "time": "2022-07-30T15:56:11+00:00" }, { "name": "guzzlehttp/guzzle", @@ -3612,29 +3612,33 @@ }, { "name": "phpoption/phpoption", - "version": "1.8.1", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15" + "reference": "dc5ff11e274a90cc1c743f66c9ad700ce50db9ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", - "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/dc5ff11e274a90cc1c743f66c9ad700ce50db9ab", + "reference": "dc5ff11e274a90cc1c743f66c9ad700ce50db9ab", "shasum": "" }, "require": { - "php": "^7.0 || ^8.0" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + "bamarni/composer-bin-plugin": "^1.8", + "phpunit/phpunit": "^8.5.28 || ^9.5.21" }, "type": "library", "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": true + }, "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } }, "autoload": { @@ -3667,7 +3671,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.8.1" + "source": "https://github.com/schmittjoh/php-option/tree/1.9.0" }, "funding": [ { @@ -3679,7 +3683,7 @@ "type": "tidelift" } ], - "time": "2021-12-04T23:24:31+00:00" + "time": "2022-07-30T15:51:26+00:00" }, { "name": "pragmarx/google2fa", diff --git a/package-lock.json b/package-lock.json index 35e7b92..fef9c28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1967,9 +1967,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "node_modules/@types/node": { - "version": "18.6.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.2.tgz", - "integrity": "sha512-KcfkBq9H4PI6Vpu5B/KoPeuVDAbmi+2mDBqGPGUgoL7yXQtcWGu2vJWmmRkneWK3Rh0nIAX192Aa87AqKHYChQ==" + "version": "18.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.3.tgz", + "integrity": "sha512-6qKpDtoaYLM+5+AFChLhHermMQxc3TOEFIDzrZLPRGHPrLEwqFkkT5Kx3ju05g6X7uDPazz3jHbKPX0KzCjntg==" }, "node_modules/@types/parse-json": { "version": "4.0.0", @@ -10707,9 +10707,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "@types/node": { - "version": "18.6.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.2.tgz", - "integrity": "sha512-KcfkBq9H4PI6Vpu5B/KoPeuVDAbmi+2mDBqGPGUgoL7yXQtcWGu2vJWmmRkneWK3Rh0nIAX192Aa87AqKHYChQ==" + "version": "18.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.3.tgz", + "integrity": "sha512-6qKpDtoaYLM+5+AFChLhHermMQxc3TOEFIDzrZLPRGHPrLEwqFkkT5Kx3ju05g6X7uDPazz3jHbKPX0KzCjntg==" }, "@types/parse-json": { "version": "4.0.0",