Skip to content
Snippets Groups Projects
Commit a9f641fa authored by jurgenhaas's avatar jurgenhaas
Browse files

#3 Move setup tasks for new projects into a composer plugin

parent bc2615d1
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@
"composer/installers": "^1.0.20",
"drupal-composer/drupal-scaffold": "^2.0.1",
"cweagans/composer-patches": "~1.0",
"lakedrops/d8-project-scaffold": "dev-master",
"drupal/core": "8.1.7",
"drush/drush": "~8.0",
"drupal/console": "~0.10",
......@@ -64,29 +65,22 @@
},
"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",
"@preProcessTheme"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
"@preProcessTheme"
],
"preProcessTheme": [
"cd web/themes/custom/NAME && gulp css --env production"
]
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold"
},
"config": {
"discard-changes": true
},
"extra": {
"drupal-scaffold": {
"excludes": [
"sites/default/default.settings.php",
"sites/default/default.services.yml",
"sites/development.services.yml",
"sites/example.settings.local.php",
"sites/example.sites.php"
]
},
"installer-paths": {
"web/core": [
"type:drupal-core"
......
# 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
parameters:
session.storage.options:
gc_probability: 1
gc_divisor: 100
gc_maxlifetime: 200000
cookie_lifetime: 2000000
twig.config:
debug: false
auto_reload: null
cache: true
renderer.config:
required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions']
auto_placeholder_conditions:
max-age: 0
contexts: ['session', 'user']
tags: []
http.response.debug_cacheability_headers: false
factory.keyvalue:
{}
factory.keyvalue.expirable:
{}
filter_protocols:
- http
- https
- ftp
- news
- nntp
- tel
- telnet
- mailto
- irc
- ssh
- sftp
- webcal
- rtsp
<?php
assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$config['system.logging']['error_level'] = 'verbose';
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
# $settings['cache']['bins']['render'] = 'cache.backend.null';
# $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
$settings['extension_discovery_scan_tests'] = TRUE;
$settings['rebuild_access'] = TRUE;
$settings['skip_permissions_hardening'] = TRUE;
<?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';
}
<?php
/**
* @file
* Contains \DrupalProject\composer\ScriptHandler.
*/
namespace DrupalProject\composer;
use Symfony\Component\Filesystem\Filesystem;
class ScriptHandler {
protected static function getDrupalRoot($project_root) {
return $project_root . '/web';
}
public static function createRequiredFiles() {
$fs = new Filesystem();
$root = getcwd();
$drupalRoot = static::getDrupalRoot($root);
foreach (['modules', 'profiles', 'themes', ] as $dir) {
if (!$fs->exists($drupalRoot . '/'. $dir)) {
$fs->mkdir($drupalRoot . '/'. $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->copy($root . '/scripts/boilerplate/.htaccess', $root . '/' . $dir . '/.htaccess');
}
}
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);
}
}
foreach (['settings.php', 'services.yml', 'settings.local.php', ] 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);
}
}
if (!$fs->exists($drupalRoot . '/sites/default/files/config')) {
$fs->symlink($root . '/config/default', $drupalRoot . '/sites/default/files/config');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment