Legacy services clean up (#3367)
* Deleted remaining legacy service bits * Removed badge from README * Removed no longer needed try/catch * Deleted refactoring script * Switched to const * Reinstated doc * Ran Prettier
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
<a href="https://circleci.com/gh/badges/daily-tests">
|
||||
<img src="https://img.shields.io/circleci/project/github/badges/daily-tests.svg?label=service%20tests"
|
||||
alt="service-test status"></a>
|
||||
<a href="https://docs.google.com/spreadsheets/d/1cHIUSVaiKrIFw3KIu0yt-EMNlMkIfU5alE7YKZ4PeOE/edit#gid=0">
|
||||
<img src="https://img.shields.io/github/search/badges/shields/extends%20LegacyService.svg?label=legacy%20services%20needing%20refactor"
|
||||
alt="legacy services needing refactor"></a>
|
||||
<a href="https://coveralls.io/github/badges/shields">
|
||||
<img src="https://img.shields.io/coveralls/github/badges/shields.svg"
|
||||
alt="coverage"></a>
|
||||
|
||||
@@ -184,14 +184,8 @@ module.exports = class BaseService {
|
||||
|
||||
static getDefinition() {
|
||||
const { category, name, isDeprecated } = this
|
||||
|
||||
let base, format, pattern, queryParams
|
||||
try {
|
||||
;({ base, format, pattern } = this.route)
|
||||
queryParams = getQueryParamNames(this.route)
|
||||
} catch (e) {
|
||||
// Legacy services do not have a route.
|
||||
}
|
||||
const { base, format, pattern } = this.route
|
||||
const queryParams = getQueryParamNames(this.route)
|
||||
|
||||
const examples = this.examples.map((example, index) =>
|
||||
transformExample(example, index, this)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
**_WARNING: all legacy services have been rewritten, this document may contain outdated information._**
|
||||
|
||||
# Tips for rewriting legacy services
|
||||
|
||||
## Background
|
||||
|
||||
@@ -110,7 +110,6 @@
|
||||
"start": "concurrently --names server,frontend \"npm run start:server\" \"cross-env GATSBY_BASE_URL=http://localhost:8080 gatsby develop --port 3000\"",
|
||||
"e2e": "start-server-and-test start http://localhost:3000 test:e2e",
|
||||
"e2e-on-build": "cross-env CYPRESS_baseUrl=http://localhost:8080 start-server-and-test start:server http://localhost:8080 test:e2e",
|
||||
"refactoring-report": "node scripts/refactoring-cli.js",
|
||||
"badge": "cross-env NODE_CONFIG_ENV=test TRACE_SERVICES=true node scripts/badge-cli.js"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const chalk = require('chalk')
|
||||
const { namedColors } = require('../gh-badges/lib/color')
|
||||
const { floorCount } = require('../services/color-formatters')
|
||||
const { loadServiceClasses } = require('../core/base-service/loader')
|
||||
|
||||
const serviceClasses = loadServiceClasses()
|
||||
const legacyServices = serviceClasses
|
||||
.map(cls => (typeof cls.registerLegacyRouteHandler === 'function' ? 1 : 0))
|
||||
.reduce((a, b) => a + b)
|
||||
const newServices = serviceClasses.length - legacyServices
|
||||
const percentDone = ((newServices / serviceClasses.length) * 100).toFixed(2)
|
||||
const color = floorCount(percentDone, 10, 50, 100)
|
||||
|
||||
console.log(`Found ${serviceClasses.length} services:`)
|
||||
console.log(`- ${legacyServices} legacy services`)
|
||||
console.log(`- ${newServices} new services`)
|
||||
console.log(chalk.hex(namedColors[color])(`${percentDone}% done`))
|
||||
@@ -1,34 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const { BaseService } = require('.')
|
||||
|
||||
// This adapter allows running legacy badges in the new file layout and
|
||||
// service architecture.
|
||||
//
|
||||
// There are some tips for rewriting legacy services:
|
||||
// https://github.com/badges/shields/blob/master/doc/rewriting-services.md
|
||||
//
|
||||
// Do not use this for new services. New services should derive from e.g.
|
||||
// BaseJsonService. Refer to the tutorial:
|
||||
// https://github.com/badges/shields/blob/master/doc/TUTORIAL.md
|
||||
class LegacyService extends BaseService {
|
||||
// Provide a placeholder for services which do not define a route.
|
||||
static get route() {
|
||||
return { pattern: '' }
|
||||
}
|
||||
|
||||
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
|
||||
throw Error(`registerLegacyRouteHandler() not implemented for ${this.name}`)
|
||||
}
|
||||
|
||||
static register({ camp, handleRequest, githubApiProvider }, serviceConfig) {
|
||||
const { cacheHeaders: cacheHeaderConfig } = serviceConfig
|
||||
this.registerLegacyRouteHandler({
|
||||
camp,
|
||||
cache: (...args) => handleRequest(cacheHeaderConfig, ...args),
|
||||
githubApiProvider,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LegacyService
|
||||
Reference in New Issue
Block a user