Skip to content

Commit

Permalink
Deprecate HackageDeps service
Browse files Browse the repository at this point in the history
HackageDeps will allways return a landing page with 200 and no text about outdated packages.
The site is down and looking for someone to take over.
Therefor api information is false and non functional.
  • Loading branch information
jNullj committed Oct 18, 2024
1 parent 1d2bf19 commit 5f17d1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 58 deletions.
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' })

0 comments on commit 5f17d1f

Please sign in to comment.