Skip to content

Register shopware/conflicts composer repository on install and update - #24

Merged
Soner (shyim) merged 3 commits into
mainfrom
feat/add-conflicts-repo
Jul 4, 2026
Merged

Soner (shyim) merged 3 commits into
mainfrom
feat/add-conflicts-repo

Conversation

@shyim

Copy link
Copy Markdown
Member

What & why

This PR ensures https://shopware.github.io/conflicts/ is registered as a Composer repository on new installations and on updates, so the shopware/conflicts package can always be resolved.

See the conflicts package usage docs: https://github.com/shopware/conflicts/blob/main/USAGES.md

Changes

  • Resources/install-template/composer.json — add the conflicts composer repository to the template that bootstraps new installations.
  • Services/ProjectComposerJsonUpdater.php — new idempotent ensureConflictsRepository() method, called from update(). update() is the common choke point invoked by both InstallController::run (new installs, after the template is copied) and UpdateController::run (updates, against the existing project composer.json — including Flex projects where FlexMigrator is not invoked). The repo is matched by URL, so it is not duplicated whether existing repositories is an indexed list or a named map.
  • Tests/Services/ProjectComposerJsonUpdaterTest.php — updated assertions to reflect the conflicts repository and added testUpdateKeepsExistingConflictsRepository to verify an already-present conflicts repo is preserved without duplication.

FlexMigrator::patchRootComposerJson is intentionally untouched: ProjectComposerJsonUpdater::update() runs in both flows, so adding the repo there covers all cases without duplicating logic and without perturbing the FlexMigratorTest symlink-repository expectations.

Verification

  • vendor/bin/phpunit → 86 tests, 257 assertions, OK
  • vendor/bin/phpstan analyse → No errors
  • vendor/bin/php-cs-fixer fix --dry-run → 0 files to fix
  • Install template composer.json is valid JSON

Soner (shyim) and others added 3 commits July 4, 2026 21:50
…update

Add https://shopware.github.io/conflicts/ as a composer repository so the
shopware/conflicts package can be resolved during new installations and
updates.

- install-template/composer.json: include the conflicts composer repository
  in the template used to bootstrap new installations
- ProjectComposerJsonUpdater: idempotently ensure the conflicts composer
  repository is present on every update() run (covers both install and
  update flows, including Flex projects where FlexMigrator is not invoked)
- Tests: update assertions to reflect the conflicts repository and add a
  test verifying an existing conflicts repository is preserved without
  duplication
…) repo

The previous implementation always inserted the shopware/conflicts
repository under a named key ("shopware-conflicts"), which corrupted an
existing indexed-list "repositories" array into a mixed
{"0":...,"1":...,"shopware-conflicts":...} structure on JSON encode.

composer.json "repositories" can be either an indexed list or a keyed
(named) map. Preserve the existing layout:

- Add a shared addRepository() helper that appends a list item when the
  existing "repositories" is an indexed list (or empty), and adds a named
  entry when it is a keyed map.
- Refactor ensureConflictsRepository() to use it (with URL-based dedupe via
  hasRepository() so an existing conflicts repo is never duplicated).
- Apply the same form-preserving behavior to configureRepositories() for
  the SW_RECOVERY_REPOSITORY override, fixing the same latent corruption.

Tests:
- Existing assertions updated to the now-correct list-form output when
  starting without repositories.
- testConflictsRepositoryPreservesIndexedListForm and
  testConflictsRepositoryPreservesKeyedMapForm explicitly cover both
  layouts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant