Skip to content

Commit

Permalink
satisifies -> satisfies (github#15814)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahs authored Sep 30, 2020
1 parent 7e49813 commit 5caa6f2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/enterprise-server-releases.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const versionSatisifiesRange = require('./version-satisfies-range')
const versionSatisfiesRange = require('./version-satisfies-range')

// GHES Release Lifecycle Dates:
// https://github.com/github/enterprise-releases/blob/master/docs/supported-versions.md#release-lifecycle-dates
Expand Down Expand Up @@ -36,7 +36,7 @@ const all = supported.concat(deprecated)
const latest = supported[0]
const oldestSupported = supported[supported.length - 1]
const nextDeprecationDate = dates[oldestSupported].deprecationDate
const deprecatedOnNewSite = deprecated.filter(version => versionSatisifiesRange(version, '>=2.13'))
const deprecatedOnNewSite = deprecated.filter(version => versionSatisfiesRange(version, '>=2.13'))
const firstVersionDeprecatedOnNewSite = '2.13'
// starting from 2.18, we updated the archival script to create stubbed HTML redirect files
const lastVersionWithoutStubbedRedirectFiles = '2.17'
Expand Down
4 changes: 2 additions & 2 deletions lib/get-applicable-versions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const allVersions = require('./all-versions')
const versionSatisifiesRange = require('./version-satisfies-range')
const versionSatisfiesRange = require('./version-satisfies-range')

// return an array of versions that an article's product versions encompasses
function getApplicableVersions (frontmatterVersions, filepath) {
Expand Down Expand Up @@ -33,7 +33,7 @@ function getApplicableVersions (frontmatterVersions, filepath) {
relevantVersions.forEach(relevantVersion => {
// special handling for versions with numbered releases
if (relevantVersion.hasNumberedReleases) {
if (versionSatisifiesRange(relevantVersion.currentRelease, planValue)) {
if (versionSatisfiesRange(relevantVersion.currentRelease, planValue)) {
applicableVersions.push(relevantVersion.version)
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/redirects/get-old-paths-from-permalink.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { latest, lastReleaseWithLegacyFormat } = require('../enterprise-server-releases')
const { getPathWithoutLanguage, getPathWithLanguage } = require('../path-utils')
const patterns = require('../patterns')
const versionSatisifiesRange = require('../version-satisfies-range')
const versionSatisfiesRange = require('../version-satisfies-range')
const currentlySupportedVersions = Object.keys(require('../all-versions'))
const nonEnterpriseDefaultVersion = require('../non-enterprise-default-version')

Expand Down Expand Up @@ -32,7 +32,7 @@ module.exports = function getOldPathsFromPath (currentPath, languageCode, curren
}

// create old path /user from current path /user/github on 2.16+ only
if (currentlySupportedVersions.includes(currentVersion) || versionSatisifiesRange(currentVersion, '>2.15')) {
if (currentlySupportedVersions.includes(currentVersion) || versionSatisfiesRange(currentVersion, '>2.15')) {
oldPaths.add(currentPath
.replace('/user/github', '/user'))
}
Expand All @@ -55,7 +55,7 @@ module.exports = function getOldPathsFromPath (currentPath, languageCode, curren
// ------ END LEGACY VERSION FORMAT REPLACEMENTS ------//

// ------ BEGIN MODERN VERSION FORMAT REPLACEMENTS ------//
if (currentlySupportedVersions.includes(currentVersion) || versionSatisifiesRange(currentVersion, `>${lastReleaseWithLegacyFormat}`)) {
if (currentlySupportedVersions.includes(currentVersion) || versionSatisfiesRange(currentVersion, `>${lastReleaseWithLegacyFormat}`)) {
oldPaths.forEach(oldPath => {
// create old path /github from new path /free-pro-team@latest/github
oldPaths.add(oldPath
Expand Down
2 changes: 1 addition & 1 deletion lib/version-satisfies-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const semver = require('semver')

// workaround for Enterprise Server 11.10.340 because we can't use semver to
// compare it to 2.x like we can with 2.0+
module.exports = function versionSatisifiesRange (version, range) {
module.exports = function versionSatisfiesRange (version, range) {
if (version === '11.10.340') return range.startsWith('<')

return semver.satisfies(semver.coerce(version), range)
Expand Down
6 changes: 3 additions & 3 deletions middleware/archived-enterprise-versions-assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path')
const versionSatisifiesRange = require('../lib/version-satisfies-range')
const versionSatisfiesRange = require('../lib/version-satisfies-range')
const enterpriseServerReleases = require('../lib/enterprise-server-releases')
const patterns = require('../lib/patterns')
const firstVersionDeprecatedOnNewSite = '2.13'
Expand Down Expand Up @@ -32,10 +32,10 @@ module.exports = async (req, res, next) => {

// paths are slightly different depending on the enterprise version
let proxyPath
if (versionSatisifiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)) {
if (versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)) {
// routing for >=2.13
proxyPath = path.join('/', requestedVersion, assetPath)
} else if (versionSatisifiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) {
} else if (versionSatisfiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) {
// routing for <2.13
proxyPath = path.join('/', requestedVersion, 'assets', assetPath)
}
Expand Down
14 changes: 7 additions & 7 deletions middleware/archived-enterprise-versions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')
const { latest, deprecated, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
const patterns = require('../lib/patterns')
const versionSatisifiesRange = require('../lib/version-satisfies-range')
const versionSatisfiesRange = require('../lib/version-satisfies-range')
const got = require('got')
const findPage = require('../lib/find-page')

Expand All @@ -26,14 +26,14 @@ module.exports = async (req, res, next) => {

// redirect language-prefixed URLs like /en/enterprise/2.10 -> /enterprise/2.10
// (this only applies to versions <2.13)
if (req.path.startsWith('/en/') && versionSatisifiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) {
if (req.path.startsWith('/en/') && versionSatisfiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) {
return res.redirect(301, req.baseUrl + req.path.replace(/^\/en/, ''))
}

// find redirects for versions between 2.13 and 2.17
// starting with 2.18, we updated the archival script to create stubbed HTML redirect files
if (versionSatisifiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`) &&
versionSatisifiesRange(requestedVersion, `<=${lastVersionWithoutStubbedRedirectFiles}`)) {
if (versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`) &&
versionSatisfiesRange(requestedVersion, `<=${lastVersionWithoutStubbedRedirectFiles}`)) {
const redirect = req.context.redirects[req.path]
if (redirect && redirect !== req.path) {
return res.redirect(301, redirect)
Expand Down Expand Up @@ -68,7 +68,7 @@ module.exports = async (req, res, next) => {
// for >=2.13: /2.13/en/enterprise/2.13/user/articles/viewing-contributions-on-your-profile
// for <2.13: /2.12/user/articles/viewing-contributions-on-your-profile
function getProxyPath (reqPath, requestedVersion) {
const proxyPath = versionSatisifiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)
const proxyPath = versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)
? path.join('/', requestedVersion, reqPath)
: reqPath.replace(/^\/enterprise/, '')

Expand All @@ -78,8 +78,8 @@ function getProxyPath (reqPath, requestedVersion) {
// from 2.13 to 2.17, we lost access to frontmatter redirects during the archival process
// this workaround finds potentially relevant frontmatter redirects in currently supported pages
function getFallbackRedirects (req, requestedVersion) {
if (versionSatisifiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) return
if (versionSatisifiesRange(requestedVersion, `>${lastVersionWithoutStubbedRedirectFiles}`)) return
if (versionSatisfiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) return
if (versionSatisfiesRange(requestedVersion, `>${lastVersionWithoutStubbedRedirectFiles}`)) return

const pathWithNewVersion = req.path.replace(requestedVersion, latest)

Expand Down

0 comments on commit 5caa6f2

Please sign in to comment.