From 283ed2c4bf55c08124b9bae439b8f72540798e18 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Tue, 24 May 2022 15:29:36 +0200 Subject: [PATCH] Added updater backend https://github.com/codedge/laravel-selfupdater --- composer.json | 6 +- composer.lock | 410 +++++++++++++++++- config/self-update.php | 155 +++++++ .../mails/update-available.blade.php | 5 + .../vendor/self-update/self-update.blade.php | 0 5 files changed, 574 insertions(+), 2 deletions(-) create mode 100644 config/self-update.php create mode 100644 resources/views/vendor/self-update/mails/update-available.blade.php create mode 100644 resources/views/vendor/self-update/self-update.blade.php diff --git a/composer.json b/composer.json index 6b98332..419711d 100755 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "GPL-3.0-or-later", "require": { "php": "^7.3|^8.0", + "codedge/laravel-selfupdater": "^3.4", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "geo-sot/laravel-env-editor": "^1.1", @@ -55,7 +56,10 @@ "config": { "optimize-autoloader": true, "preferred-install": "dist", - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/composer.lock b/composer.lock index fd99cd7..1e2d56d 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "abd272ad948dfda0e9f2b936b59624dd", + "content-hash": "b58534a63ebf96d8d66b784eaf5ed8ab", "packages": [ { "name": "asm89/stack-cors", @@ -122,6 +122,91 @@ ], "time": "2021-08-15T20:50:18+00:00" }, + { + "name": "codedge/laravel-selfupdater", + "version": "3.4.1", + "source": { + "type": "git", + "url": "https://github.com/codedge/laravel-selfupdater.git", + "reference": "45f8ed72e8a2df57595340c5515ecbfed351df7e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codedge/laravel-selfupdater/zipball/45f8ed72e8a2df57595340c5515ecbfed351df7e", + "reference": "45f8ed72e8a2df57595340c5515ecbfed351df7e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-zip": "*", + "guzzlehttp/guzzle": "^7.4", + "laravel/framework": "^8.83.10", + "league/uri": "^6.5", + "php": "^7.4 || ^8.0 || ^8.1", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-phpunit": "^1.1" + }, + "require-dev": { + "dg/bypass-finals": "^1.3", + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.5", + "orchestra/testbench": "^6.24.1", + "phpunit/phpunit": "^9.5.20" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Updater": "Codedge\\Updater\\UpdaterFacade" + }, + "providers": [ + "Codedge\\Updater\\UpdaterServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Codedge\\Updater\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Holger Lösken", + "email": "holger.loesken@codedge.de", + "homepage": "https://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": "2022-05-01T16:00:55+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.4", @@ -1545,6 +1630,173 @@ ], "time": "2022-04-17T13:12:02+00:00" }, + { + "name": "league/uri", + "version": "6.5.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri.git", + "reference": "c68ca445abb04817d740ddd6d0b3551826ef0c5a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/c68ca445abb04817d740ddd6d0b3551826ef0c5a", + "reference": "c68ca445abb04817d740ddd6d0b3551826ef0c5a", + "shasum": "" + }, + "require": { + "ext-json": "*", + "league/uri-interfaces": "^2.3", + "php": "^7.3 || ^8.0", + "psr/http-message": "^1.0" + }, + "conflict": { + "league/uri-schemes": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19 || ^3.0", + "phpstan/phpstan": "^0.12.90", + "phpstan/phpstan-phpunit": "^0.12.22", + "phpstan/phpstan-strict-rules": "^0.12.11", + "phpunit/phpunit": "^8.0 || ^9.0", + "psr/http-factory": "^1.0" + }, + "suggest": { + "ext-fileinfo": "Needed to create Data URI from a filepath", + "ext-intl": "Needed to improve host validation", + "league/uri-components": "Needed to easily manipulate URI objects", + "psr/http-factory": "Needed to use the URI factory" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" + } + ], + "description": "URI manipulation library", + "homepage": "http://uri.thephpleague.com", + "keywords": [ + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "middleware", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "uri-template", + "url", + "ws" + ], + "support": { + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri/issues", + "source": "https://github.com/thephpleague/uri/tree/6.5.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2021-08-27T09:54:07+00:00" + }, + { + "name": "league/uri-interfaces", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri-interfaces.git", + "reference": "00e7e2943f76d8cb50c7dfdc2f6dee356e15e383" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/00e7e2943f76d8cb50c7dfdc2f6dee356e15e383", + "reference": "00e7e2943f76d8cb50c7dfdc2f6dee356e15e383", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19", + "phpstan/phpstan": "^0.12.90", + "phpstan/phpstan-phpunit": "^0.12.19", + "phpstan/phpstan-strict-rules": "^0.12.9", + "phpunit/phpunit": "^8.5.15 || ^9.5" + }, + "suggest": { + "ext-intl": "to use the IDNA feature", + "symfony/intl": "to use the IDNA feature via Symfony Polyfill" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" + } + ], + "description": "Common interface for URI representation", + "homepage": "http://github.com/thephpleague/uri-interfaces", + "keywords": [ + "rfc3986", + "rfc3987", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/thephpleague/uri-interfaces/issues", + "source": "https://github.com/thephpleague/uri-interfaces/tree/2.3.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2021-06-28T04:27:21+00:00" + }, { "name": "monolog/monolog", "version": "2.6.0", @@ -1938,6 +2190,162 @@ ], "time": "2021-12-04T23:24:31+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "phing/phing": "^2.16.3", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.1.0" + }, + "time": "2020-12-13T13:06:13+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.7.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "e3baed2ee2ef322e0f9b8fe8f87fdbe024c7c719" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e3baed2ee2ef322e0f9b8fe8f87fdbe024c7c719", + "reference": "e3baed2ee2ef322e0f9b8fe8f87fdbe024c7c719", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.7.1" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-05-24T09:05:09+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4a3c437c09075736285d1cabb5c75bf27ed0bc84", + "reference": "4a3c437c09075736285d1cabb5c75bf27ed0bc84", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.5.0" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.1.1" + }, + "time": "2022-04-20T15:24:25+00:00" + }, { "name": "psr/container", "version": "1.1.1", diff --git a/config/self-update.php b/config/self-update.php new file mode 100644 index 0000000..f3e15fe --- /dev/null +++ b/config/self-update.php @@ -0,0 +1,155 @@ + env('SELF_UPDATER_SOURCE', 'github'), + + /* + |-------------------------------------------------------------------------- + | Version installed + |-------------------------------------------------------------------------- + | + | Set this to the version of your software installed on your system. + | + */ + + 'version_installed' => env('SELF_UPDATER_VERSION_INSTALLED', ''), + + /* + |-------------------------------------------------------------------------- + | Repository types + |-------------------------------------------------------------------------- + | + | A repository can be of different types, which can be specified here. + | Current options: + | - github + | - gitlab + | - http + | + */ + + 'repository_types' => [ + 'github' => [ + 'type' => 'github', + 'repository_vendor' => env('SELF_UPDATER_REPO_VENDOR', ''), + 'repository_name' => env('SELF_UPDATER_REPO_NAME', ''), + 'repository_url' => '', + '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', ''), + ], + 'gitlab' => [ + 'type' => 'gitlab', + 'repository_id' => env('SELF_UPDATER_REPO_URL', ''), + 'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'), + 'private_access_token' => env('SELF_UPDATER_GITLAB_PRIVATE_ACCESS_TOKEN', ''), + ], + 'http' => [ + 'type' => 'http', + 'repository_url' => env('SELF_UPDATER_REPO_URL', ''), + 'pkg_filename_format' => env('SELF_UPDATER_PKG_FILENAME_FORMAT', 'v_VERSION_'), + 'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'), + 'private_access_token' => env('SELF_UPDATER_HTTP_PRIVATE_ACCESS_TOKEN', ''), + ], + ], + + /* + |-------------------------------------------------------------------------- + | Exclude folders from update + |-------------------------------------------------------------------------- + | + | Specific folders which should not be updated and will be skipped during the + | update process. + | + | Here's already a list of good examples to skip. You may want to keep those. + | + */ + + 'exclude_folders' => [ + '__MACOSX', + 'node_modules', + 'bootstrap/cache', + 'bower', + 'storage/app', + 'storage/framework', + 'storage/logs', + 'storage/self-update', + 'vendor', + ], + + /* + |-------------------------------------------------------------------------- + | Event Logging + |-------------------------------------------------------------------------- + | + | Configure if fired events should be logged + | + */ + + 'log_events' => env('SELF_UPDATER_LOG_EVENTS', false), + + /* + |-------------------------------------------------------------------------- + | Notifications + |-------------------------------------------------------------------------- + | + | Specify for which events you want to get notifications. Out of the box you can use 'mail'. + | + */ + + 'notifications' => [ + 'notifications' => [ + \Codedge\Updater\Notifications\Notifications\UpdateSucceeded::class => ['mail'], + \Codedge\Updater\Notifications\Notifications\UpdateFailed::class => ['mail'], + \Codedge\Updater\Notifications\Notifications\UpdateAvailable::class => ['mail'], + ], + + /* + * Here you can specify the notifiable to which the notifications should be sent. The default + * notifiable will use the variables specified in this config file. + */ + 'notifiable' => \Codedge\Updater\Notifications\Notifiable::class, + + 'mail' => [ + 'to' => [ + 'address' => env('SELF_UPDATER_MAILTO_ADDRESS', 'notifications@example.com'), + 'name' => env('SELF_UPDATER_MAILTO_NAME', ''), + ], + + 'from' => [ + 'address' => env('SELF_UPDATER_MAIL_FROM_ADDRESS', 'updater@example.com'), + 'name' => env('SELF_UPDATER_MAIL_FROM_NAME', 'Update'), + ], + ], + ], + + /* + |--------------------------------------------------------------------------- + | Register custom artisan commands + |--------------------------------------------------------------------------- + */ + + 'artisan_commands' => [ + 'pre_update' => [ + //'command:signature' => [ + // 'class' => Command class + // 'params' => [] + //] + ], + 'post_update' => [ + + ], + ], + +]; diff --git a/resources/views/vendor/self-update/mails/update-available.blade.php b/resources/views/vendor/self-update/mails/update-available.blade.php new file mode 100644 index 0000000..ffa14dc --- /dev/null +++ b/resources/views/vendor/self-update/mails/update-available.blade.php @@ -0,0 +1,5 @@ +Hello! + +The new version {{ $newVersion }} is available. + +Kind regards diff --git a/resources/views/vendor/self-update/self-update.blade.php b/resources/views/vendor/self-update/self-update.blade.php new file mode 100644 index 0000000..e69de29