From 08b47fe8be79716935125a2d5a721b51e2bee404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Krzy=C5=BCanowski?= Date: Sun, 8 Sep 2024 12:00:55 +0200 Subject: [PATCH 1/5] Displaying name of created action --- src/Processors/Make.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Processors/Make.php b/src/Processors/Make.php index 77635268..b0569998 100644 --- a/src/Processors/Make.php +++ b/src/Processors/Make.php @@ -21,15 +21,9 @@ class Make extends Processor public function handle(): void { - $this->notification->task('Creating an operation', fn () => $this->run()); - } - - protected function run(): void - { - $name = $this->getName(); - $path = $this->getPath(); + $pathWithName = $this->getPath().$this->getName(); - $this->create($path . '/' . $name); + $this->notification->task('Creating an operation ['.$pathWithName.']', fn () => $this->create($pathWithName)); } protected function create(string $path): void @@ -59,6 +53,7 @@ protected function getFilename(string $branch): string ->prepend($this->getTime()) ->finish('.php') ->prepend($directory . '/') + ->ltrim('./') ->toString(); } From 4bc837e69856c6b2b83503d82639c9cb33c2b6e9 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sun, 8 Sep 2024 16:15:08 +0300 Subject: [PATCH 2/5] Update Make.php --- src/Processors/Make.php | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Processors/Make.php b/src/Processors/Make.php index b0569998..e3c8e83d 100644 --- a/src/Processors/Make.php +++ b/src/Processors/Make.php @@ -7,6 +7,7 @@ use DragonCode\Support\Facades\Filesystem\File; use DragonCode\Support\Facades\Filesystem\Path; use DragonCode\Support\Facades\Helpers\Str; +use DragonCode\Support\Helpers\Ables\Stringable; use function base_path; use function date; @@ -21,14 +22,26 @@ class Make extends Processor public function handle(): void { - $pathWithName = $this->getPath().$this->getName(); + $this->notification->task($this->message(), fn () => $this->create()); + } - $this->notification->task('Creating an operation ['.$pathWithName.']', fn () => $this->create($pathWithName)); + protected function message(): string + { + return 'Operation [' . $this->displayName($this->getFullPath()) . '] created successfully'; } - protected function create(string $path): void + protected function create(): void { - File::copy($this->stubPath(), $path); + File::copy($this->stubPath(), $this->getFullPath()); + } + + protected function displayName(string $path): string + { + return Str::of($path) + ->when(! $this->showFullPath(), fn (Stringable $str) => $str->after(base_path())) + ->replace('\\', '/') + ->ltrim('./') + ->toString(); } protected function getName(): string @@ -43,6 +56,11 @@ protected function getPath(): string return $this->options->path; } + protected function getFullPath(): string + { + return $this->getPath() . $this->getName(); + } + protected function getFilename(string $branch): string { $directory = Path::dirname($branch); @@ -53,6 +71,7 @@ protected function getFilename(string $branch): string ->prepend($this->getTime()) ->finish('.php') ->prepend($directory . '/') + ->replace('\\', '/') ->ltrim('./') ->toString(); } @@ -95,4 +114,9 @@ protected function stubPath(): string return $this->defaultStub; } + + protected function showFullPath(): bool + { + return $this->config->showFullPath(); + } } From 0f9ae3570ab60ad8184327297b01fbaaa0a8ee8e Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sun, 8 Sep 2024 16:15:54 +0300 Subject: [PATCH 3/5] Update Config.php --- src/Helpers/Config.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Helpers/Config.php b/src/Helpers/Config.php index 4425baf7..ab3298cb 100644 --- a/src/Helpers/Config.php +++ b/src/Helpers/Config.php @@ -51,6 +51,11 @@ public function gitPath(): string return base_path(); } + public function showFullPath(): bool + { + return (bool) $this->config->get('deploy-operations.show.full_path'); + } + protected function directory(): string { return $this->config->get('deploy-operations.path', base_path('operations')); From 240b9af55fe58cb54adcb0b65d820a20cf6725cf Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sun, 8 Sep 2024 16:16:14 +0300 Subject: [PATCH 4/5] Update deploy-operations.php --- config/deploy-operations.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/config/deploy-operations.php b/config/deploy-operations.php index 84b7cbf4..8c44461b 100644 --- a/config/deploy-operations.php +++ b/config/deploy-operations.php @@ -123,4 +123,27 @@ 'name' => env('DEPLOY_OPERATIONS_QUEUE_NAME'), ], + + /* + |-------------------------------------------------------------------------- + | Show + |-------------------------------------------------------------------------- + | + | This option determines the display settings for various information messages. + | + */ + + 'show' => [ + /* + |-------------------------------------------------------------------------- + | Full Path + |-------------------------------------------------------------------------- + | + | This parameter determines how exactly the link to the created file should + | be displayed - the full path to the file or a relative one. + | + */ + + 'full_path' => env('DEPLOY_OPERATIONS_SHOW_FULL_PATH', false), + ], ]; From eaa5ccfc9a9202c6931aa2019410cc93612ce610 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sun, 8 Sep 2024 16:21:43 +0300 Subject: [PATCH 5/5] Update Make.php --- src/Processors/Make.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Processors/Make.php b/src/Processors/Make.php index e3c8e83d..2b77bad4 100644 --- a/src/Processors/Make.php +++ b/src/Processors/Make.php @@ -22,17 +22,19 @@ class Make extends Processor public function handle(): void { - $this->notification->task($this->message(), fn () => $this->create()); + $fullPath = $this->getFullPath(); + + $this->notification->task($this->message($fullPath), fn () => $this->create($fullPath)); } - protected function message(): string + protected function message(string $path): string { - return 'Operation [' . $this->displayName($this->getFullPath()) . '] created successfully'; + return 'Operation [' . $this->displayName($path) . '] created successfully'; } - protected function create(): void + protected function create(string $path): void { - File::copy($this->stubPath(), $this->getFullPath()); + File::copy($this->stubPath(), $path); } protected function displayName(string $path): string @@ -46,9 +48,9 @@ protected function displayName(string $path): string protected function getName(): string { - $branch = $this->getBranchName(); - - return $this->getFilename($branch); + return $this->getFilename( + $this->getBranchName() + ); } protected function getPath(): string