diff --git a/.gitignore b/.gitignore index 6744b32cd53c2e38f602664e88253bb53043c92e..776258c7ed339ed4ffa30e19827743912917a40a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ web/themes/contrib web/profiles/contrib # Ignore Drupal's file directory +web/sites/*/services.yml web/sites/*/settings.php web/sites/*/files web/sites/*/private diff --git a/README.md b/README.md index be0d9fa66b1018a26f704eb0d3d681dd4a351f4f..8e1753d6f2cea7849035d6c86582a36138882683 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,11 @@ ``` composer create-project drupal/d8-project:dev-master DIRNAME --repository '{"type": "vcs","url": "git@gitlab.paragon-es.de:drupal/d8-project.git"}' --stability dev --no-interaction ``` + +# Links + +[Using Composer to install Drupal packages through Drupal.org](https://www.drupal.org/node/2718229) + +# Credit + +[Composer template for Drupal projects](https://github.com/drupal-composer/drupal-project) diff --git a/config/default/staging/.htaccess b/config/default/staging/.htaccess deleted file mode 100644 index 1238c0d2cb8915b364aaaaa198098010a1dc5fff..0000000000000000000000000000000000000000 --- a/config/default/staging/.htaccess +++ /dev/null @@ -1,23 +0,0 @@ -# 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 deleted file mode 100644 index 1238c0d2cb8915b364aaaaa198098010a1dc5fff..0000000000000000000000000000000000000000 --- a/config/default/sync/.htaccess +++ /dev/null @@ -1,23 +0,0 @@ -# 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/live/.htaccess b/scripts/boilerplate/.htaccess similarity index 100% rename from config/default/live/.htaccess rename to scripts/boilerplate/.htaccess diff --git a/scripts/boilerplate/template.services.yml b/scripts/boilerplate/template.services.yml new file mode 100644 index 0000000000000000000000000000000000000000..23f6483cc72f3f073f034f1bdcfab66cefea801b --- /dev/null +++ b/scripts/boilerplate/template.services.yml @@ -0,0 +1,155 @@ +parameters: + session.storage.options: + # Default ini options for sessions. + # + # Some distributions of Linux (most notably Debian) ship their PHP + # installations with garbage collection (gc) disabled. Since Drupal depends + # on PHP's garbage collection for clearing sessions, ensure that garbage + # collection occurs by using the most common settings. + # @default 1 + gc_probability: 1 + # @default 100 + gc_divisor: 100 + # + # Set session lifetime (in seconds), i.e. the time from the user's last + # visit to the active session may be deleted by the session garbage + # collector. When a session is deleted, authenticated users are logged out, + # and the contents of the user's $_SESSION variable is discarded. + # @default 200000 + gc_maxlifetime: 200000 + # + # Set session cookie lifetime (in seconds), i.e. the time from the session + # is created to the cookie expires, i.e. when the browser is expected to + # discard the cookie. The value 0 means "until the browser is closed". + # @default 2000000 + cookie_lifetime: 2000000 + # + # Drupal automatically generates a unique session cookie name based on the + # full domain name used to access the site. This mechanism is sufficient + # for most use-cases, including multi-site deployments. However, if it is + # desired that a session can be reused across different subdomains, the + # cookie domain needs to be set to the shared base domain. Doing so assures + # that users remain logged in as they cross between various subdomains. + # To maximize compatibility and normalize the behavior across user agents, + # the cookie domain should start with a dot. + # + # @default none + # cookie_domain: '.example.com' + # + twig.config: + # Twig debugging: + # + # When debugging is enabled: + # - The markup of each Twig template is surrounded by HTML comments that + # contain theming information, such as template file name suggestions. + # - Note that this debugging markup will cause automated tests that directly + # check rendered HTML to fail. When running automated tests, 'debug' + # should be set to FALSE. + # - The dump() function can be used in Twig templates to output information + # about template variables. + # - Twig templates are automatically recompiled whenever the source code + # changes (see auto_reload below). + # + # For more information about debugging Twig templates, see + # https://www.drupal.org/node/1906392. + # + # Not recommended in production environments + # @default false + debug: false + # Twig auto-reload: + # + # Automatically recompile Twig templates whenever the source code changes. + # If you don't provide a value for auto_reload, it will be determined + # based on the value of debug. + # + # Not recommended in production environments + # @default null + auto_reload: null + # Twig cache: + # + # By default, Twig templates will be compiled and stored in the filesystem + # to increase performance. Disabling the Twig cache will recompile the + # templates from source each time they are used. In most cases the + # auto_reload setting above should be enabled rather than disabling the + # Twig cache. + # + # Not recommended in production environments + # @default true + cache: true + renderer.config: + # Renderer required cache contexts: + # + # The Renderer will automatically associate these cache contexts with every + # render array, hence varying every render array by these cache contexts. + # + # @default ['languages:language_interface', 'theme', 'user.permissions'] + required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions'] + # Renderer automatic placeholdering conditions: + # + # Drupal allows portions of the page to be automatically deferred when + # rendering to improve cache performance. That is especially helpful for + # cache contexts that vary widely, such as the active user. On some sites + # those may be different, however, such as sites with only a handful of + # users. If you know what the high-cardinality cache contexts are for your + # site, specify those here. If you're not sure, the defaults are fairly safe + # in general. + # + # For more information about rendering optimizations see + # https://www.drupal.org/developing/api/8/render/arrays/cacheability#optimizing + auto_placeholder_conditions: + # Max-age at or below which caching is not considered worthwhile. + # + # Disable by setting to -1. + # + # @default 0 + max-age: 0 + # Cache contexts with a high cardinality. + # + # Disable by setting to []. + # + # @default ['session', 'user'] + contexts: ['session', 'user'] + # Tags with a high invalidation frequency. + # + # Disable by setting to []. + # + # @default [] + tags: [] + # Cacheability debugging: + # + # Responses with cacheability metadata (CacheableResponseInterface instances) + # get X-Drupal-Cache-Tags and X-Drupal-Cache-Contexts headers. + # + # For more information about debugging cacheable responses, see + # https://www.drupal.org/developing/api/8/response/cacheable-response-interface + # + # Not recommended in production environments + # @default false + http.response.debug_cacheability_headers: false + factory.keyvalue: + {} + # Default key/value storage service to use. + # @default keyvalue.database + # default: keyvalue.database + # Collection-specific overrides. + # state: keyvalue.database + factory.keyvalue.expirable: + {} + # Default key/value expirable storage service to use. + # @default keyvalue.database.expirable + # default: keyvalue.database.expirable + # Allowed protocols for URL generation. + filter_protocols: + - http + - https + - ftp + - news + - nntp + - tel + - telnet + - mailto + - irc + - ssh + - sftp + - webcal + - rtsp diff --git a/scripts/boilerplate/template.settings.php b/scripts/boilerplate/template.settings.php new file mode 100644 index 0000000000000000000000000000000000000000..85485e3ebfb5eee2397f38c2484a56d0168b4df6 --- /dev/null +++ b/scripts/boilerplate/template.settings.php @@ -0,0 +1,34 @@ +<?php + +$databases = array ( + 'default' => array ( + 'default' => array ( + 'driver' => 'mysql', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'database' => 'example', + 'username' => 'username', + 'password' => 'password', + 'host' => '127.0.0.1', + 'port' => '3306', + 'prefix' => '', + ), + ), +); + +$settings['update_free_access'] = FALSE; +$settings['container_yamls'][] = __DIR__ . '/services.yml'; +$settings['install_profile'] = 'standard'; +$settings['file_public_path'] = 'sites/default/files'; +$settings['file_private_path'] = 'sites/default/private'; +$settings['hash_salt'] = ''; +$settings['trusted_host_patterns'] = array( + '^www\.example\.com$', +); + +$config_directories['sync'] = 'sites/default/files/config/sync'; +$config_directories['staging'] = 'sites/default/files/config/staging'; +$config_directories['live'] = 'sites/default/files/config/live'; + +if (file_exists(__DIR__ . '/settings.local.php')) { + include __DIR__ . '/settings.local.php'; +} diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 018f6a99c75770f5436caa237b8a4182cc6f1025..faeff3c57a3c760c4a770becfc70e2ac9c7e835c 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -7,7 +7,6 @@ namespace DrupalProject\composer; -use Composer\Script\Event; use Symfony\Component\Filesystem\Filesystem; class ScriptHandler { @@ -16,45 +15,44 @@ class ScriptHandler { return $project_root . '/web'; } - public static function createRequiredFiles(Event $event) { + public static function createRequiredFiles() { $fs = new Filesystem(); - $root = static::getDrupalRoot(getcwd()); + $root = getcwd(); + $drupalRoot = static::getDrupalRoot($root); - $dirs = [ - 'modules', - 'profiles', - 'themes', - ]; + foreach (['modules', 'profiles', 'themes', ] as $dir) { + if (!$fs->exists($drupalRoot . '/'. $dir)) { + $fs->mkdir($drupalRoot . '/'. $dir); + $fs->touch($drupalRoot . '/'. $dir . '/.gitkeep'); + } + } - // Required for unit testing - foreach ($dirs as $dir) { + foreach (['config/default/live', 'config/default/staging', 'config/default/sync', 'settings/default', 'files/default/files', 'files/default/private', ] as $dir) { if (!$fs->exists($root . '/'. $dir)) { $fs->mkdir($root . '/'. $dir); - $fs->touch($root . '/'. $dir . '/.gitkeep'); + $fs->copy($root . '/scripts/boilerplate/.htaccess', $root . '/' . $dir); } } - // 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"); + foreach (['files', 'private', ] as $dir) { + if (!$fs->exists($drupalRoot . '/sites/default/' . $dir)) { + $fs->symlink($root . '/files/default/' . $dir, $drupalRoot . '/sites/default/' . $dir); + $fs->chmod($drupalRoot . '/sites/default/' . $dir, 0755); + } } - // 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"); + foreach (['settings.php', 'services.yml', ] as $template) { + if (!$fs->exists($drupalRoot . '/sites/default/' . $template)) { + $fs->copy($root . '/scripts/boilerplate/template.' . $template, $root . '/settings/default/' . $template); + $fs->symlink($root . '/settings/default/' . $template, $drupalRoot . '/sites/default/' . $template); + $fs->chmod($drupalRoot . '/sites/default/' . $template, 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"); + if (!$fs->exists($drupalRoot . '/sites/default/files/config')) { + $fs->symlink($root . '/config/default', $drupalRoot . '/sites/default/files/config'); } + } }