Skip to content

Commit f64c278

Browse files
committed
Cleaned up script stuff
1 parent 2fa532b commit f64c278

8 files changed

Lines changed: 62 additions & 53 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
vendor
3+
composer.lock
4+
*.cache

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea
12
vendor
23
composer.lock
34
*.cache

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
],
1212
"require": {
1313
"ext-dom": "*",
14+
"ext-xsl": "*",
1415
"drupal/system_stream_wrapper": "^2.1",
1516
"drush/drush": "^12 || ^13",
1617
"itk-dev/serviceplatformen": "dev-feature/SF2900-Fordelingskomponenten as 1.7.9999",
@@ -20,6 +21,7 @@
2021
"drupal/coder": "^8.3",
2122
"ergebnis/composer-normalize": "^2.50",
2223
"mglaman/phpstan-drupal": "^2.0",
24+
"palantirnet/drupal-rector": "^0.21.1",
2325
"phpstan/extension-installer": "^1.4",
2426
"phpunit/phpunit": "^9.6",
2527
"vincentlanglet/twig-cs-fixer": "^3.13"

rector.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
__DIR__ . '/src',
1515
// __DIR__ . '/tests',
1616
])
17+
->withSkip([
18+
__DIR__ . '/vendor',
19+
])
1720
->withSets([
1821
Drupal10SetList::DRUPAL_10,
1922
])

scripts/base

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -74,53 +74,9 @@ module_name=$(basename "$module_path")
7474
trap teardown EXIT
7575

7676
setup() {
77-
compose down --remove-orphans
78-
compose pull
79-
compose up --detach --remove-orphans --wait
80-
81-
# @todo Do this in a dockerfile.
82-
compose exec drupal sh -c 'apt update && apt --yes install git'
83-
84-
# Allow all plugins to run.
85-
composer --no-plugins config allow-plugins true
86-
composer --no-plugins config minimum-stability dev
87-
88-
composer --no-plugins config extra.drupal-lenient.allow-all --json true
89-
# composer --no-plugins config extra.drupal-lenient.allowed-list --json '[ "drupal/coc_forms_auto_export", "drupal/webform_node_element" ]'
90-
composer require mglaman/composer-drupal-lenient --with-all-dependencies
91-
92-
# --------------------------------------------------------------------------------------------------------------------
93-
# We need to install dev requirements from our module, so we use
94-
# wikimedia/composer-merge-plugin to merge our module composer.json into
95-
# Drupal's.
96-
#
97-
# wikimedia/composer-merge-plugin is dead and has some issues
98-
# https://github.com/wikimedia/composer-merge-plugin/issues/159 »
99-
# https://github.com/wikimedia/composer-merge-plugin/pull/253
100-
#
101-
# Install wikimedia/composer-merge-plugin without any configuration
102-
composer require wikimedia/composer-merge-plugin --with-all-dependencies
103-
# Patch to make COMPOSER_IGNORE_PLATFORM_REQS=1 have effect
104-
# https://github.com/wikimedia/composer-merge-plugin/pull/253
105-
shell sh -c 'cd vendor/wikimedia/composer-merge-plugin/ && curl https://patch-diff.githubusercontent.com/raw/wikimedia/composer-merge-plugin/pull/253.diff | patch --strip=1'
106-
107-
# Configure wikimedia/composer-merge-plugin
108-
composer --no-plugins config extra.merge-plugin.include "$module_path/composer.json"
109-
# Use --json to actually set a boolean value (rather that a string value, e.g. "true")
110-
composer --no-plugins config extra.merge-plugin.merge-extra --json true
111-
composer --no-plugins config extra.merge-plugin.merge-extra-deep --json true
112-
113-
composer update
114-
# Our module and its dev requirements are now installed.
115-
# --------------------------------------------------------------------------------------------------------------------
116-
117-
# Reset Drupal installation
118-
compose exec drupal sh -c 'find . -name .ht.sqlite -ls -delete; rm web/sites/default/settings.php' || true
119-
# Install a minimal Drupal site.
120-
drush --yes site:install --db-url='sqlite://sites/default/files/.ht.sqlite?module=sqlite' minimal -vvv
121-
122-
# Uncomment this line if you need to debug
123-
# shell bash
77+
# compose down --remove-orphans
78+
compose pull --ignore-buildable
79+
compose up --detach --remove-orphans --wait # --build
12480

12581
# Finally, install our module.
12682
drush --yes pm:install "$module_name"

scripts/code-analysis

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
66
cd "$script_dir"
77

88
execute() {
9-
composer require --dev symfony/phpunit-bridge
109
shell vendor/bin/phpstan --configuration="$module_path/phpstan.neon" --memory-limit=256M
1110
}
1211

scripts/compose.yaml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,52 @@
22

33
services:
44
drupal:
5-
image: drupal:${DRUPAL_VERSION:-10}-apache
5+
# image: drupal:${DRUPAL_VERSION:-10}-apache
6+
build:
7+
context: ../
8+
dockerfile_inline: |
9+
FROM drupal:${DRUPAL_VERSION:-10}-apache
10+
11+
COPY ./composer.json web/modules/${MODULE_NAME?}/
12+
13+
# https://github.com/docker-library/docs/blob/master/php/README.md#how-to-install-more-php-extensions
14+
RUN apt update && apt --yes install git libxml2-dev libxslt1-dev \
15+
&& docker-php-ext-configure soap \
16+
&& docker-php-ext-install soap \
17+
&& docker-php-ext-configure xsl \
18+
&& docker-php-ext-install xsl
19+
20+
# --------------------------------------------------------------------------------------------------------------------
21+
# We need to install dev requirements from our module, so we use
22+
# wikimedia/composer-merge-plugin to merge our module composer.json into
23+
# Drupal's.
24+
#
25+
# wikimedia/composer-merge-plugin is dead and has some issues
26+
# https://github.com/wikimedia/composer-merge-plugin/issues/159 »
27+
# https://github.com/wikimedia/composer-merge-plugin/pull/253
28+
RUN composer --no-plugins config allow-plugins true \
29+
&& composer --no-plugins config minimum-stability dev \
30+
# Use --json to actually set a boolean value (rather that a string value, e.g. "true")
31+
&& composer --no-plugins config extra.drupal-lenient.allow-all --json true \
32+
33+
# Configure wikimedia/composer-merge-plugin
34+
&& composer --no-plugins config extra.merge-plugin.merge-extra --json true \
35+
&& composer --no-plugins config extra.merge-plugin.merge-extra-deep --json true \
36+
&& composer --no-plugins config extra.merge-plugin.include "web/modules/${MODULE_NAME?}/composer.json" \
37+
&& composer require mglaman/composer-drupal-lenient wikimedia/composer-merge-plugin --with-all-dependencies
38+
39+
# Patch to make COMPOSER_IGNORE_PLATFORM_REQS=1 have effect
40+
# https://github.com/wikimedia/composer-merge-plugin/pull/253
41+
# RUN cd vendor/wikimedia/composer-merge-plugin/ && curl https://patch-diff.githubusercontent.com/raw/wikimedia/composer-merge-plugin/pull/253.diff | patch --strip=1
42+
43+
# Reset Drupal installation
44+
RUN find . -name .ht.sqlite -delete \
45+
&& find web/sites/default -name -delete
46+
47+
# Install a minimal Drupal site.
48+
# https://www.drush.org/13.x/commands/site_install/
49+
RUN drush --yes site:install --db-url=sqlite://sites/default/files/.ht.sqlite?module=sqlite minimal -vvv
50+
651
ports:
752
- 80
853
volumes:
@@ -13,10 +58,10 @@ services:
1358
# volume (which is what we're creating here) will be initialized with the
1459
# existing content of the image at the same location
1560
- /var/www/html/sites
16-
# Mount our code into the web/modules/contrib folder
17-
- ../:/opt/drupal/web/modules/contrib/$MODULE_NAME
61+
# Mount our code into the web/modules folder
62+
- ../:/opt/drupal/web/sites/default/modules/$MODULE_NAME
1863
environment:
1964
# Let the module path, i.e. the mounted path, be known in the container
20-
MODULE_PATH: web/modules/contrib/$MODULE_NAME
65+
MODULE_PATH: web/sites/default/modules/$MODULE_NAME
2166
# https://getcomposer.org/doc/03-cli.md#composer-ignore-platform-req-or-composer-ignore-platform-reqs
2267
COMPOSER_IGNORE_PLATFORM_REQS: 1

scripts/rector

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
66
cd "$script_dir"
77

88
execute() {
9-
composer require --dev palantirnet/drupal-rector
109
shell vendor/bin/rector --config="$module_path/rector.php"
1110
}
1211

0 commit comments

Comments
 (0)