Skip to content

Commit

Permalink
Remove versions feature flag code (#15793)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sarahs authored Sep 29, 2020
1 parent 6762f8c commit aa5a62d
Show file tree
Hide file tree
Showing 95 changed files with 1,342 additions and 3,974 deletions.
3 changes: 1 addition & 2 deletions feature-flags.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"FEATURE_TEST_TRUE": true,
"FEATURE_TEST_FALSE": false,
"FEATURE_NEW_VERSIONS": true
"FEATURE_TEST_FALSE": false
}
8 changes: 0 additions & 8 deletions includes/article-version-switcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
<details class="dropdown-withArrow d-inline-block details details-reset mb-4 position-relative close-when-clicked-outside article-versions">
<summary class="d-flex flex-items-center flex-justify-between f4 h5-mktg btn-outline-mktg btn-mktg p-2">
<!-- GitHub.com, Enterprise Server 2.16, etc -->
{% if process.env.FEATURE_NEW_VERSIONS %}
<span class="d-md-none d-xl-inline-block mr-1">{{ site.data.ui.pages.article_version }}</span> {{ allVersions[currentVersion].versionTitle }}
{% else %}
<span class="d-md-none d-xl-inline-block mr-1">{{ site.data.ui.pages.article_version }}</span> {{ productNames[currentVersion] }}
{% endif %}
<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>
</summary>

Expand All @@ -16,11 +12,7 @@
href="{{ permalink.href }}"
class="d-block py-2 {% if currentPath == permalink.href %}link-blue active{% else %}link-gray-dark no-underline{% endif %}"
>
{% if process.env.FEATURE_NEW_VERSIONS %}
{{ allVersions[permalink.pageVersion].versionTitle }}</a>
{% else %}
{{ productNames[permalink.pageVersion] }}</a>
{% endif %}
{% endfor %}
</div>
</details>
Expand Down
3 changes: 0 additions & 3 deletions includes/deprecation-banner.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{% unless process.env.FEATURE_NEW_VERSIONS %}
{% assign enterpriseServerReleases = enterpriseVersions %}
{% endunless %}
{% if currentVersion contains enterpriseServerReleases.oldestSupported %}
<div class="deprecation-banner border rounded-1 mb-2 bg-yellow-light p-3 border-yellow f5">
<p>
Expand Down
8 changes: 1 addition & 7 deletions includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ <h4 class="text-mono f5 text-normal text-gray d-md-none">{{ site.data.ui.homepag
<div id="current-product" class="d-flex flex-items-center flex-justify-between" style="padding-top: 2px;">
<!-- Product switcher - GitHub.com, Enterprise Server, etc -->
<!-- 404 and 500 error layouts are not real pages so we need to hardcode the name for those -->
{% if process.env.FEATURE_NEW_VERSIONS %}
{{ allProducts[currentProduct].name }}
{% else %}
{{ currentProduct.name }}
{% endif %}
<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>
</div>
</summary>
Expand All @@ -57,7 +53,7 @@ <h4 class="text-mono f5 text-normal text-gray d-md-none">{{ site.data.ui.homepag
{% for product in activeProducts %}
<a href="{% unless product.external %}/{{ currentLanguage }}{% endunless %}{{ product.href }}"
class="d-block py-2
{% 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 %}">
{% 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 %}">
{{ product.name }}
{% if product.external %}
<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>
Expand All @@ -68,10 +64,8 @@ <h4 class="text-mono f5 text-normal text-gray d-md-none">{{ site.data.ui.homepag
</details>
</div>

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

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

Expand Down
7 changes: 1 addition & 6 deletions includes/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ <h1 class="h1-mktg mb-3">{{ site.data.ui.search.need_help }}</h1>
<h3 class="text-mono f5 text-normal text-gray text-md-center mb-4">{{ site.data.ui.homepage.explore_by_product }}</h3>
<div class="d-flex flex-wrap gutter gutter-xl-spacious">
{% for product in activeProducts %}
{% if process.env.FEATURE_NEW_VERSIONS %}
{% assign productVersions = product.versions %}
{% else %}
{% assign productVersions = currentVersion %}
{% endif %}
{% if productVersions contains currentVersion or currentVersion == 'homepage' %}
{% if product.versions contains currentVersion or currentVersion == 'homepage' %}
<div class="d-flex flex-column col-12 col-sm-6 col-lg-3 pb-4">
<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 }}
{% if product.external %}
Expand Down
15 changes: 1 addition & 14 deletions includes/sidebar-homepage.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
{% if process.env.FEATURE_NEW_VERSIONS %}
{% include all-products-link %}
{% endif %}

{% for product in activeProducts %}

{% if process.env.FEATURE_NEW_VERSIONS %}
{% assign productVersions = product.versions %}
{% else %}
{% assign productVersions = currentVersion %}
{% endif %}

{% if productVersions contains currentVersion or currentVersion == 'homepage' %}
{% if product.versions contains currentVersion or currentVersion == 'homepage' %}
<li
title="{{product.name}}{% if product.external %} (External Site){% endif %}"
class="sidebar-product"
>
{% if process.env.FEATURE_NEW_VERSIONS %}
<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">
{% else %}
<a href="{% unless product.external %}/{{currentLanguage}}{% endunless %}{{product.href}}" class="f4 pl-4 pr-5 py-2">
{% endif %}
{{ product.name }}
{% if product.external %}
<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>
Expand Down
4 changes: 0 additions & 4 deletions includes/sidebar-specific-product.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
also gets an `is-current-page` class.
-->

{% if process.env.FEATURE_NEW_VERSIONS %}
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct] %}
{% else %}
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct.id] %}
{% endif %}
{% include all-products-link %}
<li title="{{product.title}}" class="sidebar-product mb-2">
<a href="/{{currentLanguage}}{{product.href}}" class="pl-4 pr-5 pb-1 f4">{{ product.title }}</a>
Expand Down
4 changes: 0 additions & 4 deletions includes/support.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
<h4 class="mb-3">
{{ site.data.ui.support.still_need_help }}
</h4>
{% if process.env.FEATURE_NEW_VERSIONS %}
{% if currentVersion contains 'enterprise' %}{% assign isEnterprise = true %}{% else %}{% assign isEnterprise = false %}{% endif %}
{% else %}
{% if currentVersion != 'dotcom' %}{% assign isEnterprise = true %}{% else %}{% assign isEnterprise = false %}{% endif %}
{% endif %}
<a id="ask-community" href="https://github.community" class="btn btn-outline">
{% octicon "people" width="16" %}
{{ site.data.ui.support.ask_community }}
Expand Down
40 changes: 7 additions & 33 deletions lib/all-products.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,29 @@ const { difference } = require('lodash')
const yaml = require('js-yaml')
const contentDir = path.join(process.cwd(), 'content')
const frontmatter = require('@github-docs/frontmatter')
const getApplicableVersions = require('./get-applicable-versions')

let getApplicableVersions
if (process.env.FEATURE_NEW_VERSIONS) {
getApplicableVersions = require('./get-applicable-versions')
}

// the product order is determined by a yml file
// the product order is determined by data/products.yml
const productsFile = path.join(process.cwd(), 'data/products.yml')
const productsYml = yaml.load(fs.readFileSync(productsFile, 'utf8'))
const sortedProductIds = productsYml.productsInOrder

let contentProductIds = fs.readdirSync(contentDir, { withFileTypes: true })
const contentProductIds = fs.readdirSync(contentDir, { withFileTypes: true })
.filter(entry => entry.isDirectory())
.map(entry => entry.name)

// TODO this can be removed when we replace content/enterprise/admin with content/admin
if (!process.env.FEATURE_NEW_VERSIONS) {
contentProductIds = contentProductIds.map(id => id.replace('enterprise', 'enterpriseServer'))
}

assert(difference(sortedProductIds, contentProductIds).length === 0)
assert(difference(contentProductIds, sortedProductIds).length === 0)

const internalProducts = {}

sortedProductIds.forEach(productId => {
const relPath = process.env.FEATURE_NEW_VERSIONS
? productId
: productId === 'enterpriseServer' ? 'enterprise/admin' : productId

const relPath = productId
const dir = path.join('content', relPath)
const toc = path.join(dir, 'index.md')
const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))

let applicableVersions, href
if (process.env.FEATURE_NEW_VERSIONS) {
applicableVersions = getApplicableVersions(data.versions, toc)
href = path.join('/', applicableVersions[0], productId)
} else {
href = path.join('/', relPath)
}
const applicableVersions = getApplicableVersions(data.versions, toc)
const href = path.join('/', applicableVersions[0], productId)

internalProducts[productId] = {
id: productId,
Expand All @@ -56,11 +38,7 @@ sortedProductIds.forEach(productId => {
wip: data.wip || false
}

if (process.env.FEATURE_NEW_VERSIONS) {
internalProducts[productId].versions = applicableVersions
} else {
internalProducts[productId].hasEnterpriseUserVersions = productsYml.hasEnterpriseUserVersions.some(id => id === productId)
}
internalProducts[productId].versions = applicableVersions
})

const externalProducts = {
Expand All @@ -78,10 +56,6 @@ const externalProducts = {
}
}

if (!process.env.FEATURE_NEW_VERSIONS) {
Object.keys(externalProducts).forEach(id => { externalProducts[id].hasEnterpriseUserVersions = false })
}

const allProducts = Object.assign({}, internalProducts, externalProducts)

module.exports = allProducts
84 changes: 39 additions & 45 deletions lib/all-versions.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
const enterpriseServerReleases = require('./enterprise-server-releases')

if (!process.env.FEATURE_NEW_VERSIONS) {
module.exports = ['dotcom'].concat(enterpriseServerReleases.supported)
}

if (process.env.FEATURE_NEW_VERSIONS) {
// version = "plan"@"release"
// example: enterprise-server@2.21
// 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
},
{
plan: 'enterprise-server',
planTitle: 'Enterprise Server',
releases: enterpriseServerReleases.supported,
latestRelease: enterpriseServerReleases.latest,
hasNumberedReleases: true
// version = "plan"@"release"
// example: enterprise-server@2.21
// 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
},
{
plan: 'enterprise-server',
planTitle: 'Enterprise Server',
releases: enterpriseServerReleases.supported,
latestRelease: enterpriseServerReleases.latest,
hasNumberedReleases: true
}
]

const allVersions = {}

// combine the plans and releases to get allVersions object
// e.g. free-pro-team@latest, enterprise-server@2.21, enterprise-server@2.20, 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
}
]

const allVersions = {}

// combine the plans and releases to get allVersions object
// e.g. free-pro-team@latest, enterprise-server@2.21, enterprise-server@2.20, 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
}

allVersions[version] = Object.assign(versionObj, planObj)
})
allVersions[version] = Object.assign(versionObj, planObj)
})
})

module.exports = allVersions
}
module.exports = allVersions
4 changes: 1 addition & 3 deletions lib/check-developer-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi

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

if (!linkedPageVersions.includes(version) && $(internalLink).attr('class') !== 'dotcom-only') {
brokenLinks.links.push({ 'broken link': link, reason: `${version} not found in linked page versions`, 'linked page': linkedPage.fullPath })
Expand Down
4 changes: 1 addition & 3 deletions lib/check-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ module.exports = async function checkLinks ($, page, context, version, checkedLi

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

if (!linkedPageVersions.includes(version) && $(internalLink).attr('class') !== 'dotcom-only') {
brokenLinks.links.push({ 'broken link': link, reason: `${version} not found in linked page versions`, 'linked page': linkedPage.fullPath })
Expand Down
4 changes: 1 addition & 3 deletions lib/find-page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const slash = require('slash')
const patterns = require('./patterns')
const allVersions = process.env.FEATURE_NEW_VERSIONS
? Object.keys(require('./all-versions'))
: require('./all-versions')
const allVersions = Object.keys(require('./all-versions'))
const { getVersionedPathWithLanguage } = require('./path-utils')

module.exports = function findPage (href, pages, redirects = {}, languageCode = 'en', sourceLanguage = null) {
Expand Down
32 changes: 7 additions & 25 deletions lib/frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const semverRange = {
conform: require('semver').validRange,
message: 'Must be a valid SemVer range'
}
const productIds = Object.keys(require('./all-products'))
const versionIds = Object.keys(require('./all-versions'))

const schema = {
Expand Down Expand Up @@ -68,30 +67,13 @@ const schema = {
}
}

if (process.env.FEATURE_NEW_VERSIONS) {
schema.properties.versions = {
type: ['object', 'string'], // allow a '*' string to indicate all versions
required: true,
properties: versionIds.reduce((acc, versionId) => {
acc[versionId] = semverRange
return acc
}, {})
}
}

if (!process.env.FEATURE_NEW_VERSIONS) {
schema.properties.productVersions = {
type: 'object',
required: true,
properties: productIds.reduce((acc, productId) => {
// github used to be called dotcom
// TODO: rename `dotcom` to `github` in all the markdown files' frontmatter
if (productId === 'github') productId = 'dotcom'

acc[productId] = semverRange
return acc
}, {})
}
schema.properties.versions = {
type: ['object', 'string'], // allow a '*' string to indicate all versions
required: true,
properties: versionIds.reduce((acc, versionId) => {
acc[versionId] = semverRange
return acc
}, {})
}

function frontmatter (markdown, opts = {}) {
Expand Down
Loading

0 comments on commit aa5a62d

Please sign in to comment.