Split the importer module out from the installer module (#468)

* Split the importer module out from the installer module

* Cleanup of unused imports

* Move updater into separate module #453

* Remove unused imports/formatting

* Disable the install and importer modules at the end of the setup

* Unused imports; update IJ style

* test explicit stage for php+mysql

* add more to matrix

* Add different MariaDB versions

* undo
This commit is contained in:
Nabeel S
2019-12-12 15:07:35 -05:00
committed by GitHub
parent a58bca390b
commit e862537a20
64 changed files with 856 additions and 259 deletions

View File

@@ -6,7 +6,7 @@ namespace App\Contracts;
* @property mixed $id
* @property bool $skip_mutator
*
* @method static create(array $attrs)
* @method static Model create(array $attrs)
* @method static Model find(int $id)
* @method static Model select(array $array)
* @method static Model where(array $array)

View File

@@ -5,9 +5,6 @@ namespace App\Facades;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Facade;
/**
* Class Utils
*/
class Utils extends Facade
{
/**

View File

@@ -25,7 +25,7 @@ use App\Models\Subfleet;
use App\Models\User;
use App\Repositories\SettingRepository;
use App\Services\ModuleService;
use Illuminate\Contracts\Container\BindingResolutionException;
use App\Support\Utils;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
@@ -76,13 +76,10 @@ class AppServiceProvider extends ServiceProvider
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
try {
if (config('app.debug_toolbar') === true) {
app('debugbar')->enable();
} else {
app('debugbar')->disable();
}
} catch (BindingResolutionException $e) {
if (config('app.debug_toolbar') === true) {
Utils::enableDebugToolbar();
} else {
Utils::disableDebugToolbar();
}
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Services\Installer;
use App\Contracts\Service;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
use PDO;
class DatabaseService extends Service
{
/**
* Check the PHP version that it meets the minimum requirement
*
* @param $driver
* @param $host
* @param $port
* @param $name
* @param $user
* @param $pass
*
* @return bool
*/
public function checkDbConnection($driver, $host, $port, $name, $user, $pass)
{
Log::info('Testing Connection: '.$driver.'::'.$user.':<hidden>@'.$host.':'.$port.';'.$name);
// TODO: Needs testing
if ($driver === 'postgres') {
$dsn = "pgsql:host=$host;port=$port;dbname=$name";
try {
$conn = new PDO($dsn, $user, $pass);
} catch (\PDOException $e) {
throw $e;
}
return true;
}
// Default MySQL
$dsn = "mysql:host=$host;port=$port;dbname=$name";
Log::info('Connection string: '.$dsn);
try {
$conn = new PDO($dsn, $user, $pass);
} catch (\PDOException $e) {
throw $e;
}
return true;
}
/**
* Setup the database by running the migration commands
* Only run the setup for sqlite, otherwise, we're assuming
* that the MySQL database has already been created
*/
public function setupDB()
{
$output = '';
if (config('database.default') === 'sqlite') {
Artisan::call('database:create');
$output .= Artisan::output();
}
return trim($output);
}
}

View File

@@ -3,6 +3,7 @@
namespace App\Services\Installer;
use App\Contracts\Service;
use Nwidart\Modules\Facades\Module;
class InstallerService extends Service
{
@@ -36,4 +37,16 @@ class InstallerService extends Service
return false;
}
/**
* Disable the installer and importer modules
*/
public function disableInstallerModules()
{
$module = Module::find('installer');
$module->disable();
$module = Module::find('importer');
$module->disable();
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Services\Installer;
use Illuminate\Support\Facades\Log;
trait LoggerTrait
{
protected function comment($text)
{
Log::info($text);
}
protected function info($text)
{
Log::info($text);
}
protected function error($text)
{
Log::error($text);
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Support;
use Illuminate\Contracts\Container\BindingResolutionException;
use Nwidart\Modules\Facades\Module;
/**
@@ -9,6 +10,28 @@ use Nwidart\Modules\Facades\Module;
*/
class Utils
{
/**
* Enable the debug toolbar
*/
public static function enableDebugToolbar()
{
try {
app('debugbar')->enable();
} catch (BindingResolutionException $e) {
}
}
/**
* Disable the debug toolbar
*/
public static function disableDebugToolbar()
{
try {
app('debugbar')->disable();
} catch (BindingResolutionException $e) {
}
}
/**
* Is the installer enabled?
*