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

Add improved codesniffer support. #151

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
13 changes: 13 additions & 0 deletions .ddev/commands/web/phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

## Description: Run PHP_CodeSniffer's code beautifier
## Usage: phpcbf [flags] [args]
## Example: "ddev phpcbf --standard=core/phpcs.xml.dist index.php" or "ddev phpcbf index.php"
## HostWorkingDir: true
## ExecRaw: true

if ! command -v phpcbf >/dev/null; then
echo "phpcbf is not available. You may need to 'ddev composer require squizlabs/php_codesniffer'"
exit 1
fi
phpcbf "$@"
13 changes: 13 additions & 0 deletions .ddev/commands/web/phpcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

## Description: Run PHP_CodeSniffer's codesniffer
## Usage: phpcs [flags] [args]
## Example: "ddev phpcs --standard=core/phpcs.xml.dist index.php" or "ddev phpcs index.php"
## HostWorkingDir: true
## ExecRaw: true

if ! command -v phpcs >/dev/null; then
echo "phpcs is not available. You may need to 'ddev composer require squizlabs/php_codesniffer'"
exit 1
fi
phpcs "$@"
54 changes: 36 additions & 18 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
name: DrupalPod
type: drupal10
type: drupal
docroot: web
php_version: "8.1"
php_version: "8.3"
webserver_type: nginx-fpm
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mariadb
version: "10.4"
version: "10.6"
use_dns_when_possible: true
composer_version: "2"
web_environment: []
nodejs_version: "18"
corepack_enable: false

# Key features of DDEV's config.yaml:

# name: <projectname> # Name of the project, automatically provides
# http://projectname.ddev.site and https://projectname.ddev.site

# type: <projecttype> # drupal6/7/8, backdrop, typo3, wordpress, php
# type: <projecttype> # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
# information on the different project types
# "drupal" covers recent Drupal 8+

# docroot: <relative_path> # Relative path to the directory containing index.php.

# php_version: "8.1" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"

# You can explicitly specify the webimage but this
# is not recommended, as the images are often closely tied to DDEV's' behavior,
Expand All @@ -33,9 +36,9 @@ nodejs_version: "18"

# database:
# type: <dbtype> # mysql, mariadb, postgres
# version: <version> # database version, like "10.4" or "8.0"
# version: <version> # database version, like "10.11" or "8.0"
# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0
# PostgreSQL versions can be 9-15.
# PostgreSQL versions can be 9-16.

# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
Expand Down Expand Up @@ -74,10 +77,17 @@ nodejs_version: "18"
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
# To reinstall Composer after the image was built, run "ddev debug refresh".

# nodejs_version: "18"
# change from the default system Node.js version to another supported version, like 14, 16, 18, 20.
# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any
# Node.js version, including v6, etc.
# nodejs_version: "20"
# change from the default system Node.js version to any other version.
# Numeric version numbers can be complete (i.e. 18.15.0) or
# incomplete (18, 17.2, 16). 'lts' and 'latest' can be used as well along with
# other named releases.
# see https://www.npmjs.com/package/n#specifying-nodejs-versions
# Note that you can continue using 'ddev nvm' or nvm inside the web container
# to change the project's installed node version if you need to.

# corepack_enable: false
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm

# additional_hostnames:
# - somename
Expand Down Expand Up @@ -105,6 +115,13 @@ nodejs_version: "18"
# If true, turns off the normal warning that says
# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set"

# ddev_version_constraint: ""
# Example:
# ddev_version_constraint: ">= 1.22.4"
# This will enforce that the running ddev version is within this constraint.
# See https://github.com/Masterminds/semver#checking-version-constraints for
# supported constraint formats

# working_dir:
# web: /var/www/html
# db: /home
Expand All @@ -129,8 +146,8 @@ nodejs_version: "18"
# - "mutagen": enables Mutagen for this project.
# - "nfs": enables NFS for this project.
#
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen

# fail_on_hook_fail: False
# Decide whether 'ddev start' should be interrupted by a failing hook
Expand Down Expand Up @@ -241,10 +258,10 @@ nodejs_version: "18"
# override_config: false
# By default, config.*.yaml files are *merged* into the configuration
# But this means that some things can't be overridden
# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge
# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge
# and you can't erase existing hooks or all environment variables.
# However, with "override_config: true" in a particular config.*.yaml file,
# 'nfs_mount_enabled: false' can override the existing values, and
# 'use_dns_when_possible: false' can override the existing values, and
# hooks:
# post-start: []
# or
Expand All @@ -262,5 +279,6 @@ nodejs_version: "18"
# for them. Example:
#hooks:
# post-import-db:
# - exec: drush cr
# - exec: drush updb
# - exec: drush sql:sanitize
# - exec: drush updatedb
# - exec: drush cache:rebuild
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ src/**/package-lock.json
src/**/out/
src/**/*.vsix
src/**/.vscode-test/
drush/
.ddev/config.gitpod.yaml
22 changes: 1 addition & 21 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: drupalpod/drupalpod-gitpod-base:20230922
image: drupalpod/drupalpod-gitpod-base:20240419

# DDEV and composer are running as part of the prebuild
# when starting a workspace all docker images are ready
Expand All @@ -7,7 +7,6 @@ tasks:
.gitpod/utils/send-a-message-gcs.sh > /tmp/output1.txt
.gitpod/utils/ddev-in-gitpod-setup.sh
.gitpod/utils/set-base-environment.sh
time ddev start
command: |
# Temporary fix for wrong value of GITPOD_REPO_ROOT when opening a Gitpod snapshot
# Todo: remove this when this issue is resolved - https://github.com/gitpod-io/gitpod/issues/9804
Expand Down Expand Up @@ -76,22 +75,3 @@ ports:
name: xdebug
description: xdebug
onOpen: ignore

github:
prebuilds:
# enable for the master/default branch (defaults to true)
master: true
# enable for all branches in this repo (defaults to false)
branches: true
# enable for pull requests coming from this repo (defaults to true)
pullRequests: true
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: false
# add a check to pull requests (defaults to true)
addCheck: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
addComment: false
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
addBadge: true
# add a label once the prebuild is ready to pull requests (defaults to false)
addLabel: true
2 changes: 2 additions & 0 deletions .gitpod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

1. Update `.gitpod/images/Dockerfile`:

1. Update `ddev` latest version.
1. Update `minio` latest version.
1. Update `gitui` latest version.
1. Update `lazygit` latest version.

1. Generate new custom docker image:

Expand Down
8 changes: 8 additions & 0 deletions .gitpod/drupal/drupalpod-setup/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eu -o pipefail

# Remove site that was installed before (for debugging)
rm -rf "${GITPOD_REPO_ROOT}"/web
rm -rf "${GITPOD_REPO_ROOT}"/vendor
rm -f "${GITPOD_REPO_ROOT}"/composer.json
rm -f "${GITPOD_REPO_ROOT}"/composer.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/usr/bin/env bash
set -eu -o pipefail

# Check if additional modules should be installed
export DEVEL_NAME="devel"
export DEVEL_PACKAGE="drupal/devel"

export ADMIN_TOOLBAR_NAME="admin_toolbar_tools"
export ADMIN_TOOLBAR_PACKAGE="drupal/admin_toolbar"

# TODO: once Drupalpod extension supports additional modules - remove these 2 lines
export DP_EXTRA_DEVEL=1
export DP_EXTRA_ADMIN_TOOLBAR=1

# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
if [[ "$DP_CORE_VERSION" =~ ^10(\..*)?$ ]]; then
Expand All @@ -12,8 +24,8 @@ fi
# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
if [[ "$DP_CORE_VERSION" =~ ^11(\..*)?$ ]]; then
# admin_toolbar and devel are not compatible yet with Drupal 11
DP_EXTRA_ADMIN_TOOLBAR=
DP_EXTRA_DEVEL=
export DP_EXTRA_ADMIN_TOOLBAR=
export DP_EXTRA_DEVEL=
if [ "$DP_PROJECT_TYPE" != "project_core" ]; then
export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient
else
Expand Down
20 changes: 20 additions & 0 deletions .gitpod/drupal/drupalpod-setup/ddev_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eu -o pipefail

# set PHP version, based on https://www.drupal.org/docs/getting-started/system-requirements/php-requirements#versions
major_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 1)
minor_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 2)

# Before Drupal 10.2, we should use php 8.2, otherwise use php 8.3
if (( major_version < 10 )) || { (( major_version == 10 )) && (( minor_version < 2 )); }; then
php_version="8.2"
else
php_version="8.3"
fi

cat <<CONFIGEND > "${GITPOD_REPO_ROOT}"/.ddev/config.gitpod.yaml
#ddev-gitpod-generated
php_version: "$php_version"
CONFIGEND

time ddev start
2 changes: 1 addition & 1 deletion .gitpod/drupal/drupalpod-setup/drupal_setup_contrib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ if [ -n "$COMPOSER_DRUPAL_LENIENT" ]; then
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require "$COMPOSER_DRUPAL_LENIENT" --no-install
fi
# Add the project to composer (it will get the version according to the branch under `/repo/name_of_project`)
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require drupal/"$DP_PROJECT_NAME" --no-install
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require drupal/"$DP_PROJECT_NAME" --no-interaction --no-install
8 changes: 7 additions & 1 deletion .gitpod/drupal/drupalpod-setup/drupal_setup_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ cd "${GITPOD_REPO_ROOT}" &&
# Removing the conflict part of composer
echo "$(cat composer.json | jq 'del(.conflict)' --indent 4)" >composer.json

# If a core issue branch was chosen, we want the version of Drupal core that is in that issue branch
# This is very helpful for issues that started with previous Drupal core versions, and the issue version automatically got updated to latest current drupal version
if [ "$DP_PROJECT_TYPE" == "project_core" ] && [ -n "$DP_ISSUE_BRANCH" ]; then
time composer require drupal/core-recommended:* drupal/core-project-message:* drupal/core-composer-scaffold:* --no-update
fi

# Only after composer update, /web/core get symlinked to /repos/drupal/core
# repos/drupal/core -> web/core
time composer update --lock
time composer update

# vendor -> repos/drupal/vendor
if [ ! -L "$GITPOD_REPO_ROOT"/repos/drupal/vendor ]; then
Expand Down
Loading