Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ddev quickstart command #87

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ 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

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).
Expand Down
35 changes: 35 additions & 0 deletions commands/host/quickstart
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ project_files:
- commands/web/poser
- commands/web/stylelint
- commands/web/symlink-project
- commands/host/quickstart
- config.contrib.yaml
File renamed without changes.
37 changes: 37 additions & 0 deletions tests/full-quickstart.bats
Original file line number Diff line number Diff line change
@@ -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
}