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

[Maven] Added badge for Maven-Cenral last-update (#10301) #10585

Merged
merged 5 commits into from
Oct 12, 2024

Conversation

MohanKumarAmbati
Copy link
Contributor

@MohanKumarAmbati MohanKumarAmbati commented Oct 4, 2024

  • Added badge for Maven-Central last-update

Hi @chris48s, can you please add hacktoberfest-accepted label to this PR so that it is considered under it.

closes - #10301

Thanks in advance.

Copy link
Contributor

github-actions bot commented Oct 4, 2024

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

Generated by 🚫 dangerJS against d723037

@MohanKumarAmbati MohanKumarAmbati changed the title [Maven] Added badge for Maven-Cenral last-update (#10301) hacktoberfest-accepted - [Maven] Added badge for Maven-Cenral last-update (#10301) Oct 5, 2024
@MohanKumarAmbati MohanKumarAmbati changed the title hacktoberfest-accepted - [Maven] Added badge for Maven-Cenral last-update (#10301) [Maven] Added badge for Maven-Cenral last-update (#10301) Oct 5, 2024
@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Oct 8, 2024
return this._requestXml({
schema,
url: `https://repo1.maven.org/maven2/${group}/${artifact}/maven-metadata.xml`,
httpErrors: { 404: 'solution not found' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the significance of the word "solution" here? Given the names of the params, I'd assume "artifact not found" would be the error here

Comment on lines 51 to 56
const date = new Date(
`${metadata.versioning.lastUpdated}`.replace(
/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/,
'$4:$5:$6 $2/$3/$1',
),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of trying to do this with regex, lets use dayjs to:

  • parse this
  • make sure it is valid
  • throw an exception if it is not

We can pass a dayjs object straight to formatDate() and ageColor()

Suggested code:

import dayjs from 'dayjs'
import { InvalidResponse } from '../index.js'

const date = dayjs(metadata.versioning.lastUpdated, "YYYYMMDDHHmmss")

if (!date.isValid()) {
  throw new InvalidResponse({ prettyMessage: 'invalid date' })
}

return this.constructor.render({ date })

Copy link
Contributor

🚀 Updated review app: https://pr-10585-badges-shields.fly.dev

@chris48s chris48s added this pull request to the merge queue Oct 12, 2024
Merged via the queue into badges:master with commit e3808c1 Oct 12, 2024
23 checks passed
@MohanKumarAmbati
Copy link
Contributor Author

Thank you @chris48s, this is a very special to me as it is my first contribution towards open-source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants