-
Notifications
You must be signed in to change notification settings - Fork 45
feat: add methods to fetch package info from new composer 2 api #72
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
feat: add methods to fetch package info from new composer 2 api #72
Conversation
884e865 to
f92072b
Compare
|
Hey @JellyBellyDev, thank you for taking the time to make this pull request. I've had a quick look - do you think it's possible to change from Composer 1 to Composer 2 API results under the hood, while keeping the API surface of this package the same? If that's possible, that would be my suggested approach, even if it's only for the Versions data collection. It would be nice to avoid adding the new methods like |
|
Hi @robbieaverill the new version of composer api expose two new endpoint:
If we want change under the hood the method If we do this, wouldn't it be fair to also provide a method that uses the lite version ( |
|
Hi @JellyBellyDev, apologies for the delay in responding to you. I personally don't think it's important for this library to expose the underlying Packagist API responses. The fact that we have one public method that does this already is okay. If you want to add another protected method to expose the lite version, go for it. Hopefully we can avoid exposing this as a public method though. Your logic change seems reasonable to retain compatibility with the existing data structure we provide here. |
|
Hi @robbieaverill, thanks for the reply, don't worry about the late! ;) |
|
Hi @JellyBellyDev, apologies. My recommendation would be to change the |
|
Hey @JellyBellyDev, are you still keen to get this over the line? It'd be a great addition to get merged |
|
@robbieaverill forgive me, I completely forgot about this issue. Complete ASAP! ;) |
…erride getComposer to use new api
f92072b to
179847d
Compare
|
@robbieaverill PTAL I override the method |
| public function getComposerLite(string $package): array | ||
| { | ||
| return $this->respond(sprintf($this->url('/p/%s.json'), $package)); | ||
| return $this->respond(sprintf($this->url('/p2/%s.json'), $package)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming that the change of the API we consume in this method was deliberate? I have no problem with changing the underlying API we consume from v1 to v2. Is the intention of adding getComposerLite() to allow access to the original v1 API endpoint, or to return the same results as getComposer() except without dev dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I confirm!
I add getComposerLite() to return the same results of getComposer() except without dev dependencies as descripted here in the Getting package data section.
|
Thanks! |
|
it was a pleasure! 🚀 |
| */ | ||
| public function getComposer(string $package): array | ||
| { | ||
| return $this->respond(sprintf($this->url('/p2/%s~dev.json'), $package)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful. The ~dev.json files is a not about getting all versions. It is about getting dev versions. None of the releases (be them stable releases or beta releases) are in that file. If you want to get all versions, you need to load both files.
I add two new add methods to fetch package info from new composer 2 API.
I tried to add spec test but I'm not understand why not work.
@robbieaverill could you help me understand?
Thanks