-
-
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
[GitHub] latest release badge #1122
Conversation
- Badge shows readable format of release date of latest version - Color fades with age of release
lib/github-provider.js
Outdated
const colorB = makeColorB('#007ec6', data ); // blue | ||
const baseColor = Color(colorB); | ||
const weeksSinceRelease = moment().diff(releaseDate, 'weeks'); | ||
const factor = Math.max(Math.min(weeksSinceRelease / 25, 0.9), 0.1); |
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.
Please don't ask me about this 😊😊😊....
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.
Does the color scheme provided by age
in color-formatters
seem reasonable enough to use here, instead?
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.
Okay, but that is not lighten or brighten color. Anyways, I am cleaning the existing code with age
function
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 picking this up!
lib/github-provider.js
Outdated
try { | ||
const data = JSON.parse(buffer); | ||
|
||
if (!data.created_at) throw 'Project has no releases'; |
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.
Instead of throwing, this should return a badge with a helpful message.
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.
actually, problem is that data
is always a object even if the the repo is the exist. So, data.created_at
will not throw any error as it will be always null or a valid value.
If you think, we should return a valid message, then I've to check the status code first then data.created_at
. -- NO PROBLEM AT ALL.
Should i do this?
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.
Ah, I gotcha. Yes, it'd be better to add a test for a nonexistent repo, determine how to detect that condition, and return a useful message.
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.
ok! Then, I should check the returned status code
lib/github-provider.js
Outdated
sameDay : '[Today]', | ||
lastWeek : '[last] dddd', | ||
sameElse : now => releaseDate.year() == now.year() ? 'D MMM' : 'D MMM YYYY' | ||
}); |
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.
Could you use formatDate
from text-formatters
?
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.
Oh, the code it is already exists. 😃 ..
lib/github-provider.js
Outdated
const colorB = makeColorB('#007ec6', data ); // blue | ||
const baseColor = Color(colorB); | ||
const weeksSinceRelease = moment().diff(releaseDate, 'weeks'); | ||
const factor = Math.max(Math.min(weeksSinceRelease / 25, 0.9), 0.1); |
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.
Does the color scheme provided by age
in color-formatters
seem reasonable enough to use here, instead?
server.js
Outdated
@@ -3323,6 +3324,9 @@ cache(function(data, match, sendBadge, request) { | |||
}); | |||
})); | |||
|
|||
// GitHub release date integration. | |||
mapGithubReleaseDate(camp, githubApiUrl, githubAuth) |
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.
Could you add service tests?
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.
Ah, just saw your note about that!
|
||
const { handleRequest: cache } = require('./request-handler'); | ||
const { | ||
makeBadgeData: getBadgeData, | ||
makeLabel: getLabel, | ||
getLogo | ||
makeLogo: getLogo, |
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.
sorry, I made a mistake on previous pull request. I didn't noticed that getLogo
is not defined in badge-data
. It is alias of makeLogo
lib/github-provider.js
Outdated
//github return 404 if repo not found or no release | ||
if(res.statusCode === 404) { | ||
badgeData.text[1] = 'not found'; | ||
sendBadge(format, badgeData); |
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.
Is it good to return not found
? or just invalid
??
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.
Yea, no releases or repo not found would be clearer than invalid.
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.
Big String ^^
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.
It's helpful though! It tells the user what could be wrong.
Hahaha Travis CI still in pending 🌞 |
I kicked the build. It's running now. |
package.json
Outdated
@@ -24,6 +24,7 @@ | |||
"dependencies": { | |||
"camp": "~16.2.3", | |||
"chrome-web-store-item-property": "~1.1.2", | |||
"color": "^1.0.3", |
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.
This is no longer needed.
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.
👍 Oop! I forget to remove that.
service-tests/github.js
Outdated
t.create('Release Date. e.g release date|today') | ||
.get('/release-date/microsoft/vscode.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: Joi.equal('release date'), |
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.
You can simplify this and the one below to e.g. name: 'release date'
. I've gone ahead and done with the existing tests in #1127.
service-tests/github.js
Outdated
.get('/release-date/not-valid-name/not-valid-repo.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: Joi.equal('release date'), | ||
value: 'no releases or repo not found' |
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.
Since these are both hard-coded, it can be written like this:
.expectJSON({ name: 'release date', value: 'no releases or repo not found' })
20306b5
to
31e58c0
Compare
Not ready yet. |
ready. |
Will this account for any release? |
hi, @tooomm full release |
Does it makes sense to extend this for Many repos use pre-releases to distribute betas next to stable releases. |
yep! right! okay I'll add. Lets wait for what @paulmelnikow says - should I open a different pull request on it or it will be included here? (I am saying because this PR is extended from #905) Btw, I think, there is no explicit API for getting latest pre-release version. |
You might be right there. For displaying releases it works like that: GitHub release: | https://img.shields.io/github/release/qubyte/rubidium.svg So it looks like one just displays all releases (including pre-releases) and the first just displays full releases. Example with a different pre-release as seen in a readme on github: |
Github service tests passing locally. That's a great idea to add prerelease-date. Let's do it in a separate PR so we can close this out! Thanks for all your work on this! 🏅 |
If you keep on looking into that |
pull request #905
Hi, please review the code. I've separated the code to
lib/github-provider.js
& made few modification on it.[the branch was too old, I've managed conflicting code & removed few code with standard function]
Please guide me for further changes. [I have not yet added tests. I'll add it by tommrow & for now please ingore the lint issue. I'll fix it then.]