Skip to content
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

Deprecate [HackageDeps] service #10618

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 8 additions & 45 deletions services/hackage/hackage-deps.service.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
import { BaseService, pathParams } from '../index.js'
import { deprecatedService } from '../index.js'

export default class HackageDeps extends BaseService {
static category = 'dependencies'

static route = {
export const HackageDeps = deprecatedService({
category: 'dependencies',
route: {
base: 'hackage-deps/v',
pattern: ':packageName',
}

static openApi = {
'/hackage-deps/v/{packageName}': {
get: {
summary: 'Hackage Dependencies',
parameters: pathParams({
name: 'packageName',
example: 'lens',
}),
},
},
}

static defaultBadgeData = { label: 'dependencies' }

static render({ isOutdated }) {
if (isOutdated) {
return { message: 'outdated', color: 'orange' }
} else {
return { message: 'up to date', color: 'brightgreen' }
}
}

async handle({ packageName }) {
const reverseUrl = `http://packdeps.haskellers.com/licenses/${packageName}`
const feedUrl = `http://packdeps.haskellers.com/feed/${packageName}`

// first call /reverse to check if the package exists
// this will throw a 404 if it doesn't
await this._request({ url: reverseUrl })

// if the package exists, then query /feed to check the dependencies
const { buffer } = await this._request({ url: feedUrl })

const outdatedStr = `Outdated dependencies for ${packageName} `
const isOutdated = buffer.includes(outdatedStr)
return this.constructor.render({ isOutdated })
}
}
},
label: 'hackagedeps',
dateAdded: new Date('2024-10-18'),
})
22 changes: 9 additions & 13 deletions services/hackage/hackage-deps.tester.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import Joi from 'joi'
import { createServiceTester } from '../tester.js'
export const t = await createServiceTester()
import { ServiceTester } from '../tester.js'
export const t = new ServiceTester({
id: 'hackagedeps',
title: 'Hackage Dependencies',
pathPrefix: '/hackage-deps/v',
})

t.create('hackage deps (valid)')
.get('/lens.json')
.expectBadge({
label: 'dependencies',
message: Joi.string().regex(/^(up to date|outdated)$/),
})

t.create('hackage deps (not found)')
.get('/not-a-package.json')
.expectBadge({ label: 'dependencies', message: 'not found' })
t.create('hackage deps (deprecated)')
.get('/package.json')
.expectBadge({ label: 'hackagedeps', message: 'no longer available' })
Loading