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 4 commits into
base: main
Choose a base branch
from

Conversation

andrewbelcher
Copy link

@andrewbelcher andrewbelcher commented Jul 10, 2025

The Issue

Streamline to process of switching branch by adding a command.

How This PR Solves The Issue

Adds the command.

Manual Testing Instructions

ddev add-on get https://github.com/andrewbelcher//ddev-drupal-contrib/tarball/132-core-version-command
ddev restart
ddev core-version ^10.5

Automated Testing Overview

No tests added yet.

Release/Deployment Notes

Addition of a new core-version command to update the version configuration and code via a single command, e.g.:

ddev core-version ^11.2

@weitzman
Copy link
Collaborator

I think we should change our documentation from recommending a config.local.yaml file to a new .env.contrib file. Those get read by DDEV during startup. Best of all, we can use the https://ddev.readthedocs.io/en/stable/users/usage/commands/#dotenv-set command to set the value there. This way we dont have to use regex to change values.

@weitzman
Copy link
Collaborator

This will need a test

@andrewbelcher
Copy link
Author

I have:

  • Switched to using .ddev/.env. Worth noting that it needs to be .ddev/.env as .ddev/.env.* is only available either at docker compose time, or in the specific service that * refers to.
  • As such, the default is now handled by the change in expand-composer-json, which also required a tweak to the full.bats test. I've also switch the setup to use ddev dotenv set for alternative versions.
  • I've updated the core-version command to use ddev dotenv set including allowing no arguments and default which both clear the value.
  • I've added a new test file for the core-version which cycles through ensuring the switch and rebuild works as expected.

@andrewbelcher andrewbelcher force-pushed the 132-core-version-command branch from 373ac97 to 3dd8477 Compare July 15, 2025 20:53
@stasadev
Copy link
Member

  • Switched to using .ddev/.env. Worth noting that it needs to be .ddev/.env as .ddev/.env.* is only available either at docker compose time, or in the specific service that * refers to.

If it's only for the web container, then using .ddev/.env.web should be good enough.

The only difference in using .ddev/.env is that env values from here are passed to all running containers.

@andrewbelcher
Copy link
Author

Good shout! I got caught up in not being able to use .env.contrib and forgot that .env.web would be nicely scoped! Updated and test pass locally.

@@ -76,11 +76,16 @@ Override any environment variable value from [.ddev/config.contrib.yaml](config.

### Changing the Drupal core version

In `.ddev/config.local.yaml` set the Drupal core version:
Use the `ddev core-version` command to set the core version environment variable and update the code, for example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

web_environment:
- DRUPAL_CORE=^11
```shell
ddev core-version ^11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think many people will omit the carat here. Can we handle that seamlessly? If not, lets error if its not a valid constraint.

@weitzman
Copy link
Collaborator

Do you think it would simplify if we run ddev dotenv set .ddev/.env.web --drupal-core "^11" as a post-install action? That way we can rely that this env var is set and we dont have to sprinkle defaults in our scripts. Users can use the new command to bump their version when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants