-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up self-update and rollback commands, box config, composer depend…
…encies, stub
- Loading branch information
1 parent
ac40a8a
commit 179765c
Showing
7 changed files
with
213 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php declare(string_types = 1); | ||
/** | ||
* @author hollodotme | ||
*/ | ||
|
||
namespace IceHawk\StaticPageGenerator; | ||
|
||
use IceHawk\StaticPageGenerator\ConsoleCommands\RollBack; | ||
use IceHawk\StaticPageGenerator\ConsoleCommands\SelfUpdate; | ||
use Symfony\Component\Console\Application; | ||
|
||
error_reporting( -1 ); | ||
ini_set( 'display_errors', 'On' ); | ||
|
||
require(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
define( 'PHAR_DIR', dirname( __DIR__ ) ); | ||
define( 'WORKING_DIR', getcwd() ); | ||
|
||
try | ||
{ | ||
$app = new Application( 'Static page generator', '@package_version@' ); | ||
$app->addCommands( | ||
[ | ||
new GenerateComponent( 'generate:component' ), | ||
new SelfUpdate( 'self-update' ), | ||
new RollBack( 'rollback' ), | ||
] | ||
); | ||
$code = $app->run(); | ||
exit($code); | ||
} | ||
catch ( \Throwable $e ) | ||
{ | ||
echo "Uncaught " . get_class( $e ) . " with message: " . $e->getMessage() . "\n"; | ||
echo $e->getTraceAsString(); | ||
exit(1); | ||
} |
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,31 @@ | ||
{ | ||
"chmod": "0755", | ||
"compression": "GZ", | ||
"compactors": [ | ||
"Herrera\\Box\\Compactor\\Php" | ||
], | ||
"directories": [ | ||
"src/" | ||
], | ||
"files": [ | ||
"LICENSE" | ||
], | ||
"finder": [ | ||
{ | ||
"name": "*.php", | ||
"exclude": [ | ||
"bin", | ||
"tm" | ||
], | ||
"in": "vendor" | ||
} | ||
], | ||
"extract": false, | ||
"git-version": "package_version", | ||
"intercept": true, | ||
"main": "bin/main.php", | ||
"metadata": "Static page generator", | ||
"output": "build/static-page-generator.phar", | ||
"shebang": "#!/usr/bin/env php", | ||
"stub": 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,49 @@ | ||
<?php declare(string_types = 1); | ||
/** | ||
* @author hollodotme | ||
*/ | ||
|
||
namespace IceHawk\StaticPageGenerator\ConsoleCommands; | ||
|
||
use Humbug\SelfUpdate\Strategy\GithubStrategy; | ||
use Humbug\SelfUpdate\Updater; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Logger\ConsoleLogger; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Class RollBack | ||
* @package IceHawk\StaticPageGenerator\ConsoleCommands | ||
*/ | ||
final class RollBack extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
$this->setDescription( 'Rolls back this PHAR to the previous version.' ); | ||
} | ||
|
||
protected function execute( InputInterface $input, OutputInterface $output ) | ||
{ | ||
$logger = new ConsoleLogger( $output ); | ||
$updater = new Updater( null, false, Updater::STRATEGY_GITHUB ); | ||
|
||
/** @var GithubStrategy $strategy */ | ||
$strategy = $updater->getStrategy(); | ||
|
||
$strategy->setPackageName( 'icehawk/static-page-generator' ); | ||
$strategy->setPharName( 'static-page-generator.phar' ); | ||
$strategy->setCurrentLocalVersion( '@package_version@' ); | ||
|
||
if ( $updater->rollback() ) | ||
{ | ||
$logger->info( 'Roll back successful!' ); | ||
} | ||
else | ||
{ | ||
$logger->alert( 'Roll back failed.' ); | ||
} | ||
|
||
return 0; | ||
} | ||
} |
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,77 @@ | ||
<?php declare(string_types = 1); | ||
/** | ||
* @author hollodotme | ||
*/ | ||
|
||
namespace IceHawk\StaticPageGenerator\ConsoleCommands; | ||
|
||
use Humbug\SelfUpdate\Strategy\GithubStrategy; | ||
use Humbug\SelfUpdate\Updater; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Logger\ConsoleLogger; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Class SelfUpdate | ||
* @package IceHawk\StaticPageGenerator\ConsoleCommands | ||
*/ | ||
final class SelfUpdate extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
$this->setAliases( [ 'selfupdate' ] ); | ||
$this->setDescription( 'Updates this PHAR to latest version.' ); | ||
|
||
$this->addOption( | ||
'stability', 's', InputOption::VALUE_OPTIONAL, | ||
sprintf( | ||
'Specify the stability (%s, %s or %s)', | ||
GithubStrategy::STABLE, | ||
GithubStrategy::UNSTABLE, | ||
GithubStrategy::ANY | ||
), | ||
GithubStrategy::STABLE | ||
); | ||
} | ||
|
||
protected function execute( InputInterface $input, OutputInterface $output ) | ||
{ | ||
$logger = new ConsoleLogger( $output ); | ||
$updater = new Updater( null, false, Updater::STRATEGY_GITHUB ); | ||
|
||
/** @var GithubStrategy $strategy */ | ||
$strategy = $updater->getStrategy(); | ||
|
||
$strategy->setPackageName( 'icehawk/static-page-generator' ); | ||
$strategy->setPharName( 'static-page-generator.phar' ); | ||
$strategy->setCurrentLocalVersion( '@package_version@' ); | ||
|
||
$stability = $input->getOption( 'stability' ); | ||
$strategy->setStability( $stability ); | ||
|
||
if ( $updater->hasUpdate() ) | ||
{ | ||
$newVersion = $updater->getNewVersion(); | ||
|
||
$logger->info( sprintf( 'The current stable version available is: %s', $newVersion ) ); | ||
$logger->info( 'Updating...' ); | ||
|
||
if ( $updater->update() ) | ||
{ | ||
$logger->info( sprintf( 'Successful! You now have version %s installed', $newVersion ) ); | ||
} | ||
} | ||
elseif ( false === $updater->getNewVersion() ) | ||
{ | ||
$logger->alert( 'There is no stable version available.' ); | ||
} | ||
else | ||
{ | ||
$logger->info( '@package_version@ is the latest stable version.' ); | ||
} | ||
|
||
return 0; | ||
} | ||
} |
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,15 +1,15 @@ | ||
<?php | ||
|
||
|
||
|
||
<?php declare(strict_types = 1); | ||
/** | ||
* @author hollodotme | ||
*/ | ||
|
||
namespace IceHawk\StaticPageGenerator\Exceptions; | ||
|
||
|
||
|
||
|
||
|
||
/** | ||
* Class StaticPageGeneratorException | ||
* @package IceHawk\StaticPageGenerator\Exceptions | ||
*/ | ||
class StaticPageGeneratorException extends \Exception | ||
{ | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.