Skip to content

Commit

Permalink
⚡ improve the updater and installer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
roelreijneveld committed Dec 28, 2020
1 parent bf334c2 commit 036ceaf
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 24 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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!

<a name="update"></a>

## 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.
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/FortifyUITablerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(){
Expand Down
46 changes: 28 additions & 18 deletions src/Commands/FortifyUITablerUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
32 changes: 30 additions & 2 deletions src/FortifyUITablerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 036ceaf

Please sign in to comment.