forked from badges/shields
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate HackageDeps service (badges#10618)
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
Showing
2 changed files
with
17 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }) |