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

[packagist] api v2 support #7681

Merged
merged 20 commits into from
Mar 5, 2022

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented Mar 4, 2022

Closes #7020.
As discussed in #7575 (comment) , lets merge this bit and use it as a baseline for further work
@calebcartwright - are you good to give this one a quick 👍 ?

GeoffSelby and others added 18 commits February 6, 2022 10:13
Packagist deprecated the original `packagist.org/p/username/package` endpoint in favor of v2 `packagist.org/p2/username/package` endpoint. Because of this, new packages aren't being found using v1.

This PR updates the Packagist service to use the new endpoint.
Some packages don't return the same data structure as others with the new api endpoints. This changes the validation schema to account for the potential differences.
Address issues raised by @chris48s in badges#6508, which this PR is base on.
Includes:

* Remove getDefaultBranch() from base class for it is no longer used.
* Change try-catch statement syntax to align code style.
* Rename findRelease() to findLatestRelease() for clarity.
* Change BasePackagistService.decompressResponse to static
  method BasePackagistService.expandPackageVersions.
* Fix expandPackageVersions implementation.
* Add unit test for the function.
* extend BasePackagistService.findLatestRelease to also handle
  PackagistVersion.
* remove PackagistVersion.transform.
* Update findLatestRelease to throw NotFound itself.
* Update PackagistLicense and PackagistVersion and remove the
  NotFound throwing logics.
* The test was on a false assumption that '__unset' might appear
  inside an array leaf while the composer's MetadataMinifier::minify
  never does thing recursively. The '__unset' should be value of the
  top level key.
@chris48s chris48s added the service-badge New or updated service badge label Mar 4, 2022
@shields-ci
Copy link

shields-ci commented Mar 4, 2022

Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!

Generated by 🚫 dangerJS against 350c441

@calebcartwright
Copy link
Member

@calebcartwright - are you good to give this one a quick +1 ?

Yeah will give it a quick pass after work today

@chris48s
Copy link
Member Author

chris48s commented Mar 4, 2022

Yeah no worries.

Just to clarify, these commits take us up to the point in the previous PR where you left the comments

Was going to ask if it'd be worth adding some unit tests for this function since the logic, though not terribly complex, isn't exactly trivial either.
I see that we're indirectly testing it with tests that targetting some of the child classes. That works for me, at least as long as we don't end up duplicating tests down the road

and

I believe my mental context is fresh enough at the moment to follow this, but if anyone is receptive and willing to do so in a follow up PR, I think a brief inline comment summarizing the what/why would be helpful for future readers (likely myself included)

last time.

@repo-ranger repo-ranger bot merged commit dcc7e28 into badges:master Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Packagist badge cannot handle composer v2-only packages
5 participants