Files
shields/services/nuget-fixtures.js
Paul Melnikow 5e99aad2de Rewrite [NuGet] badges including [myget chocolatey resharper powershellgallery] (#2257)
The NuGet badge examples are straggling in all-badge-examples. Rather than move them as is, I thought it made more sense to refactor the services and see if they could be generated. I didn't take that on here; this is a straight rewrite of the badges. The old implementations were fairly difficult to follow. The new implementations are complicated too, though I hope much more readable.

Though the NuGet behaviors could be consolidated into a single flag, I split `withTenant` and `withFeed` into separate flags, thinking naming the behaviors makes the implementations easier to understand. I defaulted these to true, thinking that really this is really a MyGet implementation which is generalized to NuGet. Though maybe it makes more sense to have the MyGet style as the default. Probably it doesn't matter much either way.

I added a helper class ServiceUrlBuilder to construct the Shields service URL. It's useful in this complex case where the URL must be built up conditionally. This might be useful in a couple other places.

I also wrote a new service to handle the Powershell badges. They've diverged a little bit from the Nuget v2. There's a bit of shared code which I factored out.

If the XML Nuget APIs are more reliable, we could consider switching everything else over to them, though for now I would like to get this merged and get #2078 fixed.

Fix #2078
2018-11-14 17:28:15 -05:00

64 lines
1.3 KiB
JavaScript

'use strict'
const queryIndex = JSON.stringify({
resources: [
{
'@id': 'https://api-v2v3search-0.nuget.org/query',
'@type': 'SearchQueryService',
},
],
})
const nuGetV2VersionJsonWithDash = JSON.stringify({
d: {
results: [
{ NormalizedVersion: '1.2-beta', Version: 'xxx', DownloadCount: 0 },
],
},
})
const nuGetV2VersionJsonFirstCharZero = JSON.stringify({
d: {
results: [{ NormalizedVersion: '0.35', Version: 'xxx', DownloadCount: 0 }],
},
})
const nuGetV2VersionJsonFirstCharNotZero = JSON.stringify({
d: {
results: [{ NormalizedVersion: '1.2.7', Version: 'xxx', DownloadCount: 0 }],
},
})
const nuGetV3VersionJsonWithDash = JSON.stringify({
data: [
{
totalDownloads: 0,
versions: [{ version: '1.2-beta' }],
},
],
})
const nuGetV3VersionJsonFirstCharZero = JSON.stringify({
data: [
{
totalDownloads: 0,
versions: [{ version: '0.35' }],
},
],
})
const nuGetV3VersionJsonFirstCharNotZero = JSON.stringify({
data: [
{
totalDownloads: 0,
versions: [{ version: '1.2.7' }],
},
],
})
module.exports = {
queryIndex,
nuGetV2VersionJsonWithDash,
nuGetV2VersionJsonFirstCharZero,
nuGetV2VersionJsonFirstCharNotZero,
nuGetV3VersionJsonWithDash,
nuGetV3VersionJsonFirstCharZero,
nuGetV3VersionJsonFirstCharNotZero,
}