From 232b703ee2a5f174c4a0e73c710fd74703afe885 Mon Sep 17 00:00:00 2001 From: Ariel Barreiro Date: Mon, 21 Oct 2024 14:37:00 -0300 Subject: [PATCH 1/4] feat: ddev quickstart command --- README.md | 11 +++---- commands/host/quickstart | 22 ++++++++++++++ install.yaml | 1 + tests/{full.bats => full-manual.bats} | 0 tests/full-quickstart.bats | 41 +++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 5 deletions(-) create mode 100755 commands/host/quickstart rename tests/{full.bats => full-manual.bats} (100%) create mode 100644 tests/full-quickstart.bats diff --git a/README.md b/README.md index fb567f9..eb9fae1 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` - automatically ## 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..76333ba --- /dev/null +++ b/commands/host/quickstart @@ -0,0 +1,22 @@ +#!/bin/bash + +## #ddev-generated +## Description: Quickstart command that setup the ddev-contrib-drupal addon for module development. +## Usage: quickstart +## Example: ddev quickstart + +ddev restart +ddev poser +ddev mutagen sync +ddev symlink-project +ddev mutagen sync +cp .ddev/config.yaml .ddev/cmp.config.yaml +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..d4f6140 --- /dev/null +++ b/tests/full-quickstart.bats @@ -0,0 +1,41 @@ +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 start +} + +teardown_file() { + load '_common.bash' + _common_teardown +} + +@test "ddev quickstart" { + ddev quickstart +} + +@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 +} From 6926f25f70557c3228f877b0c8105bc89fe61190 Mon Sep 17 00:00:00 2001 From: Ariel Barreiro Date: Mon, 21 Oct 2024 14:38:35 -0300 Subject: [PATCH 2/4] docs: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb9fae1..f7d723b 100644 --- a/README.md +++ b/README.md @@ -14,7 +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 quickstart` - automatically +6. Run `ddev quickstart` ## Update From 8c0fbb216c1f9a7166c3c110553673413e4a4a4f Mon Sep 17 00:00:00 2001 From: Ariel Barreiro Date: Mon, 21 Oct 2024 15:16:07 -0300 Subject: [PATCH 3/4] fix: automatically set php 8.3 for D11 --- commands/host/quickstart | 15 ++++++++++++++- tests/full-quickstart.bats | 6 +----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/commands/host/quickstart b/commands/host/quickstart index 76333ba..634a9ac 100755 --- a/commands/host/quickstart +++ b/commands/host/quickstart @@ -1,16 +1,29 @@ #!/bin/bash -## #ddev-generated +#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 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 diff --git a/tests/full-quickstart.bats b/tests/full-quickstart.bats index d4f6140..44c89c0 100644 --- a/tests/full-quickstart.bats +++ b/tests/full-quickstart.bats @@ -7,7 +7,7 @@ setup_file() { fi load '_common.bash' _common_setup - ddev start + ddev quickstart } teardown_file() { @@ -15,10 +15,6 @@ teardown_file() { _common_teardown } -@test "ddev quickstart" { - ddev quickstart -} - @test "php tools availability" { ddev phpcs --version ddev phpstan --version From 030410da5d61bcc2554d2166ef32f0c8ac98bac0 Mon Sep 17 00:00:00 2001 From: Ariel Barreiro Date: Mon, 21 Oct 2024 18:56:07 -0300 Subject: [PATCH 4/4] chore: typo --- commands/host/quickstart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/host/quickstart b/commands/host/quickstart index 634a9ac..7feb0ed 100755 --- a/commands/host/quickstart +++ b/commands/host/quickstart @@ -10,7 +10,7 @@ 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 if the wrong PHP version for the wrong core is setup. +# 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