diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6744b32cd53c2e38f602664e88253bb53043c92e --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +files/ +settings/ + +# Ignore directories generated by Composer +composer.lock +drush/contrib +vendor +web/core +web/modules/contrib +web/themes/contrib +web/profiles/contrib + +# Ignore Drupal's file directory +web/sites/*/settings.php +web/sites/*/files +web/sites/*/private + +# Ignore files generated by PhpStorm +.idea diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..98b121c7bbb8a5c968526c0d39802379a3b60c13 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,5 @@ +Deploy: + script: + - "apb deploy" + only: + - some-branch diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..5b9cb9f10bb53730f7358304bb86c99107e32bca --- /dev/null +++ b/composer.json @@ -0,0 +1,99 @@ +{ + "name": "drupal/d8-project", + "description": "Drupal 8 template for a composer based deployment workflow", + "type": "project", + "license": "GPL-2.0+", + "authors": [ + { + "name": "Jürgen Haas", + "role": "Drupal Expert" + }, + { + "name": "Richard Papp", + "role": "Drupal Expert" + } + ], + "repositories": [ + { + "type": "composer", + "url": "https://packages.drupal.org/8" + } + ], + "require": { + "composer/installers": "^1.0.20", + "drupal-composer/drupal-scaffold": "^2.0.1", + "cweagans/composer-patches": "~1.0", + "drupal/core": "8.1.2", + "drush/drush": "~8.0", + "drupal/console": "~0.10", + "drupal/address": "1.0-beta3", + "drupal/admin_toolbar": "1.15", + "drupal/browser_refresh": "1.0", + "drupal/coffee": "1.0-beta1", + "drupal/ctools": "3.0-alpha26", + "drupal/entity": "1.0-alpha3", + "drupal/node_view_permissions": "1.0", + "drupal/pathauto": "1.0-alpha3", + "drupal/piwik": "1.0", + "drupal/rules": "3.0-alpha1", + "drupal/smtp": "1.0-alpha0", + "drupal/video": "1.2", + "drupal/videojs": "1.0", + "drupal/metatag": "1.0.x-dev", + "drupal/slack": "1.0.x-dev", + "drupal/honeypot": "1.23", + "drupal/maillog": "1.0.x-dev" + }, + "require-dev": { + "behat/mink": "~1.7", + "behat/mink-goutte-driver": "~1.2", + "jcalderonzumba/gastonjs": "~1.0.2", + "jcalderonzumba/mink-phantomjs-driver": "~0.3.1", + "mikey179/vfsStream": "~1.2", + "phpunit/phpunit": "~4.8", + "symfony/css-selector": "~2.8" + }, + "conflict": { + "drupal/drupal": "*" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "classmap": [ + "scripts/composer/ScriptHandler.php" + ] + }, + "scripts": { + "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold", + "post-install-cmd": [ + "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" + ], + "post-update-cmd": [ + "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" + ] + }, + "extra": { + "installer-paths": { + "web/core": [ + "type:drupal-core" + ], + "web/modules/contrib/{$name}": [ + "type:drupal-module" + ], + "web/profiles/contrib/{$name}": [ + "type:drupal-profile" + ], + "web/themes/contrib/{$name}": [ + "type:drupal-theme" + ], + "drush/contrib/{$name}": [ + "type:drupal-drush" + ] + }, + "patches": { + "drupal/node_view_permissions": { + "Replace String with SafeMarkup class": "https://www.drupal.org/files/issues/node-view-permissions-php7-support-2683175-2.patch" + } + } + } +} diff --git a/config/default/live/.htaccess b/config/default/live/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..1238c0d2cb8915b364aaaaa198098010a1dc5fff --- /dev/null +++ b/config/default/live/.htaccess @@ -0,0 +1,23 @@ +# Deny all requests from Apache 2.4+. +<IfModule mod_authz_core.c> + Require all denied +</IfModule> + +# Deny all requests from Apache 2.0-2.2. +<IfModule !mod_authz_core.c> + Deny from all +</IfModule> +# Turn off all options we don't need. +Options -Indexes -ExecCGI -Includes -MultiViews + +# Set the catch-all handler to prevent scripts from being executed. +SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 +<Files *> + # Override the handler again if we're run later in the evaluation list. + SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 +</Files> + +# If we know how to do it safely, disable the PHP engine entirely. +<IfModule mod_php5.c> + php_flag engine off +</IfModule> \ No newline at end of file diff --git a/config/default/staging/.htaccess b/config/default/staging/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..1238c0d2cb8915b364aaaaa198098010a1dc5fff --- /dev/null +++ b/config/default/staging/.htaccess @@ -0,0 +1,23 @@ +# Deny all requests from Apache 2.4+. +<IfModule mod_authz_core.c> + Require all denied +</IfModule> + +# Deny all requests from Apache 2.0-2.2. +<IfModule !mod_authz_core.c> + Deny from all +</IfModule> +# Turn off all options we don't need. +Options -Indexes -ExecCGI -Includes -MultiViews + +# Set the catch-all handler to prevent scripts from being executed. +SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 +<Files *> + # Override the handler again if we're run later in the evaluation list. + SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 +</Files> + +# If we know how to do it safely, disable the PHP engine entirely. +<IfModule mod_php5.c> + php_flag engine off +</IfModule> \ No newline at end of file diff --git a/config/default/sync/.htaccess b/config/default/sync/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..1238c0d2cb8915b364aaaaa198098010a1dc5fff --- /dev/null +++ b/config/default/sync/.htaccess @@ -0,0 +1,23 @@ +# Deny all requests from Apache 2.4+. +<IfModule mod_authz_core.c> + Require all denied +</IfModule> + +# Deny all requests from Apache 2.0-2.2. +<IfModule !mod_authz_core.c> + Deny from all +</IfModule> +# Turn off all options we don't need. +Options -Indexes -ExecCGI -Includes -MultiViews + +# Set the catch-all handler to prevent scripts from being executed. +SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 +<Files *> + # Override the handler again if we're run later in the evaluation list. + SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 +</Files> + +# If we know how to do it safely, disable the PHP engine entirely. +<IfModule mod_php5.c> + php_flag engine off +</IfModule> \ No newline at end of file diff --git a/drush/README.md b/drush/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8c85c145d6dc6a11be19cd21fd1edb55aaad52c6 --- /dev/null +++ b/drush/README.md @@ -0,0 +1 @@ +This directory contains commands, configuration and site aliases for Drush. See http://packages.drush.org/ for a directory of Drush commands installable via Composer. diff --git a/drush/policy.drush.inc b/drush/policy.drush.inc new file mode 100644 index 0000000000000000000000000000000000000000..6a1242e5de1aa160a1ea2939d1e5efd359b90722 --- /dev/null +++ b/drush/policy.drush.inc @@ -0,0 +1,39 @@ +<?php + +/* + * Customize this file as desired. See https://github.com/drush-ops/drush/blob/8.x/examples/policy.drush.inc for documentation. + */ + +/** + * Implements drush_hook_COMMAND_validate(). + * + * Encourage folks to use `composer` instead of Drush pm commands + */ +function drush_policy_pm_updatecode_validate() { + return _deny_message(); +} + +function drush_policy_pm_update_validate() { + return _deny_message(); +} + +function drush_policy_pm_download_validate() { + return _deny_message(); +} + +function _deny_message() { + if (!drush_get_option('pm-force')) { + $msg = 'This codebase is assembled with Composer instead of Drush. Use `composer update` and `composer require` instead of `drush pm-updatecode` and `drush pm-download`. You may override this error by using the --pm-force option.'; + return drush_set_error('POLICY_PM_DENY', dt($msg)); + } +} + +/** + * Implements hook_drush_help_alter(). + */ +function policy_drush_help_alter(&$command) { + if (in_array($command['command'], array('pm-updatecode', 'pm-update', 'pm-download'))) { + $command['options']['pm-force'] = 'Override site policy and allow Drush codebase management (pm-* commands)'; + } +} + diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php new file mode 100644 index 0000000000000000000000000000000000000000..018f6a99c75770f5436caa237b8a4182cc6f1025 --- /dev/null +++ b/scripts/composer/ScriptHandler.php @@ -0,0 +1,60 @@ +<?php + +/** + * @file + * Contains \DrupalProject\composer\ScriptHandler. + */ + +namespace DrupalProject\composer; + +use Composer\Script\Event; +use Symfony\Component\Filesystem\Filesystem; + +class ScriptHandler { + + protected static function getDrupalRoot($project_root) { + return $project_root . '/web'; + } + + public static function createRequiredFiles(Event $event) { + $fs = new Filesystem(); + $root = static::getDrupalRoot(getcwd()); + + $dirs = [ + 'modules', + 'profiles', + 'themes', + ]; + + // Required for unit testing + foreach ($dirs as $dir) { + if (!$fs->exists($root . '/'. $dir)) { + $fs->mkdir($root . '/'. $dir); + $fs->touch($root . '/'. $dir . '/.gitkeep'); + } + } + + // Prepare the settings file for installation + if (!$fs->exists($root . '/sites/default/settings.php')) { + $fs->copy($root . '/sites/default/default.settings.php', $root . '/sites/default/settings.php'); + $fs->chmod($root . '/sites/default/settings.php', 0666); + $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666"); + } + + // Prepare the services file for installation + if (!$fs->exists($root . '/sites/default/services.yml')) { + $fs->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml'); + $fs->chmod($root . '/sites/default/services.yml', 0666); + $event->getIO()->write("Create a sites/default/services.yml file with chmod 0666"); + } + + // Create the files directory with chmod 0777 + if (!$fs->exists($root . '/sites/default/files')) { + $oldmask = umask(0); + $fs->mkdir($root . '/sites/default/files', 0777); + umask($oldmask); + $event->getIO()->write("Create a sites/default/files directory with chmod 0777"); + } + } + +}