@@ -20,22 +20,39 @@ cd "${MAGENTO_DIR}" || exit 1
2020
2121php -r "
2222 \$ manifest = json_decode(file_get_contents('${MODULE_COMPOSER_JSON} '), true);
23+ if (\$ manifest === null) {
24+ fwrite(STDERR, 'ERROR: Could not parse module composer.json at ${MODULE_COMPOSER_JSON} ' . PHP_EOL);
25+ exit(1);
26+ }
2327 \$ deps = [];
2428 foreach (\$ manifest['require'] ?? [] as \$ package => \$ constraint) {
25- if (\$ package !== 'php' && !str_starts_with(\$ package, 'magento/')) {
26- \$ deps[\$ package] = \$ constraint;
29+ // Skip php, magento/*, and Composer platform packages (ext-*, lib-*, composer-*-api).
30+ // Platform packages have no vendor/ directory and would cause repeated failed installs.
31+ if (\$ package === 'php'
32+ || str_starts_with(\$ package, 'magento/')
33+ || str_starts_with(\$ package, 'ext-')
34+ || str_starts_with(\$ package, 'lib-')
35+ || \$ package === 'composer-runtime-api'
36+ || \$ package === 'composer-plugin-api') {
37+ continue;
2738 }
39+ \$ deps[\$ package] = \$ constraint;
2840 }
29- \$ missing = [];
41+ \$ missingConstraints = [];
42+ \$ missingNames = [];
3043 foreach (\$ deps as \$ package => \$ constraint) {
3144 if (!is_dir('vendor/' . \$ package)) {
32- \$ missing[] = escapeshellarg(\"\$ package:\$ constraint\" );
45+ \$ missingConstraints[] = escapeshellarg(\"\$ package:\$ constraint\" );
46+ \$ missingNames[] = escapeshellarg(\$ package);
3347 }
3448 }
35- if (\$ missing) {
36- \$ cmd = 'composer require --no-interaction ' . implode(' ', \$ missing);
37- echo 'Installing MageForge module dependencies: ' . implode(', ', \$ missing) . PHP_EOL;
38- passthru(\$ cmd, \$ exitCode);
49+ if (\$ missingConstraints) {
50+ echo 'Installing MageForge module dependencies: ' . implode(', ', \$ missingNames) . PHP_EOL;
51+ // Add constraints without resolving first, then update only the new packages.
52+ // This prevents Composer from touching unrelated Magento core dependencies.
53+ passthru('composer require --no-interaction --no-update ' . implode(' ', \$ missingConstraints), \$ exitCode);
54+ if (\$ exitCode !== 0) { exit(\$ exitCode); }
55+ passthru('composer update --no-interaction ' . implode(' ', \$ missingNames), \$ exitCode);
3956 exit(\$ exitCode);
4057 }
4158"
0 commit comments