mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:29:03 -05:00 
			
		
		
		
	Refactor self updater
This commit is contained in:
		
							parent
							
								
									c77faa746d
								
							
						
					
					
						commit
						b6d26fa7c9
					
				@ -56,27 +56,37 @@ class SelfUpdateController extends BaseController
 | 
			
		||||
     */
 | 
			
		||||
    public function update(\Codedge\Updater\UpdaterManager $updater)
 | 
			
		||||
    {
 | 
			
		||||
        set_time_limit(0);
 | 
			
		||||
        define('STDIN', fopen('php://stdin', 'r'));
 | 
			
		||||
 | 
			
		||||
        if (Ninja::isNinja()) {
 | 
			
		||||
            return response()->json(['message' => ctrans('texts.self_update_not_available')], 403);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // /* .git MUST be owned/writable by the webserver user */
 | 
			
		||||
        // $repo = new GitRepository(base_path());
 | 
			
		||||
 | 
			
		||||
        // nlog('Are there changes to pull? '.$repo->hasChanges());
 | 
			
		||||
        // $output = '';
 | 
			
		||||
        // $it = new \RecursiveDirectoryIterator("/home/david/Development/invoiceninja");
 | 
			
		||||
 | 
			
		||||
        // $x=1;
 | 
			
		||||
        // // Loop through files
 | 
			
		||||
        // foreach(new \RecursiveIteratorIterator($it) as $file) {
 | 
			
		||||
 | 
			
		||||
        // $updater = new \Codedge\Updater\UpdaterManager();
 | 
			
		||||
        // var_dum
 | 
			
		||||
        //    if(is_file($file) && is_writable($file))
 | 
			
		||||
        //     nlog('writable ' .$x);
 | 
			
		||||
        //   elseif(is_file($file))
 | 
			
		||||
        //     nlog("{$file} is not writable {$x}");
 | 
			
		||||
        //   //exit;
 | 
			
		||||
          
 | 
			
		||||
        //   $x++;
 | 
			
		||||
        //   // if ($file->isWritable() === false) {
 | 
			
		||||
        //   //       $checkPermission = false;
 | 
			
		||||
        //   //   }
 | 
			
		||||
          
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        // Check if new version is available
 | 
			
		||||
        if($updater->source()->isNewVersionAvailable()) {
 | 
			
		||||
 | 
			
		||||
            // Get the current installed version
 | 
			
		||||
            echo $updater->source()->getVersionInstalled();
 | 
			
		||||
 | 
			
		||||
            // Get the new version available
 | 
			
		||||
            $versionAvailable = $updater->source()->getVersionAvailable();
 | 
			
		||||
 | 
			
		||||
@ -85,38 +95,23 @@ class SelfUpdateController extends BaseController
 | 
			
		||||
 | 
			
		||||
            // Run the update process
 | 
			
		||||
            $updater->source()->update($release);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
            
 | 
			
		||||
        // try {
 | 
			
		||||
        $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); }
 | 
			
		||||
 | 
			
		||||
        //     $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('cache:clear');
 | 
			
		||||
        Artisan::call('debugbar:clear');
 | 
			
		||||
        Artisan::call('route:clear');
 | 
			
		||||
        Artisan::call('view:clear');
 | 
			
		||||
        Artisan::call('config:clear');
 | 
			
		||||
 | 
			
		||||
        //     Artisan::call('clear-compiled');
 | 
			
		||||
        //     Artisan::call('cache:clear');
 | 
			
		||||
        //     Artisan::call('debugbar:clear');
 | 
			
		||||
        //     Artisan::call('route:clear');
 | 
			
		||||
        //     Artisan::call('view:clear');
 | 
			
		||||
        //     Artisan::call('config:clear');
 | 
			
		||||
        return response()->json(['message' => 'Update completed'], 200);
 | 
			
		||||
 | 
			
		||||
        //     // $output = $repo->execute('stash');
 | 
			
		||||
        //     // $output = $repo->execute('reset --hard origin/v5-stable');
 | 
			
		||||
        //     $output = $repo->execute('pull origin');
 | 
			
		||||
 | 
			
		||||
        // } catch (GitException $e) {
 | 
			
		||||
            
 | 
			
		||||
        //     nlog($output);
 | 
			
		||||
        //     nlog($e->getMessage());
 | 
			
		||||
        //     return response()->json(['message'=>$e->getMessage()], 500);
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        // dispatch(function () {
 | 
			
		||||
        //     Artisan::call('ninja:post-update');
 | 
			
		||||
        // });
 | 
			
		||||
 | 
			
		||||
        return response()->json(['message' => $output], 200);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function checkVersion()
 | 
			
		||||
 | 
			
		||||
@ -36,12 +36,12 @@
 | 
			
		||||
        "checkout/checkout-sdk-php": "^1.0",
 | 
			
		||||
        "cleverit/ubl_invoice": "^1.3",
 | 
			
		||||
        "coconutcraig/laravel-postmark": "^2.10",
 | 
			
		||||
        "codedge/laravel-selfupdater": "^3.2",
 | 
			
		||||
        "composer/composer": "^2",
 | 
			
		||||
        "czproject/git-php": "^3.17",
 | 
			
		||||
        "turbo124/laravel-gmail": "^5",
 | 
			
		||||
        "doctrine/dbal": "^2.10",
 | 
			
		||||
        "fakerphp/faker": "^1.14",
 | 
			
		||||
        "fideloper/proxy": "^4.2",
 | 
			
		||||
        "fakerphp/faker": "^1.14",
 | 
			
		||||
        "google/apiclient": "^2.7",
 | 
			
		||||
        "guzzlehttp/guzzle": "^7.0.1",
 | 
			
		||||
        "hashids/hashids": "^4.0",
 | 
			
		||||
@ -67,7 +67,6 @@
 | 
			
		||||
        "stripe/stripe-php": "^7.50",
 | 
			
		||||
        "symfony/http-client": "^5.2",
 | 
			
		||||
        "turbo124/beacon": "^1.0",
 | 
			
		||||
        "turbo124/laravel-gmail": "^5",
 | 
			
		||||
        "webpatser/laravel-countries": "dev-master#75992ad",
 | 
			
		||||
        "wildbit/swiftmailer-postmark": "^3.3"
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										130
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										130
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							@ -4,7 +4,7 @@
 | 
			
		||||
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
 | 
			
		||||
        "This file is @generated automatically"
 | 
			
		||||
    ],
 | 
			
		||||
    "content-hash": "c7966839cf1cb74e25348aff4acadb1c",
 | 
			
		||||
    "content-hash": "64a35682f0e808b80b4784d812271f0b",
 | 
			
		||||
    "packages": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "authorizenet/authorizenet",
 | 
			
		||||
@ -51,16 +51,16 @@
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "aws/aws-sdk-php",
 | 
			
		||||
            "version": "3.178.0",
 | 
			
		||||
            "version": "3.176.9",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/aws/aws-sdk-php.git",
 | 
			
		||||
                "reference": "214e3d98c54277cd8965f1cf307dce39631407bf"
 | 
			
		||||
                "reference": "17dc67514b148979994758fbfb54088a8a3393bf"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/214e3d98c54277cd8965f1cf307dce39631407bf",
 | 
			
		||||
                "reference": "214e3d98c54277cd8965f1cf307dce39631407bf",
 | 
			
		||||
                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/17dc67514b148979994758fbfb54088a8a3393bf",
 | 
			
		||||
                "reference": "17dc67514b148979994758fbfb54088a8a3393bf",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
@ -135,9 +135,9 @@
 | 
			
		||||
            "support": {
 | 
			
		||||
                "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
 | 
			
		||||
                "issues": "https://github.com/aws/aws-sdk-php/issues",
 | 
			
		||||
                "source": "https://github.com/aws/aws-sdk-php/tree/3.178.0"
 | 
			
		||||
                "source": "https://github.com/aws/aws-sdk-php/tree/3.176.9"
 | 
			
		||||
            },
 | 
			
		||||
            "time": "2021-04-08T18:13:16+00:00"
 | 
			
		||||
            "time": "2021-04-06T18:13:47+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "bacon/bacon-qr-code",
 | 
			
		||||
@ -563,88 +563,6 @@
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2021-02-24T13:45:30+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "codedge/laravel-selfupdater",
 | 
			
		||||
            "version": "3.2.2",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/codedge/laravel-selfupdater.git",
 | 
			
		||||
                "reference": "ade06363a1a8175adcf070f392f1fd25eef5c214"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/codedge/laravel-selfupdater/zipball/ade06363a1a8175adcf070f392f1fd25eef5c214",
 | 
			
		||||
                "reference": "ade06363a1a8175adcf070f392f1fd25eef5c214",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
                "ext-json": "*",
 | 
			
		||||
                "ext-zip": "*",
 | 
			
		||||
                "guzzlehttp/guzzle": "6.* || 7.*",
 | 
			
		||||
                "laravel/framework": "^8.33.1",
 | 
			
		||||
                "php": "^7.3 || ^7.4 || ^8.0"
 | 
			
		||||
            },
 | 
			
		||||
            "require-dev": {
 | 
			
		||||
                "dg/bypass-finals": "^1.3",
 | 
			
		||||
                "mikey179/vfsstream": "^1.6",
 | 
			
		||||
                "mockery/mockery": "^1.4",
 | 
			
		||||
                "orchestra/testbench": "^6.14.0",
 | 
			
		||||
                "phpunit/phpunit": "^9.5.3"
 | 
			
		||||
            },
 | 
			
		||||
            "type": "library",
 | 
			
		||||
            "extra": {
 | 
			
		||||
                "laravel": {
 | 
			
		||||
                    "aliases": {
 | 
			
		||||
                        "Updater": "Codedge\\Updater\\UpdaterFacade"
 | 
			
		||||
                    },
 | 
			
		||||
                    "providers": [
 | 
			
		||||
                        "Codedge\\Updater\\UpdaterServiceProvider"
 | 
			
		||||
                    ]
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            "autoload": {
 | 
			
		||||
                "psr-4": {
 | 
			
		||||
                    "Codedge\\Updater\\": "src/"
 | 
			
		||||
                },
 | 
			
		||||
                "files": [
 | 
			
		||||
                    "src/helpers.php"
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "notification-url": "https://packagist.org/downloads/",
 | 
			
		||||
            "license": [
 | 
			
		||||
                "MIT"
 | 
			
		||||
            ],
 | 
			
		||||
            "authors": [
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "Holger Lösken",
 | 
			
		||||
                    "email": "holger.loesken@codedge.de",
 | 
			
		||||
                    "homepage": "http://codedge.de",
 | 
			
		||||
                    "role": "Developer"
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "description": "Providing an auto-updating functionality for your self-hosted Laravel application.",
 | 
			
		||||
            "keywords": [
 | 
			
		||||
                "auto update",
 | 
			
		||||
                "auto-update",
 | 
			
		||||
                "laravel",
 | 
			
		||||
                "laravel application",
 | 
			
		||||
                "self update",
 | 
			
		||||
                "self-hosted laravel application",
 | 
			
		||||
                "self-update",
 | 
			
		||||
                "update"
 | 
			
		||||
            ],
 | 
			
		||||
            "support": {
 | 
			
		||||
                "issues": "https://github.com/codedge/laravel-selfupdater/issues",
 | 
			
		||||
                "source": "https://github.com/codedge/laravel-selfupdater"
 | 
			
		||||
            },
 | 
			
		||||
            "funding": [
 | 
			
		||||
                {
 | 
			
		||||
                    "url": "https://github.com/codedge",
 | 
			
		||||
                    "type": "github"
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2021-03-20T09:31:26+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "composer/ca-bundle",
 | 
			
		||||
            "version": "1.2.9",
 | 
			
		||||
@ -2841,16 +2759,16 @@
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "laravel/framework",
 | 
			
		||||
            "version": "v8.36.2",
 | 
			
		||||
            "version": "v8.36.1",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/laravel/framework.git",
 | 
			
		||||
                "reference": "0debd8ad6b5aa1f61ccc73910adf049af4ca0444"
 | 
			
		||||
                "reference": "91c454715b81b9a39f718651d4e2f8104d45e7c2"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/laravel/framework/zipball/0debd8ad6b5aa1f61ccc73910adf049af4ca0444",
 | 
			
		||||
                "reference": "0debd8ad6b5aa1f61ccc73910adf049af4ca0444",
 | 
			
		||||
                "url": "https://api.github.com/repos/laravel/framework/zipball/91c454715b81b9a39f718651d4e2f8104d45e7c2",
 | 
			
		||||
                "reference": "91c454715b81b9a39f718651d4e2f8104d45e7c2",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
@ -3005,7 +2923,7 @@
 | 
			
		||||
                "issues": "https://github.com/laravel/framework/issues",
 | 
			
		||||
                "source": "https://github.com/laravel/framework"
 | 
			
		||||
            },
 | 
			
		||||
            "time": "2021-04-07T12:37:22+00:00"
 | 
			
		||||
            "time": "2021-04-06T21:14:06+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "laravel/slack-notification-channel",
 | 
			
		||||
@ -10910,16 +10828,16 @@
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "facade/flare-client-php",
 | 
			
		||||
            "version": "1.6.1",
 | 
			
		||||
            "version": "1.5.0",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/facade/flare-client-php.git",
 | 
			
		||||
                "reference": "f2b0969f2d9594704be74dbeb25b201570a98098"
 | 
			
		||||
                "reference": "9dd6f2b56486d939c4467b3f35475d44af57cf17"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/facade/flare-client-php/zipball/f2b0969f2d9594704be74dbeb25b201570a98098",
 | 
			
		||||
                "reference": "f2b0969f2d9594704be74dbeb25b201570a98098",
 | 
			
		||||
                "url": "https://api.github.com/repos/facade/flare-client-php/zipball/9dd6f2b56486d939c4467b3f35475d44af57cf17",
 | 
			
		||||
                "reference": "9dd6f2b56486d939c4467b3f35475d44af57cf17",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
@ -10963,7 +10881,7 @@
 | 
			
		||||
            ],
 | 
			
		||||
            "support": {
 | 
			
		||||
                "issues": "https://github.com/facade/flare-client-php/issues",
 | 
			
		||||
                "source": "https://github.com/facade/flare-client-php/tree/1.6.1"
 | 
			
		||||
                "source": "https://github.com/facade/flare-client-php/tree/1.5.0"
 | 
			
		||||
            },
 | 
			
		||||
            "funding": [
 | 
			
		||||
                {
 | 
			
		||||
@ -10971,26 +10889,26 @@
 | 
			
		||||
                    "type": "github"
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "time": "2021-04-08T08:50:01+00:00"
 | 
			
		||||
            "time": "2021-03-31T07:32:54+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "facade/ignition",
 | 
			
		||||
            "version": "2.8.2",
 | 
			
		||||
            "version": "2.7.0",
 | 
			
		||||
            "source": {
 | 
			
		||||
                "type": "git",
 | 
			
		||||
                "url": "https://github.com/facade/ignition.git",
 | 
			
		||||
                "reference": "cb7f790e6306caeb4a9ffe21e59942b7128cc630"
 | 
			
		||||
                "reference": "bdc8b0b32c888f6edc838ca641358322b3d9506d"
 | 
			
		||||
            },
 | 
			
		||||
            "dist": {
 | 
			
		||||
                "type": "zip",
 | 
			
		||||
                "url": "https://api.github.com/repos/facade/ignition/zipball/cb7f790e6306caeb4a9ffe21e59942b7128cc630",
 | 
			
		||||
                "reference": "cb7f790e6306caeb4a9ffe21e59942b7128cc630",
 | 
			
		||||
                "url": "https://api.github.com/repos/facade/ignition/zipball/bdc8b0b32c888f6edc838ca641358322b3d9506d",
 | 
			
		||||
                "reference": "bdc8b0b32c888f6edc838ca641358322b3d9506d",
 | 
			
		||||
                "shasum": ""
 | 
			
		||||
            },
 | 
			
		||||
            "require": {
 | 
			
		||||
                "ext-json": "*",
 | 
			
		||||
                "ext-mbstring": "*",
 | 
			
		||||
                "facade/flare-client-php": "^1.6",
 | 
			
		||||
                "facade/flare-client-php": "^1.3.7",
 | 
			
		||||
                "facade/ignition-contracts": "^1.0.2",
 | 
			
		||||
                "filp/whoops": "^2.4",
 | 
			
		||||
                "illuminate/support": "^7.0|^8.0",
 | 
			
		||||
@ -11048,7 +10966,7 @@
 | 
			
		||||
                "issues": "https://github.com/facade/ignition/issues",
 | 
			
		||||
                "source": "https://github.com/facade/ignition"
 | 
			
		||||
            },
 | 
			
		||||
            "time": "2021-04-08T10:42:53+00:00"
 | 
			
		||||
            "time": "2021-03-30T15:55:38+00:00"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "name": "facade/ignition-contracts",
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ return [
 | 
			
		||||
    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
			
		||||
    'app_domain' => env('APP_DOMAIN', ''),
 | 
			
		||||
    'app_version' => '5.1.42',
 | 
			
		||||
    'app_tag' => 'v5.1.42',
 | 
			
		||||
    'app_tag' => '5.1.40-release',
 | 
			
		||||
    'minimum_client_version' => '5.0.16',
 | 
			
		||||
    'terms_version' => '1.0.1',
 | 
			
		||||
    'api_secret' => env('API_SECRET', false),
 | 
			
		||||
 | 
			
		||||
@ -44,7 +44,7 @@ return [
 | 
			
		||||
            'repository_url' => 'https://github.com/',
 | 
			
		||||
            'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'),
 | 
			
		||||
            'private_access_token' => env('SELF_UPDATER_GITHUB_PRIVATE_ACCESS_TOKEN', ''),
 | 
			
		||||
            'use_branch' => env('SELF_UPDATER_USE_BRANCH', 'v5-stable'),
 | 
			
		||||
            'use_branch' => env('SELF_UPDATER_USE_BRANCH', ''),
 | 
			
		||||
        ],
 | 
			
		||||
        'http' => [
 | 
			
		||||
            'type' => 'http',
 | 
			
		||||
@ -89,7 +89,7 @@ return [
 | 
			
		||||
    |
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    'log_events' => env('SELF_UPDATER_LOG_EVENTS', false),
 | 
			
		||||
    'log_events' => env('SELF_UPDATER_LOG_EVENTS', true),
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
    |--------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
@ -5,10 +5,8 @@ use Illuminate\Support\Facades\Route;
 | 
			
		||||
//Auth::routes(['password.reset' => false]);
 | 
			
		||||
 | 
			
		||||
Route::get('/', 'BaseController@flutterRoute')->middleware('guest');
 | 
			
		||||
 | 
			
		||||
    Route::get('self-update', 'SelfUpdateController@update')->middleware('guest');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Route::get('setup', 'SetupController@index')->middleware('guest');
 | 
			
		||||
Route::post('setup', 'SetupController@doSetup')->middleware('guest');
 | 
			
		||||
Route::get('update', 'SetupController@update')->middleware('guest');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user