#!/bin/bash # Create a new Drupal project # # Copyright (C) 2017 Antonio Ospite # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e usage() { cat < Create a new Drupal project in the 'destdir' directory. Options: -h, --help display this usage message and exit EOF } while [ $# -gt 0 ]; do case "$1" in -h|--help) usage exit 0 ;; -*) echo "Error: Unknown option '${1}'" 1>&2 ;; *) break ;; esac shift done [ "x$1" = "x" ] && { usage 1>&2; exit 1; } [ -d "$1" ] && { echo "Aborting, project directory already exists." 1>&2; exit 1; } DESTDIR="$1" command -v composer &> /dev/null || { echo "Aborting, 'composer' not available." 1>&2; exit 1; } command -v git &> /dev/null || { echo "Aborting, 'git' not available." 1>&2; exit 1; } # Create a new project keeping the VCS metadata so it's easier to bring in # updates to drupal-composer/drupal-project itself. echo "Creating a new Drupal project..." composer create-project drupal-composer/drupal-project:8.x-dev@dev "$DESTDIR" --keep-vcs --stability dev --no-interaction pushd "$DESTDIR" git remote rename origin upstream git checkout -b master echo >> .gitignore echo "# Ignore the configuration for the bootstrap script" >> .gitignore echo "bootstrap.conf" >> .gitignore # Add some patches, use sed until composer can do that from the command line # (e.g. composer config ...) sed -i -e 's@"extra": {@"extra": {\ "patches-file": "composer.patches.json",@' composer.json cat > composer.patches.json < bootstrap.conf < .htaccess <