diff --git a/README.md b/README.md index fb567f9..f7d723b 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,7 @@ DDEV integration for developing Drupal contrib projects. As a general philosophy - Remove underscores in the project name, or replace with hyphens. (DDEV will do this for you in v1.23.5+) - See [Misc](#misc) for help on using alternate versions of Drupal core. 5. Run `ddev get ddev/ddev-drupal-contrib` -6. Run `ddev start` -7. Run `ddev poser` -8. Run `ddev symlink-project` -9. `ddev config --update` to detect expected Drupal and PHP versions. -10. `ddev restart` +6. Run `ddev quickstart` ## Update @@ -26,6 +22,11 @@ Update by running the `ddev get ddev/ddev-drupal-contrib` command. ## Commands +This project provides the following DDEV host commands. + +- [ddev quickstart](commands/host/quickstart) + - Runs all necessary commands to get you up and running. + This project provides the following DDEV container commands. - [ddev poser](https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/poser). diff --git a/commands/host/quickstart b/commands/host/quickstart new file mode 100755 index 0000000..7feb0ed --- /dev/null +++ b/commands/host/quickstart @@ -0,0 +1,35 @@ +#!/bin/bash + +#ddev-generated +## Description: Quickstart command that setup the ddev-contrib-drupal addon for module development. +## Usage: quickstart +## Example: ddev quickstart + +set -e -o pipefail + +ddev restart +DDEV_DRUPAL_CORE=$(ddev exec 'echo "${DRUPAL_CORE/^/}"') + +# We have to do this check here, otherwise ddev poser will fail if the wrong PHP version for the wrong core is setup. +if [ "$DDEV_DRUPAL_CORE" -ge "11" ] ; then + echo -e "\033[0;33m[warning] Drupal ${DDEV_DRUPAL_CORE} requires PHP 8.3+, configuring and restarting ddev.\033[0m" + ddev config --php-version=8.3 + ddev restart +fi + +# Continue running all necessary commands +ddev poser +ddev mutagen sync +ddev symlink-project +ddev mutagen sync +cp .ddev/config.yaml .ddev/cmp.config.yaml +# Allow ddev to further change necessary defaults based on detected core. +ddev config --update +ddev mutagen sync +if ! ddev exec -- cmp -s .ddev/config.yaml .ddev/cmp.config.yaml > /dev/null 2>&1; then + echo -e "\033[0;33m[warning] config.yaml changed, restarting ddev.\033[0m" + ddev restart +fi +ddev exec -- rm .ddev/cmp.config.yaml +ddev exec "cd web/core && yarn install" +ddev mutagen sync diff --git a/install.yaml b/install.yaml index 4d69c1f..09f7b10 100644 --- a/install.yaml +++ b/install.yaml @@ -10,4 +10,5 @@ project_files: - commands/web/poser - commands/web/stylelint - commands/web/symlink-project + - commands/host/quickstart - config.contrib.yaml diff --git a/tests/full.bats b/tests/full-manual.bats similarity index 100% rename from tests/full.bats rename to tests/full-manual.bats diff --git a/tests/full-quickstart.bats b/tests/full-quickstart.bats new file mode 100644 index 0000000..44c89c0 --- /dev/null +++ b/tests/full-quickstart.bats @@ -0,0 +1,37 @@ +load helpers/bats-support/load.bash +load helpers/bats-assert/load.bash + +setup_file() { + if [ -n "$TEST_DRUPAL_CORE" ] && [ "$TEST_DRUPAL_CORE" != "10" ] && [ "$TEST_DRUPAL_CORE" != "11" ]; then + skip "TEST_DRUPAL_CORE=$TEST_DRUPAL_CORE not handled by this test suite" >&2 + fi + load '_common.bash' + _common_setup + ddev quickstart +} + +teardown_file() { + load '_common.bash' + _common_teardown +} + +@test "php tools availability" { + ddev phpcs --version + ddev phpstan --version + ddev phpunit --version +} + +@test "drupal core version" { + run -0 ddev exec 'drush st --fields=drupal-version --format=string | cut -d. -f1' + if [ -n "${TEST_DRUPAL_CORE}" ]; then + assert_output "${TEST_DRUPAL_CORE}" + else + DDEV_DRUPAL_CORE=$(ddev exec 'echo "${DRUPAL_CORE/^/}"') + assert_output "$DDEV_DRUPAL_CORE" + fi +} + +@test "node tools availability" { + ddev stylelint --version + ddev eslint --version +}