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

@@ -1,115 +0,0 @@
<?php
namespace Modules\Installer\Http\Controllers;
use App\Contracts\Controller;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Modules\Installer\Services\Importer\ImporterService;
class ImporterController extends Controller
{
private $importerSvc;
public function __construct(ImporterService $importerSvc)
{
$this->importerSvc = $importerSvc;
try {
app('debugbar')->disable();
} catch (BindingResolutionException $e) {
}
}
/**
* Show the main page for the importer; show form for the admin email
* and the credentials for the other database
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
try {
app('debugbar')->disable();
} catch (BindingResolutionException $e) {
}
return view('installer::importer/step1-configure');
}
/**
* The post from the above
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function config(Request $request)
{
try {
app('debugbar')->disable();
} catch (BindingResolutionException $e) {
}
try {
// Save the credentials to use later
$this->importerSvc->saveCredentialsFromRequest($request);
// Generate the import manifest
$manifest = $this->importerSvc->generateImportManifest();
} catch (\Exception $e) {
Log::error($e->getMessage());
// Send it to run, step1
return view('installer::importer/error', [
'error' => $e->getMessage(),
]);
}
// Send it to run, step1
return view('installer::importer/step2-processing', [
'manifest' => $manifest,
]);
}
/**
* Run the importer. Pass in query string with a few different parameters:
*
* stage=STAGE NAME
* start=record_start
*
* @param \Illuminate\Http\Request $request
*
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function run(Request $request)
{
try {
app('debugbar')->disable();
} catch (BindingResolutionException $e) {
}
$importer = $request->input('importer');
$start = $request->input('start');
Log::info('Starting stage '.$importer.' from offset '.$start);
$this->importerSvc->run($importer, $start);
return response()->json([
'message' => 'completed',
]);
}
/**
* Complete the import
*/
public function complete()
{
return redirect('/');
}
}

View File

@@ -7,18 +7,18 @@ use App\Facades\Utils;
use App\Models\User;
use App\Repositories\AirlineRepository;
use App\Services\AnalyticsService;
use App\Services\Installer\DatabaseService;
use App\Services\Installer\InstallerService;
use App\Services\Installer\MigrationService;
use App\Services\Installer\SeederService;
use App\Services\UserService;
use App\Support\Countries;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Modules\Installer\Services\ConfigService;
use Modules\Installer\Services\DatabaseService;
use Modules\Installer\Services\RequirementsService;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
@@ -64,10 +64,7 @@ class InstallerController extends Controller
$this->seederSvc = $seederSvc;
$this->userService = $userService;
try {
app('debugbar')->disable();
} catch (BindingResolutionException $e) {
}
\App\Support\Utils::disableDebugToolbar();
}
/**
@@ -109,7 +106,7 @@ class InstallerController extends Controller
$message = 'Failed! '.$e->getMessage();
}
return view('installer::flash/dbtest', [
return view('installer::install/dbtest', [
'status' => $status,
'message' => $message,
]);
@@ -354,6 +351,9 @@ class InstallerController extends Controller
*/
public function complete(Request $request)
{
$installerSvc = app(InstallerService::class);
$installerSvc->disableInstallerModules();
return redirect('/login');
}
}

View File

@@ -1,96 +0,0 @@
<?php
namespace Modules\Installer\Http\Controllers;
use App\Contracts\Controller;
use App\Services\Installer\MigrationService;
use App\Services\Installer\SeederService;
use function count;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
/**
* Class UpdaterController
*/
class UpdaterController extends Controller
{
private $migrationSvc;
private $seederSvc;
/**
* UpdaterController constructor.
*
* @param MigrationService $migrationSvc
* @param SeederService $seederSvc
*/
public function __construct(
MigrationService $migrationSvc,
SeederService $seederSvc
) {
$this->migrationSvc = $migrationSvc;
$this->seederSvc = $seederSvc;
}
/**
* Display a listing of the resource.
*/
public function index()
{
return view('installer::update/index-start');
}
/**
* Step 1. Check if there's an update available. Check if there
* are any unrun migrations
*
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function step1(Request $request)
{
$migrations = $this->migrationSvc->migrationsAvailable();
if (count($migrations) > 0) {
Log::info('No migrations found');
}
return view('installer::update/steps/step1-update-available');
}
/**
* Step 2 Run all of the migrations
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function run_migrations(Request $request)
{
Log::info('Update: run_migrations', $request->post());
$migrations = $this->migrationSvc->migrationsAvailable();
if (count($migrations) === 0) {
$this->seederSvc->syncAllSeeds();
return view('installer::update/steps/step3-update-complete');
}
$output = $this->migrationSvc->runAllMigrations();
$this->seederSvc->syncAllSeeds();
return view('installer::update/steps/step2-migrations-done', [
'console_output' => $output,
]);
}
/**
* Final step
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function complete(Request $request)
{
return redirect('/login');
}
}