Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/Commands/Base/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
**/
namespace Talevskiigor\ComposerBump\Commands\Base;


use Illuminate\Console\Command;

use Talevskiigor\ComposerBump\Helpers\Bumper;
use Talevskiigor\ComposerBump\Helpers\FileHelper;


/**
* Class BaseCommand
*
* @package Talevskiigor\ComposerBump\Commands\Base
*/
class BaseCommand extends Command
{
/**
Expand All @@ -33,7 +35,6 @@ class BaseCommand extends Command
*/
protected $description = '';


/**
* Create a new command instance.
*/
Expand All @@ -45,21 +46,13 @@ public function __construct()

}


/**
* Execute the console command.
* @return mixed
* @throws \Exception
*/
public function handle()
{

throw new \Exception("You need to implement your own handle() method.", 1);

}





throw new \Exception("You need to implement your own handle() method.", 1);
}
}
24 changes: 10 additions & 14 deletions src/Commands/BumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

/**
* Class BumpCommand
*
* @package Talevskiigor\ComposerBump\Commands
*/
class BumpCommand extends BaseCommand
{
/**
Expand All @@ -20,25 +25,16 @@ class BumpCommand extends BaseCommand
*/
protected $description = 'Bump version (This is alias of bump:patch)';





/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{

$oldVersion = $this->fileHelper->getVersion();

$newVersion = $this->bumper->bump($oldVersion)->get();

$this->fileHelper->setVersion($newVersion)->save();

$this->info('Bump from: '. $oldVersion.' to ' . $newVersion);
}

$oldVersion = $this->fileHelper->getVersion();
$newVersion = $this->bumper->bump($oldVersion)->get();
$this->fileHelper->setVersion($newVersion)->save();
$this->info('Bump from: ' . $oldVersion . ' to ' . $newVersion);
}
}
16 changes: 6 additions & 10 deletions src/Commands/BumpMajorCommand.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php


namespace Talevskiigor\ComposerBump\Commands;

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

/**
* Class BumpMajorCommand
*
* @package Talevskiigor\ComposerBump\Commands
*/
class BumpMajorCommand extends BaseCommand
{
/**
Expand All @@ -19,11 +23,7 @@ class BumpMajorCommand extends BaseCommand
*
* @var string
*/
protected $description = 'Bump MAJOR version (MAJOR.minor.patch => verison 1.0.0)';




protected $description = 'Bump MAJOR version (MAJOR.minor.patch => version 1.0.0)';

/**
* Execute the console command.
Expand All @@ -32,13 +32,9 @@ class BumpMajorCommand extends BaseCommand
*/
public function handle()
{

$oldVersion = $this->fileHelper->getVersion();

$newVersion = $this->bumper->bumpMajor($oldVersion)->get();

$this->fileHelper->setVersion($newVersion)->save();

$this->info('Bump from: '. $oldVersion.' to ' . $newVersion);
}

Expand Down
25 changes: 11 additions & 14 deletions src/Commands/BumpMinorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

/**
* Class BumpMinorCommand
*
* @package Talevskiigor\ComposerBump\Commands
*/
class BumpMinorCommand extends BaseCommand
{
/**
Expand All @@ -18,11 +23,7 @@ class BumpMinorCommand extends BaseCommand
*
* @var string
*/
protected $description = 'Bump MINOR version (major.MINOR.patch => verison 0.1.0)';




protected $description = 'Bump MINOR version (major.MINOR.patch => version 0.1.0)';

/**
* Execute the console command.
Expand All @@ -31,14 +32,10 @@ class BumpMinorCommand extends BaseCommand
*/
public function handle()
{

$oldVersion = $this->fileHelper->getVersion();

$newVersion = $this->bumper->bumpMinor($oldVersion)->get();

$this->fileHelper->setVersion($newVersion)->save();

$this->info('Bump from: '. $oldVersion.' to ' . $newVersion);
}
$oldVersion = $this->fileHelper->getVersion();
$newVersion = $this->bumper->bumpMinor($oldVersion)->get();
$this->fileHelper->setVersion($newVersion)->save();
$this->info('Bump from: ' . $oldVersion . ' to ' . $newVersion);
}

}
25 changes: 10 additions & 15 deletions src/Commands/BumpPatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

/**
* Class BumpPatchCommand
*
* @package Talevskiigor\ComposerBump\Commands
*/
class BumpPatchCommand extends BaseCommand
{
/**
Expand All @@ -20,26 +25,16 @@ class BumpPatchCommand extends BaseCommand
*/
protected $description = 'Increments PATCH version (major.minor.PATCH => verison 0.0.1)';





/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{

$oldVersion = $this->fileHelper->getVersion();

$newVersion = $this->bumper->bumpPatch($oldVersion)->get();

$this->fileHelper->setVersion($newVersion)->save();

$this->info('Bump from: '. $oldVersion.' to ' . $newVersion);
}


$oldVersion = $this->fileHelper->getVersion();
$newVersion = $this->bumper->bumpPatch($oldVersion)->get();
$this->fileHelper->setVersion($newVersion)->save();
$this->info('Bump from: ' . $oldVersion . ' to ' . $newVersion);
}
}
19 changes: 8 additions & 11 deletions src/Commands/UndoBumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

/**
* Class UndoBumpCommand
*
* @package Talevskiigor\ComposerBump\Commands
*/
class UndoBumpCommand extends BaseCommand
{
/**
Expand All @@ -20,29 +25,21 @@ class UndoBumpCommand extends BaseCommand
*/
protected $description = 'Restore last changes in the compose.json';





/**
* Execute the console command.
*
* @return mixed
* @throws \Exception
*/
public function handle()
{

$this->error(str_repeat('!!! WARNING !!!',3));
$this->error(' This will replace content of: composer.json file with content from file: composer.json-backup !!!');
if ($this->confirm('Are you suere? [y|N]')) {
$this->fileHelper->restoreBackupFile();
$this->info('Restored file: composer.json-backup into file: composer.json');
}else {
} else {
$this->info('Action was canceled.');
}


}


}
}
48 changes: 35 additions & 13 deletions src/ComposerBump.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
<?php
namespace Talevskiigor\ComposerBump;
<?php

class ComposerBump{
namespace Talevskiigor\ComposerBump;

public function __construct(){
$this->fileHelper = new \Talevskiigor\ComposerBump\Helpers\FileHelper();
}
/**
* Class ComposerBump
*
* @package Talevskiigor\ComposerBump
*/
class ComposerBump
{
/**
* ComposerBump constructor.
*/
public function __construct()
{
$this->fileHelper = new \Talevskiigor\ComposerBump\Helpers\FileHelper();
}

public function version(){
return $this->getVersion();
}
/**
* Get Version (alias)
*
* @return |null
*/
public function version()
{
return $this->getVersion();
}

public function getVersion(){
return $this->fileHelper->getVersion();
}
/**
* Get Version
*
* @return string|null
*/
public function getVersion()
{
return $this->fileHelper->getVersion();
}

}
}
18 changes: 7 additions & 11 deletions src/ComposerBumpServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php

namespace Talevskiigor\ComposerBump;

use Illuminate\Support\ServiceProvider;

/**
* Class ComposerBumpServiceProvider
*
* @package Talevskiigor\ComposerBump
*/
class ComposerBumpServiceProvider extends ServiceProvider
{


/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{

$this->mergeConfigFrom(
__DIR__ . '/config.php', 'ComposerBump'
);
Expand All @@ -32,21 +35,14 @@ public function boot()
*/
public function register()
{

$this->app->bind('ComposerBump', \Talevskiigor\ComposerBump\ComposerBump::class);

$this->registerBumpGenerator();

$this->registerBumpPatchGenerator();

$this->registerBumpMinorGenerator();

$this->registerBumpMajorGenerator();

$this->registerUndoBump();
}


private function registerBumpGenerator()
{
$this->app->singleton('bump.bump', function ($app) {
Expand Down Expand Up @@ -91,4 +87,4 @@ private function registerUndoBump()

$this->commands('bump.bump.undo');
}
}
}
Loading