Refactor for self updater

This commit is contained in:
David Bomba 2022-03-19 14:10:00 +11:00
parent 51371674fc
commit 8e6772ef75
3 changed files with 50 additions and 30 deletions

View File

@ -54,7 +54,7 @@ class PostUpdate extends Command
$output = [];
exec('vendor/bin/composer install --no-dev -o', $output);
// exec('vendor/bin/composer install --no-dev -o', $output);
info(print_r($output,1));
info("finished running composer install ");

View File

@ -53,8 +53,43 @@ class SelfUpdateController extends BaseController
* ),
* )
*/
public function update(\Codedge\Updater\UpdaterManager $updater)
// public function old_update(\Codedge\Updater\UpdaterManager $updater)
// {
// set_time_limit(0);
// define('STDIN', fopen('php://stdin', 'r'));
// if (Ninja::isHosted()) {
// return response()->json(['message' => ctrans('texts.self_update_not_available')], 403);
// }
// $this->testWritable();
// // Get the new version available
// $versionAvailable = $updater->source()->getVersionAvailable();
// // Create a release
// $release = $updater->source()->fetch($versionAvailable);
// $updater->source()->update($release);
// $cacheCompiled = base_path('bootstrap/cache/compiled.php');
// if (file_exists($cacheCompiled)) { unlink ($cacheCompiled); }
// $cacheServices = base_path('bootstrap/cache/services.php');
// if (file_exists($cacheServices)) { unlink ($cacheServices); }
// Artisan::call('clear-compiled');
// Artisan::call('route:clear');
// Artisan::call('view:clear');
// Artisan::call('optimize');
// return response()->json(['message' => 'Update completed'], 200);
// }
public function update()
{
set_time_limit(0);
define('STDIN', fopen('php://stdin', 'r'));
@ -64,32 +99,6 @@ class SelfUpdateController extends BaseController
$this->testWritable();
// Get the new version available
$versionAvailable = $updater->source()->getVersionAvailable();
// Create a release
$release = $updater->source()->fetch($versionAvailable);
$updater->source()->update($release);
$cacheCompiled = base_path('bootstrap/cache/compiled.php');
if (file_exists($cacheCompiled)) { unlink ($cacheCompiled); }
$cacheServices = base_path('bootstrap/cache/services.php');
if (file_exists($cacheServices)) { unlink ($cacheServices); }
Artisan::call('clear-compiled');
Artisan::call('route:clear');
Artisan::call('view:clear');
Artisan::call('optimize');
return response()->json(['message' => 'Update completed'], 200);
}
public function new_update()
{
$contents = file_get_contents($this->getDownloadUrl());
Storage::disk('local')->put('invoiceninja.zip', $contents);
@ -106,6 +115,19 @@ class SelfUpdateController extends BaseController
unlink($file);
$cacheCompiled = base_path('bootstrap/cache/compiled.php');
if (file_exists($cacheCompiled)) { unlink ($cacheCompiled); }
$cacheServices = base_path('bootstrap/cache/services.php');
if (file_exists($cacheServices)) { unlink ($cacheServices); }
Artisan::call('clear-compiled');
Artisan::call('route:clear');
Artisan::call('view:clear');
Artisan::call('migrate', ['--force' => true]);
Artisan::call('optimize');
return response()->json(['message' => 'Update completed'], 200);
}

View File

@ -40,8 +40,6 @@
"checkout/checkout-sdk-php": "^1.0",
"cleverit/ubl_invoice": "^1.3",
"coconutcraig/laravel-postmark": "^2.10",
"codedge/laravel-selfupdater": "^3.2",
"composer/composer": "^2",
"doctrine/dbal": "^3.0",
"eway/eway-rapid-php": "^1.3",
"fakerphp/faker": "^1.14",