Skip to content

Commit

Permalink
[src/Console/AdminLtePlugins]: Treat moment.js as independent plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsmania committed Jul 13, 2024
1 parent 81a39e5 commit 77492b4
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/Console/PackageResources/PluginsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class PluginsResource extends PackageResource
/**
* The available plugins data. A plugin can contain next data keys:
* - name: The name of the plugin.
* - source: The source of the plugin (relative to base source)
* - target: The target of the plugin (relative to base target)
* - source: The source of the plugin (relative to base source).
* - target: The target of the plugin (relative to base target).
* - resources: An array with resources data items.
* - ignore: A list of file patterns to ignore.
* - recursive: Whether to copy files recursively (default is true).
* - dependencies: A list of plugin keys that are required as dependencies.
*
* When the target is not specified, the source will be used as the
* relative path to the base target destination. A resource can contain the
Expand Down Expand Up @@ -74,10 +75,8 @@ class PluginsResource extends PackageResource
],
'daterangepicker' => [
'name' => 'Date Range Picker',
'resources' => [
['source' => 'daterangepicker'],
['source' => 'moment'],
],
'source' => 'daterangepicker',
'dependencies' => ['moment'],
],
'ekkoLightbox' => [
'name' => 'Ekko Lightbox',
Expand Down Expand Up @@ -157,6 +156,10 @@ class PluginsResource extends PackageResource
],
'recursive' => false,
],
'moment' => [
'name' => 'Moment.js',
'source' => 'moment',
],
'paceProgress' => [
'name' => 'Pace Progress',
'source' => 'pace-progress',
Expand Down Expand Up @@ -186,10 +189,8 @@ class PluginsResource extends PackageResource
],
'tempusdominusBootstrap4' => [
'name' => 'Tempus Dominus for Bootstrap 4',
'resources' => [
['source' => 'tempusdominus-bootstrap-4'],
['source' => 'moment'],
],
'source' => 'tempusdominus-bootstrap-4',
'dependencies' => ['moment'],
],
'toastr' => [
'name' => 'Toastr',
Expand Down Expand Up @@ -355,7 +356,13 @@ protected function preparePlugin($plugin)
*/
protected function installPlugin($plugin)
{
// Check if we need to export the entire plugin.
// First, check and install dependencies plugins, if any.

foreach(($plugin['dependencies'] ?? []) as $pluginKey) {
$this->install($pluginKey);
}

// Now, check if we need to export the entire plugin.

if (! isset($plugin['resources'])) {
$this->publishResource($plugin);
Expand Down

0 comments on commit 77492b4

Please sign in to comment.