Skip to content

Commit 79a77d9

Browse files
authored
feat: use DRUPAL_PROJECTS_PATH for all commands. fixes #111 (#112)
* feat: use DRUPAL_PROJECTS_PATH for all commands * refactor: centralize DRUPAL_PROJECTS_PATH in config - Move DRUPAL_PROJECTS_PATH to config.contrib.yaml - Remove individual definitions from command files - Improve documentation for theme support * docs: clarify configurable project location in commands section Link to configuration section and note default location. * docs: align symlink location documentation Make messaging consistent about configurable project location throughout README and command description * docs: align README references in config.contrib.yaml
1 parent be0c27e commit 79a77d9

File tree

10 files changed

+21
-13
lines changed

10 files changed

+21
-13
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ This project provides the following DDEV container commands.
4040
- Creates a temporary [composer.contrib.json](https://getcomposer.org/doc/03-cli.md#composer) so that `drupal/core-recommended` becomes a dev dependency. This way the composer.json from the module is untouched.
4141
- Runs `composer install` AND `yarn install` so that dependencies are available. Additional arguments to `ddev poser` like --prefer-source are passed along to `composer install`
4242
- Note: it is perfectly acceptable to skip this command and edit the require-dev of composer.json by hand.
43-
- [ddev symlink-project](https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/symlink-project). Symlinks the top level files of your project into web/modules/custom so that Drupal finds your module. This command runs automatically on every `ddev start` _as long as Composer has generated `vendor/autoload.php`_ which occurs during `composer install/update`. See codebase image below.
43+
- [ddev symlink-project](https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/symlink-project). Symlinks your project files into the configured location (defaults to `web/modules/custom`) so Drupal can find your module. This command runs automatically on every `ddev start` _as long as Composer has generated `vendor/autoload.php`_ which occurs during `composer install/update`. See codebase image below.
4444

45-
Run tests on the `web/modules/custom` directory:
45+
Run tests on your project code (defaults to `web/modules/custom`, [configurable](#changing-the-symlink-location)):
4646

4747
- `ddev phpunit` Run [PHPUnit](https://github.com/sebastianbergmann/phpunit) tests.
4848
- `ddev nightwatch` Run Nightwatch tests, requires [DDEV Selenium Standalone Chrome](https://github.com/ddev/ddev-selenium-standalone-chrome).
4949
- `ddev phpcs` Run [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer).
5050
- `ddev phpcbf` Fix phpcs findings.
51-
- `ddev phpstan`. Run [phpstan](https://phpstan.org) on the web/modules/custom directory.
51+
- `ddev phpstan`. Run [phpstan](https://phpstan.org) on project files.
5252
- `ddev eslint` Run [ESLint](https://github.com/eslint/eslint) on JavaScript files.
5353
- `ddev stylelint` Run [Stylelint](https://github.com/stylelint/stylelint) on CSS files.
5454

@@ -96,7 +96,11 @@ web_environment:
9696
- DRUPAL_PROJECTS_PATH=modules
9797
```
9898

99-
Then restart DDEV by running `ddev restart`.
99+
Then run `ddev restart` to update the symlink location.
100+
101+
All [ddev-drupal-contrib commands](#commands) run against your project code in the configured symlink location.
102+
103+
To use with Drupal themes, set `DRUPAL_PROJECTS_PATH=themes/custom` in your config.
100104

101105
## Example of successful test
102106

commands/web/eslint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if "$DDEV_DOCROOT/core/node_modules/.bin/eslint" --version >/dev/null ; then
1212
test -e .prettierrc.json || ln -s $DDEV_DOCROOT/core/.prettierrc.json .
1313
test -e .prettierignore || echo '*.yml' > .prettierignore
1414
# Change directory to the project root folder
15-
cd "$DDEV_DOCROOT/modules/custom/${DDEV_SITENAME//-/_}" || exit
15+
cd "$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/${DDEV_SITENAME//-/_}" || exit
1616
"$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 . "$@"
1717
else
1818
echo "eslint is not available. You may need to 'ddev exec \"cd $DDEV_DOCROOT/core && yarn install\"'"

commands/web/nightwatch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
## Example: "ddev nightwatch"
88
## ExecRaw: true
99

10-
yarn --cwd "$DDEV_DOCROOT/core" test:nightwatch "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/modules/custom/" "$@"
10+
yarn --cwd "$DDEV_DOCROOT/core" test:nightwatch "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/" "$@"

commands/web/phpcbf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ if ! command -v phpcbf >/dev/null; then
1212
exit 1
1313
fi
1414
test -e phpcs.xml.dist || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpcs.xml.dist
15-
phpcbf -s --report-full --report-summary --report-source $DDEV_DOCROOT/modules/custom "$@"
15+
phpcbf -s --report-full --report-summary --report-source $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH "$@"

commands/web/phpcs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ if ! command -v phpcs >/dev/null; then
1212
exit 1
1313
fi
1414
test -e phpcs.xml.dist || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpcs.xml.dist
15-
phpcs -s --report-full --report-summary --report-source $DDEV_DOCROOT/modules/custom --ignore=*/.ddev/* "$@"
15+
phpcs -s --report-full --report-summary --report-source $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH --ignore=*/.ddev/* "$@"

commands/web/phpstan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ test -e phpstan.neon || curl -OL https://git.drupalcode.org/project/gitlab_templ
1616
sed -i 's/BASELINE_PLACEHOLDER/phpstan-baseline.neon/g' phpstan.neon
1717
# Add an empty baseline file to ensure it exists.
1818
test -e phpstan-baseline.neon || touch phpstan-baseline.neon
19-
phpstan analyse $DDEV_DOCROOT/modules/custom "$@"
19+
phpstan analyse $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH "$@"

commands/web/phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ if [ -f "phpunit.xml" ]; then
1818
phpunit "$@"
1919
else
2020
# Bootstrap Drupal tests and run all custom module tests.
21-
phpunit --bootstrap $PWD/$DDEV_DOCROOT/core/tests/bootstrap.php $DDEV_DOCROOT/modules/custom "$@"
21+
phpunit --bootstrap $PWD/$DDEV_DOCROOT/core/tests/bootstrap.php $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH "$@"
2222
fi

commands/web/stylelint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
if $DDEV_DOCROOT/core/node_modules/.bin/stylelint --version >/dev/null ; then
1111
# Change directory to the project root folder
12-
cd "$DDEV_DOCROOT/modules/custom/${DDEV_SITENAME//-/_}" || exit
12+
cd "$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/${DDEV_SITENAME//-/_}" || exit
1313
"$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/node_modules/.bin/stylelint" --color --config "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/core/.stylelintrc.json" "./**/*.css" "$@"
1414
else
1515
echo "stylelint is not available. You may need to 'ddev exec \"cd $DDEV_DOCROOT/core && yarn install\"'"

commands/web/symlink-project

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
#ddev-generated
44
## Command provided by https://github.com/ddev/ddev-drupal-contrib
5-
## Description: Symlink all root files/dirs into web.modules/custom/[PROJECT_NAME]
5+
## Description: Symlink project files into the configured location (defaults to `web/modules/custom/[PROJECT_NAME]`)
66
## Usage: symlink-project [flags] [args]
77
## Example: "ddev symlink-project"
88
## ExecRaw: true
99

1010
export _WEB_ROOT=$DDEV_DOCROOT
11-
export DRUPAL_PROJECTS_PATH=${DRUPAL_PROJECTS_PATH:-modules/custom}
1211
#todo use more dynamic ref.
1312
cd "$DDEV_COMPOSER_ROOT" || exit
1413
curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/scripts/symlink_project.php

config.contrib.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#ddev-generated
22
## Command provided by https://github.com/ddev/ddev-drupal-contrib
3+
## To customize this configuration, see:
4+
## https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/
35
web_environment:
46
# To change the Drupal core version, see the README:
57
# https://github.com/ddev/ddev-drupal-contrib/blob/main/README.md#changing-the-drupal-core-version
@@ -10,6 +12,9 @@ web_environment:
1012
- SIMPLETEST_BASE_URL=http://web
1113
- BROWSERTEST_OUTPUT_DIRECTORY=/tmp
1214
- BROWSERTEST_OUTPUT_BASE_URL=${DDEV_PRIMARY_URL}
15+
# To change the location of your project code, see the README:
16+
# https://github.com/ddev/ddev-drupal-contrib/blob/main/README.md#changing-the-symlink-location
17+
- DRUPAL_PROJECTS_PATH=modules/custom
1318
hooks:
1419
post-start:
1520
- exec-host: |

0 commit comments

Comments
 (0)