forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all-versions.js
59 lines (52 loc) · 1.99 KB
/
all-versions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const enterpriseServerReleases = require('./enterprise-server-releases')
// version = "plan"@"release"
// example: [email protected]
// where "enterprise-server" is the plan and "2.21" is the release
const versionDelimiter = '@'
const latestNonNumberedRelease = 'latest'
const plans = [
{
plan: 'free-pro-team',
planTitle: 'Free, Pro, and Team',
releases: [latestNonNumberedRelease],
latestRelease: latestNonNumberedRelease,
nonEnterpriseDefault: true, // permanent way to refer to this plan if the name changes
openApiBaseName: 'api.github.com', // used for REST
miscBaseName: 'dotcom' // used for GraphQL and webhooks
},
{
plan: 'enterprise-server',
planTitle: 'Enterprise Server',
releases: enterpriseServerReleases.supported,
latestRelease: enterpriseServerReleases.latest,
hasNumberedReleases: true,
openApiBaseName: 'ghes-',
miscBaseName: 'ghes-'
},
{
plan: 'github-ae',
planTitle: 'GitHub AE',
releases: [latestNonNumberedRelease],
latestRelease: latestNonNumberedRelease,
openApiBaseName: 'github.ae',
miscBaseName: 'ghae'
}
]
const allVersions = {}
// combine the plans and releases to get allVersions object
// e.g. free-pro-team@latest, [email protected], [email protected], etc.
plans.forEach(planObj => {
planObj.releases.forEach(release => {
const version = `${planObj.plan}${versionDelimiter}${release}`
const versionObj = {
version,
versionTitle: planObj.hasNumberedReleases ? `${planObj.planTitle} ${release}` : planObj.planTitle,
latestVersion: `${planObj.plan}${versionDelimiter}${planObj.latestRelease}`,
currentRelease: release,
openApiVersionName: planObj.hasNumberedReleases ? `${planObj.openApiBaseName}${release}` : planObj.openApiBaseName,
miscVersionName: planObj.hasNumberedReleases ? `${planObj.miscBaseName}${release}` : planObj.miscBaseName
}
allVersions[version] = Object.assign(versionObj, planObj)
})
})
module.exports = allVersions