Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve package resources #1285

Merged
merged 27 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
93c18f5
[src/Console]: Improve abstract class PackageResource
dfsmania Jun 2, 2024
7f8212e
[src/Console]: Improve AssetsResource class
dfsmania Jun 2, 2024
3762c33
[src/Console]: Fix Style CI in AssetsResource class
dfsmania Jun 2, 2024
a684929
[src/Console]: Rename AssetsResource to AdminlteAssetsResoruce
dfsmania Jun 2, 2024
a70dcf4
[src/Console]: Fix some issues detected on AdminLtePluginCommand class
dfsmania Jun 2, 2024
492eb7a
[src/Console]: Improve AuthViewsResource class
dfsmania Jun 2, 2024
97c4849
[src/Console]: Improve BasicRoutesResource class
dfsmania Jun 2, 2024
b884f7a
[src/Console]: Fix Style CI in BasicRoutesResource class
dfsmania Jun 2, 2024
b4a5ef1
[src/Console]: Rename BasicRoutesResource to AuthRoutesResource
dfsmania Jun 2, 2024
d7d2cb8
[src/Console]: Remove BasicViewsResource
dfsmania Jun 2, 2024
4f9674b
[src/Console]: Improve ConfigResource class
dfsmania Jun 2, 2024
26c4d7e
[src/Console]: Improve TranslationsResource class
dfsmania Jun 8, 2024
21bb6cc
[src/Console]: Add some fixes to AdminlteAssetsResource class
dfsmania Jun 9, 2024
befa238
[src/Console]: Add some fixes to AuthRoutesResource class
dfsmania Jun 9, 2024
c7e5b66
[src/Console]: Add some fixes to AuthViewsResource class
dfsmania Jun 9, 2024
f75c6c9
[tests/Console]: Add fix when testing auth views resources
dfsmania Jun 9, 2024
28ce9be
[src/Console]: Add some fixes to ConfigResource class
dfsmania Jun 9, 2024
49ae018
[src/Console]: Add some fixes to TranslationsResource class
dfsmania Jun 9, 2024
0dc0dbb
[src/Console]: Rework all logic in the MainViewsResource class
dfsmania Jun 15, 2024
f6be224
[src/Console]: Rename MainViewsResource to LayoutViewsResource
dfsmania Jun 16, 2024
0e93508
[src/Console]: Improve PluginsResource class
dfsmania Jun 17, 2024
017f1cc
[src/Console]: Fix method getSourceData() of PluginsResource class
dfsmania Jun 17, 2024
c35c8de
[src/Console]: Revert install/uninstall return boolean
dfsmania Jun 18, 2024
779beaf
[src/Console]: Minor fix on method documentation of PluginsResource
dfsmania Jun 18, 2024
0c7b1d5
[src/Console] Solve some minor issues
dfsmania Jun 18, 2024
184f4fd
[src/Console] Improve console tests
dfsmania Jun 25, 2024
e489982
[tests/Console]: Minor improvements on the console tests
dfsmania Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/Console/AdminLteInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace JeroenNoten\LaravelAdminLte\Console;

use Illuminate\Console\Command;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AssetsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AdminlteAssetsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AuthRoutesResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AuthViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\BasicRoutesResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\BasicViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\ConfigResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\MainViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\LayoutViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\TranslationsResource;

class AdminLteInstallCommand extends Command
Expand All @@ -20,8 +19,8 @@ class AdminLteInstallCommand extends Command
*/
protected $signature = 'adminlte:install
{--type=basic : The installation type: basic (default), enhanced or full}
{--only=* : To install only specific resources: assets, config, translations, auth_views, basic_views, basic_routes or main_views. Can\'t be used with option --with}
{--with=* : To install with additional resources: auth_views, basic_views, basic_routes or main_views}
{--only=* : To install only specific resources: assets, config, translations, auth_views, basic_routes or main_views. Can\'t be used with option --with}
{--with=* : To install with additional resources: auth_views, basic_routes or main_views}
{--force : To force the overwrite of existing files}
{--interactive : The installation will guide you through the process}';

Expand Down Expand Up @@ -79,20 +78,19 @@ public function __construct()
// Fill the array with the package resources.

$this->pkgResources = [
'assets' => new AssetsResource(),
'assets' => new AdminlteAssetsResource(),
'config' => new ConfigResource(),
'translations' => new TranslationsResource(),
'main_views' => new MainViewsResource(),
'main_views' => new LayoutViewsResource(),
'auth_views' => new AuthViewsResource(),
'basic_views' => new BasicViewsResource(),
'basic_routes' => new BasicRoutesResource(),
'basic_routes' => new AuthRoutesResource(),
];

// Add the resources related to each available --type option.

$basic = ['assets', 'config', 'translations'];
$enhanced = array_merge($basic, ['auth_views']);
$full = array_merge($enhanced, ['basic_views', 'basic_routes']);
$full = array_merge($enhanced, ['basic_routes']);

$this->optTypeResources = [
'basic' => $basic,
Expand All @@ -108,7 +106,6 @@ public function __construct()
'translations' => ['translations'],
'main_views' => ['main_views'],
'auth_views' => ['auth_views'],
'basic_views' => ['basic_views'],
'basic_routes' => ['basic_routes'],
];

Expand All @@ -117,7 +114,6 @@ public function __construct()
$this->optWithResources = [
'main_views' => ['main_views'],
'auth_views' => ['auth_views'],
'basic_views' => ['basic_views'],
'basic_routes' => ['basic_routes'],
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/Console/AdminLtePluginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ protected function installPlugin($pluginKey)
{
// Customize the output messages.

$confirmMsg = $this->plugins->getInstallMessage('install');
$overwriteMsg = $this->plugins->getInstallMessage('overwrite');
$confirmMsg = $this->plugins->getInstallMessage('install') ?? '';
$overwriteMsg = $this->plugins->getInstallMessage('overwrite') ?? '';

$confirmMsg = strtr($confirmMsg, [':plugin' => $pluginKey]);
$overwriteMsg = strtr($overwriteMsg, [':plugin' => $pluginKey]);
Expand Down Expand Up @@ -420,7 +420,7 @@ protected function removePlugin($pluginKey)
{
// Customize the output messages.

$confirmMsg = $this->plugins->getInstallMessage('remove');
$confirmMsg = $this->plugins->getInstallMessage('remove') ?? '';
$confirmMsg = strtr($confirmMsg, [':plugin' => $pluginKey]);

// Check if the plugin is valid.
Expand Down
14 changes: 6 additions & 8 deletions src/Console/AdminLteStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace JeroenNoten\LaravelAdminLte\Console;

use Illuminate\Console\Command;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AssetsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AdminlteAssetsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AuthRoutesResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\AuthViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\BasicRoutesResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\BasicViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\ConfigResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\MainViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\LayoutViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\TranslationsResource;

class AdminLteStatusCommand extends Command
Expand Down Expand Up @@ -69,13 +68,12 @@ public function __construct()
// Fill the array with the package resources.

$this->pkgResources = [
'assets' => new AssetsResource(),
'assets' => new AdminlteAssetsResource(),
'config' => new ConfigResource(),
'translations' => new TranslationsResource(),
'main_views' => new MainViewsResource(),
'main_views' => new LayoutViewsResource(),
'auth_views' => new AuthViewsResource(),
'basic_views' => new BasicViewsResource(),
'basic_routes' => new BasicRoutesResource(),
'basic_routes' => new AuthRoutesResource(),
];
}

Expand Down
19 changes: 10 additions & 9 deletions src/Console/AdminLteUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\Console;

use Illuminate\Console\Command;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\MainViewsResource;
use JeroenNoten\LaravelAdminLte\Console\PackageResources\LayoutViewsResource;

class AdminLteUpdateCommand extends Command
{
Expand All @@ -27,9 +27,9 @@ class AdminLteUpdateCommand extends Command
*
* @var string
*/
protected $mainViewsWarn = '<fg=yellow>Outdated main views at %s</>
protected $layoutViewsWarn = '<fg=yellow>Outdated layout views at %s</>
<fg=cyan>
We detected that the package main views were previously published and they
We detected that the package layout views were previously published and they
differs from the ones currently available. Note this package may not work
correctly if you do not update those views manually in order to include the
latest changes. In the particular case you have recently changed those views
Expand All @@ -48,14 +48,15 @@ public function handle()

$this->call('adminlte:install', $options);

// When the main views were previously installed and they differs from
// the original ones, alarm the user that those views may require a
// manual update.
// When the layout views were previously published and they differs
// from the package default ones, alarm the user to notify that those
// views may require a manual update.

$mainViewsRes = new MainViewsResource();
$layoutViewsRes = new LayoutViewsResource();

if ($mainViewsRes->exists() && ! $mainViewsRes->installed()) {
$this->info(sprintf($this->mainViewsWarn, $mainViewsRes->target));
if ($layoutViewsRes->exists() && ! $layoutViewsRes->installed()) {
$msg = sprintf($this->layoutViewsWarn, $layoutViewsRes->target);
$this->info($msg);
}
}
}
Loading