-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat!: add MageForge bind-mount setup and dependency management #198
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
+126
−15
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c4d6c3c
feat!: add script to install MageForge module dependencies and update…
dermatz eb669a6
Potential fix for pull request finding
dermatz fb2141b
fix: enhance MageForge installation script and config for bind-mount …
dermatz 3c66815
fix: improve error handling and dependency installation logic in modu…
dermatz 3028a59
fix: enhance error handling for Magento installation and module depen…
dermatz ffb3e94
fix: update MageForge module enabling process to use bin/magento command
dermatz f1ee048
fix: require Hyvä theme and install MageForge module dependencies bef…
dermatz 89098c7
fix: remove merch section from README and adjust theme types section
dermatz e4dea5e
#198 - fix constraint check, add --with-dependencies, and make mysql …
dermatz 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
Some comments aren't visible on the classic Files Changed page.
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
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,75 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ## Description: Install MageForge module dependencies into the Magento vendor directory | ||
| ## Usage: install-module-deps | ||
| ## Example: ddev install-module-deps | ||
|
|
||
| # The module source is bind-mounted (not Composer-installed), so its third-party | ||
| # dependencies are not resolved automatically. Read them from the module's composer.json | ||
| # and install the non-Magento/non-PHP ones into the Magento vendor. | ||
|
|
||
| MAGENTO_DIR="/var/www/html/magento" | ||
| MODULE_COMPOSER_JSON="/var/www/html/composer.json" | ||
|
|
||
| # Skip if Magento is not yet installed (e.g. on initial ddev start before install-magento) | ||
| if [[ ! -f "${MAGENTO_DIR}/vendor/autoload.php" ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| cd "${MAGENTO_DIR}" || exit 1 | ||
|
|
||
| php -r " | ||
| \$manifest = json_decode(file_get_contents('${MODULE_COMPOSER_JSON}'), true); | ||
| if (\$manifest === null) { | ||
| fwrite(STDERR, 'ERROR: Could not parse module composer.json at ${MODULE_COMPOSER_JSON}' . PHP_EOL); | ||
| exit(1); | ||
| } | ||
| \$deps = []; | ||
| foreach (\$manifest['require'] ?? [] as \$package => \$constraint) { | ||
| // Skip php, magento/*, and Composer platform packages (ext-*, lib-*, composer-*-api). | ||
| // Platform packages have no vendor/ directory and would cause repeated failed installs. | ||
| if (\$package === 'php' | ||
| || str_starts_with(\$package, 'magento/') | ||
| || str_starts_with(\$package, 'ext-') | ||
| || str_starts_with(\$package, 'lib-') | ||
| || \$package === 'composer-runtime-api' | ||
| || \$package === 'composer-plugin-api') { | ||
| continue; | ||
| } | ||
| \$deps[\$package] = \$constraint; | ||
| } | ||
| \$missingConstraints = []; | ||
| \$missingNames = []; | ||
| // Read Magento's composer.json once to compare declared constraints. | ||
| \$magentoManifest = is_file('composer.json') | ||
| ? json_decode(file_get_contents('composer.json'), true) | ||
| : null; | ||
| foreach (\$deps as \$package => \$constraint) { | ||
| \$vendorDir = 'vendor/' . \$package; | ||
| \$needsInstall = !is_dir(\$vendorDir); | ||
| if (!\$needsInstall) { | ||
| // Check whether Magento's composer.json already declares the exact required | ||
| // constraint. This detects constraint bumps in the module (e.g. ^0.3 → ^0.4) | ||
| // and triggers a re-install when the constraint changes. | ||
| \$declaredConstraint = \$magentoManifest['require'][\$package] | ||
| ?? \$magentoManifest['require-dev'][\$package] | ||
| ?? null; | ||
| if (\$declaredConstraint !== \$constraint) { | ||
| \$needsInstall = true; | ||
| } | ||
| } | ||
| if (\$needsInstall) { | ||
| \$missingConstraints[] = escapeshellarg(\"\$package:\$constraint\"); | ||
| \$missingNames[] = escapeshellarg(\$package); | ||
| } | ||
| } | ||
| if (\$missingConstraints) { | ||
| echo 'Installing MageForge module dependencies: ' . implode(', ', \$missingNames) . PHP_EOL; | ||
| // Add constraints without resolving first, then update only the new packages. | ||
| // This prevents Composer from touching unrelated Magento core dependencies. | ||
| passthru('composer require --no-interaction --no-update ' . implode(' ', \$missingConstraints), \$exitCode); | ||
| if (\$exitCode !== 0) { exit(\$exitCode); } | ||
| passthru('composer update --no-interaction --with-dependencies ' . implode(' ', \$missingNames), \$exitCode); | ||
| exit(\$exitCode); | ||
| } | ||
| " |
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
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
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.