Skip to content

Commit 6f2ea65

Browse files
authored
Merge pull request #5 from BeAPI/feature/composer-2
Composer 2 compatibility
2 parents b132953 + e282658 commit 6f2ea65

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
"email": "[email protected]"
99
}
1010
],
11+
"minimum-stability": "dev",
1112
"require": {
1213
"php": ">=5.6",
13-
"composer-plugin-api": "^1.1"
14+
"composer-plugin-api": "^1.0 || ^2.0"
1415
},
1516
"require-dev": {
16-
"composer/composer": "^1.4"
17+
"composer/composer": "^2.0"
1718
},
1819
"autoload": {
1920
"psr-4": {

src/Command/MakeStableCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
2626
$output->writeln( "<info>Before proceeding please make sure all your requires have the appropriate minimum stability & some releases !</info>" );
2727

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

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

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

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

7070
$composerFile->write( $composerJson );
7171
$output->writeln( "All requires are now at \"*@stable\" version \o/" );
72+
return 0;
7273
} catch ( RuntimeException $e ) {
7374
$output->writeln( "<error>An error occurred</error>" );
7475
$output->writeln( sprintf( "<error>%s</error>", $e->getMessage() ) );
75-
exit;
76+
return 1;
7677
}
7778
}
7879
}

src/MakeStable.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ public function activate(Composer $composer, IOInterface $io)
2626
$this->io = $io;
2727
}
2828

29-
public function getCapabilities()
29+
public function deactivate( Composer $composer, IOInterface $io ) {}
30+
31+
public function uninstall( Composer $composer, IOInterface $io ) {}
32+
33+
public function getCapabilities()
3034
{
3135
return [
32-
'Composer\Plugin\Capability\CommandProvider' => __NAMESPACE__ . '\\MakeStable',
36+
CommandProvider::class => __CLASS__,
3337
];
3438
}
3539

0 commit comments

Comments
 (0)