FEATURE: make installation working again

This commit is contained in:
Michal Kváček
2016-09-20 23:06:42 +02:00
parent 5f8dab0068
commit 67cd7fb36f
9 changed files with 793 additions and 389 deletions
+1
View File
@@ -1,3 +1,4 @@
APP_KEY=
APP_ENV= APP_ENV=
APP_DEBUG= APP_DEBUG=
+1 -1
View File
@@ -63,7 +63,7 @@ class SetTemplate extends Command
} }
// theme written // theme written
$this->line('Template successfully setup.'); $this->line('Template successfully set up.');
$this->line(''); $this->line('');
$this->line(' ** PUBLISHING ASSETS AND VIEWS **'); $this->line(' ** PUBLISHING ASSETS AND VIEWS **');
// publish assets and views for module and theme // publish assets and views for module and theme
-6
View File
@@ -35,12 +35,6 @@
} }
}, },
"scripts": { "scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [ "post-install-cmd": [
"php artisan clear-compiled", "php artisan clear-compiled",
"php artisan optimize" "php artisan optimize"
+674 -326
View File
File diff suppressed because it is too large Load Diff
@@ -1,21 +0,0 @@
@extendVisitor('defaultLayout')
@section('content')
<h2>{{$page->title}}</h2>
<hr>
{!! $page->content !!}
<form action="{{route('comments.new', ['id' => $page->id])}}" method="post">
{!! csrf_field() !!}
<input type="text" name="name">
<input type="email" name="email">
<textarea name="message" id="" cols="30" rows="10">
</textarea>
<input type="submit">
</form>
@endsection
@@ -1 +0,0 @@
{{dd($page)}}
+96 -32
View File
@@ -1,4 +1,4 @@
#/bin/bash #!/bin/bash
if [ "$1" == "devel" ]; then if [ "$1" == "devel" ]; then
INSTALL_DEVEL=1 INSTALL_DEVEL=1
@@ -120,32 +120,93 @@ echo $WEBSITE_PARENT > $WEBSITE_PARENT_FILE
# setup permissions # setup permissions
chmod 0777 bootstrap/cache -R chmod 0777 bootstrap/cache -R
chmod 0777 storage -R chmod 0777 storage -R
chmod 0777 resources/views/visitor/$TEMPLATE_NAME -R chmod 0777 public -R
chmod 0777 modules/* chmod 0777 modules/*
chmod 0777 public/uploads -R chmod 0777 public/uploads -R
# copy settings if neccesarry
if [ ! -e .env ]; then
cp .env.example .env
# edit config
vim .env
fi
# create autoload files - no matter what
composer dump-autoload
# install dependencies - no matter what
if [ $INSTALL_DEVEL -eq 0 ]; then
composer install --no-dev
else
composer install
fi
# init database structure
if [ ! -e $DB_INITIALIZED_FILE ]; then if [ ! -e $DB_INITIALIZED_FILE ]; then
echo " --------------------------"
echo " * Database setup * "
echo ""
echo "MySQL host [localhost]: "
read MYSQL_HOST
if [ "$MYSQL_HOST" == "" ]; then
MYSQL_HOST="localhost"
fi
echo ""
echo "MySQL user:"
read MYSQL_USER
echo ""
echo "MySQL password:"
read MYSQL_PASSWORD
echo ""
echo "MySQL database (must exist and should be empty):"
read MYSQL_DATABASE
# copy settings if neccesarry
if [ ! -e .env ]; then
cp .env.example .env
sed -i -e s/SITE_URL=/SITE_URL=$WEBSITE_DOMAIN/ .env
sed -i -e s/UPLOAD_URL=/UPLOAD_URL=$WEBSITE_DOMAIN/ .env
echo ""
echo "Environment (production, development, testing, local):"
read ENVIRONMENT
if [ "$ENVIRONMENT" == "local" ]; then
INSTALL_DEVEL=1
fi
sed -i -e s/APP_ENV=/APP_ENV=$ENVIRONMENT/ .env
if [ "$ENVIRONMENT" != "production" ]; then
echo ""
echo "Turn on debugging? [y/N]"
read DEBUG_INPUT
else
DEBUG_INPUT="n"
fi
if [ "$DEBUG_INPUT" == "y" ]; then
sed -i -e s/APP_DEBUG=/APP_DEBUG=true/ .env
else
sed -i -e s/APP_DEBUG=/APP_DEBUG=false/ .env
fi
sed -i -e s/DB_HOST=/DB_HOST=$MYSQL_HOST/ .env
sed -i -e s/DB_USERNAME=/DB_USERNAME=$MYSQL_USER/ .env
sed -i -e s/DB_PASSWORD=/DB_PASSWORD=$MYSQL_PASSWORD/ .env
sed -i -e s/DB_DATABASE=/DB_DATABASE=$MYSQL_DATABASE/ .env
# review config
vim .env
fi
# init database structure
# init, migrate and seed database # init, migrate and seed database
php artisan db:init ./database/schema.sql && SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < $SCRIPT_PATH/../database/schema.sql
# create autoload files - no matter what
composer dump-autoload
# install dependencies - no matter what
if [ $INSTALL_DEVEL -eq 0 ]; then
composer install --no-dev
else
composer install
fi
php artisan migrate && php artisan migrate &&
php artisan db:seed && php artisan db:seed &&
touch $DB_INITIALIZED_FILE touch $DB_INITIALIZED_FILE
@@ -166,32 +227,35 @@ php artisan key:generate
if [ ! -e $THEME_SET_FILE ]; then if [ ! -e $THEME_SET_FILE ]; then
echo " --------------------------" echo " --------------------------"
echo " * Theme setup * " echo " * Template setup * "
echo "" echo ""
while [ "$THEME_NAME" == "" ]; do while [ "$THEME_NAME" == "" ]; do
echo ""
echo "Template name (use any of following): " echo "Template name (use any of following): "
for i in $(ls -d resources/views/visitor/*/); do for i in $(ls -d templates/*/ | grep -v Base); do
basename `echo ${i%%/}`; basename `echo ${i%%/}`;
done done
read THEME_NAME read THEME_NAME
if [ ! -d resources/views/visitor/$THEME_NAME ]; then if [ ! -d templates/$THEME_NAME ]; then
echo "Theme $THEME_NAME is not valid. Try again" echo "Theme $THEME_NAME is not valid. Try again"
THEME_NAME="" THEME_NAME=""
fi fi
done done
# setup theme # setup theme
php artisan theme:set $THEME_NAME php artisan template:set $THEME_NAME
# set write perms on published views php artisan vendor:publish --tag=module-views --force -n
for MODULE in `ls resources/views/modules`; do php artisan vendor:publish --tag=public-assets --force -n
chmod 0777 resources/views/modules/$MODULE/visitor/$THEME_NAME -R php artisan vendor:publish
done
# setup permissions on published directories
chmod 0777 public -R
chmod 0777 resources/views/visitor -R
chmod 0777 resources/views/modules -R
echo $THEME_NAME > $THEME_SET_FILE echo $THEME_NAME > $THEME_SET_FILE
fi fi
@@ -221,7 +285,7 @@ echo " -----------------------------------"
echo " * GIT BRANCH *" echo " * GIT BRANCH *"
echo "" echo ""
echo "Create new Git branch? (n for no)" echo "Create new Git branch? [y/n]"
read NEW_GIT_BRANCH read NEW_GIT_BRANCH
# create new branch in git # create new branch in git
+11 -2
View File
@@ -37,9 +37,18 @@ if [ ! $? -eq 0 ]; then
echo " *****************************" echo " *****************************"
exit 2 exit 2
fi fi
composer dump-autoload
php artisan migrate php artisan migrate --force -n
php artisan module:migrate --force -n
php artisan vendor:publish --tag=module-views --force -n php artisan vendor:publish --tag=module-views --force -n
php artisan vendor:publish --tag=public-assets --force -n php artisan vendor:publish --tag=public-assets --force -n
php artisan vendor:publish
composer install --no-dev composer install --no-dev
chmod 0777 bootstrap/cache -R
chmod 0777 storage -R
chmod 0777 modules/*
chmod 0777 public/uploads -R
chmod 0777 resources/views/visitor -R
chmod 0777 resources/views/modules -R
+10
View File
@@ -3,6 +3,7 @@ namespace Templates\Jednostrankovka;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Models\Content; use App\Models\Content;
use Illuminate\Support\Facades\Artisan;
use Templates\Base\OnePage\Handlers\OnePage; use Templates\Base\OnePage\Handlers\OnePage;
class Handler extends OnePage class Handler extends OnePage
@@ -37,6 +38,15 @@ class Handler extends OnePage
{ {
} }
public static function install()
{
try {
Artisan::call('install-module', ['name' => 'StaticPages']);
} catch (\Exception $e) {
//
}
}
/** /**
* Get list of registered templates and supported modules. * Get list of registered templates and supported modules.
* *