From 036ceaf4b37ac8d3dbda24184297c92b3d8ceb86 Mon Sep 17 00:00:00 2001 From: RoelReijn <34895541+RoelReijn@users.noreply.github.com> Date: Mon, 28 Dec 2020 14:21:07 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20improve=20the=20updater=20and=20ins?= =?UTF-8?q?taller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commands have been changed to be more future-proof. In addition, the updater now offers the possibility to update different levels. This means that you do not have to overwrite all files when updating. Also the README has been adapted to the new functions. --- README.md | 33 ++++++++++++- src/Commands/FortifyUITablerCommand.php | 4 +- src/Commands/FortifyUITablerUpdateCommand.php | 46 +++++++++++-------- src/FortifyUITablerServiceProvider.php | 32 ++++++++++++- 4 files changed, 91 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c595a0d..78db86e 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ Laravel 8 has a new and very efficient application scaffolding package called [J This package is a preset for FortifyUI, it brings ready-to-use and beautiful templates for the most important pages which include: login, registration, password reset pages and two factor authentication. In the latest release, avatars and device management are introduced. The templates are based and build on the [Tabler.io](https://tabler.io) framework which is build with Bootstrap 5.0. -This preset includes Tabler assets for [release 1.0.0-alpha.17](https://github.com/tabler/tabler/releases/tag/v1.0.0-alpha.17). +This preset includes Tabler assets for [release 1.0.0-alpha.21](https://github.com/tabler/tabler/releases/tag/v1.0.0-alpha.21). - [Installation](#installation) +- [Update Instructions](#update) - [Two Factor Authentication](#2fa) - [Mail Verification](#mail-verification) - [Password Confirmation](#password-confirmation) @@ -30,11 +31,39 @@ composer require proxeuse/fortify-tabler Once installed, please run the installer using the following PHP artisan command. The installer will take you through the installation process and ask you some questions. ```bash -php artisan fortify-ui:tabler +php artisan tabler:install ``` Please do not forget to run the `php artisan migrate` command after the successfull installation! + + +## Update Instructions + +You are able to perform certain updates using the built in updater. This updater will try to override certain files which are included in a new release. Please note that changes applied to those files will be discarded and you should make sure your changes are safe. + +Firstly, make sure that you update all files from the repository. This can be done by running the following command or by copying the contents of the repository to your `/vendor/proxeuse/fortify-tabler/` folder. + +```bash +composer update +``` + +Once succeeded, you should run the built in update command. You're able to choose between a couple of different updates. + +```bash +php artisan fortify:update +``` + +The command above will update all files, it functions the same as the `--type=full` command. All of other the options are listed below: + +| Command | Action | +|-------------------------------------------------|--------------------------------------------------------------------------------------| +| `php artisan tabler:update --type=full` | This will override all files originally installed by the installer. | +| `php artisan tabler:update --type=views` | This will override all views which are used by the installer. | +| `php artisan tabler:update --type=language` | This will replace the language files with updated ones. | +| `php artisan tabler:update --type=controllers` | This will update the controllers which are used by the package. | +| `php artisan tabler:update --type=public` | This will update all public resources, including for example `.css` and `.js` files. | + ### Set session driver to database This package features a function for users to force-logout devices from their account. In order for this function to work you'll need to have set the session driver to database. This can be done by chaning the `SESSION_DRIVER` variable in the `.env` file to `database`. A part of the file will look like the one below. In this example the session lifetime is set to 5 days instead of the default 2 hours. diff --git a/src/Commands/FortifyUITablerCommand.php b/src/Commands/FortifyUITablerCommand.php index 8e53e72..b063719 100644 --- a/src/Commands/FortifyUITablerCommand.php +++ b/src/Commands/FortifyUITablerCommand.php @@ -7,7 +7,7 @@ class FortifyUITablerCommand extends Command { - public $signature = 'fortify-ui:tabler'; + public $signature = 'tabler:install'; public $description = 'Install Tabler.io with views and resources'; @@ -46,7 +46,7 @@ public function handle() protected function publishAssets() { - $this->callSilent('vendor:publish', ['--tag' => 'fortify-ui-tabler-resources', '--force' => true]); + $this->callSilent('vendor:publish', ['--tag' => 'tabler-resources', '--force' => true]); } protected function changeSessionDriver(){ diff --git a/src/Commands/FortifyUITablerUpdateCommand.php b/src/Commands/FortifyUITablerUpdateCommand.php index f45690b..f35f08d 100644 --- a/src/Commands/FortifyUITablerUpdateCommand.php +++ b/src/Commands/FortifyUITablerUpdateCommand.php @@ -7,40 +7,50 @@ class FortifyUITablerUpdateCommand extends Command { - public $signature = 'fortify-ui:tabler-update'; + public $signature = 'tabler:update {--T|type=full : The type of update. Either full, public, language, views or controllers.}'; public $description = 'Update views, resources and routes for the Tabler.io framework.'; public function handle() { // confirm the installation - if ($this->confirm('Do you wish to continue? This updater will try to overwrite existing views, resources, language files and routes.', true)) { - // install fortifyUI - \Artisan::call('fortify-ui:install'); - $this->info('FortifyUI has been updated. Proceeding to update Tabler.io.'); - - // publish the assets, routes, controllers, etc. - $this->publishAssets(); + if ($this->confirm('Do you wish to continue? This updater will try to override certain files which may include files you\'ve edited.', true)) { + switch ($this->option("type")) { + case "public": + // publish public assets + $this->callSilent('vendor:publish', ['--tag' => 'tabler-update-public', '--force' => true]); + break; + case "language": + // publish language files + $this->callSilent('vendor:publish', ['--tag' => 'tabler-update-language', '--force' => true]); + break; + case "views": + // publish views + $this->callSilent('vendor:publish', ['--tag' => 'tabler-update-views', '--force' => true]); + break; + case "controllers": + // publish controllers + $this->callSilent('vendor:publish', ['--tag' => 'tabler-update-controllers', '--force' => true]); + break; + default: + // publish all files + $this->callSilent('vendor:publish', ['--tag' => 'tabler-update-full', '--force' => true]); + break; + } // create symbolic link - \Artisan::call('storage:link'); + $this->callSilent('storage:link'); // Clear the Route cache - \Artisan::call('route:clear'); - \Artisan::call('route:cache'); + $this->callSilent('route:clear'); + $this->callSilent('route:cache'); // print success message $this->info('The Tabler.io Framework is now updated.'); - $this->newLine(); - $this->line('Please run php artisan migrate before continuing.'); + $this->info('Please run php artisan migrate before continuing.'); } else { // print abort message $this->error('Update is aborted'); } } - - protected function publishAssets() - { - $this->callSilent('vendor:publish', ['--tag' => 'fortify-ui-tabler-resources', '--force' => true]); - } } diff --git a/src/FortifyUITablerServiceProvider.php b/src/FortifyUITablerServiceProvider.php index b005da4..485b66e 100644 --- a/src/FortifyUITablerServiceProvider.php +++ b/src/FortifyUITablerServiceProvider.php @@ -17,13 +17,41 @@ public function boot() // Load Migrations $this->loadMigrationsFrom(__DIR__.'/../stubs/database/migrations'); - // Publis files + // Publish files $this->publishes([ __DIR__ . '/../stubs/resources/views' => base_path('resources/views'), __DIR__ . '/../stubs/public' => base_path('public'), __DIR__ . '/../stubs/resources/lang' => base_path('resources/lang'), __DIR__ . '/../stubs/app/Http/Controllers' => base_path('app/Http/Controllers'), - ], 'fortify-ui-tabler-resources'); + ], 'tabler-resources'); + + // Update all files + $this->publishes([ + __DIR__ . '/../stubs/resources/views' => base_path('resources/views'), + __DIR__ . '/../stubs/public' => base_path('public'), + __DIR__ . '/../stubs/resources/lang' => base_path('resources/lang'), + __DIR__ . '/../stubs/app/Http/Controllers' => base_path('app/Http/Controllers'), + ], 'tabler-update-full'); + + // Update public files + $this->publishes([ + __DIR__ . '/../stubs/public' => base_path('public'), + ], 'tabler-update-public'); + + // Update views + $this->publishes([ + __DIR__ . '/../stubs/resources/views' => base_path('resources/views'), + ], 'tabler-update-views'); + + // Update controllers + $this->publishes([ + __DIR__ . '/../stubs/app/Http/Controllers' => base_path('app/Http/Controllers'), + ], 'tabler-update-controllers'); + + // Update all files + $this->publishes([ + __DIR__ . '/../stubs/resources/lang' => base_path('resources/lang'), + ], 'tabler-update-language'); $this->commands([ FortifyUITablerCommand::class,