<repo_name>savaslabs/D8Default<file_sep>/Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "savas/trusty64"
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", 2048]
  end

  project = 'default'
  sitename = 'Default D8'

  config.vm.synced_folder ".", "/var/www/#{project}.dev", :nfs => true
  config.vm.hostname = "#{project}.dev"
  # SSH options.
  config.ssh.insert_key = false
  config.ssh.forward_agent  = true
  config.vm.network :private_network, ip: "192.168.88.96"
  
  # Creating the project directory and restarting apache...
  $script = <<SCRIPT
mkdir -p /var/www/#{project}.dev/www/web
sudo service apache2 restart
SCRIPT
  config.vm.provision "shell", inline: $script

  #Installing Drupal via Composer Template for Drupal Projects
  $script = <<SCRIPT
echo Installing Drupal Base Install...
cd /var/www/#{project}.dev
rmdir /var/www/#{project}.dev/www/web
composer create-project drupal-composer/drupal-project:8.x-dev www --stability dev --no-interaction
echo Downloading devel module...
cd /var/www/#{project}.dev/www
sudo service apache2 restart
composer require drupal/devel:8.*
cd /var/www/#{project}.dev/www/web 
mysql -u root -proot -e "create database drupal"
mysql -u root -proot -e "grant all on drupal.* to root@localhost identified by 'root'";
../vendor/bin/drush si -y --account-name=admin --account-pass=<PASSWORD> --db-su=root --db-su-pw=root --db-url=mysql://root:root@localhost/drupal --site-name=#{sitename}
../vendor/bin/drush en devel -y
mkdir -p modules/custom
mkdir -p themes/contrib
mkdir -p themes/custom
mkdir -p profiles/contrib
mkdir -p profiles/custom
touch modules/custom/README.md
touch themes/custom/README.md
touch profiles/custom/README.md
echo Creating drush symlink...
sudo ln -s /var/www/#{project}.dev/www/vendor/bin/drush /usr/local/bin/drush
SCRIPT
  config.vm.provision "shell", inline: $script
end
<file_sep>/README.md
# D8Default
This project is a starting point for a Drupal 8 base install managed with Composer.  This project installs D8 and the devel module from the https://github.com/drupal-composer/drupal-project.  Please consult the README in the drupal-composer/drupal-project for more details.

This repository assumes that you will be using a base VM box that is configured with a full lamp stack, has Composer installed, and all the testing tools that you will be utilizing (Selenium, NodeJS, etc.).  If not, then you will need to add provisioning to the Vagrantfile to add these items to your base box when you run "make init".

The following base boxes are configured as such:

* https://atlas.hashicorp.com/savas/boxes/trusty64 (`savas/trusty64`)

To use the repository, clone this repo, modify the Vagrantfile to change the name of the "project" and "sitename" variables located on lines 20-21, save the changes and run "make init".

You will need to add a new origin repository to your project; the "make init" process will remove any existing origin repo from your project on the initial build.

Use the README.md in your project for project documentation.

## Updating Drupal Core

To update Drupal Core, see https://github.com/drupal-composer/drupal-project#updating-drupal-core

## Adding contrib modules and committing custom code

Only custom modules, themes and profiles should be committed to the code repository.  The contrib modules should be added to the composer.json file.

To add a new contrib module to a project, change to the project directory where the project's composer.json file is located (usually inside the www directory), and issue the command `composer require drupal/<contrib-module-name>:8.*`. If you need to pin a specific module version, that can be added instead of the asterisk, which will update to the latest stable or recommended version.  `composer require` will update the composer.json and composer.lock files so make sure you commit both back to the project as part of your pull request.

The same goes for a base theme, or a base profile.

Only the modules/custom, themes/custom and profiles/custom directories will be committed to the code repository.

## Updating after an upstream merge / rebase
To update your project after an upstream merge or rebase so that your core and contrib modules are in sync with the project repository, issue the following command:

`composer install`

This will update your local installation based on the contents of the composer.lock file.
