-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[npm] - Last update badge added #10641
[npm] - Last update badge added #10641
Conversation
|
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.
also this.
…ti/shields into npm-latest-package-update
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.
Finished a review round, i have some inputs.
I think we could benefit from using buildRoute
but i could not find an elegant way to use it while adding version
queryparam, let me know if you have an idea.
But i think that we could also just define the route in the service.
I noticed scoped packages failed, notice my change requests that fix that, maybe we should add a test for scoped package as well.
Just thinking whether we can do something like taking queryparam as input, if |
this is to add other query params schema, other than the one present in NpmBase.
Other way - 96ced45, introduced new |
Just quickly unwinding this.. what problem does the AFAIK a npm version is immutable. Once you've pushed a release with a given version number you can't push that version again. So the "last updated" timestamp for a specific version is static. It is a value that isn't going to change (unlike "last updated" for the package itself or a tag, which will change over time as versions are published). |
This param helps to fetch Also yeah it won't change 🙂. As the data is available, I thought of giving it like an option to fetch last updated for a particular version. Thought it would be good to have one. |
"Last update" by version is not very useful, indeed. However, it would be good to get the last update for a given dist-tag esp. for projects that keep several active release branches. See Verdaccio, for example. |
Makes sense, @MohanKumarAmbati can you add tags to your fetch and enable tags in path? (also openapi and tests) |
Thanks for the input @mbtools, but looks like they're not exposing last updated time in the API verdaccio - next-8. please let me know if there is an API that we can make use of. |
After you fetch the manifest (https://registry.npmjs.org/verdaccio), lookup the dist-tag and get the associated version: Then use that version to get the time: For next-8, the time would be |
Hi @chris48s, can you please add |
Thank you @chris48s |
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.
Two more small things, but overall seems alright.
|
||
let date | ||
|
||
if (tag && tag in packageData['dist-tags']) { |
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.
tag in packageData['dist-tags']
I think we could improve a bit if we test the array once and use the result twice. I would expect this to be a long array for some packages.
Co-authored-by: jNullj <15849761+jNullj@users.noreply.github.com>
…ti/shields into npm-latest-package-update
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.
LGTM, Thank you @MohanKumarAmbati for the contribution.
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.
Thanks for your work on this @MohanKumarAmbati , and for taking the review @jNullj
Just having a quick look over this I have a couple of additional comments.
Co-authored-by: chris48s <chris48s@users.noreply.github.com>
nice work. thanks @MohanKumarAmbati 🙏 |
🚀 Updated review app: https://pr-10641-badges-shields.fly.dev |
Thanks. Good work all. I'm going to merge this. One thing I have realised about this badge is that it will work fine for most packages, but the Shields has a hard limit on the size of response we will accept from an API. We cap it at 10Mb so for some subset of packages this badge will not work. I think that's just something we live with. In reality the number of packages that actually generate such a huge response (>10Mb) is quite small. |
The typescript package is another one (13 MB). You could get the abbreviated manifest first (https://github.com/npm/registry/blob/main/docs/responses/package-metadata.md). That has last-modified time already and the tags. Then if a tag was selected, get the individual version json instead of the complete manifest. |
That's a huge difference.
From the test-abbreviated we can get The only thing i think is useful with abbreviated response is when we don't use a tag. Altho, i think i just found a trick ;) "_npmOperationalInternal":{
"tmp":"tmp/npm_7.24.2_1633367792820_0.6414313657198436",
"host":"s3://npm-registry-packages"
}
Not sure if we can trust this, but it sure looks like a cool party trick |
Making 2 requests in sequence has its own performance impact. I think a reasonable solution would be:
That would be a huge improvement for the most common case. I think we should stick to relying on the documented API behaviour. Relying on undocumented assumptions about API internals generally ends up biting us in the long run. |
Hi Team,
Extending NpmBase points registry URL to https://registry.npmjs.org/express/latest - latest, which do not include last updated time. Hence, extended BaseJsonService to fetch the json.
closes - #10023