Skip to content

Commit

Permalink
Merge branch 'master' into 4040-gitea
Browse files Browse the repository at this point in the history
  • Loading branch information
CanisHelix authored Jan 7, 2024
2 parents 3e55e8d + 16d0ebb commit b1a08e1
Show file tree
Hide file tree
Showing 16 changed files with 577 additions and 447 deletions.
291 changes: 115 additions & 176 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@renovatebot/pep440": "^3.0.17",
"@renovatebot/ruby-semver": "^3.0.22",
"@sentry/node": "^7.91.0",
"@sentry/node": "^7.92.0",
"@shields_io/camp": "^18.1.2",
"@xmldom/xmldom": "0.8.10",
"badge-maker": "file:badge-maker",
Expand Down Expand Up @@ -147,15 +147,15 @@
"@docusaurus/core": "^2.4.3",
"@easyops-cn/docusaurus-search-local": "^0.40.1",
"@mdx-js/react": "^1.6.21",
"@typescript-eslint/parser": "^6.16.0",
"c8": "^8.0.1",
"@typescript-eslint/parser": "^6.17.0",
"c8": "^9.0.0",
"caller": "^1.1.0",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"chai-datetime": "^1.8.0",
"chai-string": "^1.4.0",
"child-process-promise": "^2.2.1",
"clsx": "^2.0.0",
"clsx": "^2.1.0",
"concurrently": "^8.2.2",
"cypress": "^13.6.2",
"cypress-wait-for-stable-dom": "^0.1.0",
Expand All @@ -171,7 +171,7 @@
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-icedfrisby": "^0.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^46.9.1",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-mocha": "^10.2.0",
"eslint-plugin-no-extension-in-require": "^0.2.0",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -192,7 +192,7 @@
"mocha-junit-reporter": "^2.2.1",
"mocha-yaml-loader": "^1.0.3",
"nock": "13.4.0",
"node-mocks-http": "^1.14.0",
"node-mocks-http": "^1.14.1",
"nodemon": "^3.0.2",
"npm-run-all": "^4.1.5",
"open-cli": "^8.0.0",
Expand All @@ -209,7 +209,7 @@
"sinon-chai": "^3.7.0",
"snap-shot-it": "^7.9.10",
"start-server-and-test": "2.0.3",
"tsd": "^0.30.1",
"tsd": "^0.30.3",
"url": "^0.11.3"
},
"engines": {
Expand Down
107 changes: 107 additions & 0 deletions services/galaxytoolshed/galaxytoolshed-version.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { NotFound, pathParams } from '../index.js'
import { renderVersionBadge } from '../version.js'
import GalaxyToolshedService from './galaxytoolshed-base.js'

export class GalaxyToolshedVersion extends GalaxyToolshedService {
static category = 'version'
static route = {
base: 'galaxytoolshed/v',
pattern: ':repository/:owner/:tool?/:requirement?',
}

static openApi = {
'/galaxytoolshed/v/{repository}/{owner}': {
get: {
summary: 'Galaxy Toolshed - Repository Version',
parameters: pathParams(
{
name: 'repository',
example: 'sra_tools',
},
{
name: 'owner',
example: 'iuc',
},
),
},
},
'/galaxytoolshed/v/{repository}/{owner}/{tool}': {
get: {
summary: 'Galaxy Toolshed - Tool Version',
parameters: pathParams(
{
name: 'repository',
example: 'sra_tools',
},
{
name: 'owner',
example: 'iuc',
},
{
name: 'tool',
example: 'fastq_dump',
},
),
},
},
'/galaxytoolshed/v/{repository}/{owner}/{tool}/{requirement}': {
get: {
summary: 'Galaxy Toolshed - Tool Requirement Version',
parameters: pathParams(
{
name: 'repository',
example: 'sra_tools',
},
{
name: 'owner',
example: 'iuc',
},
{
name: 'tool',
example: 'fastq_dump',
},
{
name: 'requirement',
example: 'perl',
},
),
},
},
}

static transform({ response, tool, requirement }) {
if (tool !== undefined) {
const dataTool = response[1].valid_tools.find(x => x.id === tool)
if (dataTool === undefined) {
throw new NotFound({ prettyMessage: 'tool not found' })
}
// Requirement version
if (requirement !== undefined) {
const dataRequirement = dataTool.requirements.find(
x => x.name === requirement,
)
if (dataRequirement === undefined) {
throw new NotFound({ prettyMessage: 'requirement not found' })
}
return dataRequirement.version
}
// Tool version
return dataTool.version
}
// Repository version
return response[1].changeset_revision
}

async handle({ repository, owner, tool, requirement }) {
const response = await this.fetchLastOrderedInstallableRevisionsSchema({
repository,
owner,
})
const version = this.constructor.transform({
response,
tool,
requirement,
})
return renderVersionBadge({ version })
}
}
51 changes: 51 additions & 0 deletions services/galaxytoolshed/galaxytoolshed-version.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { withRegex, isVPlusTripleDottedVersion } from '../test-validators.js'
import { createServiceTester } from '../tester.js'

export const t = await createServiceTester()

t.create('version - repository')
.get('/sra_tools/iuc.json')
.expectBadge({
label: 'galaxytoolshed',
message: withRegex(/^([\w\d]+)$/),
})
t.create('version - tool').get('/sra_tools/iuc/fastq_dump.json').expectBadge({
label: 'galaxytoolshed',
message: isVPlusTripleDottedVersion,
})
t.create('version - requirement')
.get('/sra_tools/iuc/fastq_dump/perl.json')
.expectBadge({
label: 'galaxytoolshed',
message: isVPlusTripleDottedVersion,
})

// Not found
t.create('version - changesetRevision not found')
.get('/bioqc/badilla.json')
.expectBadge({
label: 'galaxytoolshed',
message: 'changesetRevision not found',
})
t.create('version - repository not found')
.get('/sra_too/iuc.json')
.expectBadge({
label: 'galaxytoolshed',
message: 'not found',
})
t.create('version - owner not found').get('/sra_tool/iu.json').expectBadge({
label: 'galaxytoolshed',
message: 'not found',
})
t.create('version - tool not found')
.get('/sra_tools/iuc/fastq_dum.json')
.expectBadge({
label: 'galaxytoolshed',
message: 'tool not found',
})
t.create('version - requirement not found')
.get('/sra_tools/iuc/fastq_dump/per.json')
.expectBadge({
label: 'galaxytoolshed',
message: 'requirement not found',
})
95 changes: 59 additions & 36 deletions services/myget/myget.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { createServiceFamily } from '../nuget/nuget-v3-service-family.js'

const { NugetVersionService: Version, NugetDownloadService: Downloads } =
Expand All @@ -8,51 +9,73 @@ const { NugetVersionService: Version, NugetDownloadService: Downloads } =
})

class MyGetVersionService extends Version {
static examples = [
{
title: 'MyGet',
pattern: 'myget/:feed/v/:packageName',
namedParams: { feed: 'mongodb', packageName: 'MongoDB.Driver.Core' },
staticPreview: this.render({ version: '2.6.1' }),
},
{
title: 'MyGet (with prereleases)',
pattern: 'myget/:feed/vpre/:packageName',
namedParams: { feed: 'mongodb', packageName: 'MongoDB.Driver.Core' },
staticPreview: this.render({ version: '2.7.0-beta0001' }),
static openApi = {
'/myget/{feed}/{variant}/{packageName}': {
get: {
summary: 'MyGet Version',
parameters: pathParams(
{ name: 'feed', example: 'mongodb' },
{
name: 'variant',
example: 'v',
schema: { type: 'variant', enum: ['v', 'vpre'] },
description:
'Latest stable version (`v`) or Latest version including prereleases (`vpre`).',
},
{ name: 'packageName', example: 'MongoDB.Driver.Core' },
),
},
},
{
title: 'MyGet tenant',
pattern: ':tenant.myget/:feed/v/:packageName',
namedParams: {
tenant: 'tizen',
feed: 'dotnet',
packageName: 'Tizen.NET',
'/{tenant}/{feed}/{variant}/{packageName}': {
get: {
summary: 'MyGet Version (tenant)',
parameters: pathParams(
{
name: 'tenant',
example: 'tizen.myget',
description: 'MyGet Tenant in the format `name.myget`',
},
{ name: 'feed', example: 'dotnet' },
{
name: 'variant',
example: 'v',
schema: { type: 'variant', enum: ['v', 'vpre'] },
description:
'Latest stable version (`v`) or Latest version including prereleases (`vpre`).',
},
{ name: 'packageName', example: 'Tizen.NET' },
),
},
staticPreview: this.render({ version: '9.0.0.16564' }),
},
]
}
}

class MyGetDownloadService extends Downloads {
static examples = [
{
title: 'MyGet',
pattern: 'myget/:feed/dt/:packageName',
namedParams: { feed: 'mongodb', packageName: 'MongoDB.Driver.Core' },
staticPreview: this.render({ downloads: 419 }),
static openApi = {
'/myget/{feed}/dt/{packageName}': {
get: {
summary: 'MyGet Downloads',
parameters: pathParams(
{ name: 'feed', example: 'mongodb' },
{ name: 'packageName', example: 'MongoDB.Driver.Core' },
),
},
},
{
title: 'MyGet tenant',
pattern: ':tenant.myget/:feed/dt/:packageName',
namedParams: {
tenant: 'cefsharp',
feed: 'cefsharp',
packageName: 'CefSharp.Common',
'/{tenant}/{feed}/dt/{packageName}': {
get: {
summary: 'MyGet Downloads (tenant)',
parameters: pathParams(
{
name: 'tenant',
example: 'tizen.myget',
description: 'MyGet Tenant in the format `name.myget`',
},
{ name: 'feed', example: 'dotnet' },
{ name: 'packageName', example: 'Tizen.NET' },
),
},
staticPreview: this.render({ downloads: 9748 }),
},
]
}
}

export { MyGetVersionService, MyGetDownloadService }
3 changes: 3 additions & 0 deletions services/npm/npm-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const queryParamSchema = Joi.object({
registry_uri: optionalUrl,
}).required()

export const packageNameDescription =
'This may be the name of an unscoped package like `package-name` or a [scoped package](https://docs.npmjs.com/about-scopes) like `@author/package-name`'

// Abstract class for NPM badges which display data about the latest version
// of a package.
export default class NpmBase extends BaseJsonService {
Expand Down
38 changes: 19 additions & 19 deletions services/npm/npm-collaborators.service.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { pathParam, queryParam } from '../index.js'
import { renderContributorBadge } from '../contributor-count.js'
import NpmBase from './npm-base.js'

const keywords = ['node']
import NpmBase, { packageNameDescription } from './npm-base.js'

export default class NpmCollaborators extends NpmBase {
static category = 'activity'

static route = this.buildRoute('npm/collaborators', { withTag: false })

static examples = [
{
title: 'npm collaborators',
pattern: ':packageName',
namedParams: { packageName: 'prettier' },
staticPreview: this.render({ collaborators: 6 }),
keywords,
},
{
title: 'npm collaborators',
pattern: ':packageName',
namedParams: { packageName: 'prettier' },
queryParams: { registry_uri: 'https://registry.npmjs.com' },
staticPreview: this.render({ collaborators: 6 }),
keywords,
static openApi = {
'/npm/collaborators/{packageName}': {
get: {
summary: 'NPM Collaborators',
parameters: [
pathParam({
name: 'packageName',
example: 'prettier',
description: packageNameDescription,
}),
queryParam({
name: 'registry_uri',
example: 'https://registry.npmjs.com',
}),
],
},
},
]
}

static defaultBadgeData = {
label: 'npm collaborators',
Expand Down
Loading

0 comments on commit b1a08e1

Please sign in to comment.