From ca2bd8f306848b33fae1d1fd153a22336a7bae2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E6=B5=B7=E5=86=9B?= Date: Thu, 4 Feb 2021 10:20:59 +0800 Subject: [PATCH 1/4] add compsoer path config --- config/paket.php | 13 ++++++++++++- src/PaketServiceProvider.php | 5 +++-- src/Support/Composer.php | 17 +++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/config/paket.php b/config/paket.php index a321b5c..5110035 100644 --- a/config/paket.php +++ b/config/paket.php @@ -27,6 +27,17 @@ 'base_uri' => env('PAKET_BASE_URI', 'paket'), + /* + |-------------------------------------------------------------------------- + | Composer PATH + |-------------------------------------------------------------------------- + | + | to change this path to anything your composer location. + | + */ + + 'composer_path' => env('PAKET_COMPOSER_PATH', '/usr/bin/composer'), + /* |-------------------------------------------------------------------------- | Paket Route Middlewares @@ -43,4 +54,4 @@ Authorize::class, ], -]; +]; \ No newline at end of file diff --git a/src/PaketServiceProvider.php b/src/PaketServiceProvider.php index b64ca2a..a43915b 100644 --- a/src/PaketServiceProvider.php +++ b/src/PaketServiceProvider.php @@ -107,7 +107,8 @@ private function registerBindings(): void return new Composer( $this->app->make(Filesystem::class), base_path(), - storage_path('paket/jobs') + storage_path('paket/jobs'), + Config::get('paket.composer_path', '/usr/bin/composer') ); }); @@ -123,4 +124,4 @@ private function registerListeners(): void { Event::listen(JobHasBeenCreated::class, JobRunner::class); } -} +} \ No newline at end of file diff --git a/src/Support/Composer.php b/src/Support/Composer.php index 27c4b01..50247ec 100644 --- a/src/Support/Composer.php +++ b/src/Support/Composer.php @@ -44,18 +44,27 @@ final class Composer */ private $loggingPath; + /** + * The composer location path. + * + * @var string + */ + private $composerPath; + /** * Create a new Composer manager instance. * * @param \Illuminate\Filesystem\Filesystem $files * @param string $workingPath * @param string $loggingPath + * @param string $composerPath */ - public function __construct(Filesystem $files, string $workingPath, string $loggingPath) + public function __construct(Filesystem $files, string $workingPath, string $loggingPath,string $composerPath='/usr/bin/composer') { $this->files = $files; $this->workingPath = $workingPath; $this->loggingPath = $loggingPath; + $this->composerPath = $composerPath; } /** @@ -102,7 +111,7 @@ public function install(RequirementContract $requirement, JobContract $job): voi $command = sprintf( '%s require %s %s', - '/usr/bin/composer', + $this->composerPath, $requirement, implode(' ', $flags) ); @@ -131,7 +140,7 @@ public function uninstall(RequirementContract $requirement, JobContract $job): v $command = sprintf( '%s remove %s %s', - '/usr/bin/composer', + $this->composerPath, $requirement->getName(), implode(' ', $flags) ); @@ -201,4 +210,4 @@ private function writeLineToLogFile(string $jobLogFile, string $line): void { $this->files->append($jobLogFile, $line . "\n"); } -} +} \ No newline at end of file From 12efa2f188f8ad7b8d62fe143764d173326d0a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E6=B5=B7=E5=86=9B?= Date: Thu, 4 Feb 2021 10:34:52 +0800 Subject: [PATCH 2/4] style ci fixed --- config/paket.php | 2 +- src/PaketServiceProvider.php | 2 +- src/Support/Composer.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/paket.php b/config/paket.php index 5110035..7e86074 100644 --- a/config/paket.php +++ b/config/paket.php @@ -54,4 +54,4 @@ Authorize::class, ], -]; \ No newline at end of file +]; diff --git a/src/PaketServiceProvider.php b/src/PaketServiceProvider.php index a43915b..dcb56ab 100644 --- a/src/PaketServiceProvider.php +++ b/src/PaketServiceProvider.php @@ -124,4 +124,4 @@ private function registerListeners(): void { Event::listen(JobHasBeenCreated::class, JobRunner::class); } -} \ No newline at end of file +} diff --git a/src/Support/Composer.php b/src/Support/Composer.php index 50247ec..801054d 100644 --- a/src/Support/Composer.php +++ b/src/Support/Composer.php @@ -59,7 +59,7 @@ final class Composer * @param string $loggingPath * @param string $composerPath */ - public function __construct(Filesystem $files, string $workingPath, string $loggingPath,string $composerPath='/usr/bin/composer') + public function __construct(Filesystem $files, string $workingPath, string $loggingPath, string $composerPath = '/usr/bin/composer') { $this->files = $files; $this->workingPath = $workingPath; @@ -210,4 +210,4 @@ private function writeLineToLogFile(string $jobLogFile, string $line): void { $this->files->append($jobLogFile, $line . "\n"); } -} \ No newline at end of file +} From 939e700c0022d296116ba83e9d9d1ed7bdb92cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E6=B5=B7=E5=86=9B?= Date: Thu, 4 Feb 2021 15:37:56 +0800 Subject: [PATCH 3/4] Remove $composerPath default value --- src/Support/Composer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Support/Composer.php b/src/Support/Composer.php index 801054d..28ff54b 100644 --- a/src/Support/Composer.php +++ b/src/Support/Composer.php @@ -59,7 +59,7 @@ final class Composer * @param string $loggingPath * @param string $composerPath */ - public function __construct(Filesystem $files, string $workingPath, string $loggingPath, string $composerPath = '/usr/bin/composer') + public function __construct(Filesystem $files, string $workingPath, string $loggingPath, string $composerPath) { $this->files = $files; $this->workingPath = $workingPath; @@ -210,4 +210,4 @@ private function writeLineToLogFile(string $jobLogFile, string $line): void { $this->files->append($jobLogFile, $line . "\n"); } -} +} \ No newline at end of file From d194129d89fa7c01f524b413c50c8628e502e8be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E6=B5=B7=E5=86=9B?= Date: Thu, 4 Feb 2021 15:44:54 +0800 Subject: [PATCH 4/4] Remove $composerPath default value --- src/Support/Composer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/Composer.php b/src/Support/Composer.php index 28ff54b..afb29a7 100644 --- a/src/Support/Composer.php +++ b/src/Support/Composer.php @@ -210,4 +210,4 @@ private function writeLineToLogFile(string $jobLogFile, string $line): void { $this->files->append($jobLogFile, $line . "\n"); } -} \ No newline at end of file +}