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

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
# Drupal editor configuration normalization
# @see http://editorconfig.org/
# This is the top-most .editorconfig file; do not search in parent directories.
root = true
# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{composer.json,composer.lock}]
indent_size = 4
.env 0 → 100644
PHP_VERSION=7.3
COMPOSE_PROJECT_NAME=spoons
vendor
composer.lock
# DrupalSpoons
This composer plugin prepares your Drupal project for CI and/or local tests.
{
"name": "lakedrops/drupal-spoons",
"description": "Composer Plugin to prepare Drupal project for CI and/or local tests.",
"type": "composer-plugin",
"homepage": "https://gitlab.lakedrops.com/composer/plugin/drupal-spoons",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Jürgen Haas",
"email": "juergen@paragon-es.de",
"homepage": "https://www.paragon-es.de",
"role": "Drupal Expert"
}
],
"support": {
"issues": "https://gitlab.lakedrops.com/composer/plugin/drupal-spoons/issues",
"source": "https://gitlab.lakedrops.com/composer/plugin/drupal-spoons/tree/master"
},
"require": {
"php": ">=7",
"composer-plugin-api": "^1.0.0"
},
"require-dev": {
"composer/composer": "^1.10",
"phpunit/phpunit": "^8.4"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"LakeDrops\\DrupalSpoons\\": "src/"
}
}
}
<?php
namespace LakeDrops\DrupalSpoons;
use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability;
use Composer\Command\BaseCommand;
class CommandProvider implements CommandProviderCapability {
/**
* Retrieves an array of commands
*
* @return BaseCommand[]
*/
public function getCommands(): array {
return [
new DrupalSpoonsCommand(),
];
}
}
<?php
namespace LakeDrops\DrupalSpoons;
use Composer\Command\BaseCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class DrupalSpoonsCommand extends BaseCommand {
/**
* {@inheritdoc}
*/
protected function configure() {
$this->setName('lakedrops:drupalspoons');
$this->setDescription('Prepare Drupal project for CI and/or local tests.');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$handler = new Handler($this->getComposer(), $this->getIO());
$handler->configureProject();
}
}
<?php
namespace LakeDrops\DrupalSpoons;
use Composer\Composer;
use Composer\IO\IOInterface;
use Symfony\Component\Filesystem\Filesystem;
/**
* Class Handler.
*
* @package LakeDrops\Behat4Drupal
*/
class Handler {
/**
* The composer object of this session.
*
* @var \Composer\Composer
*/
protected $composer;
/**
* The input-output object of the composer session.
*
* @var \Composer\IO\IOInterface
*/
protected $io;
/**
* Handler constructor.
*
* @param \Composer\Composer $composer
* The composer object of this session.
* @param \Composer\IO\IOInterface $io
* The input-output object of the composer session.
*/
public function __construct(Composer $composer, IOInterface $io) {
$this->composer = $composer;
$this->io = $io;
}
/**
* Configure Drupal project for CI and/or local tests.
*/
public function configureProject() {
$options = $this->getOptions();
$fs = new Filesystem();
$installationManager = $this->composer->getInstallationManager();
// Directory where the root project is being created.
$projectRoot = getcwd();
}
/**
* Retrieve configuration for this package.
*
* @return array
* The settings from the extra configuration.
*/
protected function getOptions(): array {
$extra = $this->composer->getPackage()->getExtra() + ['drupalspoons' => []];
return $extra['drupalspoons'] + [
];
}
}
<?php
namespace LakeDrops\DrupalSpoons;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\Capable;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
/**
* Composer plugin for handling drupal spoons.
*/
class Plugin implements PluginInterface, EventSubscriberInterface, Capable {
/**
* The handler object to do the real work then.
*
* @var \LakeDrops\DrupalSpoons\Handler
*/
protected $handler;
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io) {
$this->handler = new Handler($composer, $io);
}
/**
* {@inheritdoc}
*/
public function getCapabilities(): array {
return [
\Composer\Plugin\Capability\CommandProvider::class => CommandProvider::class,
];
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array {
return [
ScriptEvents::POST_INSTALL_CMD => 'configureProject',
ScriptEvents::POST_UPDATE_CMD => 'configureProject',
];
}
/**
* Post install and post update command event callback.
*
* @param \Composer\Script\Event $event
* The event that triggered the plugin.
*/
public function configureProject(Event $event) {
$this->handler->configureProject();
}
}
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