Skip to content

Add a core-version command. #133

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

Open
wants to merge 2 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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ Override any environment variable value from [.ddev/config.contrib.yaml](config.

### Changing the Drupal core version

Use the `ddev core-version` command to set the core version environment variable and update the code, for example:

```shell
ddev core-version ^11
```

You can also do this manually:

In `.ddev/config.local.yaml` set the Drupal core version:

```yaml
Expand Down
25 changes: 25 additions & 0 deletions commands/host/core-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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 when config.local.yaml doesn't exist, or has no web_environment key.
if [[ ! -f .ddev/config.local.yaml || ! `grep '^web_environment:' .ddev/config.local.yaml` ]]; then
echo -e "web_environment:\n - DRUPAL_CORE=$1" >> .ddev/config.local.yaml
# Handle when we have a DRUPAL_CORE env var already.
elif [[ `grep 'DRUPAL_CORE=' .ddev/config.local.yaml` ]]; then
sed -ri "s/^(\s+)- DRUPAL_CORE=.*/\1- DRUPAL_CORE=$1/" .ddev/config.local.yaml
# Handle when we do not have a DRUPAL_CORE env var already.
else
# Additionally handle if web_environment is set to an empty array.
sed -ri "s/web_environment:\s+\[\s*\]/web_environment:/" .ddev/config.local.yaml
sed -i "/web_environment:/a \ \ - DRUPAL_CORE=$1" .ddev/config.local.yaml
fi

ddev restart
ddev poser
1 change: 1 addition & 0 deletions install.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: ddev-drupal-contrib

project_files:
- commands/host/core-version
- commands/web/eslint
- commands/web/expand-composer-json
- commands/web/nightwatch
Expand Down