Skip to content

Commit ad06d21

Browse files
committed
build(generate-routes): adapt to @octokit/routes v20
1 parent b4a5c07 commit ad06d21

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

scripts/generate-routes.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const routes = require('@octokit/routes')
55
const newRoutes = {}
66

77
function normalize (methodName) {
8-
return camelCase(methodName.replace(/^edit/, 'update'))
8+
return camelCase(methodName)
99
}
1010

1111
const endpoints = Object.keys(routes).reduce((result, scope) => {
@@ -26,6 +26,7 @@ endpoints.forEach(endpoint => {
2626
// new route
2727
newRoutes[idName] = {
2828
method: endpoint.method,
29+
headers: endpoint.headers,
2930
params: endpoint.params.reduce((result, param) => {
3031
result[param.name] = {
3132
type: param.type
@@ -37,19 +38,21 @@ endpoints.forEach(endpoint => {
3738
result[param.name].required = true
3839
}
3940
if (param.mapTo) {
40-
result[param.name].mapTo = param.mapTo
41+
result[param.name].mapTo = param.mapTo === 'input' ? 'data' : param.mapTo
42+
43+
if (result[param.name].mapTo === 'data' === param.name) {
44+
delete result[param.name].mapTo
45+
}
4146
}
4247
if (param.enum) {
4348
result[param.name].enum = param.enum
4449
}
4550
if (param.regex) {
4651
result[param.name].validation = param.regex
4752
}
48-
if (param.alias) {
49-
result[param.name].alias = param.alias
50-
}
5153
if (param.deprecated) {
52-
result[param.name].deprecated = param.deprecated
54+
result[param.name].deprecated = true
55+
result[param.name].alias = param.deprecated.after.name
5356
}
5457
return result
5558
}, {}),
@@ -66,6 +69,11 @@ endpoints.forEach(endpoint => {
6669
accept: previewHeaders
6770
}
6871
}
72+
73+
if (endpoint.deprecated) {
74+
newRoutes[idName].deprecated = `octokit.scim.${camelCase(endpoint.deprecated.before.idName)}() has been renamed to octokit.scim.${camelCase(endpoint.deprecated.after.idName)}() (${endpoint.deprecated.date})`
75+
}
6976
})
7077

7178
require('fs').writeFileSync('routes.json', JSON.stringify(sortKeys(newRoutes, { deep: true }), null, 2) + '\n')
79+
console.log(`routes.json written.`)

0 commit comments

Comments
 (0)