From 96ac446aa52f4032b841e478230dbf2b3e1c0eeb Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 8 Oct 2025 22:00:52 +0100 Subject: [PATCH] Update Drupal configuration files Signed-off-by: Oliver Davies --- drupal-cms/.gitignore | 44 ++++++++++++++++ drupal-cms/.tmux-sessionizer | 8 +++ drupal-cms/build | 8 +++ drupal-cms/build-configs.yaml | 6 +++ drupal-cms/clean | 11 ++++ drupal-cms/start | 5 ++ drupal-cms/tools/scripts/new-drupal-module | 29 +++++++++++ drupal-nix-flake/.gitignore | 5 +- drupal-nix-flake/clean | 11 ++++ drupal-nix-flake/start | 5 ++ .../tools/scripts/new-drupal-module | 29 +++++++++++ drupal/.envrc | 2 +- drupal/.gitignore | 51 ++++++++++++++++--- drupal/build-configs.yaml | 8 +++ drupal/clean | 11 ++++ drupal/flake.nix | 5 +- drupal/start | 5 ++ drupal/tools/scripts/new-drupal-module | 29 +++++++++++ drupal/web/modules/example/example.info.yml | 3 ++ .../web/modules/example/example.routing.yml | 7 +++ .../src/Controller/ExamplePageController.php | 17 +++++++ .../tests/src/Functional/ExampleTest.php | 24 +++++++++ 22 files changed, 309 insertions(+), 14 deletions(-) create mode 100644 drupal-cms/.gitignore create mode 100755 drupal-cms/.tmux-sessionizer create mode 100755 drupal-cms/build create mode 100644 drupal-cms/build-configs.yaml create mode 100755 drupal-cms/clean create mode 100755 drupal-cms/start create mode 100755 drupal-cms/tools/scripts/new-drupal-module create mode 100755 drupal-nix-flake/clean create mode 100755 drupal-nix-flake/start create mode 100755 drupal-nix-flake/tools/scripts/new-drupal-module create mode 100644 drupal/build-configs.yaml create mode 100755 drupal/clean create mode 100755 drupal/start create mode 100755 drupal/tools/scripts/new-drupal-module create mode 100644 drupal/web/modules/example/example.info.yml create mode 100644 drupal/web/modules/example/example.routing.yml create mode 100644 drupal/web/modules/example/src/Controller/ExamplePageController.php create mode 100644 drupal/web/modules/example/tests/src/Functional/ExampleTest.php diff --git a/drupal-cms/.gitignore b/drupal-cms/.gitignore new file mode 100644 index 0000000..237b194 --- /dev/null +++ b/drupal-cms/.gitignore @@ -0,0 +1,44 @@ +/.direnv/ +/.editorconfig +/.env +/.gitattributes +/.phpunit.result.cache +/bin/ +/data/ +/phpcs.xml +/phpunit.xml +/phpstan.neon +/recipes/README.txt +/vendor/ + +/web/.csslintrc +/web/.eslintignore +/web/.eslintrc.json +/web/.ht.router.php +/web/.htaccess +/web/INSTALL.txt +/web/README.md +/web/autoload.php +/web/core/ +/web/example.gitignore +/web/index.php +/web/libraries/ +/web/modules/README.txt +/web/modules/contrib/ +/web/profiles/ +/web/robots.txt +/web/sites/*/files/ +/web/sites/*/private/ +/web/sites/*/services*.yml +/web/sites/*/settings*.php +/web/sites/README.txt +/web/sites/default/default.services.yml +/web/sites/default/default.settings.php +/web/sites/development.services.yml +/web/sites/example.settings.local.php +/web/sites/example.sites.php +/web/sites/simpletest/ +/web/themes/README.txt +/web/themes/contrib/ +/web/update.php +/web/web.config diff --git a/drupal-cms/.tmux-sessionizer b/drupal-cms/.tmux-sessionizer new file mode 100755 index 0000000..255caa9 --- /dev/null +++ b/drupal-cms/.tmux-sessionizer @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +tmux new-window -dn scratch +tmux new-window -dn server + +tmux send-keys -t server "nix run" Enter + +nvim . diff --git a/drupal-cms/build b/drupal-cms/build new file mode 100755 index 0000000..76d2f0e --- /dev/null +++ b/drupal-cms/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -euo pipefail + +composer install +composer recipe:unpack + +php -S localhost:8888 -t web diff --git a/drupal-cms/build-configs.yaml b/drupal-cms/build-configs.yaml new file mode 100644 index 0000000..cc075ae --- /dev/null +++ b/drupal-cms/build-configs.yaml @@ -0,0 +1,6 @@ +--- +name: drupal-cms +template: php-drupal +parameters: + database: + name: drupal_cms diff --git a/drupal-cms/clean b/drupal-cms/clean new file mode 100755 index 0000000..169cf0b --- /dev/null +++ b/drupal-cms/clean @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +rm -rf \ + web/core \ + web/modules/contrib \ + web/profiles/contrib \ + web/themes/contrib \ + bin \ + vendor diff --git a/drupal-cms/start b/drupal-cms/start new file mode 100755 index 0000000..95bd344 --- /dev/null +++ b/drupal-cms/start @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +nix run "$@" diff --git a/drupal-cms/tools/scripts/new-drupal-module b/drupal-cms/tools/scripts/new-drupal-module new file mode 100755 index 0000000..29764d2 --- /dev/null +++ b/drupal-cms/tools/scripts/new-drupal-module @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +NAME="$1" + +DIR="web/modules/custom/$NAME" + +test -d "$DIR" && echo "Module $NAME already exists." && exit 1 + +DIRS=( + "$DIR/src" + "$DIR/tests/src" +) + +FILES=( + "$DIR/$NAME.info.yml" + "$DIR/$NAME.routing.yml" + "$DIR/$NAME.services.yml" + "$DIR/README.md" +) + +mkdir -p "${DIRS[@]}" + +touch "${FILES[@]}" + +echo "# $NAME" > "$DIR/README.md" + +echo "Created $DIR." diff --git a/drupal-nix-flake/.gitignore b/drupal-nix-flake/.gitignore index c0fe792..237b194 100644 --- a/drupal-nix-flake/.gitignore +++ b/drupal-nix-flake/.gitignore @@ -8,6 +8,7 @@ /phpcs.xml /phpunit.xml /phpstan.neon +/recipes/README.txt /vendor/ /web/.csslintrc @@ -21,10 +22,10 @@ /web/core/ /web/example.gitignore /web/index.php +/web/libraries/ /web/modules/README.txt /web/modules/contrib/ -/web/profiles/README.txt -/web/profiles/contrib/ +/web/profiles/ /web/robots.txt /web/sites/*/files/ /web/sites/*/private/ diff --git a/drupal-nix-flake/clean b/drupal-nix-flake/clean new file mode 100755 index 0000000..169cf0b --- /dev/null +++ b/drupal-nix-flake/clean @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +rm -rf \ + web/core \ + web/modules/contrib \ + web/profiles/contrib \ + web/themes/contrib \ + bin \ + vendor diff --git a/drupal-nix-flake/start b/drupal-nix-flake/start new file mode 100755 index 0000000..95bd344 --- /dev/null +++ b/drupal-nix-flake/start @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +nix run "$@" diff --git a/drupal-nix-flake/tools/scripts/new-drupal-module b/drupal-nix-flake/tools/scripts/new-drupal-module new file mode 100755 index 0000000..29764d2 --- /dev/null +++ b/drupal-nix-flake/tools/scripts/new-drupal-module @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +NAME="$1" + +DIR="web/modules/custom/$NAME" + +test -d "$DIR" && echo "Module $NAME already exists." && exit 1 + +DIRS=( + "$DIR/src" + "$DIR/tests/src" +) + +FILES=( + "$DIR/$NAME.info.yml" + "$DIR/$NAME.routing.yml" + "$DIR/$NAME.services.yml" + "$DIR/README.md" +) + +mkdir -p "${DIRS[@]}" + +touch "${FILES[@]}" + +echo "# $NAME" > "$DIR/README.md" + +echo "Created $DIR." diff --git a/drupal/.envrc b/drupal/.envrc index a5dbbcb..3550a30 100644 --- a/drupal/.envrc +++ b/drupal/.envrc @@ -1 +1 @@ -use flake . +use flake diff --git a/drupal/.gitignore b/drupal/.gitignore index 7171a80..237b194 100644 --- a/drupal/.gitignore +++ b/drupal/.gitignore @@ -1,7 +1,44 @@ -.editorconfig -.gitattributes -data/ -recipes/README.txt -vendor/ -web/ -web/core/ +/.direnv/ +/.editorconfig +/.env +/.gitattributes +/.phpunit.result.cache +/bin/ +/data/ +/phpcs.xml +/phpunit.xml +/phpstan.neon +/recipes/README.txt +/vendor/ + +/web/.csslintrc +/web/.eslintignore +/web/.eslintrc.json +/web/.ht.router.php +/web/.htaccess +/web/INSTALL.txt +/web/README.md +/web/autoload.php +/web/core/ +/web/example.gitignore +/web/index.php +/web/libraries/ +/web/modules/README.txt +/web/modules/contrib/ +/web/profiles/ +/web/robots.txt +/web/sites/*/files/ +/web/sites/*/private/ +/web/sites/*/services*.yml +/web/sites/*/settings*.php +/web/sites/README.txt +/web/sites/default/default.services.yml +/web/sites/default/default.settings.php +/web/sites/development.services.yml +/web/sites/example.settings.local.php +/web/sites/example.sites.php +/web/sites/simpletest/ +/web/themes/README.txt +/web/themes/contrib/ +/web/update.php +/web/web.config diff --git a/drupal/build-configs.yaml b/drupal/build-configs.yaml new file mode 100644 index 0000000..1705d6a --- /dev/null +++ b/drupal/build-configs.yaml @@ -0,0 +1,8 @@ +--- +name: drupal +template: php-drupal +parameters: + database: + name: drupal-lab + nix: + phpPackage: php83 diff --git a/drupal/clean b/drupal/clean new file mode 100755 index 0000000..169cf0b --- /dev/null +++ b/drupal/clean @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +rm -rf \ + web/core \ + web/modules/contrib \ + web/profiles/contrib \ + web/themes/contrib \ + bin \ + vendor diff --git a/drupal/flake.nix b/drupal/flake.nix index fb4cbf5..0974606 100644 --- a/drupal/flake.nix +++ b/drupal/flake.nix @@ -30,7 +30,6 @@ databasePort = 3306; webPort = 8000; - in with lib; { @@ -45,7 +44,7 @@ enable = true; initialDatabases = [ - { name = "drupal_nix_flake_example"; } + { name = "drupal-lab"; } ]; settings.mysqld.port = toString databasePort; @@ -75,8 +74,6 @@ phpPackages.composer ]; }; - - formatter = pkgs.nixfmt-rfc-style; }; }; } diff --git a/drupal/start b/drupal/start new file mode 100755 index 0000000..95bd344 --- /dev/null +++ b/drupal/start @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +nix run "$@" diff --git a/drupal/tools/scripts/new-drupal-module b/drupal/tools/scripts/new-drupal-module new file mode 100755 index 0000000..29764d2 --- /dev/null +++ b/drupal/tools/scripts/new-drupal-module @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +NAME="$1" + +DIR="web/modules/custom/$NAME" + +test -d "$DIR" && echo "Module $NAME already exists." && exit 1 + +DIRS=( + "$DIR/src" + "$DIR/tests/src" +) + +FILES=( + "$DIR/$NAME.info.yml" + "$DIR/$NAME.routing.yml" + "$DIR/$NAME.services.yml" + "$DIR/README.md" +) + +mkdir -p "${DIRS[@]}" + +touch "${FILES[@]}" + +echo "# $NAME" > "$DIR/README.md" + +echo "Created $DIR." diff --git a/drupal/web/modules/example/example.info.yml b/drupal/web/modules/example/example.info.yml new file mode 100644 index 0000000..45cf496 --- /dev/null +++ b/drupal/web/modules/example/example.info.yml @@ -0,0 +1,3 @@ +name: Example +type: module +core_version_requirement: ^11 diff --git a/drupal/web/modules/example/example.routing.yml b/drupal/web/modules/example/example.routing.yml new file mode 100644 index 0000000..82ce49d --- /dev/null +++ b/drupal/web/modules/example/example.routing.yml @@ -0,0 +1,7 @@ +example.page: + path: /example + defaults: + _controller: Drupal\example\Controller\ExamplePageController + methods: [GET] + requirements: + _permission: access content diff --git a/drupal/web/modules/example/src/Controller/ExamplePageController.php b/drupal/web/modules/example/src/Controller/ExamplePageController.php new file mode 100644 index 0000000..08b6043 --- /dev/null +++ b/drupal/web/modules/example/src/Controller/ExamplePageController.php @@ -0,0 +1,17 @@ + $this->t('This page is powered by Drupal and Nix.'), + ]; + } + +} diff --git a/drupal/web/modules/example/tests/src/Functional/ExampleTest.php b/drupal/web/modules/example/tests/src/Functional/ExampleTest.php new file mode 100644 index 0000000..bc230c9 --- /dev/null +++ b/drupal/web/modules/example/tests/src/Functional/ExampleTest.php @@ -0,0 +1,24 @@ +drupalGet('/example'); + + $assert = $this->assertSession(); + + $assert->statusCodeEquals(200); + $assert->pageTextContains('This page is powered by Drupal and Nix.'); + } +}