diff --git a/src/Commands/ChangeOwnerConfigJson.php b/src/Commands/ChangeOwnerConfigJson.php new file mode 100644 index 0000000..73b79d7 --- /dev/null +++ b/src/Commands/ChangeOwnerConfigJson.php @@ -0,0 +1,36 @@ +option('user'); + $jsonsPath = config('telegram-git-notifier.data_file.storage_folder'); + if (is_string($jsonsPath) && file_exists($jsonsPath)) { + exec("chown -R $user:$user $jsonsPath"); + } + } +} diff --git a/src/Providers/TelegramGitNotifierServiceProvider.php b/src/Providers/TelegramGitNotifierServiceProvider.php index 504d943..7ed2954 100644 --- a/src/Providers/TelegramGitNotifierServiceProvider.php +++ b/src/Providers/TelegramGitNotifierServiceProvider.php @@ -2,6 +2,7 @@ namespace CSlant\LaravelTelegramGitNotifier\Providers; +use CSlant\LaravelTelegramGitNotifier\Commands\ChangeOwnerConfigJson; use Illuminate\Support\ServiceProvider; class TelegramGitNotifierServiceProvider extends ServiceProvider @@ -25,27 +26,9 @@ public function boot(): void $this->loadTranslationsFrom(__DIR__.'/../../lang', 'tg-notifier'); - $configPath = __DIR__.'/../../config/telegram-git-notifier.php'; - $this->publishes([ - $configPath => config_path('telegram-git-notifier.php'), - ], 'config'); - - $this->publishes([ - __DIR__.'/../../resources/views' => config('telegram-git-notifier.defaults.paths.views'), - ], 'views'); - - $this->publishes([ - __DIR__.'/../../lang' => resource_path('lang/vendor/tg-notifier'), - ], 'lang'); + $this->registerCommands(); - $this->publishes([ - __DIR__.'/../../../telegram-git-notifier/config/jsons' => config('telegram-git-notifier.data_file.storage_folder'), - ], 'config_jsons'); - - $jsonsPath = config('telegram-git-notifier.data_file.storage_folder'); - if (is_string($jsonsPath) && file_exists($jsonsPath)) { - exec("chown -R www-data:www-data $jsonsPath"); - } + $this->registerAssetPublishing(); } /** @@ -68,4 +51,37 @@ public function provides(): ?array { return ['telegram-git-notifier']; } + + /** + * @return void + */ + protected function registerCommands(): void + { + $this->commands([ + ChangeOwnerConfigJson::class, + ]); + } + + /** + * @return void + */ + protected function registerAssetPublishing(): void + { + $configPath = __DIR__.'/../../config/telegram-git-notifier.php'; + $this->publishes([ + $configPath => config_path('telegram-git-notifier.php'), + ], 'config'); + + $this->publishes([ + __DIR__.'/../../resources/views' => config('telegram-git-notifier.defaults.paths.views'), + ], 'views'); + + $this->publishes([ + __DIR__.'/../../lang' => resource_path('lang/vendor/tg-notifier'), + ], 'lang'); + + $this->publishes([ + __DIR__.'/../../../telegram-git-notifier/config/jsons' => config('telegram-git-notifier.data_file.storage_folder'), + ], 'config_jsons'); + } }