#!/bin/bash -x # Copyright 2016 Ludovic Pouzenc # Copyright 2016 Nicolas Goaziou # # This file is part of CHD Gestion. # # CHD Gestion is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # CHD Gestion is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CHD Gestion. If not, see . # this=$(readlink -f $0) src_dir=$(dirname $this) cd /var/www # Sauver la précédente fournée if [ -d chd_gestion ] then [ -d chd_gestion.bkp ] && rm -r chd_gestion.bkp/ mv chd_gestion chd_gestion.bkp fi # Installer un nouveau CakePHP ( http://book.cakephp.org/3.0/en/quickstart.html#getting-cakephp ) [ -f composer.phar ] || wget https://getcomposer.org/composer.phar mkdir chd_gestion cd chd_gestion || exit ln -s ../composer.phar # Personnaliser les dépendances (forcer CakePHP 3.1.10) cp -a "$src_dir/composer.json" . # Deployer un squellette d'appli (avec les dépendances) yes | php composer.phar create-project # Cakephp/app nous sert de base, mais a été installé comme dépendance à cause de l'utilisation du composer.json rsync -ai --exclude **/empty ./vendor/cakephp/app/ . # Ajouter PHPUnit ( http://book.cakephp.org/3.0/en/development/testing.html#installing-phpunit ) #php composer.phar require --dev phpunit/phpunit:5.* # Ajouter le plugin Search ( https://github.com/FriendsOfCake/search ) #php composer.phar require friendsofcake/search "dev-master" # Ajouter un theme pour altérer le comportement de bake (http://book.cakephp.org/3.0/en/bake/development.html#creating-a-bake-theme ) yes | bin/cake bake plugin CustomTheme # Paramétrer le français en langue par défaut ( http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#setting-the-default-locale ) sed --in-place -e "s/ini_set('intl.default_locale', '[^']*')/ini_set('intl.default_locale', 'fr_FR')/" config/bootstrap.php # Page d'accueil = Liste des adhérents (http://book.cakephp.org/3.0/en/development/routing.html#quick-tour ) sed --in-place -e "s#connect('/', [^)]\\+)#connect('/', ['controller' => 'Adherents', 'action' => 'index'])#" config/routes.php cat >> config/bootstrap.php <<"EOT" # Ajouter des pluriel irréguliers vu de la langue anglaise # http://book.cakephp.org/3.0/en/core-libraries/inflector.html#loading-custom-inflections Inflector::rules('uninflected', ['ipmgmt']); Inflector::rules('uninflected', ['relais']); Inflector::rules('irregular', ['interesse' => 'interesses']); # Ne pas afficher les heures par défaut use Cake\I18n\Time; Time::setToStringFormat([IntlDateFormatter::SHORT, -1]); EOT # Ajout des personnalisations qui s'expriment pas facilement dans un script rsync -ai "$src_dir/before-bake/" ./ # Génération de l'ensemble du CRUD ( http://book.cakephp.org/3.0/en/bake/usage.html ) for table in $(bin/cake bake all | sed -ne 's/^- \(.*\)$/\1/p' | grep -vE '^v_') do yes | bin/cake bake all --theme=CustomTheme $table done # Ecarsement de certains modèles générés rsync -aib --backup-dir=../src.orig "$src_dir/after-bake/src/" ./src/