Added a one click deploy command
This commit is contained in:
9
.env.example.php
Normal file
9
.env.example.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'DB_DRIVER' => 'mysql',
|
||||
'DB_HOST' => 'localhost',
|
||||
'DB_DATABASE' => 'cachet',
|
||||
'DB_USERNAME' => 'homestead',
|
||||
'DB_PASSWORD' => 'secret',
|
||||
];
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@
|
||||
.env.php
|
||||
config.codekit
|
||||
!.env.heroku.php
|
||||
!.env.example.php
|
||||
|
||||
# Assets development
|
||||
/node_modules
|
||||
|
||||
@@ -127,6 +127,7 @@ return [
|
||||
|
||||
'CachetHQ\Cachet\Providers\RepositoryServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RoutingServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ConsoleServiceProvider',
|
||||
|
||||
],
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Artisan Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Each available Artisan command must be registered with the console so
|
||||
| that it is available to be called. We'll register every command so
|
||||
| the console gets access to each of the command object instances.
|
||||
|
|
||||
*/
|
||||
@@ -54,7 +54,7 @@
|
||||
"post-install-cmd": [
|
||||
"php artisan optimize",
|
||||
"chmod -R 755 app/storage",
|
||||
"php artisan migrate"
|
||||
"php artisan cachet:one-click-deploy"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"php artisan clear-compiled",
|
||||
|
||||
88
src/Commands/OneClickDeployCommand.php
Normal file
88
src/Commands/OneClickDeployCommand.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class OneClickDeployCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cachet:one-click-deploy';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Installs CachetHQ on one click supported services';
|
||||
|
||||
/**
|
||||
* Should we run the migrations?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $migrate;
|
||||
|
||||
/**
|
||||
* Create a new one click deploy command instance.
|
||||
*
|
||||
* @param bool $migrate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($migrate)
|
||||
{
|
||||
$this->migrate = $migrate;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ($this->migrate) {
|
||||
return $this->runMigrations();
|
||||
}
|
||||
|
||||
$this->info('Please run "php artisan migrate" to finish the installation.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
protected function runMigrations()
|
||||
{
|
||||
$options = [
|
||||
'--database' => $this->input->getOption('database'),
|
||||
'--force' => $this->input->getOption('force'),
|
||||
'--seed' => $this->input->getOption('seed'),
|
||||
];
|
||||
|
||||
return $this->call('migrate', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
|
||||
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
31
src/Providers/ConsoleServiceProvider.php
Normal file
31
src/Providers/ConsoleServiceProvider.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Commands\OneClickDeployCommand;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConsoleServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->commands('CachetHQ\Cachet\Commands\OneClickDeployCommand');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('CachetHQ\Cachet\Commands\OneClickDeployCommand', function ($app) {
|
||||
return new OneClickDeployCommand($app->environment('heroku'));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user