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

fix composer install when no ready-made-env exist #65

Closed
wants to merge 5 commits into from
Closed
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
34 changes: 27 additions & 7 deletions .gitpod/drupal/drupalpod-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ GITMODULESEND
install_version=~"$d"
;;
esac
cd "$GITPOD_REPO_ROOT" && ddev composer create -y --no-install drupal/recommended-project:"$install_version"

# Create required composer.json and composer.lock files
cd "$GITPOD_REPO_ROOT" && ddev . composer create -n --no-install drupal/recommended-project:"$install_version" temp-composer-files
cp "$GITPOD_REPO_ROOT"/temp-composer-files/* "$GITPOD_REPO_ROOT"/.
rm -rf "$GITPOD_REPO_ROOT"/temp-composer-files
fi
fi

Expand Down Expand Up @@ -205,11 +209,6 @@ GITMODULESEND
repositories.drupal-core2 \
' '"'"' {"type": "path", "url": "'"repos/drupal/core"'"} '"'"' '

# Patch Drush to fix `drush cr` when core is symlinked
# https://github.com/drush-ops/drush/pull/4713
cd "$GITPOD_REPO_ROOT" && \
patch -p1 < "$GITPOD_REPO_ROOT"/src/composer-drupal-core-setup/drush-cr-when-core-is-symlinked.patch

# Removing the conflict part of composer
echo "$(cat composer.json | jq 'del(.conflict)' --indent 4)" > composer.json

Expand All @@ -235,7 +234,20 @@ GITMODULESEND
if [ "$DP_PROJECT_TYPE" == "project_core" ]; then

# Update composer.lock to allow composer's symlink of repos/drupal/core
cd "${GITPOD_REPO_ROOT}" && time ddev composer require drupal/core drupal/drupal
if [ "$ready_made_env_exist" ]; then
cd "${GITPOD_REPO_ROOT}" && time ddev composer require drupal/core drupal/drupal
else
cd "${GITPOD_REPO_ROOT}" && time ddev composer config repositories.lenient composer https://packages.drupal.org/lenient
cd "${GITPOD_REPO_ROOT}" && time ddev composer require \
drush/drush \
drupal/coder

# Download extra modules
if [ -n "$EXTRA_MODULES" ]; then
cd "${GITPOD_REPO_ROOT}" && \
ddev composer require "$ADMIN_TOOLBAR_PACKAGE"
fi
fi

# Set special setup for composer for working on Drupal core
cd "$GITPOD_REPO_ROOT"/web && \
Expand All @@ -245,6 +257,11 @@ GITMODULESEND
cd "${GITPOD_REPO_ROOT}" && time ddev composer require drupal/"$DP_PROJECT_NAME"
fi

# Patch Drush to fix `drush cr` when core is symlinked
# https://github.com/drush-ops/drush/pull/4713
cd "$GITPOD_REPO_ROOT" && \
patch -p1 < "$GITPOD_REPO_ROOT"/src/composer-drupal-core-setup/drush-cr-when-core-is-symlinked.patch
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this patch fail if a different version of drush is installed? It seems sort of brittle without being able to determine if it should be patched or not.

Copy link
Owner Author

@shaal shaal Jan 10, 2022

Choose a reason for hiding this comment

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

Good question...
https://github.com/Weitzman said this bug will not be fixed in Drush, but a problem that should get fixed in Drupal core itself.

(But I think that even if drupal 9.4 will get this fixed, all previous Drupal versions will still have that issue)

Copy link
Owner Author

Choose a reason for hiding this comment

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


# Configure phpcs for drupal.
cd "$GITPOD_REPO_ROOT" && \
vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer
Expand All @@ -253,6 +270,9 @@ GITMODULESEND

# Install from scratch, if a full site install is required or ready-made-env doesn't exist
if [ -n "$DP_REINSTALL" ] || [ ! "$ready_made_env_exist" ]; then
# restart ddev - so settings.php gets updated to include settings.ddev.php
ddev restart

# New site install
ddev drush si -y --account-pass=admin --site-name="DrupalPod" "$DP_INSTALL_PROFILE"

Expand Down
2 changes: 1 addition & 1 deletion .gitpod/drupal/envs-prep/create-environments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for d in "${allDrupalSupportedVersions[@]}"; do
cd "$WORK_DIR"/"$d" && \
ddev composer require \
drupal/admin_toolbar \
drush/drush:^10 \
drush/drush \
drupal/coder \
drupal/devel

Expand Down
6 changes: 2 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (select script from list of sh files)",
"cwd": "${workspaceFolder}",
"program": "${command:SelectScriptName}",
"args": []
"name": "Bash-Debug (simplest configuration)",
"program": "${file}"
}
]
}