Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sparks committed Nov 9, 2017
0 parents commit 9886bc1
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Ignore directories generated by Composer
drush/contrib
vendor
bin
web/core
web/libraries
web/modules/contrib
web/themes/contrib
web/profiles/contrib

# Ignore Drupal's file directory
web/sites/default/files
private/*
tmp/*

# Ignore files generated by PhpStorm
.idea

# Ignore apple generated files
.DS_Store

# Ignore configuration files that may contain sensitive information.
web/sites/*/settings.local.php
web/sites/*/settings.devdesktop.php
web/sites/*/services*.yml

# Ignore paths that contain user-generated content.
web/sites/*/files
web/sites/*/private

# Ignore SimpleTest multi-site environment.
web/sites/simpletest

# Ignore Acquia Dev Desktop configs.
web/sites/*.dd
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Coming soon
72 changes: 72 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "sparksinteractive/sector-project",
"description": "Sparks Interactive: Sector Distribution. Built using drupal-project template.",
"type": "project",
"license": "GPL-2.0+",
"homepage": "https://www.sector.org.nz",
"authors": [
{
"name": "Sparks Interactive",
"role": "Development"
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"require": {
"sparksinteractive/sector-distribution": "~8.0",
"composer/installers": "^1.2",
"oomphinc/composer-installers-extender": "^1.1",
"drupal-composer/drupal-scaffold": "^2.2",
"cweagans/composer-patches": "~1.0",
"drupal/console": "~1.0"
},
"require-dev": {
"drush/drush": "9.0.0-beta7"
},
"conflict": {
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
]
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"pre-install-cmd": [
"Sector\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"Sector\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"Sector\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"Sector\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": [
"type:drupal-library"
],
"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"]
},
"patches": {
}
}
}
98 changes: 98 additions & 0 deletions scripts/composer/ScriptHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

/**
* @file
* Contains \Sector\composer\ScriptHandler.
*/

namespace Sector\composer;

use Composer\Script\Event;
use Composer\Semver\Comparator;
use Symfony\Component\Filesystem\Filesystem;

class ScriptHandler {

protected static function getDrupalRoot($project_root) {
return $project_root . '/web';
}

public static function createRequiredFiles(Event $event) {
$fs = new Filesystem();
$root = static::getDrupalRoot(getcwd());

$dirs = [
'modules',
'profiles',
'themes',
];

// Required for unit testing
foreach ($dirs as $dir) {
if (!$fs->exists($root . '/'. $dir)) {
$fs->mkdir($root . '/'. $dir);
$fs->touch($root . '/'. $dir . '/.gitkeep');
}
}

// Prepare the settings file for installation
if (!$fs->exists($root . '/sites/default/settings.php') and $fs->exists($root . '/sites/default/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");
}

// Prepare the services file for installation
if (!$fs->exists($root . '/sites/default/services.yml') and $fs->exists($root . '/sites/default/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");
}

// 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");
}
}

/**
* Checks if the installed version of Composer is compatible.
*
* Composer 1.0.0 and higher consider a `composer install` without having a
* lock file present as equal to `composer update`. We do not ship with a lock
* file to avoid merge conflicts downstream, meaning that if a project is
* installed with an older version of Composer the scaffolding of Drupal will
* not be triggered. We check this here instead of in drupal-scaffold to be
* able to give immediate feedback to the end user, rather than failing the
* installation after going through the lengthy process of compiling and
* downloading the Composer dependencies.
*
* @see https://github.com/composer/composer/pull/5035
*/
public static function checkComposerVersion(Event $event) {
$composer = $event->getComposer();
$io = $event->getIO();

$version = $composer::VERSION;

// The dev-channel of composer uses the git revision as version number,
// try to the branch alias instead.
if (preg_match('/^[0-9a-f]{40}$/i', $version)) {
$version = $composer::BRANCH_ALIAS_VERSION;
}

// If Composer is installed through git we have no easy way to determine if
// it is new enough, just display a warning.
if ($version === '@package_version@' || $version === '@package_branch_alias_version@') {
$io->writeError('<warning>You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.</warning>');
}
elseif (Comparator::lessThan($version, '1.0.0')) {
$io->writeError('<error>Drupal-project requires Composer version 1.0.0 or higher. Please update your Composer before continuing</error>.');
exit(1);
}
}

}

0 comments on commit 9886bc1

Please sign in to comment.