-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add dev env #192
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
Merged
feat: add dev env #192
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ## 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" | ||
|
|
||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.