Skip to content
Merged
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
19 changes: 19 additions & 0 deletions .ddev/addon-metadata/ddev-drupal-contrib/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ddev-drupal-contrib
repository: ddev/ddev-drupal-contrib
version: 1.1.4
install_date: "2025-10-07T15:03:13-07:00"
project_files:
- commands/host/core-version
- commands/web/eslint
- commands/web/expand-composer-json
- commands/web/nightwatch
- commands/web/phpcbf
- commands/web/phpcs
- commands/web/phpstan
- commands/web/phpunit
- commands/web/poser
- commands/web/stylelint
- commands/web/symlink-project
- config.contrib.yaml
global_files: []
removal_actions: []
22 changes: 22 additions & 0 deletions .ddev/commands/host/core-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Switch the core version and rebuild.
## Usage: core-version [version]
## Example: "ddev core-version ^11" or "ddev core-version ~11.1.0"

set -eu -o pipefail

# Handle default values.
DRUPAL_CORE=${1:-default}
if [ "$DRUPAL_CORE" == "default" ]; then
DRUPAL_CORE=""
fi

# Set/clear the env.
ddev dotenv set .ddev/.env.web --drupal-core "${DRUPAL_CORE}"

# Restart and rebuild.
ddev restart
ddev poser
22 changes: 22 additions & 0 deletions .ddev/commands/web/eslint
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run eslint inside the web container
## Usage: eslint [flags] [args]
## Example: "ddev eslint"
## ExecRaw: true

set -eu -o pipefail

if "$DDEV_DOCROOT/core/node_modules/.bin/eslint" --version >/dev/null ; then
# Configure prettier
test -e .prettierrc.json || ln -s $DDEV_DOCROOT/core/.prettierrc.json .
test -e .prettierignore || echo '*.yml' > .prettierignore
# Change directory to the project root folder
cd "$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/${DDEV_SITENAME//-/_}" || exit
"$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/node_modules/.bin/eslint" --config="../../../core/.eslintrc.passing.json" --no-error-on-unmatched-pattern --ignore-pattern="*.es6.js" --resolve-plugins-relative-to=$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core --ext=.js,.yml . "$@"
else
echo "eslint is not available. You may need to 'ddev exec \"cd $DDEV_DOCROOT/core && yarn install\"'"
exit 1
fi
28 changes: 28 additions & 0 deletions .ddev/commands/web/expand-composer-json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Add Drupal core and other needed dependencies.
## Usage: expand-composer-json [flags] [PROJECT_NAME]
## Example: "ddev expand-composer-json ctools"
## ExecRaw: true
## MutagenSync: true

set -eu -o pipefail

# Set the default core version.
export DRUPAL_CORE=${DRUPAL_CORE:-^11}

export _WEB_ROOT=$DDEV_DOCROOT
cd "$DDEV_COMPOSER_ROOT" || exit
curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/scripts/expand_composer_json.php
_ddev_drupal_contrib_empty_composer=false
if [[ ! -f composer.json ]]; then
echo "{}" > composer.json
_ddev_drupal_contrib_empty_composer=true
fi
php expand_composer_json.php "$DDEV_SITENAME"
rm -f expand_composer_json.php
if [ "$_ddev_drupal_contrib_empty_composer" = true ]; then
rm -f composer.json
fi
9 changes: 9 additions & 0 deletions .ddev/commands/web/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

## Description: Install Drupal and enable the module
## Usage: install
## Example: "ddev install"

vendor/bin/drush site:install --yes
vendor/bin/drush pm:enable ubc_cwl_auth --yes
vendor/bin/drush user:password admin admin --yes
12 changes: 12 additions & 0 deletions .ddev/commands/web/nightwatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run nightwatch inside the web container
## Usage: nightwatch [flags] [args]
## Example: "ddev nightwatch"
## ExecRaw: true

set -eu -o pipefail

yarn --cwd "$DDEV_DOCROOT/core" test:nightwatch "$DDEV_APPROOT/$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/" "$@"
17 changes: 17 additions & 0 deletions .ddev/commands/web/phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run phpcbf inside the web container
## Usage: phpcbf [flags] [args]
## Example: "ddev phpcbf" or "ddev phpcbf -n"
## ExecRaw: true

set -eu -o pipefail

if ! command -v phpcbf >/dev/null; then
echo "phpcbf is not available. You may need to 'ddev composer install'"
exit 1
fi
test -e phpcs.xml.dist || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpcs.xml.dist
phpcbf -s --report-full --report-summary --report-source $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH "$@"
17 changes: 17 additions & 0 deletions .ddev/commands/web/phpcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run phpcs inside the web container
## Usage: phpcs [flags] [args]
## Example: "ddev phpcs" or "ddev phpcs -n"
## ExecRaw: true

set -eu -o pipefail

if ! command -v phpcs >/dev/null; then
echo "phpcs is not available. You may need to 'ddev composer install'"
exit 1
fi
test -e phpcs.xml.dist || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpcs.xml.dist
phpcs -s --report-full --report-summary --report-source $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH --ignore=*/.ddev/* "$@"
28 changes: 28 additions & 0 deletions .ddev/commands/web/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run phpstan inside the web container
## Usage: phpstan [flags] [args]
## Example: "ddev phpstan" or "ddev phpstan -n"
## ExecRaw: true
## MutagenSync: true

set -eu -o pipefail

if ! command -v phpstan >/dev/null; then
echo "phpstan is not available. You may need to 'ddev poser'"
exit 1
fi
test -e phpstan.neon || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpstan.neon
# See https://git.drupalcode.org/project/gitlab_templates/-/commit/a107b7f1f79af12e0b09f70be47b68e3f69b4504
sed -i 's/BASELINE_PLACEHOLDER/phpstan-baseline.neon/g' phpstan.neon
# Add an empty baseline file to ensure it exists.
test -e phpstan-baseline.neon || touch phpstan-baseline.neon

EXTENSION_DIRECTORY=$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/${DDEV_SITENAME//-/_}
cd "$EXTENSION_DIRECTORY" || exit 1
# Ensure PHPStan configuration is symlinked from project root.
ln -s $DDEV_DOCROOT/phpstan.neon 2>/dev/null || true
ln -s $DDEV_DOCROOT/phpstan-baseline.neon 2>/dev/null || true
phpstan analyze . "$@"
33 changes: 33 additions & 0 deletions .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run phpunit inside the web container
## Usage: phpunit [flags] [args]
## Example: "ddev phpunit" or "ddev phpunit --stop-on-failure"
## Example: "ddev phpunit web/modules/custom/mymodule/tests/src/Unit/MyTest.php"
## Example: "ddev phpunit --filter testMyFunction"
## ExecRaw: true

set -eu -o pipefail

if ! command -v phpunit >/dev/null; then
echo "phpunit is not available. You may need to 'ddev composer install'"
exit 1
fi

# CHECK for local config.
if [ -f "phpunit.xml" ]; then
# Defer to local config
phpunit "$@"
else
# Check if we are running a specific test or test folder.
if [ $# -gt 0 ] && [ -e "$1" ]; then
TEST_PATH="$1"
shift
phpunit --bootstrap $PWD/$DDEV_DOCROOT/core/tests/bootstrap.php "$TEST_PATH" "$@"
else
# Run all custom module tests.
phpunit --bootstrap $PWD/$DDEV_DOCROOT/core/tests/bootstrap.php $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH "$@"
fi
fi
18 changes: 18 additions & 0 deletions .ddev/commands/web/poser
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Expand composer.json and run composer install.
## Usage: poser [flags] [args]
## Example: "ddev poser" or "ddev poser --prefer-source"
## ExecRaw: true
## MutagenSync: true

set -eu -o pipefail

export COMPOSER=composer.contrib.json
.ddev/commands/web/expand-composer-json
composer install "$@"
# The -f flag suppresses errors if lock file does not exist.
rm -f composer.contrib.json composer.contrib.lock
touch $DDEV_DOCROOT/core/.env
21 changes: 21 additions & 0 deletions .ddev/commands/web/stylelint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run stylelint inside the web container
## Usage: stylelint [flags] [args]
## Example: "ddev stylelint"
## ExecRaw: true

set -eu -o pipefail

if "$DDEV_DOCROOT/core/node_modules/.bin/stylelint" --version >/dev/null ; then
# Configure prettier
test -e .prettierrc.json || ln -s $DDEV_DOCROOT/core/.prettierrc.json .
# Change directory to the project root folder
cd "$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/${DDEV_SITENAME//-/_}" || exit
"$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/node_modules/.bin/stylelint" --color --config "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/.stylelintrc.json" "./**/*.css" "$@"
else
echo "stylelint is not available. You may need to 'ddev exec \"cd $DDEV_DOCROOT/core && yarn install\"'"
exit 1
fi
23 changes: 23 additions & 0 deletions .ddev/commands/web/symlink-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Symlink project files into the configured location (defaults to `web/modules/custom/[PROJECT_NAME]`)
## Usage: symlink-project [flags] [args]
## Example: "ddev symlink-project"
## ExecRaw: true

set -eu -o pipefail

export _WEB_ROOT=$DDEV_DOCROOT
#todo use more dynamic ref.
cd "$DDEV_COMPOSER_ROOT" || exit
curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/scripts/symlink_project.php

# Suppress a warning.
PROJECT_FILES=$(ls -A --ignore="web" --ignore="vendor" --ignore="symlink_project.php" --ignore=".ddev" --ignore=".idea")
export PROJECT_FILES
# Symlink name using underscores.
# @see https://www.drupal.org/docs/develop/creating-modules/naming-and-placing-your-drupal-module
php symlink_project.php "${DDEV_SITENAME//-/_}"
rm -f symlink_project.php
24 changes: 24 additions & 0 deletions .ddev/config.contrib.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## To customize this configuration, see:
## https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/
web_environment:
# To change the Drupal core version, see the README:
# https://github.com/ddev/ddev-drupal-contrib/blob/main/README.md#changing-the-drupal-core-version
# https://git.drupalcode.org/project/gitlab_templates/-/blob/1.9.6/scripts/expand_composer_json.php?ref_type=tags#L15
- IGNORE_PROJECT_DRUPAL_CORE_VERSION=1
# To change the location of your project code, see the README:
# https://github.com/ddev/ddev-drupal-contrib/blob/main/README.md#changing-the-symlink-location
- DRUPAL_PROJECTS_PATH=modules/custom
- SIMPLETEST_DB=mysql://db:db@db/db
- SIMPLETEST_BASE_URL=http://web
- BROWSERTEST_OUTPUT_DIRECTORY=/tmp
- BROWSERTEST_OUTPUT_BASE_URL=${DDEV_PRIMARY_URL}
hooks:
post-start:
- exec-host: |
if [[ -f vendor/autoload.php ]]; then
ddev symlink-project
else
exit 0
fi
Loading