Skip to content

Commit

Permalink
add update command
Browse files Browse the repository at this point in the history
  • Loading branch information
deeepak-panwar committed Feb 26, 2024
1 parent dfc6b45 commit b33791c
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
33 changes: 33 additions & 0 deletions publishable/database/seeds/EventmieDatabaseUpdateSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Seeder;
use Classiebit\Eventmie\Traits\Seedable;

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class EventmieDatabaseUpdateSeeder extends Seeder
{
use Seedable;

protected $seedersPath = __DIR__.'/';

/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
/* ===== ORDER IS IMPORTANT ===== */
/* ===== KEEP THE ORDER SAME ===== */
// update voyager tables
$this->seed('DataTypesTableSeeder');
$this->seed('DataRowsTableSeeder');
$this->seed('MenusTableSeeder');
$this->seed('MenuItemsTableSeeder');
$this->seed('PermissionsTableSeeder');
$this->seed('PermissionRoleTableSeeder');
$this->seed('SettingsTableSeeder');
}
}
110 changes: 110 additions & 0 deletions src/Commands/UpdateCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php

namespace Classiebit\Eventmie\Commands;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Intervention\Image\ImageServiceProviderLaravel5;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Process\Process;
use Classiebit\Eventmie\Traits\Seedable;
use Classiebit\Eventmie\EventmieServiceProvider;
use Facades\Classiebit\Eventmie\Eventmie;

use Illuminate\Support\Facades\File;

class UpdateCommand extends Command
{
use Seedable;

protected $seedersPath = __DIR__.'/../../publishable/database/seeds/';

/**
* The console command name.
*
* @var string
*/
protected $name = 'eventmie:update';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Eventmie Lite Updater';

protected function getOptions()
{
return [
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production', null],
];
}

/**
* Get the composer command for the environment.
*
* @return string
*/
protected function findComposer()
{
if (file_exists(getcwd().'/composer.phar')) {
return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar';
}

return 'composer';
}

public function fire(Filesystem $filesystem)
{
return $this->handle($filesystem);
}

/**
* Execute the console command.
*
* @param \Illuminate\Filesystem\Filesystem $filesystem
*
* @return void
*/
public function handle(Filesystem $filesystem)
{
$this->info('Initializing update process...');
$this->update($filesystem);
}

private function update(Filesystem $filesystem)
{
// ---- Check if everything good so far ----
$this->info('---- Dumping the autoloaded files and reloading all new files ----');
$composer = $this->findComposer();
$process = new Process([$composer.' dump-autoload']);
// Setting timeout to null to prevent installation from stopping at a certain point in time
$process->setTimeout(null);
$process->setWorkingDirectory(base_path())->run();

// 1. Run Eventmie migrations
$this->info('1. Migrating the Eventmie Lite database tables to update');
$this->call('migrate', ['--force' => $this->option('force')]);

// 2. Run database seeder
$this->info('2. Running Eventmie Lite database update seeders');
$this->seed('EventmieDatabaseUpdateSeeder');

// Copy missing extras folder's files to storage
$dir = str_replace('src/Commands', '', __DIR__);
File::copyDirectory($dir.'publishable/assets/ep_img/', public_path('/'));


// 3. Run cache clear commands
$this->info('3. Clearing application cache');
$this->call('config:clear');
$this->call('route:clear');
$this->call('view:clear');
$this->call('cache:clear');

// Finish
$version = Eventmie::getVersion();
$this->info("Congrats! Eventmie Lite successfully updated to version $version! Make sure to check Eventmie Pro FullyLoaded on our website- https://classiebit.com/eventmie-pro-fullyloaded");
}

}
2 changes: 2 additions & 0 deletions src/EventmieServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


use Classiebit\Eventmie\Commands\InstallCommand;
use Classiebit\Eventmie\Commands\UpdateCommand;

/* Bootstrap Pagination as default */
use Illuminate\Pagination\Paginator;
Expand Down Expand Up @@ -193,6 +194,7 @@ private function customVoyagerTheme()
private function registerConsoleCommands()
{
$this->commands(Commands\InstallCommand::class);
$this->commands(Commands\UpdateCommand::class);
}

/**
Expand Down

0 comments on commit b33791c

Please sign in to comment.