Skip to content
Snippets Groups Projects
Commit 90ef4893 authored by jurgenhaas's avatar jurgenhaas
Browse files

Build initial functionality

parent 4db6a85c
No related branches found
No related tags found
No related merge requests found
...@@ -17,12 +17,9 @@ ...@@ -17,12 +17,9 @@
"source": "https://gitlab.lakedrops.com/composer/plugin/drupal-spoons/tree/master" "source": "https://gitlab.lakedrops.com/composer/plugin/drupal-spoons/tree/master"
}, },
"require": { "require": {
"php": ">=7", "php": ">=7.1",
"composer-plugin-api": "^1.0.0"
},
"require-dev": {
"composer/composer": "^1.10", "composer/composer": "^1.10",
"phpunit/phpunit": "^8.4" "composer-plugin-api": "^1.0.0"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
......
...@@ -4,6 +4,7 @@ namespace LakeDrops\DrupalSpoons; ...@@ -4,6 +4,7 @@ namespace LakeDrops\DrupalSpoons;
use Composer\Composer; use Composer\Composer;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Json\JsonFile;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
/** /**
...@@ -50,6 +51,30 @@ class Handler { ...@@ -50,6 +51,30 @@ class Handler {
// Directory where the root project is being created. // Directory where the root project is being created.
$projectRoot = getcwd(); $projectRoot = getcwd();
$full_name = $this->composer->getPackage()->getName();
[, $project_name] = explode('/', $full_name);
$moduleRoot = $projectRoot . "/web/modules/custom/$project_name";
// Prepare directory for current module.
if ($fs->exists($moduleRoot)) {
$fs->remove($moduleRoot);
}
$fs->mkdir($moduleRoot);
foreach (scandir($projectRoot) as $item) {
if (!in_array($item, ['.git', 'vemdor', 'web'])) {
$rel = $fs->makePathRelative($projectRoot, $moduleRoot);
$fs->symlink($rel, $moduleRoot . "/$item");
}
}
// Append DrupalSpoon related components to composer.json.
$jsonFile = new JsonFile($projectRoot . '/composer.json');
$content = [];
if ($jsonFile->exists()) {
$content = $jsonFile->read();
}
$content = array_merge_recursive($content, $options);
$jsonFile->write($content);
} }
/** /**
...@@ -61,6 +86,70 @@ class Handler { ...@@ -61,6 +86,70 @@ class Handler {
protected function getOptions(): array { protected function getOptions(): array {
$extra = $this->composer->getPackage()->getExtra() + ['drupalspoons' => []]; $extra = $this->composer->getPackage()->getExtra() + ['drupalspoons' => []];
return $extra['drupalspoons'] + [ return $extra['drupalspoons'] + [
'repositories' => [
[
'type' => 'composer',
'url' => 'https://packages.drupal.org/8',
],
],
'require_dev' => [
'composer/installers' => '^1',
'drupal/core-composer-scaffold' => '^8.8',
'cweagans/composer-patches' => '~1.0',
'drupal/core-recommended' => '^8.8',
'drupal/core-dev' => '^8.8',
'drush/drush' => '^10',
'mglaman/phpstan-drupal' => '^0.12',
'phpstan/phpstan-deprecation-rules' => '^0.12',
'php-parallel-lint/php-parallel-lint' => '^1.2',
'zaporylie/composer-drupal-optimizations' => '^1.0',
],
'scripts' => [
'si' => 'drush si -v --db-url=${SIMPLETEST_DB:-mysql://root:password@mariadb/db}',
'phpcs' => 'phpcs --runtime-set ignore_warnings_on_exit 1 --runtime-set ignore_errors_on_exit 1 web/modules/custom',
'lint' => 'parallel-lint --exclude web --exclude vendor .',
'webserver' => 'cd web && php -S 0.0.0.0:8888 .ht.router.php',
'chromedriver' => 'chromedriver --port=9515 --verbose --whitelisted-ips --log-path=/tmp/chromedriver.log --no-sandbox',
'unit' => 'phpunit --verbose web/modules/custom',
'phpstan' => 'phpstan analyse web/modules/custom',
'stylelint' => 'yarn --silent --cwd web/core stylelint --formatter verbose --config ./.stylelintrc.json ../modules/custom/**/*.css',
'eslint' => 'yarn --silent --cwd web/core eslint -c ./.eslintrc.json ../modules/custom',
],
'config' => [
'process-timeout' => 36000,
],
'extra' => [
'installer-paths' => [
'web/core' => [
0 => 'type:drupal-core',
],
'web/libraries/{$name}' => [
0 => 'type:drupal-library',
],
'web/modules/contrib/{$name}' => [
0 => 'type:drupal-module',
],
'web/profiles/{$name}' => [
0 => 'type:drupal-profile',
],
'web/themes/{$name}' => [
0 => 'type:drupal-theme',
],
'drush/{$name}' => [
0 => 'type:drupal-drush',
],
],
'drupal-scaffold' => [
'locations' => [
'web-root' => 'web/',
],
],
'drush' => [
'services' => [
'drush.services.yml' => '^9 || ^10',
],
],
],
]; ];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment