Skip to content

Commit

Permalink
Merge pull request #5 from BeAPI/feature/composer-2
Browse files Browse the repository at this point in the history
Composer 2 compatibility
  • Loading branch information
Rahe authored Jun 16, 2020
2 parents b132953 + e282658 commit 6f2ea65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.6",
"composer-plugin-api": "^1.1"
"composer-plugin-api": "^1.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.4"
"composer/composer": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 7 additions & 6 deletions src/Command/MakeStableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
$output->writeln( "<info>Before proceeding please make sure all your requires have the appropriate minimum stability & some releases !</info>" );

if ( false === $io->askConfirmation(
"Do you really want to set all requires as \"*@stable\" version ?",
"Do you really want to set all requires as \"*@stable\" version (y/n) ? ",
true ) ) {
exit;
return 0;
}

$composerPath = $composer->getConfig()->getConfigSource()->getName();
$composerFile = new JsonFile( $composerPath );
if ( ! $composerFile->exists() ) {
$output->writeln( "<error>Composer file not found.</error>" );
exit;
return 1;
}

// if we cannot write then bail
if ( ! is_writeable( $composerPath ) ) {
if ( ! is_writable( $composerPath ) ) {
$output->writeln( "<error>The composer.json file cannot be rewritten !</error>" );
$output->writeln( "<error>Please check your file permissions.</error>" );
exit;
return 1;
}

try {
Expand All @@ -69,10 +69,11 @@ protected function execute( InputInterface $input, OutputInterface $output ) {

$composerFile->write( $composerJson );
$output->writeln( "All requires are now at \"*@stable\" version \o/" );
return 0;
} catch ( RuntimeException $e ) {
$output->writeln( "<error>An error occurred</error>" );
$output->writeln( sprintf( "<error>%s</error>", $e->getMessage() ) );
exit;
return 1;
}
}
}
8 changes: 6 additions & 2 deletions src/MakeStable.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ public function activate(Composer $composer, IOInterface $io)
$this->io = $io;
}

public function getCapabilities()
public function deactivate( Composer $composer, IOInterface $io ) {}

public function uninstall( Composer $composer, IOInterface $io ) {}

public function getCapabilities()
{
return [
'Composer\Plugin\Capability\CommandProvider' => __NAMESPACE__ . '\\MakeStable',
CommandProvider::class => __CLASS__,
];
}

Expand Down

0 comments on commit 6f2ea65

Please sign in to comment.