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

Remove Drupal related add-on files from .ddev when not applicable #27

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

stasadev
Copy link
Member

The Issue

When people install this add-on, some Drupal related files are installed to .ddev folder, even when the project is not Drupal.

How This PR Solves The Issue

Removes these files in post_install_action.

Manual Testing Instructions

Files are removed for non Drupal:

ddev config --project-type php
ddev add-on get https://github.com/ddev/ddev-redis/tarball/20241028_stasadev_drupal_files
...
Executing post-install actions:
Removing redis/scripts/settings.ddev.redis.php as not applicable
Removing redis/scripts/setup-drupal-settings.sh as not applicable
...

Files are NOT removed for Drupal:

ddev config --project-type drupal
ddev add-on get https://github.com/ddev/ddev-redis/tarball/20241028_stasadev_drupal_files
...
Executing post-install actions: 
Settings file name: /home/stas/code/ddev/d11/web/sites/default/settings.php
...

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

@stasadev stasadev requested a review from rfay October 28, 2024 17:47
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

This seems fine, but I didn't understand turning silent results into errors.

@@ -4,11 +4,11 @@ set -e

if [[ $DDEV_PROJECT_TYPE != drupal* ]] || [[ $DDEV_PROJECT_TYPE =~ ^drupal(6|7)$ ]] ;
then
exit 0
exit 1
Copy link
Member

Choose a reason for hiding this comment

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

Why does this have to be called out as an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I remove the files only if this script fails:

if ! redis/scripts/setup-drupal-settings.sh; then
  # remove files
fi

That's why I return an error here.
Otherwise I would need to duplicate Drupal checks in install.yaml

Copy link
Member

Choose a reason for hiding this comment

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

How about checking to see if it's drupal and if not removing files? Rather than depending on the script? Or is that the same?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I remove the file from the file itself, will this work for all environments?

I thought it could have unpredictable results, for example, for Windows.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I'll try to remove the files here and see if it works.

Copy link
Member Author

Choose a reason for hiding this comment

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

It works for me.

redis/scripts/setup-drupal-settings.sh Outdated Show resolved Hide resolved
@stasadev
Copy link
Member Author

I tested it again on Linux, macOS, and traditional Windows. Works perfectly.

@stasadev stasadev merged commit 0147f41 into main Oct 31, 2024
2 checks passed
@stasadev stasadev deleted the 20241028_stasadev_drupal_files branch October 31, 2024 19:23
@rfay
Copy link
Member

rfay commented Oct 31, 2024

Thanks, sorry I didn't get back to it.

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.

2 participants