Skip to content

Commit

Permalink
Merge from upstream, fix scaffolding issue (#18)
Browse files Browse the repository at this point in the history
* Honor .env files and suggest usage (drupal-composer#351)

* Remove extra whitespace (drupal-composer#371)

* Updated argument name

* Bump minimal version

* Bump minimal version to 8.5.3

* Fix installer path for drush commandfiles.

* Composer lock from PHP 5.6

* Removing drupal-scaffold from the post-* commands
  • Loading branch information
dannylamb authored and seth-shaw-unlv committed May 29, 2018
1 parent 6dbbd1d commit 16c9bda
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .env.example
@@ -0,0 +1,27 @@
#
# Copy and rename this file to .env at root of this project.
#

# A common use case is to supply database creds via the environment. Edit settings.php
# like so:
#
# $databases['default']['default'] = [
# 'database' => getenv('MYSQL_DATABASE'),
# 'driver' => 'mysql',
# 'host' => getenv('MYSQL_HOSTNAME'),
# 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
# 'password' => getenv('MYSQL_PASSWORD'),
# 'port' => getenv('MYSQL_PORT'),
# 'prefix' => '',
# 'username' => getenv('MYSQL_USER'),
# ];
#
# Uncomment and populate as needed.
# MYSQL_DATABASE=
# MYSQL_HOSTNAME=
# MYSQL_PASSWORD=
# MYSQL_PORT=
# MYSQL_USER=

# Another common use case is to set Drush's --uri via environment.
# DRUSH_OPTIONS_URI=http://example.com
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -19,3 +19,6 @@

# Ignore files generated by PhpStorm
/.idea/

# Ignore .env files as they are personal
/.env
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/drupal-composer/drupal-project.svg?branch=8.x)](https://travis-ci.org/drupal-composer/drupal-project)

This project template should provide a kickstart for managing your site
This project template provides a starter kit for managing your site
dependencies with [Composer](https://getcomposer.org/).

If you want to know how to use it as replacement for
Expand Down Expand Up @@ -49,6 +49,7 @@ When installing the given `composer.json` some tasks are taken care of:
* Creates `web/sites/default/files`-directory.
* Latest version of drush is installed locally for use at `vendor/bin/drush`.
* Latest version of DrupalConsole is installed locally for use at `vendor/bin/drupal`.
* Creates environment variables based on your .env file. See [.env.example](.env.example).

## Updating Drupal Core

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Expand Up @@ -23,6 +23,7 @@
"drupal/console": "^1.0.2",
"drupal/core": "8.5.*",
"drush/drush": "^9.0.0",
"vlucas/phpdotenv": "^2.4",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3"
},
Expand All @@ -40,7 +41,8 @@
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
],
"files": ["load.environment.php"]
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
Expand All @@ -64,7 +66,7 @@
"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"]
"drush/Commands/{$name}": ["type:drupal-drush"]
}
}
}
52 changes: 51 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions drush/Commands/PolicyCommands.php
Expand Up @@ -19,7 +19,7 @@ class PolicyCommands extends DrushCommands {
* @throws \Exception
*/
public function sqlSyncValidate(CommandData $commandData) {
if ($commandData->input()->getArgument('destination') == '@prod') {
if ($commandData->input()->getArgument('target') == '@prod') {
throw new \Exception(dt('Per !file, you may never overwrite the production database.', ['!file' => __FILE__]));
}
}
Expand All @@ -32,7 +32,7 @@ public function sqlSyncValidate(CommandData $commandData) {
* @throws \Exception
*/
public function rsyncValidate(CommandData $commandData) {
if (preg_match("/^@prod/", $commandData->input()->getArgument('destination'))) {
if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) {
throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__]));
}
}
Expand Down
20 changes: 20 additions & 0 deletions load.environment.php
@@ -0,0 +1,20 @@
<?php

/**
* This file is included very early. See autoload.files in composer.json and
* https://getcomposer.org/doc/04-schema.md#files
*/

use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;

/**
* Load any .env file. See /.env.example.
*/
$dotenv = new Dotenv(__DIR__);
try {
$dotenv->load();
}
catch (InvalidPathException $e) {
// Do nothing. Production environments rarely use .env files.
}

0 comments on commit 16c9bda

Please sign in to comment.