diff --git a/.ddev/commands/web/install-magento b/.ddev/commands/web/install-magento index 188482e..8c33094 100755 --- a/.ddev/commands/web/install-magento +++ b/.ddev/commands/web/install-magento @@ -62,6 +62,12 @@ bin/magento setup:install \ --base-url=https://mageforge.ddev.site/ \ --language=en_US +# set developer mode +bin/magento deploy:mode:set developer + +# disable 2FA +bin/magento module:disable Magento_TwoFactorAuth Magento_AdminAdobeImsTwoFactorAuth + # install sample data bin/magento sampledata:deploy diff --git a/.ddev/commands/web/phpcbf b/.ddev/commands/web/phpcbf new file mode 100755 index 0000000..a4feb1c --- /dev/null +++ b/.ddev/commands/web/phpcbf @@ -0,0 +1,27 @@ +#!/bin/bash + +## #ddev-generated +## Description: Run phpcbf (auto-fix coding standard issues) +## Usage: phpcbf [path] +## Example: ddev phpcbf +## Example: ddev phpcbf src/src/Service/StaticContentCleaner.php +## Example: ddev phpcbf vendor/openforgeproject/mageforge/src/Block + +cd /var/www/html/magento || exit 1 + +PHPCBF_BIN="vendor/bin/phpcbf" + +# Set target path - default to vendor/openforgeproject/mageforge/src if not provided +TARGET_PATH="vendor/openforgeproject/mageforge/src" +if [[ $# -gt 0 ]] && [[ ! "$1" =~ ^- ]]; then + TARGET_PATH="$1" + shift # Remove the first argument + + # If path doesn't exist from magento dir, try from workspace root + if [[ ! -e "${TARGET_PATH}" ]] && [[ -e "../${TARGET_PATH}" ]]; then + TARGET_PATH="../${TARGET_PATH}" + fi +fi + +# Run PHPCBF with optional additional flags +"${PHPCBF_BIN}" -p -s --standard=Magento2 "$@" "${TARGET_PATH}" diff --git a/.ddev/commands/web/phpcs b/.ddev/commands/web/phpcs index 3ba102a..75f37c7 100755 --- a/.ddev/commands/web/phpcs +++ b/.ddev/commands/web/phpcs @@ -2,17 +2,26 @@ ## #ddev-generated ## Description: Run phpcs -## Usage: phpcs +## Usage: phpcs [path] ## Example: ddev phpcs +## Example: ddev phpcs src/src/Service/StaticContentCleaner.php +## Example: ddev phpcs vendor/openforgeproject/mageforge/src/Block -TEMP_DIR="/tmp/magento-coding-standard" -PHPCS_BIN="${TEMP_DIR}/vendor/bin/phpcs" +cd /var/www/html/magento || exit 1 -# Check if Magento Coding Standard is installed -if [[ ! -d ${TEMP_DIR} ]]; then - echo "Magento Coding Standard not found. Installing..." - composer create-project magento/magento-coding-standard --stability=dev "${TEMP_DIR}" +PHPCS_BIN="vendor/bin/phpcs" + +# Set target path - default to vendor/openforgeproject/mageforge/src if not provided +TARGET_PATH="vendor/openforgeproject/mageforge/src" +if [[ $# -gt 0 ]] && [[ ! "$1" =~ ^- ]]; then + TARGET_PATH="$1" + shift # Remove the first argument + + # If path doesn't exist from magento dir, try from workspace root + if [[ ! -e "${TARGET_PATH}" ]] && [[ -e "../${TARGET_PATH}" ]]; then + TARGET_PATH="../${TARGET_PATH}" + fi fi -# Run PHPCS -"${PHPCS_BIN}" -p -s --standard=Magento2 src/ +# Run PHPCS with optional additional flags +"${PHPCS_BIN}" -p -s --standard=Magento2 "$@" "${TARGET_PATH}" diff --git a/.ddev/commands/web/phpstan b/.ddev/commands/web/phpstan index b5d748a..9be32e2 100755 --- a/.ddev/commands/web/phpstan +++ b/.ddev/commands/web/phpstan @@ -2,8 +2,10 @@ ## #ddev-generated ## Description: Run PHPStan analysis with Magento extension (same as CI pipeline) -## Usage: phpstan +## Usage: phpstan [path] ## Example: ddev phpstan +## Example: ddev phpstan src/src/Block/Inspector.php +## Example: ddev phpstan vendor/openforgeproject/mageforge/src/Service # Navigate to Magento root cd /var/www/html/magento || exit 1 @@ -24,6 +26,18 @@ if [[ ! -f vendor/bin/phpstan ]]; then echo "PHPStan installation complete." fi +# Set target path - default to vendor/openforgeproject/mageforge/src if not provided or if it's a flag +TARGET_PATH="vendor/openforgeproject/mageforge/src" +if [[ $# -gt 0 ]] && [[ ! "$1" =~ ^- ]]; then + TARGET_PATH="$1" + shift # Remove the first argument + + # If path doesn't exist from magento dir, try from workspace root + if [[ ! -e "${TARGET_PATH}" ]] && [[ -e "../${TARGET_PATH}" ]]; then + TARGET_PATH="../${TARGET_PATH}" + fi +fi + # Run PHPStan with the same configuration as CI pipeline echo "Running PHPStan analysis..." -vendor/bin/phpstan analyse -c vendor/openforgeproject/mageforge/phpstan.neon vendor/openforgeproject/mageforge/src +vendor/bin/phpstan analyse -c vendor/openforgeproject/mageforge/phpstan.neon "$@" "${TARGET_PATH}"