Skip to content
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

Add support for Composer v2 #189

Merged
merged 20 commits into from
Feb 12, 2021
Merged

Commits on Feb 5, 2021

  1. Show output to highlight the extra composer update

    The message is informative and should be visible to users running Composer.
    
    Changed:
    - Log informing user that the installer is running again with merge settings applied
    - Visibility of `Logger::log()` method to output non-verbose messages
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    a6c3fd7 View commit details
    Browse the repository at this point in the history
  2. Revert lock file when extra composer update failed to complete

    Adapted from `RequireCommand` in Composer 2.
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    679b55d View commit details
    Browse the repository at this point in the history
  3. Add support for Composer v2

    In Composer v2, packages are solved first (dev and non-dev), then the lock file is written, then packages (dev and/or non-dev) are installed/updated/removed. As such, the closest alternative to the retired PRE_DEPENDENCIES_SOLVING is the new PRE_POOL_CREATE (and not PRE_OPERATIONS_EXEC as has been attempted in various plugins).
    
    The use of PRE_DEPENDENCIES_SOLVING in the merge-plugin is used to inject duplicate requirements (usually with a different version constraints) into the solver (while distinguishing between require and require-dev).
    
    To support Composer v1 and v2 without overcomplicating things, this commit replaces duplicate link tracking in `ExtraPackage` by back porting Composer 2's new static `MultiConstraint::create()` method which can be used to resolve complex-constraints early on. In turn, this makes the need for `PRE_DEPENDENCIES_SOLVING` obsolete.
    
    Bug: T248908
    
    Added:
    - Allow either ^1.1 or ^2.0 composer-plugin-api
    - New `PluginInterface` methods
    - New `MultiConstraint` back port from Composer v2 for v1
    
    Changed:
    - Replaced `PluginState::$duplicateLinks` with `MultiConstraint` to merge requirements and constraints in `ExtraPackage::mergeOrDefer()` instead of during `PRE_DEPENDENCIES_SOLVING`
    - Locking condition on `POST_PACKAGE_INSTALL` to force update in Composer v2
    - Testing of `POST_PACKAGE_INSTALL` to reflect forced update in Composer v2
    - Mocking of `VcsRepository` to support `HttpDownloader`  for Composer v2
    
    Removed:
    - Event `PRE_DEPENDENCIES_SOLVING` and method `MergePlugin::onDependencySolve()` since `ExtraPackage::mergeOrDefer()` handles duplicate package constraints
    - Mocked event `PRE_DEPENDENCIES_SOLVING` in `MergePluginTest::triggerPlugin()` since duplicates are no longer tracked
    - Assertions for obsolete `$extraInstalls` from `MergePluginTest::triggerPlugin()`
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    ca47835 View commit details
    Browse the repository at this point in the history
  4. Update local repository in example composer.json

    Added:
    - "repositories.only" to limit the repository's scope
    
    Changed:
    - "repositories.type" to "path" to use the plugin from the parent directory
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    face63b View commit details
    Browse the repository at this point in the history
  5. Improve merging constraints using Intervals helper

    Added `Intervals::isSubsetOf()`, from composer/semver v3, to use the smallest possible constraint in `ExtraPackage::mergeConstraints()`.
    
    Suggestion made by @Seldaek in: https://github.com/wikimedia/composer-merge-plugin/pull/189/files/a5c96e46520c6877792bc3d5fb01b44b0ab8d275#r511653048
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    4c8cedf View commit details
    Browse the repository at this point in the history
  6. Update instructions in README

    Removed `—lock` from sub-level updating instructions.
    Does not update sub-levels in Composer v1 or v2.
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    d962a36 View commit details
    Browse the repository at this point in the history
  7. Centralize Composer version check to PluginState

    Added:
    - Property and method `PluginState::isComposer1` to resolve Composer's version once
    
    Changed:
    - Class `MergePlugin` to use new `isComposer1` method
    - Class `ExtraPackage` to use new `isComposer1` method
    
    Fixed:
    - Missing `PluginState` type-hint on `ExtraPackage::mergeOrDefer()`
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    c529537 View commit details
    Browse the repository at this point in the history
  8. Update MultiConstraint back port

    Added:
    - PHPUnit/PHPCS annotations to ignore file
    
    Changed:
    - Updated to composer/semver v3.2.4
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    c3c950a View commit details
    Browse the repository at this point in the history
  9. Update installation section in README

    Added:
    - Instructions for safely upgrading the plugin to support Composer 2
    
    Changed:
    - Requirements to indicate Composer compatibility
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    1683470 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    453dc8a View commit details
    Browse the repository at this point in the history
  11. Include MultiConstraint in sniffs and coverage

    Fixed:
    - Syntax issues raised by PHPCS
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    81536f5 View commit details
    Browse the repository at this point in the history
  12. Update GitHub Actions to test Composer v2

    Added:
    - Action "ramsey/composer-install" to handle installation and caching
    - Steps to test Composer v1 and Composer v2 as dependencies
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    3a72cc9 View commit details
    Browse the repository at this point in the history
  13. Remove unused use statements

    Removed `InstallerEvent` and `InstallerEvents`.
    
    Amends 4da0ee8
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    e8ea480 View commit details
    Browse the repository at this point in the history
  14. Fix condition syntax in MultiConstraint

    Fixed mix of yoda and non-yoda conditions.
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    86bdb3e View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    3f68047 View commit details
    Browse the repository at this point in the history
  16. Update plugin name occurrences in README

    Normalize naming across file.
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    702596b View commit details
    Browse the repository at this point in the history
  17. Revert force update for Composer 2

    Restore original behaviour to only trigger update when lock file is not locked.
    In Composer 2, it is always locked.
    
    Added console log to notify user they may need to perform a manual update.
    
    Amends 4da0ee8
    mcaskill committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    7e6723b View commit details
    Browse the repository at this point in the history

Commits on Feb 7, 2021

  1. Add non-breaking whitespace to README

    To prevent orphan version numbers when paired with software.
    mcaskill committed Feb 7, 2021
    Configuration menu
    Copy the full SHA
    daa4e87 View commit details
    Browse the repository at this point in the history
  2. Refactor first install of merged requirements

    Adds tracking of merged requirements to `ExtraPackage` and `MergePlugin` to control if `MergePlugin::onPostInstallOrUpdate()` needs to trigger a `composer update` to install or update new requirements. The merged requirements are now assigned to `Installer::setUpdateAllowList()` to restrict the update operation to those new requirements. This prevents all other packages (such as root requirements) from being updated.
    
    This solution provides consistent support of both the first-install feature and subsequent changes to merge-patterns between Composer 1 and 2.
    
    Added:
    - Property `ExtraPackage::$mergedRequirements` (and getter method) to track new requirements during merging process of `ExtraPackage::mergeOrDefer()`.
    - Property `MergePlugin::$updateAllowList` (and getter method) to track all new requirements during merging process of `MergePlugin::mergeFile()`.
    - Conditional statement in `MergePlugin::onPostInstallOrUpdate()` to skip first-install if there are no extra requirements.
    
    Changed:
    - Replaced `PluginState::forceUpdate()` conditional statement in `MergePlugin::onPostInstallOrUpdate()` with `Installer::setUpdateAllowList()`
    
    FIxed:
    - Property tags for `$loaded` and `$loadedNoDev` in `MergePlugin`
    mcaskill committed Feb 7, 2021
    Configuration menu
    Copy the full SHA
    4195d45 View commit details
    Browse the repository at this point in the history

Commits on Feb 8, 2021

  1. Use setUpdateWhitelist for Composer 1

    Fixes backwards compatibility with versions older than Composer 1.10.8.
    
    Amends 4195d45
    mcaskill committed Feb 8, 2021
    Configuration menu
    Copy the full SHA
    b8b8cb4 View commit details
    Browse the repository at this point in the history