Deprecate [Bintray] service (#6423)
This commit is contained in:
@@ -68,8 +68,6 @@ public:
|
||||
|
||||
private:
|
||||
azure_devops_token: 'AZURE_DEVOPS_TOKEN'
|
||||
bintray_user: 'BINTRAY_USER'
|
||||
bintray_apikey: 'BINTRAY_API_KEY'
|
||||
bitbucket_username: 'BITBUCKET_USER'
|
||||
bitbucket_password: 'BITBUCKET_PASS'
|
||||
bitbucket_server_username: 'BITBUCKET_SERVER_USER'
|
||||
|
||||
@@ -152,8 +152,6 @@ const publicConfigSchema = Joi.object({
|
||||
|
||||
const privateConfigSchema = Joi.object({
|
||||
azure_devops_token: Joi.string(),
|
||||
bintray_user: Joi.string(),
|
||||
bintray_apikey: Joi.string(),
|
||||
discord_bot_token: Joi.string(),
|
||||
drone_token: Joi.string(),
|
||||
gh_client_id: Joi.string(),
|
||||
|
||||
@@ -80,14 +80,6 @@ An Azure DevOps Token (PAT) is required for accessing [private Azure DevOps proj
|
||||
[ado personal access tokens]: https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts#create-personal-access-tokens-to-authenticate-access
|
||||
[ado token scopes]: https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=vsts#scopes
|
||||
|
||||
### Bintray
|
||||
|
||||
- `BINTRAY_USER` (yml: `private.bintray_user`)
|
||||
- `BINTRAY_API_KEY` (yml: `private.bintray_apikey`)
|
||||
|
||||
The bintray API [requires authentication](https://bintray.com/docs/api/#_authentication)
|
||||
Create an account and obtain a token from the user profile page.
|
||||
|
||||
### Bitbucket (Cloud)
|
||||
|
||||
- `BITBUCKET_USER` (yml: `private.bitbucket_username`)
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const { metric } = require('../text-formatters')
|
||||
const { downloadCount } = require('../color-formatters')
|
||||
const { BaseJsonService } = require('..')
|
||||
|
||||
const schema = Joi.object({
|
||||
totalDownloads: Joi.number().required(),
|
||||
}).required()
|
||||
|
||||
const versionSchema = Joi.object({
|
||||
name: Joi.string().required(),
|
||||
}).required()
|
||||
|
||||
const documentation = `
|
||||
<p>
|
||||
These badges utilize unofficial Bintray APIs to retrieve download data. <br />
|
||||
As such, they may be unstable or intermittently unavailable.
|
||||
</p>`
|
||||
|
||||
module.exports = class BintrayDownloads extends BaseJsonService {
|
||||
static category = 'downloads'
|
||||
|
||||
static route = {
|
||||
base: 'bintray',
|
||||
pattern: ':interval(dt)/:subject/:repo/:packageName/:version*',
|
||||
}
|
||||
|
||||
static auth = {
|
||||
userKey: 'bintray_user',
|
||||
passKey: 'bintray_apikey',
|
||||
authorizedOrigins: ['https://bintray.com'],
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Bintray',
|
||||
staticPreview: this.render({ downloads: 69000 }),
|
||||
namedParams: {
|
||||
interval: 'dt',
|
||||
subject: 'asciidoctor',
|
||||
repo: 'maven',
|
||||
packageName: 'asciidoctorj',
|
||||
},
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Bintray (latest)',
|
||||
staticPreview: this.render({ version: 'latest', downloads: 69000 }),
|
||||
namedParams: {
|
||||
interval: 'dt',
|
||||
subject: 'asciidoctor',
|
||||
repo: 'maven',
|
||||
packageName: 'asciidoctorj',
|
||||
version: 'latest',
|
||||
},
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Bintray (version)',
|
||||
staticPreview: this.render({ version: '1.6.0', downloads: 69000 }),
|
||||
namedParams: {
|
||||
interval: 'dt',
|
||||
subject: 'asciidoctor',
|
||||
repo: 'maven',
|
||||
packageName: 'asciidoctorj',
|
||||
version: '1.6.0',
|
||||
},
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static defaultBadgeData = { label: 'downloads' }
|
||||
|
||||
static render({ version, downloads }) {
|
||||
return {
|
||||
label: version ? `downloads@${version}` : 'downloads',
|
||||
message: metric(downloads),
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
async fetch({ subject, repo, packageName, version }) {
|
||||
let actualVersion = version
|
||||
if (version === 'latest') {
|
||||
actualVersion = (
|
||||
await this._requestJson(
|
||||
this.authHelper.withBasicAuth({
|
||||
schema: versionSchema,
|
||||
url: `https://bintray.com/api/v1/packages/${subject}/${repo}/${packageName}/versions/_latest`,
|
||||
})
|
||||
)
|
||||
).name
|
||||
}
|
||||
return this._requestJson(
|
||||
this.authHelper.withBasicAuth({
|
||||
schema,
|
||||
url: actualVersion
|
||||
? `https://bintray.com/api/ui/version/${subject}/${repo}/${packageName}/${actualVersion}/total_downloads`
|
||||
: `https://bintray.com/api/ui/package/${subject}/${repo}/${packageName}/total_downloads`,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async handle({ version, subject, repo, packageName }) {
|
||||
const { totalDownloads } = await this.fetch({
|
||||
subject,
|
||||
repo,
|
||||
packageName,
|
||||
version,
|
||||
})
|
||||
return this.constructor.render({ version, downloads: totalDownloads })
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const { expect } = require('chai')
|
||||
const nock = require('nock')
|
||||
const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers')
|
||||
const BintrayDownloads = require('./bintray-downloads.service')
|
||||
|
||||
describe('BintrayDownloads', function () {
|
||||
describe('auth', function () {
|
||||
cleanUpNockAfterEach()
|
||||
|
||||
const user = 'admin'
|
||||
const pass = 'password'
|
||||
const config = {
|
||||
private: {
|
||||
bintray_user: user,
|
||||
bintray_apikey: pass,
|
||||
},
|
||||
}
|
||||
|
||||
it('sends the auth information as configured', async function () {
|
||||
const scope = nock('https://bintray.com')
|
||||
.get('/api/ui/package/asciidoctor/maven/asciidoctorj/total_downloads')
|
||||
// This ensures that the expected credentials are actually being sent with the HTTP request.
|
||||
// Without this the request wouldn't match and the test would fail.
|
||||
.basicAuth({ user, pass })
|
||||
.reply(200, {
|
||||
totalDownloads: 69,
|
||||
})
|
||||
|
||||
expect(
|
||||
await BintrayDownloads.invoke(defaultContext, config, {
|
||||
interval: 'dt',
|
||||
subject: 'asciidoctor',
|
||||
repo: 'maven',
|
||||
packageName: 'asciidoctorj',
|
||||
})
|
||||
).to.deep.equal({
|
||||
color: 'yellowgreen',
|
||||
label: 'downloads',
|
||||
message: '69',
|
||||
})
|
||||
|
||||
scope.done()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,32 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const { isMetric } = require('../test-validators')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
t.create('downloads')
|
||||
.get('/dt/asciidoctor/maven/asciidoctorj.json')
|
||||
.expectBadge({
|
||||
label: 'downloads',
|
||||
message: isMetric,
|
||||
})
|
||||
|
||||
t.create('downloads (not found)')
|
||||
.get('/dt/asciidoctor/maven/not-a-real-package.json')
|
||||
.expectBadge({
|
||||
label: 'downloads',
|
||||
message: 'not found',
|
||||
})
|
||||
|
||||
t.create('downloads (mocked)')
|
||||
.get('/dt/asciidoctor/maven/asciidoctorj.json')
|
||||
.intercept(nock =>
|
||||
nock('https://bintray.com')
|
||||
.get('/api/ui/package/asciidoctor/maven/asciidoctorj/total_downloads')
|
||||
.reply(200, {
|
||||
totalDownloads: 420,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'downloads',
|
||||
message: '420',
|
||||
})
|
||||
@@ -1,51 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const { renderVersionBadge } = require('../version')
|
||||
const { BaseJsonService } = require('..')
|
||||
|
||||
const schema = Joi.object()
|
||||
.keys({
|
||||
name: Joi.string().required(),
|
||||
})
|
||||
.required()
|
||||
|
||||
module.exports = class BintrayVersion extends BaseJsonService {
|
||||
static category = 'version'
|
||||
static route = { base: 'bintray/v', pattern: ':subject/:repo/:packageName' }
|
||||
|
||||
static auth = {
|
||||
userKey: 'bintray_user',
|
||||
passKey: 'bintray_apikey',
|
||||
authorizedOrigins: ['https://bintray.com'],
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Bintray',
|
||||
staticPreview: renderVersionBadge({ version: '1.6.0' }),
|
||||
namedParams: {
|
||||
subject: 'asciidoctor',
|
||||
repo: 'maven',
|
||||
packageName: 'asciidoctorj',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
static defaultBadgeData = { label: 'bintray' }
|
||||
|
||||
async fetch({ subject, repo, packageName }) {
|
||||
// https://bintray.com/docs/api/#_get_version
|
||||
return this._requestJson(
|
||||
this.authHelper.withBasicAuth({
|
||||
schema,
|
||||
url: `https://bintray.com/api/v1/packages/${subject}/${repo}/${packageName}/versions/_latest`,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async handle({ subject, repo, packageName }) {
|
||||
const data = await this.fetch({ subject, repo, packageName })
|
||||
return renderVersionBadge({ version: data.name })
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const { expect } = require('chai')
|
||||
const nock = require('nock')
|
||||
const { cleanUpNockAfterEach, defaultContext } = require('../test-helpers')
|
||||
const BintrayVersion = require('./bintray-version.service')
|
||||
|
||||
describe('BintrayVersion', function () {
|
||||
describe('auth', function () {
|
||||
cleanUpNockAfterEach()
|
||||
|
||||
const user = 'admin'
|
||||
const pass = 'password'
|
||||
const config = {
|
||||
private: {
|
||||
bintray_user: user,
|
||||
bintray_apikey: pass,
|
||||
},
|
||||
}
|
||||
|
||||
it('sends the auth information as configured', async function () {
|
||||
const scope = nock('https://bintray.com')
|
||||
.get('/api/v1/packages/asciidoctor/maven/asciidoctorj/versions/_latest')
|
||||
// This ensures that the expected credentials are actually being sent with the HTTP request.
|
||||
// Without this the request wouldn't match and the test would fail.
|
||||
.basicAuth({ user, pass })
|
||||
.reply(200, {
|
||||
name: '1.5.7',
|
||||
})
|
||||
|
||||
expect(
|
||||
await BintrayVersion.invoke(defaultContext, config, {
|
||||
subject: 'asciidoctor',
|
||||
repo: 'maven',
|
||||
packageName: 'asciidoctorj',
|
||||
})
|
||||
).to.deep.equal({
|
||||
label: undefined,
|
||||
message: 'v1.5.7',
|
||||
color: 'blue',
|
||||
})
|
||||
|
||||
scope.done()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const {
|
||||
isVPlusDottedVersionNClausesWithOptionalSuffix,
|
||||
} = require('../test-validators')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
t.create('version').get('/asciidoctor/maven/asciidoctorj.json').expectBadge({
|
||||
label: 'bintray',
|
||||
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
|
||||
})
|
||||
|
||||
t.create('version (not found)')
|
||||
.get('/asciidoctor/maven/not-a-real-package.json')
|
||||
.expectBadge({
|
||||
label: 'bintray',
|
||||
message: 'not found',
|
||||
})
|
||||
|
||||
t.create('version (mocked)')
|
||||
.get('/asciidoctor/maven/asciidoctorj.json')
|
||||
.intercept(nock =>
|
||||
nock('https://bintray.com')
|
||||
.get('/api/v1/packages/asciidoctor/maven/asciidoctorj/versions/_latest')
|
||||
.reply(200, {
|
||||
name: '1.5.7',
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'bintray',
|
||||
message: 'v1.5.7',
|
||||
color: 'blue',
|
||||
})
|
||||
24
services/bintray/bintray.service.js
Normal file
24
services/bintray/bintray.service.js
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
|
||||
const { deprecatedService } = require('..')
|
||||
|
||||
module.exports = [
|
||||
deprecatedService({
|
||||
category: 'downloads',
|
||||
route: {
|
||||
base: 'bintray/dt',
|
||||
pattern: ':various+',
|
||||
},
|
||||
label: 'bintray',
|
||||
dateAdded: new Date('2021-04-24'),
|
||||
}),
|
||||
deprecatedService({
|
||||
category: 'version',
|
||||
route: {
|
||||
base: 'bintray/v',
|
||||
pattern: ':various+',
|
||||
},
|
||||
label: 'bintray',
|
||||
dateAdded: new Date('2021-04-24'),
|
||||
}),
|
||||
]
|
||||
22
services/bintray/bintray.tester.js
Normal file
22
services/bintray/bintray.tester.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
const { ServiceTester } = require('../tester')
|
||||
|
||||
const t = (module.exports = new ServiceTester({
|
||||
id: 'bintray',
|
||||
title: 'Bintray',
|
||||
}))
|
||||
|
||||
t.create('no longer available (previously downloads)')
|
||||
.get('/dt/asciidoctor/maven/asciidoctorj.json')
|
||||
.expectBadge({
|
||||
label: 'bintray',
|
||||
message: 'no longer available',
|
||||
})
|
||||
|
||||
t.create('no longer available (previously version)')
|
||||
.get('/v/asciidoctor/maven/asciidoctorj.json')
|
||||
.expectBadge({
|
||||
label: 'bintray',
|
||||
message: 'no longer available',
|
||||
})
|
||||
Reference in New Issue
Block a user