[JetBrains] Plugin version badge #1164
Conversation
Related issue #1162 |
@@ -6577,6 +6577,48 @@ cache(function(data, match, sendBadge, request) { | |||
}); | |||
})); | |||
|
|||
// JetBrains Plugins repository version integration | |||
camp.route(/^\/jetbrains\/plugin\/(v)\/([^\/]+)\.(svg|png|gif|jpg|json)$/, |
platan
Oct 12, 2017
Member
Most of the code is identical with code from downloads badge (cause we are using the same API resource). Maybe we should have one function handling this?
Most of the code is identical with code from downloads badge (cause we are using the same API resource). Maybe we should have one function handling this?
ice1000
Oct 12, 2017
Author
Contributor
So how to do that? This is the first day I use JavaScript to develop 😢
So how to do that? This is the first day I use JavaScript to develop
platan
Oct 12, 2017
Member
We can have one camp.route
with (d|v)
. switch
statement should be put after checking if plugin is not found. Then handle d
and v
in this switch. You can use "Packagist integration" as a reference.
We can have one camp.route
with (d|v)
. switch
statement should be put after checking if plugin is not found. Then handle d
and v
in this switch. You can use "Packagist integration" as a reference.
return sendBadge(format, badgeData); | ||
} | ||
var version = data['plugin-repository'].category[0]["idea-plugin"][0].version[0]; | ||
badgeData.text[1] = metric(downloads); |
platan
Oct 12, 2017
Member
There is no downloads
variable in this function.
There is no downloads
variable in this function.
ice1000
Oct 12, 2017
Author
Contributor
Fixed
Fixed
|
||
try { | ||
switch (type) { | ||
case 'd': |
platan
Oct 12, 2017
Member
We have jetbrains/plugin/v
in path.
We have jetbrains/plugin/v
in path.
ice1000
Oct 12, 2017
Author
Contributor
Fixed
Fixed
t.create('downloads (plugin id from plugin.xml)') | ||
.get('/plugin/d/org.intellij.scala.json') | ||
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric })); | ||
|
||
t.create('downloads (plugin id from plugin.xml)(v)') |
platan
Oct 12, 2017
Member
Maybe version (plugin id from plugin.xml)
?
Maybe version (plugin id from plugin.xml)
?
ice1000
Oct 12, 2017
Author
Contributor
Fixed
Fixed
module.exports = t; | ||
|
||
t.create('downloads (number as a plugin id)') | ||
.get('/plugin/d/7495.json') | ||
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric })); | ||
|
||
t.create('jetbrains plugin (number as a plugin id)(v)') |
platan
Oct 12, 2017
Member
Maybe version (number as a plugin id)
?
Maybe version (number as a plugin id)
?
ice1000
Oct 12, 2017
Author
Contributor
Fixed
Fixed
t.create('downloads (user friendly plugin id)') | ||
.get('/plugin/d/1347-scala.json') | ||
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric })); | ||
|
||
t.create('downloads (user friendly plugin id)(v)') |
platan
Oct 12, 2017
Member
What do you think about version (user friendly plugin id)
What do you think about version (user friendly plugin id)
ice1000
Oct 12, 2017
Author
Contributor
Ahhh.... Wait a minute
Ahhh.... Wait a minute
ice1000
Oct 12, 2017
Author
Contributor
Fixed
Fixed
t.create('unknown plugin') | ||
.get('/plugin/d/unknown-plugin.json') | ||
.expectJSON({ name: 'downloads', value: 'not found' }); | ||
|
||
t.create('unknown plugin(v)') |
platan
Oct 12, 2017
Member
What do you think about version for unknown plugin
?
What do you think about version for unknown plugin
?
ice1000
Oct 12, 2017
Author
Contributor
Fixed
Fixed
Why do the tests fail? I think the production code and test code for version is nearly the same as |
@platan What about the newest version?
|
Build results can be found here https://travis-ci.org/badges/shields/jobs/287207493. |
@@ -93,6 +154,32 @@ t.create('missing required XML attribute') | |||
}) | |||
.expectJSON({ name: 'downloads', value: 'invalid' }); | |||
|
|||
t.create('missing required XML attribute(v)') |
platan
Oct 12, 2017
Member
You do not need this test. Version value is in version
element.
You do not need this test. Version value is in version
element.
ice1000
Oct 12, 2017
•
Author
Contributor
Fixed. How is that now?
Fixed. How is that now?
CI check done. Please check and merge. Maybe you need |
cache(function(data, match, sendBadge, request) { | ||
var pluginId = match[2]; | ||
var type = match[1]; | ||
var format = match[3]; |
paulmelnikow
Oct 12, 2017
Member
Since you're not doing anything with type
, you can remove it as a capture group in the regular expression. Just remove the parentheses around it. Then change match[2]
to match[1]
and change match[3]
to match[2]
.
Since you're not doing anything with type
, you can remove it as a capture group in the regular expression. Just remove the parentheses around it. Then change match[2]
to match[1]
and change match[3]
to match[2]
.
} | ||
|
||
try { | ||
switch (type) { |
paulmelnikow
Oct 12, 2017
Member
Since there is only one case you do not need the switch
statement at all.
Since there is only one case you do not need the switch
statement at all.
platan
Oct 12, 2017
Member
@paulmelnikow maybe you didn't see my comments (they are under "show outdated" right know).
I suggested:
"Most of the code is identical with code from downloads badge (cause we are using the same API resource). Maybe we should have one function handling this?" and "We can have one camp.route with (d|v). switch statement should be put after checking if plugin is not found. Then handle d and v in this switch. You can use "Packagist integration" as a reference."
What do you think about this?
@paulmelnikow maybe you didn't see my comments (they are under "show outdated" right know).
I suggested:
"Most of the code is identical with code from downloads badge (cause we are using the same API resource). Maybe we should have one function handling this?" and "We can have one camp.route with (d|v). switch statement should be put after checking if plugin is not found. Then handle d and v in this switch. You can use "Packagist integration" as a reference."
What do you think about this?
paulmelnikow
Oct 12, 2017
Member
I see what you mean. Yes, I agree. Combining this into one route seems like a much better approach.
I see what you mean. Yes, I agree. Combining this into one route seems like a much better approach.
ice1000
Oct 12, 2017
Author
Contributor
So should I do this?
So should I do this?
ice1000
Oct 12, 2017
Author
Contributor
Nevermind. I've done this.
Nevermind. I've done this.
|
||
const t = new ServiceTester({ id: 'jetbrains', title: 'JetBrains plugin' }); | ||
const t = new ServiceTester({ id: 'jetbrains', title: 'JetBrains plugin/version' }); |
paulmelnikow
Oct 12, 2017
Member
Rather than keep updating this, you can just call it 'JetBrains'
.
Rather than keep updating this, you can just call it 'JetBrains'
.
ice1000
Oct 12, 2017
Author
Contributor
Done.
Done.
@@ -3,31 +3,53 @@ | |||
const Joi = require('joi'); | |||
const ServiceTester = require('./runner/service-tester'); | |||
const { isMetric } = require('./helpers/validators'); | |||
const { isSemver } = require('./helpers/validators'); |
paulmelnikow
Oct 12, 2017
Member
const {
isMetric,
isSemver
} = require('./helpers/validators');
const {
isMetric,
isSemver
} = require('./helpers/validators');
ice1000
Oct 12, 2017
Author
Contributor
Done.
Done.
t.create('version (number as a plugin id)') | ||
.get('/plugin/v/7495.json') | ||
.expectJSONTypes(Joi.object().keys({ name: 'jetbrains plugin', value: isSemver })); | ||
|
paulmelnikow
Oct 12, 2017
Member
Thanks for all the great tests! Instead of interspersing these with the download tests, could you keep all the download tests together followed by all the version tests? They're a lot easier to follow that way.
Thanks for all the great tests! Instead of interspersing these with the download tests, could you keep all the download tests together followed by all the version tests? They're a lot easier to follow that way.
ice1000
Oct 12, 2017
Author
Contributor
Resorted.
Resorted.
|
Yeah, nice!! |
Also, thanks for your reviewing @platan, much appreciated! |
https://img.shields.io/jetbrains/plugin/v/9630-a8translate.svg Hmm, seems 404. @paulmelnikow How long will it take to see it work? |
Until the next deploy. Shouldn't be too long, though it's entirely outside my control so I don't have a specific ETA. You could keep an eye on this to see when it happens: https://github.com/badges/shields/commits/gh-pages |
Thank you! @paulmelnikow |
@paulmelnikow Sorry for bothering but I forgot to add this badge to the front page. Can you do it for me? |
Ah, shoot, sorry I missed that. Feel free to open another PR. |
This reverts commit 003c44c.
It should be look like:
I don't have a node.js local environment. If test fail please do tell me.