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

@@ -0,0 +1,4 @@
<?php
return [
];

View File

@@ -0,0 +1,91 @@
<?php
namespace Modules\Updater\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 UpdateController extends Controller
{
private $migrationSvc;
private $seederSvc;
/**
* @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('updater::index-start');
}
/**
* Step 1. Check if there's an update available. Check if there
* are any unrun migrations
*
* @param Request $request
*
* @return mixed
*/
public function step1(Request $request)
{
$migrations = $this->migrationSvc->migrationsAvailable();
if (count($migrations) > 0) {
Log::info('No migrations found');
}
return view('updater::steps/step1-update-available');
}
/**
* Step 2 Run all of the migrations
*
* @param Request $request
*
* @return mixed
*/
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('updater::steps/step3-update-complete');
}
$output = $this->migrationSvc->runAllMigrations();
$this->seederSvc->syncAllSeeds();
return view('updater::steps/step2-migrations-done', [
'console_output' => $output,
]);
}
/**
* Final step
*
* @param Request $request
*
* @return mixed
*/
public function complete(Request $request)
{
return redirect('/login');
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Modules\Updater\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
class UpdateServiceProvider extends ServiceProvider
{
public function boot()
{
$this->registerRoutes();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
}
/**
* Register the routes
*/
protected function registerRoutes()
{
Route::group([
'as' => 'update.',
'prefix' => 'update',
'middleware' => ['web'],
'namespace' => 'Modules\Updater\Http\Controllers',
], function () {
Route::get('/', 'UpdateController@index')->name('index');
Route::get('/step1', 'UpdateController@step1')->name('step1');
Route::post('/step1', 'UpdateController@step1')->name('step1');
Route::post('/run-migrations', 'UpdateController@run_migrations')->name('run_migrations');
Route::get('/complete', 'UpdateController@complete')->name('complete');
});
}
/**
* Register config.
*/
protected function registerConfig()
{
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'updater');
}
/**
* Register views.
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/updater');
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath,
], 'views');
$paths = array_map(
function ($path) {
return $path.'/modules/updater';
},
\Config::get('view.paths')
);
$paths[] = $sourcePath;
$this->loadViewsFrom($paths, 'updater');
}
/**
* Register translations.
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/updater');
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'updater');
} else {
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'updater');
}
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
}

View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title') - updater</title>
<link rel="shortcut icon" type="image/png" href="{{ public_asset('/assets/img/favicon.png') }}"/>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
name='viewport'/>
<meta name="base-url" content="{!! url('') !!}">
<meta name="api-key" content="{!! Auth::check() ? Auth::user()->api_key: '' !!}">
<meta name="csrf-token" content="{!! csrf_token() !!}">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet"/>
<link href="{{ public_asset('/assets/frontend/css/bootstrap.min.css') }}" rel="stylesheet"/>
<link href="{{ public_asset('/assets/frontend/css/now-ui-kit.css') }}" rel="stylesheet"/>
<link href="{{ public_asset('/assets/installer/css/vendor.css') }}" rel="stylesheet"/>
<link href="{{ public_asset('/assets/frontend/css/styles.css') }}" rel="stylesheet"/>
<link rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<style>
.table tr:first-child td { border-top: 0px; }
@yield('css')
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-toggleable-md" style="background: #067ec1;">
<div class="container" style="width: 85%!important;">
<div class="navbar-translate">
<p class="navbar-brand text-white" data-placement="bottom" target="_blank">
<a href="{{ url('/') }}">
<img src="{{ public_asset('/assets/img/logo_blue_bg.svg') }}" width="135px" style=""/>
</a>
</p>
</div>
<div class="justify-content-center" id="navigation" style="margin-left: 50px; color: white; font-size: 20px;">
@yield('title')
</div>
</div>
</nav>
<!-- End Navbar -->
{{--<div class="clearfix" style="height: 25px;"></div>--}}
<div class="wrapper">
<div class="clear"></div>
<div class="container" style="width: 50%">
<div class="row">
<div class="col-12">
@include('installer::flash.message')
@yield('content')
</div>
</div>
</div>
<div class="clearfix" style="height: 200px;"></div>
</div>
{{--<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>--}}
<script src="{{ public_mix('/assets/global/js/vendor.js') }}"></script>
<script src="{{ public_mix('/assets/frontend/js/vendor.js') }}"></script>
<script src="{{ public_mix('/assets/frontend/js/app.js') }}"></script>
<script src="{{ public_asset('/assets/installer/js/vendor.js') }}" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>
hljs.configure({languages: ['sh']});
$(document).ready(function () {
$(".select2").select2();
$('pre code').each(function (i, block) {
hljs.fixMarkup(block);
hljs.highlightBlock(block);
});
});
</script>
@yield('scripts')
</body>
</html>

View File

@@ -0,0 +1,6 @@
@if($errors->has($field))
<p class="text-danger" style="margin-top: 10px;">{{ $errors->first($field) }}</p>
{{--<div class="alert alert-danger" role="alert" style="margin-top: 10px;">
{{ $errors->first($field) }}
</div>--}}
@endif

View File

@@ -0,0 +1,11 @@
@foreach (session('flash_notification', collect())->toArray() as $message)
<div class="alert alert-danger" role="alert">
<div class="container">
<div class="alert-icon">
<i class="now-ui-icons ui-2_like"></i>
</div>
{{ $message['message'] }}
</div>
</div>
@endforeach
{{ session()->forget('flash_notification') }}

View File

@@ -0,0 +1,12 @@
@extends('installer::app')
@section('title', 'Update phpVMS')
@section('content')
<h2>phpvms updater</h2>
<p>Press continue to check if there are any updates available.</p>
{{ Form::open(['route' => 'update.step1', 'method' => 'post']) }}
<p style="text-align: right">
{{ Form::submit('Start >>', ['class' => 'btn btn-success']) }}
</p>
{{ Form::close() }}
@endsection

View File

@@ -0,0 +1,13 @@
@extends('installer::app')
@section('title', 'Update phpVMS')
@section('content')
<h2>phpvms updater</h2>
<p>It seems like you're up to date!</p>
{{ Form::open(['route' => 'update.complete', 'method' => 'GET']) }}
<p style="text-align: right">
{{ Form::submit('Complete >>', ['class' => 'btn btn-success']) }}
</p>
{{ Form::close() }}
@endsection

View File

@@ -0,0 +1,12 @@
@extends('installer::app')
@section('title', 'Update phpVMS')
@section('content')
<h2>phpvms updater</h2>
<p>Click run to complete the update!.</p>
{{ Form::open(['route' => 'update.run_migrations', 'method' => 'post']) }}
<p style="text-align: right">
{{ Form::submit('Run >>', ['class' => 'btn btn-success']) }}
</p>
{{ Form::close() }}
@endsection

View File

@@ -0,0 +1,18 @@
@extends('installer::app')
@section('title', 'Update Completed')
@section('content')
<div style="align-content: center;">
{{ Form::open(['route' => 'update.complete', 'method' => 'GET']) }}
<pre class="lang-sh">
<code class="lang-sh">
{{ $console_output }}
</code>
</pre>
<p style="text-align: right">
{{ Form::submit('Complete >>', ['class' => 'btn btn-success']) }}
</p>
{{ Form::close() }}
</div>
@endsection

View File

@@ -0,0 +1,13 @@
@extends('installer::app')
@section('title', 'Update Completed')
@section('content')
<h2>phpvms updater</h2>
<p>Update completed!.</p>
{{ Form::open(['route' => 'update.complete', 'method' => 'GET']) }}
<p style="text-align: right">
{{ Form::submit('Finish >>', ['class' => 'btn btn-success']) }}
</p>
{{ Form::close() }}
@endsection

View File

@@ -0,0 +1,30 @@
{
"name": "phpvms/updater",
"license": "",
"type": "laravel-library",
"description": "The installer module for phpVMS",
"authors": [
{
"name": "Nabeel Shahzad",
"email": "nabeel@phpvms.net"
}
],
"require": {
"composer/installers": "~1.0"
},
"extra": {
"laravel": {
"providers": [
"Modules\\Updater\\Providers\\UpdateServiceProvider"
],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Installer\\": ""
}
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "Updater",
"alias": "updater",
"description": "",
"keywords": [],
"active": 1,
"order": 0,
"providers": [
"Modules\\Updater\\Providers\\UpdateServiceProvider"
],
"aliases": {},
"files": [],
"requires": []
}