Skip to content

Commit aa5a62d

Browse files
authored
Remove versions feature flag code (#15793)
* remove FEATURE_NEW_VERSIONS from feature-flags.json * remove process.env.FEATURE_NEW_VERSIONS from include files * remove process.env.FEATURE_NEW_VERSIONS from lib files * remove process.env.FEATURE_NEW_VERSIONS from middleware files * remove process.env.FEATURE_NEW_VERSIONS from script files * remove process.env.FEATURE_NEW_VERSIONS from test files * update test fixtures to use new versions as canonical fixtures
1 parent 6762f8c commit aa5a62d

File tree

95 files changed

+1342
-3974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1342
-3974
lines changed

feature-flags.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"FEATURE_TEST_TRUE": true,
3-
"FEATURE_TEST_FALSE": false,
4-
"FEATURE_NEW_VERSIONS": true
3+
"FEATURE_TEST_FALSE": false
54
}

includes/article-version-switcher.html

-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
<details class="dropdown-withArrow d-inline-block details details-reset mb-4 position-relative close-when-clicked-outside article-versions">
33
<summary class="d-flex flex-items-center flex-justify-between f4 h5-mktg btn-outline-mktg btn-mktg p-2">
44
<!-- GitHub.com, Enterprise Server 2.16, etc -->
5-
{% if process.env.FEATURE_NEW_VERSIONS %}
65
<span class="d-md-none d-xl-inline-block mr-1">{{ site.data.ui.pages.article_version }}</span> {{ allVersions[currentVersion].versionTitle }}
7-
{% else %}
8-
<span class="d-md-none d-xl-inline-block mr-1">{{ site.data.ui.pages.article_version }}</span> {{ productNames[currentVersion] }}
9-
{% endif %}
106
<svg class="arrow ml-1" width="14px" height="8px" viewBox="0 0 14 8" xml:space="preserve" fill="none" stroke="#1277eb"><path d="M1,1l6.2,6L13,1"></path></svg>
117
</summary>
128

@@ -16,11 +12,7 @@
1612
href="{{ permalink.href }}"
1713
class="d-block py-2 {% if currentPath == permalink.href %}link-blue active{% else %}link-gray-dark no-underline{% endif %}"
1814
>
19-
{% if process.env.FEATURE_NEW_VERSIONS %}
2015
{{ allVersions[permalink.pageVersion].versionTitle }}</a>
21-
{% else %}
22-
{{ productNames[permalink.pageVersion] }}</a>
23-
{% endif %}
2416
{% endfor %}
2517
</div>
2618
</details>

includes/deprecation-banner.html

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
{% unless process.env.FEATURE_NEW_VERSIONS %}
2-
{% assign enterpriseServerReleases = enterpriseVersions %}
3-
{% endunless %}
41
{% if currentVersion contains enterpriseServerReleases.oldestSupported %}
52
<div class="deprecation-banner border rounded-1 mb-2 bg-yellow-light p-3 border-yellow f5">
63
<p>

includes/header.html

+1-7
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ <h4 class="text-mono f5 text-normal text-gray d-md-none">{{ site.data.ui.homepag
4444
<div id="current-product" class="d-flex flex-items-center flex-justify-between" style="padding-top: 2px;">
4545
<!-- Product switcher - GitHub.com, Enterprise Server, etc -->
4646
<!-- 404 and 500 error layouts are not real pages so we need to hardcode the name for those -->
47-
{% if process.env.FEATURE_NEW_VERSIONS %}
4847
{{ allProducts[currentProduct].name }}
49-
{% else %}
50-
{{ currentProduct.name }}
51-
{% endif %}
5248
<svg class="arrow ml-md-1" width="14px" height="8px" viewBox="0 0 14 8" xml:space="preserve" fill="none" stroke="#1277eb"><path d="M1,1l6.2,6L13,1"></path></svg>
5349
</div>
5450
</summary>
@@ -57,7 +53,7 @@ <h4 class="text-mono f5 text-normal text-gray d-md-none">{{ site.data.ui.homepag
5753
{% for product in activeProducts %}
5854
<a href="{% unless product.external %}/{{ currentLanguage }}{% endunless %}{{ product.href }}"
5955
class="d-block py-2
60-
{% if process.env.FEATURE_NEW_VERSIONS and product.id == currentProduct %}text-blue-mktg text-underline active{% elsif product.id == currentProduct.id %}text-blue-mktg text-underline active{% else %}link-gray-dark no-underline{% endif %}">
56+
{% if product.id == currentProduct %}text-blue-mktg text-underline active{% elsif product.id == currentProduct.id %}text-blue-mktg text-underline active{% else %}link-gray-dark no-underline{% endif %}">
6157
{{ product.name }}
6258
{% if product.external %}
6359
<span class="ml-1"><svg width="9" height="10" viewBox="0 0 9 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path stroke="#24292e" d="M.646 8.789l8-8M8.5 9V1M1 .643h8"/></svg></span>
@@ -68,10 +64,8 @@ <h4 class="text-mono f5 text-normal text-gray d-md-none">{{ site.data.ui.homepag
6864
</details>
6965
</div>
7066

71-
{% if process.env.FEATURE_NEW_VERSIONS %}
7267
<!-- Versions picker that only appears in the header on homepage/versioned homepages -->
7368
{% include homepage-version-switcher %}
74-
{% endif %}
7569

7670
<div class="d-md-inline-block">
7771

includes/landing.html

+1-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ <h1 class="h1-mktg mb-3">{{ site.data.ui.search.need_help }}</h1>
2020
<h3 class="text-mono f5 text-normal text-gray text-md-center mb-4">{{ site.data.ui.homepage.explore_by_product }}</h3>
2121
<div class="d-flex flex-wrap gutter gutter-xl-spacious">
2222
{% for product in activeProducts %}
23-
{% if process.env.FEATURE_NEW_VERSIONS %}
24-
{% assign productVersions = product.versions %}
25-
{% else %}
26-
{% assign productVersions = currentVersion %}
27-
{% endif %}
28-
{% if productVersions contains currentVersion or currentVersion == 'homepage' %}
23+
{% if product.versions contains currentVersion or currentVersion == 'homepage' %}
2924
<div class="d-flex flex-column col-12 col-sm-6 col-lg-3 pb-4">
3025
<a class="btn-mktg flex-auto d-flex flex-items-center btn-outline-mktg btn-large-mktg ws-normal " href="{% unless product.external %}/{{ currentLanguage }}{% endunless %}{% if product.versions contains currentVersion %}/{{currentVersion}}/{{product.id}}{% else %}{{product.href}}{% endif %}">{{ product.name }}
3126
{% if product.external %}

includes/sidebar-homepage.html

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
{% if process.env.FEATURE_NEW_VERSIONS %}
21
{% include all-products-link %}
3-
{% endif %}
42

53
{% for product in activeProducts %}
6-
7-
{% if process.env.FEATURE_NEW_VERSIONS %}
8-
{% assign productVersions = product.versions %}
9-
{% else %}
10-
{% assign productVersions = currentVersion %}
11-
{% endif %}
12-
13-
{% if productVersions contains currentVersion or currentVersion == 'homepage' %}
4+
{% if product.versions contains currentVersion or currentVersion == 'homepage' %}
145
<li
156
title="{{product.name}}{% if product.external %} (External Site){% endif %}"
167
class="sidebar-product"
178
>
18-
{% if process.env.FEATURE_NEW_VERSIONS %}
199
<a href="{% unless product.external %}/{{currentLanguage}}{% endunless %}{% if product.versions contains currentVersion %}/{{currentVersion}}/{{product.id}}{% else %}{{product.href}}{% endif %}" class="f4 pl-4 pr-5 py-2">
20-
{% else %}
21-
<a href="{% unless product.external %}/{{currentLanguage}}{% endunless %}{{product.href}}" class="f4 pl-4 pr-5 py-2">
22-
{% endif %}
2310
{{ product.name }}
2411
{% if product.external %}
2512
<span class="ml-1"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="octicon" width="16" height="16"> <path fill-rule="evenodd" clip-rule="evenodd" d="M14.75 1C14.8163 1 14.8799 1.02634 14.9268 1.07322C14.9737 1.12011 15 1.1837 15 1.25V5.396C15.0001 5.44551 14.9855 5.49393 14.958 5.53513C14.9305 5.57632 14.8915 5.60843 14.8457 5.62739C14.8 5.64635 14.7497 5.6513 14.7011 5.64162C14.6525 5.63194 14.608 5.60805 14.573 5.573L13.03 4.03L8.53 8.53C8.38783 8.66248 8.19978 8.7346 8.00548 8.73118C7.81118 8.72775 7.62579 8.64903 7.48838 8.51162C7.35097 8.37421 7.27225 8.18882 7.26883 7.99452C7.2654 7.80022 7.33752 7.61217 7.47 7.47L11.97 2.97L10.427 1.427C10.3919 1.39204 10.3681 1.34745 10.3584 1.2989C10.3487 1.25034 10.3536 1.20001 10.3726 1.15427C10.3916 1.10853 10.4237 1.06945 10.4649 1.04199C10.5061 1.01453 10.5545 0.999912 10.604 1H14.75ZM2.75 2C2.28587 2 1.84075 2.18437 1.51256 2.51256C1.18437 2.84075 1 3.28587 1 3.75V13.25C1 14.216 1.784 15 2.75 15H12.25C12.7141 15 13.1592 14.8156 13.4874 14.4874C13.8156 14.1592 14 13.7141 14 13.25V9.75C14 9.55109 13.921 9.36032 13.7803 9.21967C13.6397 9.07902 13.4489 9 13.25 9C13.0511 9 12.8603 9.07902 12.7197 9.21967C12.579 9.36032 12.5 9.55109 12.5 9.75V13.25C12.5 13.3163 12.4737 13.3799 12.4268 13.4268C12.3799 13.4737 12.3163 13.5 12.25 13.5H2.75C2.6837 13.5 2.62011 13.4737 2.57322 13.4268C2.52634 13.3799 2.5 13.3163 2.5 13.25V3.75C2.5 3.6837 2.52634 3.62011 2.57322 3.57322C2.62011 3.52634 2.6837 3.5 2.75 3.5H6.25C6.44891 3.5 6.63968 3.42098 6.78033 3.28033C6.92098 3.13968 7 2.94891 7 2.75C7 2.55109 6.92098 2.36032 6.78033 2.21967C6.63968 2.07902 6.44891 2 6.25 2H2.75Z"></path></svg></span>

includes/sidebar-specific-product.html

-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
also gets an `is-current-page` class.
77
-->
88

9-
{% if process.env.FEATURE_NEW_VERSIONS %}
109
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct] %}
11-
{% else %}
12-
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct.id] %}
13-
{% endif %}
1410
{% include all-products-link %}
1511
<li title="{{product.title}}" class="sidebar-product mb-2">
1612
<a href="/{{currentLanguage}}{{product.href}}" class="pl-4 pr-5 pb-1 f4">{{ product.title }}</a>

includes/support.html

-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
<h4 class="mb-3">
55
{{ site.data.ui.support.still_need_help }}
66
</h4>
7-
{% if process.env.FEATURE_NEW_VERSIONS %}
87
{% if currentVersion contains 'enterprise' %}{% assign isEnterprise = true %}{% else %}{% assign isEnterprise = false %}{% endif %}
9-
{% else %}
10-
{% if currentVersion != 'dotcom' %}{% assign isEnterprise = true %}{% else %}{% assign isEnterprise = false %}{% endif %}
11-
{% endif %}
128
<a id="ask-community" href="https://github.saobby.my.eu.orgmunity" class="btn btn-outline">
139
{% octicon "people" width="16" %}
1410
{{ site.data.ui.support.ask_community }}

lib/all-products.js

+7-33
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,29 @@ const { difference } = require('lodash')
55
const yaml = require('js-yaml')
66
const contentDir = path.join(process.cwd(), 'content')
77
const frontmatter = require('@github-docs/frontmatter')
8+
const getApplicableVersions = require('./get-applicable-versions')
89

9-
let getApplicableVersions
10-
if (process.env.FEATURE_NEW_VERSIONS) {
11-
getApplicableVersions = require('./get-applicable-versions')
12-
}
13-
14-
// the product order is determined by a yml file
10+
// the product order is determined by data/products.yml
1511
const productsFile = path.join(process.cwd(), 'data/products.yml')
1612
const productsYml = yaml.load(fs.readFileSync(productsFile, 'utf8'))
1713
const sortedProductIds = productsYml.productsInOrder
1814

19-
let contentProductIds = fs.readdirSync(contentDir, { withFileTypes: true })
15+
const contentProductIds = fs.readdirSync(contentDir, { withFileTypes: true })
2016
.filter(entry => entry.isDirectory())
2117
.map(entry => entry.name)
2218

23-
// TODO this can be removed when we replace content/enterprise/admin with content/admin
24-
if (!process.env.FEATURE_NEW_VERSIONS) {
25-
contentProductIds = contentProductIds.map(id => id.replace('enterprise', 'enterpriseServer'))
26-
}
27-
2819
assert(difference(sortedProductIds, contentProductIds).length === 0)
2920
assert(difference(contentProductIds, sortedProductIds).length === 0)
3021

3122
const internalProducts = {}
3223

3324
sortedProductIds.forEach(productId => {
34-
const relPath = process.env.FEATURE_NEW_VERSIONS
35-
? productId
36-
: productId === 'enterpriseServer' ? 'enterprise/admin' : productId
37-
25+
const relPath = productId
3826
const dir = path.join('content', relPath)
3927
const toc = path.join(dir, 'index.md')
4028
const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))
41-
42-
let applicableVersions, href
43-
if (process.env.FEATURE_NEW_VERSIONS) {
44-
applicableVersions = getApplicableVersions(data.versions, toc)
45-
href = path.join('/', applicableVersions[0], productId)
46-
} else {
47-
href = path.join('/', relPath)
48-
}
29+
const applicableVersions = getApplicableVersions(data.versions, toc)
30+
const href = path.join('/', applicableVersions[0], productId)
4931

5032
internalProducts[productId] = {
5133
id: productId,
@@ -56,11 +38,7 @@ sortedProductIds.forEach(productId => {
5638
wip: data.wip || false
5739
}
5840

59-
if (process.env.FEATURE_NEW_VERSIONS) {
60-
internalProducts[productId].versions = applicableVersions
61-
} else {
62-
internalProducts[productId].hasEnterpriseUserVersions = productsYml.hasEnterpriseUserVersions.some(id => id === productId)
63-
}
41+
internalProducts[productId].versions = applicableVersions
6442
})
6543

6644
const externalProducts = {
@@ -78,10 +56,6 @@ const externalProducts = {
7856
}
7957
}
8058

81-
if (!process.env.FEATURE_NEW_VERSIONS) {
82-
Object.keys(externalProducts).forEach(id => { externalProducts[id].hasEnterpriseUserVersions = false })
83-
}
84-
8559
const allProducts = Object.assign({}, internalProducts, externalProducts)
8660

8761
module.exports = allProducts

lib/all-versions.js

+39-45
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
11
const enterpriseServerReleases = require('./enterprise-server-releases')
22

3-
if (!process.env.FEATURE_NEW_VERSIONS) {
4-
module.exports = ['dotcom'].concat(enterpriseServerReleases.supported)
5-
}
6-
7-
if (process.env.FEATURE_NEW_VERSIONS) {
8-
// version = "plan"@"release"
9-
// example: enterprise-server@2.21
10-
// where "enterprise-server" is the plan and "2.21" is the release
11-
const versionDelimiter = '@'
12-
const latestNonNumberedRelease = 'latest'
13-
14-
const plans = [
15-
{
16-
plan: 'free-pro-team',
17-
planTitle: 'Free, Pro, and Team',
18-
releases: [latestNonNumberedRelease],
19-
latestRelease: latestNonNumberedRelease,
20-
nonEnterpriseDefault: true // permanent way to refer to this plan if the name changes
21-
},
22-
{
23-
plan: 'enterprise-server',
24-
planTitle: 'Enterprise Server',
25-
releases: enterpriseServerReleases.supported,
26-
latestRelease: enterpriseServerReleases.latest,
27-
hasNumberedReleases: true
3+
// version = "plan"@"release"
4+
// example: enterprise-server@2.21
5+
// where "enterprise-server" is the plan and "2.21" is the release
6+
const versionDelimiter = '@'
7+
const latestNonNumberedRelease = 'latest'
8+
9+
const plans = [
10+
{
11+
plan: 'free-pro-team',
12+
planTitle: 'Free, Pro, and Team',
13+
releases: [latestNonNumberedRelease],
14+
latestRelease: latestNonNumberedRelease,
15+
nonEnterpriseDefault: true // permanent way to refer to this plan if the name changes
16+
},
17+
{
18+
plan: 'enterprise-server',
19+
planTitle: 'Enterprise Server',
20+
releases: enterpriseServerReleases.supported,
21+
latestRelease: enterpriseServerReleases.latest,
22+
hasNumberedReleases: true
23+
}
24+
]
25+
26+
const allVersions = {}
27+
28+
// combine the plans and releases to get allVersions object
29+
// e.g. free-pro-team@latest, enterprise-server@2.21, enterprise-server@2.20, etc.
30+
plans.forEach(planObj => {
31+
planObj.releases.forEach(release => {
32+
const version = `${planObj.plan}${versionDelimiter}${release}`
33+
34+
const versionObj = {
35+
version,
36+
versionTitle: planObj.hasNumberedReleases ? `${planObj.planTitle} ${release}` : planObj.planTitle,
37+
latestVersion: `${planObj.plan}${versionDelimiter}${planObj.latestRelease}`,
38+
currentRelease: release
2839
}
29-
]
30-
31-
const allVersions = {}
32-
33-
// combine the plans and releases to get allVersions object
34-
// e.g. free-pro-team@latest, enterprise-server@2.21, enterprise-server@2.20, etc.
35-
plans.forEach(planObj => {
36-
planObj.releases.forEach(release => {
37-
const version = `${planObj.plan}${versionDelimiter}${release}`
38-
39-
const versionObj = {
40-
version,
41-
versionTitle: planObj.hasNumberedReleases ? `${planObj.planTitle} ${release}` : planObj.planTitle,
42-
latestVersion: `${planObj.plan}${versionDelimiter}${planObj.latestRelease}`,
43-
currentRelease: release
44-
}
4540

46-
allVersions[version] = Object.assign(versionObj, planObj)
47-
})
41+
allVersions[version] = Object.assign(versionObj, planObj)
4842
})
43+
})
4944

50-
module.exports = allVersions
51-
}
45+
module.exports = allVersions

lib/check-developer-links.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi
7979

8080
// finding the linked page isn't enough if it's a github.com page; also need to check versions
8181
if (linkedPage.relativePath.startsWith('github')) {
82-
const linkedPageVersions = process.env.FEATURE_NEW_VERSIONS
83-
? getApplicableVersions(linkedPage.versions, linkedPage.relativePath)
84-
: getApplicableVersions(linkedPage.productVersions, linkedPage.relativePath)
82+
const linkedPageVersions = getApplicableVersions(linkedPage.versions, linkedPage.relativePath)
8583

8684
if (!linkedPageVersions.includes(version) && $(internalLink).attr('class') !== 'dotcom-only') {
8785
brokenLinks.links.push({ 'broken link': link, reason: `${version} not found in linked page versions`, 'linked page': linkedPage.fullPath })

lib/check-links.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi
6868

6969
// finding the linked page isn't enough if it's a github.com page; also need to check versions
7070
if (linkedPage.relativePath.startsWith('github')) {
71-
const linkedPageVersions = process.env.FEATURE_NEW_VERSIONS
72-
? getApplicableVersions(linkedPage.versions, linkedPage.relativePath)
73-
: getApplicableVersions(linkedPage.productVersions, linkedPage.relativePath)
71+
const linkedPageVersions = getApplicableVersions(linkedPage.versions, linkedPage.relativePath)
7472

7573
if (!linkedPageVersions.includes(version) && $(internalLink).attr('class') !== 'dotcom-only') {
7674
brokenLinks.links.push({ 'broken link': link, reason: `${version} not found in linked page versions`, 'linked page': linkedPage.fullPath })

lib/find-page.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const slash = require('slash')
22
const patterns = require('./patterns')
3-
const allVersions = process.env.FEATURE_NEW_VERSIONS
4-
? Object.keys(require('./all-versions'))
5-
: require('./all-versions')
3+
const allVersions = Object.keys(require('./all-versions'))
64
const { getVersionedPathWithLanguage } = require('./path-utils')
75

86
module.exports = function findPage (href, pages, redirects = {}, languageCode = 'en', sourceLanguage = null) {

lib/frontmatter.js

+7-25
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const semverRange = {
55
conform: require('semver').validRange,
66
message: 'Must be a valid SemVer range'
77
}
8-
const productIds = Object.keys(require('./all-products'))
98
const versionIds = Object.keys(require('./all-versions'))
109

1110
const schema = {
@@ -68,30 +67,13 @@ const schema = {
6867
}
6968
}
7069

71-
if (process.env.FEATURE_NEW_VERSIONS) {
72-
schema.properties.versions = {
73-
type: ['object', 'string'], // allow a '*' string to indicate all versions
74-
required: true,
75-
properties: versionIds.reduce((acc, versionId) => {
76-
acc[versionId] = semverRange
77-
return acc
78-
}, {})
79-
}
80-
}
81-
82-
if (!process.env.FEATURE_NEW_VERSIONS) {
83-
schema.properties.productVersions = {
84-
type: 'object',
85-
required: true,
86-
properties: productIds.reduce((acc, productId) => {
87-
// github used to be called dotcom
88-
// TODO: rename `dotcom` to `github` in all the markdown files' frontmatter
89-
if (productId === 'github') productId = 'dotcom'
90-
91-
acc[productId] = semverRange
92-
return acc
93-
}, {})
94-
}
70+
schema.properties.versions = {
71+
type: ['object', 'string'], // allow a '*' string to indicate all versions
72+
required: true,
73+
properties: versionIds.reduce((acc, versionId) => {
74+
acc[versionId] = semverRange
75+
return acc
76+
}, {})
9577
}
9678

9779
function frontmatter (markdown, opts = {}) {

0 commit comments

Comments
 (0)