Skip to content
Merged
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
9 changes: 9 additions & 0 deletions .ddev/addon-metadata/ddev-opensearch/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: ddev-opensearch
repository: ddev/ddev-opensearch
version: 2.0.1
install_date: "2024-08-29T14:19:10+02:00"
project_files:
- opensearch
- docker-compose.opensearch.yaml
global_files: []
removal_actions: []
82 changes: 82 additions & 0 deletions .ddev/commands/web/install-magento
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

set -euo pipefail

## Description: Install magento and mageforge module
Comment thread
Morgy93 marked this conversation as resolved.
## Usage: install-magento
## Example: ddev install-magento

# Ensure we are always in the DDEV project root inside the container
cd /var/www/html || exit 1

# global config
MAGENTO_FOLDER="magento"

Comment thread
Morgy93 marked this conversation as resolved.
# check if Magento is already installed
if [[ -f "${MAGENTO_FOLDER}/bin/magento" ]]; then
echo "Magento is already installed. Skipping install-magento."
exit 0
fi

# download magento
composer create-project \
--repository-url=https://mirror.mage-os.org/ \
magento/project-community-edition \
magento-temp

# Create Magento Folder if not exist
if [[ ! -d "${MAGENTO_FOLDER}" ]]; then
mkdir -p "${MAGENTO_FOLDER}"
fi

# copy everything from magento-temp into magento folder
cp -a magento-temp/. "${MAGENTO_FOLDER}/"

# remove magento-temp
rm -rf magento-temp

# change to magento directory
cd "${MAGENTO_FOLDER}" || exit 1

# Remove *.sample extension
find . -name "*.sample" -type f -exec sh -c 'mv "$1" "${1%.sample}"' _ {} \;
rm -f package-lock.json # remove basic package-lock.json to avoid conflicts

# create missing local-themes.js file for grunt tasks
echo 'module.exports = {};' >dev/tools/grunt/configs/local-themes.js

# install magento
bin/magento setup:install \
--admin-email=admin@mageforge.ddev.site \
--admin-firstname=Mage \
--admin-lastname=Forge \
--admin-password=admin123 \
--admin-user=admin \
--backend-frontname=admin \
--db-host=db \
--db-name=db \
--db-password=db \
--db-user=db \
--search-engine=opensearch \
--opensearch-host=opensearch \
--opensearch-port=9200 \
--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

# add path repository pointing to the module at the repo root
composer config --json repositories.mageforge '{"type":"path","url":"..","options":{"symlink":true}}'

# require module from path repo
composer require 'openforgeproject/mageforge:*'

# enable module
bin/magento setup:upgrade
17 changes: 17 additions & 0 deletions .ddev/commands/web/magento
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

## Description: Run magento CLI inside the web container
## Usage: magento [flags] [args]
## Example: "ddev magento list" or "ddev magento maintenance:enable" or "ddev magento sampledata:reset"
## ProjectTypes: magento2
## ExecRaw: true

cd magento || exit 1

if [[ ! -x bin/magento ]]; then
echo 'bin/magento is not available in your installation.'
echo 'Please verify that you installed the shop in your working dir.'
exit 1
fi

bin/magento "$@"
19 changes: 19 additions & 0 deletions .ddev/commands/web/mago
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

## Description: Run Mago (PHP analysis, formatting, and linting)
## Usage: mago <command> [options]
## Example: "ddev mago"

set -e

# Require Mago to be installed (avoid executing remote install scripts automatically)
if ! command -v mago >/dev/null 2>&1; then
echo "mago is not installed. Please install it first: https://carthage.software/mago"
exit 1
fi

# Change to module root where mago.toml is found
cd /var/www/html

# Run Mago with provided arguments
mago "$@"
42 changes: 42 additions & 0 deletions .ddev/commands/web/phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

## Description: Run phpcbf (auto-fix coding standard issues)
## Usage: phpcbf [path]
## Example: ddev phpcbf
## Example: ddev phpcbf src/Service/StaticContentCleaner.php
## Example: ddev phpcbf vendor/openforgeproject/mageforge/src/Block

cd /var/www/html/magento || exit 1

PHPCBF_BIN="vendor-bin/coding-standard/vendor/bin/phpcbf"
PHPCBF_FALLBACK="vendor-bin/coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcbf"

if [[ ! -x "${PHPCBF_BIN}" ]]; then
PHPCBF_BIN="${PHPCBF_FALLBACK}"
fi

if [[ ! -x "${PHPCBF_BIN}" ]]; then
echo "phpcbf not found. Installing coding-standard toolchain..."
composer bin coding-standard install || exit 1
PHPCBF_BIN="${PHPCBF_FALLBACK}"
fi
Comment thread
Morgy93 marked this conversation as resolved.

if [[ ! -x "${PHPCBF_BIN}" ]]; then
echo "phpcbf binary still missing. Expected ${PHPCBF_FALLBACK}."
exit 1
fi

# 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}"
45 changes: 45 additions & 0 deletions .ddev/commands/web/phpcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

## Description: Run phpcs
## Usage: phpcs [path]
## Example: ddev phpcs
## Example: ddev phpcs src/Service/StaticContentCleaner.php
## Example: ddev phpcs vendor/openforgeproject/mageforge/src/Block

cd /var/www/html/magento || exit 1

PHPCS_BIN="vendor-bin/coding-standard/vendor/bin/phpcs"
PHPCS_FALLBACK="vendor-bin/coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs"

if [[ ! -x "${PHPCS_BIN}" ]]; then
PHPCS_BIN="${PHPCS_FALLBACK}"
fi

if [[ ! -x "${PHPCS_BIN}" ]]; then
echo "phpcs not found. Installing coding-standard toolchain..."
composer bin coding-standard install || exit 1
PHPCS_BIN="${PHPCS_FALLBACK}"
fi
Comment thread
Morgy93 marked this conversation as resolved.

if [[ ! -x "${PHPCS_BIN}" ]]; then
echo "phpcs binary still missing. Expected ${PHPCS_FALLBACK}."
exit 1
fi

# 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 starts with 'src/', convert to vendor path
if [[ "${TARGET_PATH}" =~ ^src/ ]]; then
TARGET_PATH="vendor/openforgeproject/mageforge/${TARGET_PATH}"
# If path doesn't exist from magento dir, try from workspace root
elif [[ ! -e "${TARGET_PATH}" ]] && [[ -e "../${TARGET_PATH}" ]]; then
TARGET_PATH="../${TARGET_PATH}"
fi
fi

# Run PHPCS with optional additional flags
"${PHPCS_BIN}" -p -s --standard=Magento2 "$@" "${TARGET_PATH}"
42 changes: 42 additions & 0 deletions .ddev/commands/web/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

## Description: Run PHPStan analysis with Magento extension (same as CI pipeline)
## Usage: phpstan [path]
## Example: ddev phpstan
## Example: ddev phpstan src/Block/Inspector.php
## Example: ddev phpstan vendor/openforgeproject/mageforge/src/Service

# Navigate to Magento root
cd /var/www/html/magento || exit 1

# Check if PHPStan is installed
if [[ ! -f vendor/bin/phpstan ]]; then
echo "PHPStan not found. Installing PHPStan with Magento extension..."

# Allow PHPStan extension installer
composer config --no-plugins allow-plugins.phpstan/extension-installer true

# Install PHPStan and Magento extension
composer require --dev --no-update bitexpert/phpstan-magento phpstan/phpstan:^2.0 phpstan/extension-installer

# Update dependencies (limit scope to PHPStan packages)
composer update bitexpert/phpstan-magento phpstan/phpstan phpstan/extension-installer --with-dependencies

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 "$@" "${TARGET_PATH}"
Loading
Loading