Skip to content

Commit

Permalink
clear out dynamic require
Browse files Browse the repository at this point in the history
  • Loading branch information
gracepark committed Jun 18, 2021
1 parent b688ac0 commit 7f6a277
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = {
},
rules: {
'import/no-extraneous-dependencies': ['error'],
'node/global-require': ['error']
'node/global-require': ['error'],
'import/no-dynamic-require': ['error']
},
overrides: [
{
Expand Down
3 changes: 1 addition & 2 deletions middleware/contextualizers/webhooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('path')
const { defaults } = require('lodash')
const webhookPayloads = require(path.join(process.cwd(), 'lib/webhooks'))
const webhookPayloads = require('../../lib/webhooks')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
const allVersions = require('../../lib/all-versions')

Expand Down
73 changes: 36 additions & 37 deletions middleware/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const path = require('path')
const express = require('express')
const instrument = require('../lib/instrument-middleware')
const haltOnDroppedConnection = require('./halt-on-dropped-connection')
Expand All @@ -23,42 +22,42 @@ const reqUtils = require('./req-utils')
const recordRedirect = require('./record-redirect')
const connectSlashes = require('connect-slashes')
const handleErrors = require('./handle-errors')
const handleInvalidPaths = require(path.resolve(process.cwd(), './middleware', './handle-invalid-paths'))
const detectLanguage = require(path.resolve(process.cwd(), './middleware', './detect-language'))
const context = require(path.resolve(process.cwd(), './middleware', './context'))
const shortVersions = require(path.resolve(process.cwd(), './middleware', './contextualizers/short-versions'))
const redirectsExternal = require(path.resolve(process.cwd(), './middleware', './redirects/external'))
const helpToDocs = require(path.resolve(process.cwd(), './middleware', './redirects/help-to-docs'))
const languageCodeRedirects = require(path.resolve(process.cwd(), './middleware', './redirects/language-code-redirects'))
const handleRedirects = require(path.resolve(process.cwd(), './middleware', './redirects/handle-redirects'))
const findPage = require(path.resolve(process.cwd(), './middleware', './find-page'))
const blockRobots = require(path.resolve(process.cwd(), './middleware', './block-robots'))
const archivedEnterpriseVersionsAssets = require(path.resolve(process.cwd(), './middleware', './archived-enterprise-versions-assets'))
const events = require(path.resolve(process.cwd(), './middleware', './events'))
const search = require(path.resolve(process.cwd(), './middleware', './search'))
const archivedEnterpriseVersions = require(path.resolve(process.cwd(), './middleware', './archived-enterprise-versions'))
const robots = require(path.resolve(process.cwd(), './middleware', './robots'))
const earlyAccessLinks = require(path.resolve(process.cwd(), './middleware', './contextualizers/early-access-links'))
const categoriesForSupport = require(path.resolve(process.cwd(), './middleware', './categories-for-support'))
const loaderio = require(path.resolve(process.cwd(), './middleware', './loaderio-verification'))
const triggerError = require(path.resolve(process.cwd(), './middleware', './trigger-error'))
const releaseNotes = require(path.resolve(process.cwd(), './middleware', './contextualizers/release-notes'))
const whatsNewChangelog = require(path.resolve(process.cwd(), './middleware', './contextualizers/whats-new-changelog'))
const graphQL = require(path.resolve(process.cwd(), './middleware', './contextualizers/graphql'))
const rest = require(path.resolve(process.cwd(), './middleware', './contextualizers/rest'))
const webhooks = require(path.resolve(process.cwd(), './middleware', './contextualizers/webhooks'))
const layout = require(path.resolve(process.cwd(), './middleware', './contextualizers/layout'))
const currentProductTree = require(path.resolve(process.cwd(), './middleware', './contextualizers/current-product-tree'))
const genericToc = require(path.resolve(process.cwd(), './middleware', './contextualizers/generic-toc'))
const breadcrumbs = require(path.resolve(process.cwd(), './middleware', './contextualizers/breadcrumbs'))
const earlyAccessBreadcrumbs = require(path.resolve(process.cwd(), './middleware', './contextualizers/early-access-breadcrumbs'))
const productExamples = require(path.resolve(process.cwd(), './middleware', './contextualizers/product-examples'))
const devToc = require(path.resolve(process.cwd(), './middleware', './dev-toc'))
const featuredLinks = require(path.resolve(process.cwd(), './middleware', './featured-links'))
const learningTrack = require(path.resolve(process.cwd(), './middleware', './learning-track'))
const isNextRequest = require(path.resolve(process.cwd(), './middleware', './is-next-request'))
const next = require(path.resolve(process.cwd(), './middleware', './next'))
const renderPage = require(path.resolve(process.cwd(), './middleware', './render-page'))
const handleInvalidPaths = require('./handle-invalid-paths')
const detectLanguage = require('./detect-language')
const context = require('./context')
const shortVersions = require('./contextualizers/short-versions')
const redirectsExternal = require('./redirects/external')
const helpToDocs = require('./redirects/help-to-docs')
const languageCodeRedirects = require('./redirects/language-code-redirects')
const handleRedirects = require('./redirects/handle-redirects')
const findPage = require('./find-page')
const blockRobots = require('./block-robots')
const archivedEnterpriseVersionsAssets = require('./archived-enterprise-versions-assets')
const events = require('./events')
const search = require('./search')
const archivedEnterpriseVersions = require('./archived-enterprise-versions')
const robots = require('./robots')
const earlyAccessLinks = require('./contextualizers/early-access-links')
const categoriesForSupport = require('./categories-for-support')
const loaderio = require('./loaderio-verification')
const triggerError = require('./trigger-error')
const releaseNotes = require('./contextualizers/release-notes')
const whatsNewChangelog = require('./contextualizers/whats-new-changelog')
const graphQL = require('./contextualizers/graphql')
const rest = require('./contextualizers/rest')
const webhooks = require('./contextualizers/webhooks')
const layout = require('./contextualizers/layout')
const currentProductTree = require('./contextualizers/current-product-tree')
const genericToc = require('./contextualizers/generic-toc')
const breadcrumbs = require('./contextualizers/breadcrumbs')
const earlyAccessBreadcrumbs = require('./contextualizers/early-access-breadcrumbs')
const productExamples = require('./contextualizers/product-examples')
const devToc = require('./dev-toc')
const featuredLinks = require('./featured-links')
const learningTrack = require('./learning-track')
const isNextRequest = require('./is-next-request')
const next = require('./next')
const renderPage = require('./render-page')

const { NODE_ENV } = process.env
const isDevelopment = NODE_ENV === 'development'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const contentPath = path.join(__dirname, '../../content')
const dataPath = path.join(__dirname, '../../data')
const removeUnusedAssetsScript = 'script/remove-unused-assets'
const runRemoveUnusedAssetsScript = require('../remove-unused-assets')
const elseifRegex = /{-?% elsif/

// [start-readme]
Expand Down Expand Up @@ -64,7 +65,7 @@ const allFiles = contentFiles.concat(dataFiles)

main()
console.log(`\nRunning ${removeUnusedAssetsScript}...`)
require(path.join(process.cwd(), removeUnusedAssetsScript))
runRemoveUnusedAssetsScript()

function printElseIfFoundWarning (location) {
console.log(`${location} has an 'elsif' condition! Resolve all elsifs by hand, then rerun the script.`)
Expand Down
8 changes: 4 additions & 4 deletions script/enterprise-server-releases/create-graphql-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const changesFile = path.join(graphqlStaticDir, 'upcoming-changes.json')
const objectsFile = path.join(graphqlStaticDir, 'prerendered-objects.json')
const inputObjectsFile = path.join(graphqlStaticDir, 'prerendered-input-objects.json')

const previews = require(previewsFile)
const changes = require(changesFile)
const objects = require(objectsFile)
const inputObjects = require(inputObjectsFile)
const previews = JSON.parse(fs.readFileSync(previewsFile))
const changes = JSON.parse(fs.readFileSync(changesFile))
const objects = JSON.parse(fs.readFileSync(objectsFile))
const inputObjects = JSON.parse(fs.readFileSync(inputObjectsFile))
// The prerendered objects file for the "old version" contains hardcoded links with the old version number.
// We need to update those links to include the new version to prevent a test from failing.
const regexOldVersion = new RegExp(oldVersion, 'gi')
Expand Down

0 comments on commit 7f6a277

Please sign in to comment.