-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix executing plugin in a namespace (#115)
Closes #62 Re-using the existing application to run the command in the sub-namespace is having another side-effect (besides potentially registering commands which we already are cleaning up since #96) which is that plugins are not re-loaded. As a result if a plugin is registered in a namespace, it will not be loaded at all hence all the commands it registers will not be available
- Loading branch information
Showing
14 changed files
with
164 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
Tests that extra arguments and options are not lost when forwarding the command to a bin namespace. | ||
In this scenario the dependencies are not install in the bin namespace since the parsed (forwarded) | ||
command is invalid. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/actual.txt | ||
/composer.lock | ||
/vendor/ | ||
/vendor-bin/*/composer.lock | ||
/vendor-bin/*/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tests that extra arguments and options are not lost when forwarding the command to a bin namespace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"repositories": [ | ||
{ | ||
"type": "path", | ||
"url": "../../" | ||
} | ||
], | ||
"require": { | ||
"bamarni/composer-bin-plugin": "dev-master" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"bamarni/composer-bin-plugin": true | ||
} | ||
}, | ||
"extra": { | ||
"bamarni-bin": { | ||
"forward-command": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[bamarni-bin] Checking namespace vendor-bin/composer-unused | ||
|
||
Loading packages | ||
---------------- | ||
|
||
! [NOTE] Found 0 package(s) to be checked. | ||
|
||
[OK] Done. No required packages to scan. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail | ||
|
||
# Set env envariables in order to experience a behaviour closer to what happens | ||
# in the CI locally. It should not hurt to set those in the CI as the CI should | ||
# contain those values. | ||
export CI=1 | ||
export COMPOSER_NO_INTERACTION=1 | ||
|
||
readonly ORIGINAL_WORKING_DIR=$(pwd) | ||
|
||
trap "cd ${ORIGINAL_WORKING_DIR}" err exit | ||
|
||
# Change to script directory | ||
cd "$(dirname "$0")" | ||
|
||
# Ensure we have a clean state | ||
rm -rf actual.txt || true | ||
rm -rf composer.lock || true | ||
rm -rf vendor || true | ||
rm -rf vendor-bin/*/composer.lock || true | ||
rm -rf vendor-bin/*/vendor || true | ||
|
||
composer update | ||
|
||
# Actual command to execute the test itself | ||
composer bin composer-unused unused --no-progress 2>&1 | tee > actual.txt || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/composer-unused-dump-* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"require": { | ||
"composer-runtime-api": "^2.2", | ||
"icanhazstring/composer-unused": "~0.7.12" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"icanhazstring/composer-unused": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bamarni\Composer\Bin; | ||
|
||
use Composer\Console\Application; | ||
|
||
final class FreshInstanceApplicationFactory implements NamespaceApplicationFactory | ||
{ | ||
public function create(Application $existingApplication): Application | ||
{ | ||
return new Application(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bamarni\Composer\Bin; | ||
|
||
use Composer\Console\Application; | ||
|
||
interface NamespaceApplicationFactory | ||
{ | ||
public function create(Application $existingApplication): Application; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bamarni\Composer\Bin\Tests\Fixtures; | ||
|
||
use Bamarni\Composer\Bin\NamespaceApplicationFactory; | ||
use Composer\Console\Application; | ||
|
||
final class ReuseApplicationFactory implements NamespaceApplicationFactory | ||
{ | ||
public function create(Application $existingApplication): Application | ||
{ | ||
return $existingApplication; | ||
} | ||
} |