From 007545473ba270dcdf87c3dfdc6f867baf8b38dd Mon Sep 17 00:00:00 2001 From: pxthinh Date: Sat, 25 Nov 2023 00:27:42 +0700 Subject: [PATCH 1/3] feat: create command to change owner for config json files --- src/Commands/ChangeOwnerConfigJson.php | 36 ++++++++++++ .../TelegramGitNotifierServiceProvider.php | 56 ++++++++++++------- 2 files changed, 72 insertions(+), 20 deletions(-) create mode 100644 src/Commands/ChangeOwnerConfigJson.php 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..5777386 100644 --- a/src/Providers/TelegramGitNotifierServiceProvider.php +++ b/src/Providers/TelegramGitNotifierServiceProvider.php @@ -3,6 +3,7 @@ namespace CSlant\LaravelTelegramGitNotifier\Providers; use Illuminate\Support\ServiceProvider; +use CSlant\LaravelTelegramGitNotifier\Commands\ChangeOwnerConfigJson; 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->registerPublishes(); } /** @@ -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 registerPublishes(): 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'); + } } From 1856f5528ed2eb17f9d183d19447a1e688039d0a Mon Sep 17 00:00:00 2001 From: pxthinh Date: Fri, 24 Nov 2023 17:42:25 +0000 Subject: [PATCH 2/3] Fix styling --- src/Providers/TelegramGitNotifierServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Providers/TelegramGitNotifierServiceProvider.php b/src/Providers/TelegramGitNotifierServiceProvider.php index 5777386..9557856 100644 --- a/src/Providers/TelegramGitNotifierServiceProvider.php +++ b/src/Providers/TelegramGitNotifierServiceProvider.php @@ -2,8 +2,8 @@ namespace CSlant\LaravelTelegramGitNotifier\Providers; -use Illuminate\Support\ServiceProvider; use CSlant\LaravelTelegramGitNotifier\Commands\ChangeOwnerConfigJson; +use Illuminate\Support\ServiceProvider; class TelegramGitNotifierServiceProvider extends ServiceProvider { From c1d0b4e4c40a887cbc2ab15fc2149df3e60ceaad Mon Sep 17 00:00:00 2001 From: pxthinh Date: Sat, 25 Nov 2023 00:55:45 +0700 Subject: [PATCH 3/3] feat: change the function name to registerAssetPublishing --- src/Providers/TelegramGitNotifierServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Providers/TelegramGitNotifierServiceProvider.php b/src/Providers/TelegramGitNotifierServiceProvider.php index 5777386..ab3255d 100644 --- a/src/Providers/TelegramGitNotifierServiceProvider.php +++ b/src/Providers/TelegramGitNotifierServiceProvider.php @@ -28,7 +28,7 @@ public function boot(): void $this->registerCommands(); - $this->registerPublishes(); + $this->registerAssetPublishing(); } /** @@ -65,7 +65,7 @@ protected function registerCommands(): void /** * @return void */ - protected function registerPublishes(): void + protected function registerAssetPublishing(): void { $configPath = __DIR__.'/../../config/telegram-git-notifier.php'; $this->publishes([