From 56a91659bdcff1a6bb2bf69691ef9da9722997ba Mon Sep 17 00:00:00 2001 From: Sebastien HEYD Date: Tue, 1 Sep 2020 17:10:31 +0200 Subject: [PATCH] Use of symlink with existing packages --- changelog.md | 1 + src/Commands/GitPackage.php | 2 +- src/Conveyor.php | 5 ++++- tests/IntegratedTest.php | 21 ++++++++++++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 3a760b8..e2678db 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ All Notable changes to Packager will be documented in this file. ### Updated - Support for Laravel 7 and PHPUnit 9. - `packager:new` now also supports separating vendor and name with a forward slash. +- `symlink` option is set to true as default for repositories in `composer.json` ## Version 2.4 diff --git a/src/Commands/GitPackage.php b/src/Commands/GitPackage.php index e635912..a8ece15 100644 --- a/src/Commands/GitPackage.php +++ b/src/Commands/GitPackage.php @@ -88,7 +88,7 @@ public function handle() // Clone the repository $this->info('Cloning repository...'); - exec("git clone $source ".$this->conveyor->packagePath(), $output, $exit_code); + exec("git clone -q $source ".$this->conveyor->packagePath(), $output, $exit_code); if ($exit_code != 0) { $this->error('Unable to clone repository'); diff --git a/src/Conveyor.php b/src/Conveyor.php index 5cf9638..ced08c4 100644 --- a/src/Conveyor.php +++ b/src/Conveyor.php @@ -122,6 +122,9 @@ public function addPathRepository() $params = json_encode([ 'type' => 'path', 'url' => $this->packagePath(), + 'options' => [ + 'symlink' => true, + ], ]); $command = [ 'composer', @@ -150,7 +153,7 @@ public function requirePackage() return $this->runProcess([ 'composer', 'require', - $this->vendor.'/'.$this->package, + $this->vendor.'/'.$this->package.':@dev', ]); } diff --git a/tests/IntegratedTest.php b/tests/IntegratedTest.php index 0459a14..b5f09c0 100644 --- a/tests/IntegratedTest.php +++ b/tests/IntegratedTest.php @@ -11,6 +11,7 @@ public function test_new_package_is_created() Artisan::call('packager:new', ['vendor' => 'MyVendor', 'name' => 'MyPackage']); $this->seeInConsoleOutput('Package created successfully!'); + $this->assertTrue(is_link(base_path('vendor/myvendor/mypackage'))); } public function test_new_package_is_installed() @@ -35,7 +36,7 @@ public function test_new_package_is_installed_from_custom_skeleton() $this->assertStringContainsString('AnotherVendor/AnotherPackage', $composer); } - public function test_get_existing_package() + public function test_get_package() { Artisan::call('packager:get', ['url' => 'https://github.com/Jeroen-G/packager-skeleton', 'vendor' => 'MyVendor', 'name' => 'MyPackage']); @@ -43,6 +44,24 @@ public function test_get_existing_package() $this->seeInConsoleOutput('Package downloaded successfully!'); } + public function test_get_existing_package_with_git() + { + Artisan::call('packager:git', + ['url' => 'https://github.com/Seldaek/monolog', 'vendor' => 'monolog', 'name' => 'monolog']); + + $this->seeInConsoleOutput('Package cloned successfully!'); + $this->assertTrue(is_link(base_path('vendor/monolog/monolog'))); + } + + public function test_get_existing_package_with_get() + { + Artisan::call('packager:get', + ['url' => 'https://github.com/Seldaek/monolog', 'vendor' => 'monolog', 'name' => 'monolog']); + + $this->seeInConsoleOutput('Package downloaded successfully!'); + $this->assertTrue(is_link(base_path('vendor/monolog/monolog'))); + } + public function test_list_packages() { Artisan::call('packager:new', ['vendor' => 'MyVendor', 'name' => 'MyPackage']);