diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d335c47..6acbbc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,6 +18,7 @@ jobs: - '7.2' - '7.3' - '7.4' + - '8.0' deps: - highest - lowest @@ -25,7 +26,7 @@ jobs: name: PHP ${{ matrix.php }} / ${{ matrix.deps }} steps: - uses: actions/checkout@v2 - - uses: shivammathur/setup-php@151d1849c224dd5757287959c3c93f9e748f24d1 + - uses: shivammathur/setup-php@4067ce8b814db5bfc731c8906aa3034f28911e9f with: php-version: ${{ matrix.php }} - name: Cache dependencies @@ -59,10 +60,25 @@ jobs: name: PHP 5.3 steps: - uses: actions/checkout@v2 - - uses: shivammathur/setup-php@151d1849c224dd5757287959c3c93f9e748f24d1 + - uses: shivammathur/setup-php@4067ce8b814db5bfc731c8906aa3034f28911e9f with: php-version: 5.3 - - name: Parse ComposerPlugin.php - run: php -l src/ComposerPlugin.php - - name: Parse ComposerPlugin.fake.php - run: php -l src/ComposerPlugin.fake.php + - name: Syntax check + run: | + while read file; do + php -l "$file" + done < <(find src/Legacy -type f -name "*.php") + - name: Integration test + run: | + composer global config repositories.0 path "$(pwd)" + composer global require --ignore-platform-reqs cs278/composer-audit '*@dev' + + set +e + composer global audit -vvv + result=$? + set -e + + if [ $result -ne 2 ]; then + echo "Expected audit command to exit with error code 2, got: ${result}" >&2 + exit 1 + fi diff --git a/composer.json b/composer.json index 2eb3e54..07786dd 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,6 @@ "sort-packages": true }, "extra": { - "class": "Cs278\\ComposerAudit\\ComposerPlugin" + "class": "Cs278\\ComposerAudit\\Legacy\\ComposerPlugin" } } diff --git a/src/ComposerPlugin.fake.php b/src/ComposerPlugin.fake.php deleted file mode 100644 index 927f1d0..0000000 --- a/src/ComposerPlugin.fake.php +++ /dev/null @@ -1,30 +0,0 @@ -= 70100) { - require __DIR__.'/ComposerPlugin.real.php'; - } else { - require __DIR__.'/ComposerPlugin.fake.php'; +use Composer\Composer; +use Composer\IO\IOInterface; +use Composer\Plugin\PluginInterface; +use Composer\Plugin\Capable; +use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability; + +/** + * Composer Audit Plugin declaration. + */ +final class ComposerPlugin implements PluginInterface, Capable +{ + public function activate(Composer $composer, IOInterface $io) + { + + } + + public function deactivate(Composer $composer, IOInterface $io) + { + + } + + public function uninstall(Composer $composer, IOInterface $io) + { + + } + + public function getCapabilities() + { + return [ + CommandProviderCapability::class => CommandProvider::class, + ]; } } diff --git a/src/ComposerPlugin.real.php b/src/ComposerPlugin.real.php deleted file mode 100644 index 5530670..0000000 --- a/src/ComposerPlugin.real.php +++ /dev/null @@ -1,37 +0,0 @@ - CommandProvider::class, - ]; - } -} diff --git a/src/Legacy/AuditNotCompatibleCommand.php b/src/Legacy/AuditNotCompatibleCommand.php new file mode 100644 index 0000000..f7488c3 --- /dev/null +++ b/src/Legacy/AuditNotCompatibleCommand.php @@ -0,0 +1,46 @@ +setName('audit'); + $this->setDescription('Check packages for security advisories.'); + $this->addOption( + 'no-dev', + null, + InputOption::VALUE_NONE, + 'Disable checking of development dependencies.' + ); + $this->addOption( + 'update', + null, + InputOption::VALUE_NONE, + 'Update security advisory information if a new version is available.' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; + + $output->writeln(sprintf('Composer Audit is not compatible with PHP %s', PHP_VERSION)); + + return 2; + } +} diff --git a/src/Legacy/CommandProvider.php b/src/Legacy/CommandProvider.php new file mode 100644 index 0000000..7b2e161 --- /dev/null +++ b/src/Legacy/CommandProvider.php @@ -0,0 +1,18 @@ += 70100) { + \class_alias(substr(__NAMESPACE__, 0, strrpos(__NAMESPACE__, '\\')).'\\ComposerPlugin', __NAMESPACE__.'\\ComposerPlugin'); + } else { + /** + * Composer Audit Plugin declaration. + * + * @internal This class is used when loading the plugin with PHP < 7.1. + */ + final class ComposerPlugin implements PluginInterface, Capable + { + public function activate(Composer $composer, IOInterface $io) + { + + } + + public function deactivate(Composer $composer, IOInterface $io) + { + + } + + public function uninstall(Composer $composer, IOInterface $io) + { + + } + + public function getCapabilities() + { + return array( + 'Composer\\Plugin\\Capability\\CommandProvider' => __NAMESPACE__.'\\CommandProvider', + ); + } + } + } +} diff --git a/src/Legacy/README b/src/Legacy/README new file mode 100644 index 0000000..22f42be --- /dev/null +++ b/src/Legacy/README @@ -0,0 +1,2 @@ +Code in this namespace must be compatible with the lowest PHP version that +Composer supports.