Skip to content

Commit

Permalink
Mostly reverting github/docs-internal#15313
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMGreene committed Nov 9, 2020
1 parent ed3baeb commit f410fd1
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 283 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ALGOLIA_API_KEY=
ALGOLIA_APPLICATION_ID=
ALLOW_TRANSLATION_COMMITS=
EARLY_ACCESS_HOSTNAME=
EARLY_ACCESS_SHARED_SECRET=
GITHUB_TOKEN=
7 changes: 0 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,3 @@ jobs:
run: npx jest tests/${{ matrix.test-group }}/
env:
NODE_OPTIONS: "--max_old_space_size=4096"

- name: Send Slack notification if workflow fails
uses: rtCamp/action-slack-notify@e17352feaf9aee300bf0ebc1dfbf467d80438815
if: failure() && github.ref == 'early-access'
env:
SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }}
SLACK_MESSAGE: "Tests are failing on the `early-access` branch. https://github.com/github/docs-internal/tree/early-access"
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.algolia-cache
.DS_Store
.env
node_modules
/node_modules/
npm-debug.log
coverage
content/early-access
content/early-access-test
coverage/
/assets/early-access/
/content/early-access/
/data/early-access/

# blc: broken link checker
blc_output.log
blc_output_internal.log
dist
/dist/
3 changes: 2 additions & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ files:
"data/reusables/README.md",
"data/variables/product.yml",
"data/variables/README.md",
"data/early-access",
"data/graphql",
"data/products.yml"
]
]

# These end up as env vars used by the GitHub Actions workflow
project_id_env: CROWDIN_PROJECT_ID
Expand Down
33 changes: 0 additions & 33 deletions lib/fetch-early-access-paths.js

This file was deleted.

10 changes: 4 additions & 6 deletions lib/warm-server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fetchEarlyAccessPaths = require('./fetch-early-access-paths')
let pages, site, redirects, siteTree, earlyAccessPaths
let pages, site, redirects, siteTree

module.exports = async function warmServer () {
if (!pages) {
Expand All @@ -8,17 +7,16 @@ module.exports = async function warmServer () {
}

// Promise.all is used to load multiple things in parallel
;[pages, site, earlyAccessPaths] = await Promise.all([
;[pages, site] = await Promise.all([
require('./pages')(),
require('./site-data')(),
fetchEarlyAccessPaths()
require('./site-data')()
])

redirects = await require('./redirects/precompile')(pages)
siteTree = await require('./site-tree')(pages, site, redirects)
}

return {
pages, site, redirects, siteTree, earlyAccessPaths
pages, site, redirects, siteTree
}
}
3 changes: 1 addition & 2 deletions middleware/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const featureFlags = Object.keys(require('../feature-flags'))
// Note that additional middleware in middleware/index.js adds to this context object
module.exports = async function contextualize (req, res, next) {
// Ensure that we load some data only once on first request
const { site, redirects, pages, siteTree, earlyAccessPaths } = await warmServer()
const { site, redirects, pages, siteTree } = await warmServer()
req.context = {}

// make feature flag environment variables accessible in layouts
Expand All @@ -33,7 +33,6 @@ module.exports = async function contextualize (req, res, next) {
req.context.currentPath = req.path
req.context.query = req.query
req.context.languages = languages
req.context.earlyAccessPaths = earlyAccessPaths
req.context.productNames = productNames
req.context.enterpriseServerReleases = enterpriseServerReleases
req.context.enterpriseServerVersions = Object.keys(allVersions).filter(version => version.startsWith('enterprise-server@'))
Expand Down
33 changes: 0 additions & 33 deletions middleware/early-access-paths.js

This file was deleted.

25 changes: 0 additions & 25 deletions middleware/early-access-proxy.js

This file was deleted.

3 changes: 1 addition & 2 deletions middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ module.exports = function (app) {
app.use(require('./detect-language'))
app.use(asyncMiddleware(require('./context')))
app.use('/csrf', require('./csrf-route'))
app.use(require('./early-access-paths'))
app.use(require('./early-access-proxy'))
app.use(require('./find-page'))
app.use(require('./notices'))
app.use(require('./archived-enterprise-versions'))
Expand All @@ -56,6 +54,7 @@ module.exports = function (app) {
app.use(require('./contextualizers/webhooks'))
app.use(require('./disable-caching-on-safari'))
app.get('/_500', asyncMiddleware(require('./trigger-error')))
app.get('/hidden', require('./list-hidden-pages'))
app.use(require('./breadcrumbs'))
app.use(require('./featured-links'))
app.get('/*', asyncMiddleware(require('./render-page')))
Expand Down
21 changes: 21 additions & 0 deletions middleware/list-hidden-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = async function listHidden (req, res, next) {
if (process.env.NODE_ENV === 'production') {
return res.status(403).end()
}

const hiddenPages = req.context.pages.filter(page => page.hidden)
let urls = []

hiddenPages.forEach(page => {
const pageUrls = page.permalinks.map(permalink => permalink.href)
urls = urls.concat(pageUrls)
})

const output = `
<ul>
${urls.map(url => `<li><a href="${url}">${url}</li>`).join('\n')}
</ul>
`

return res.send(output)
}
3 changes: 1 addition & 2 deletions middleware/render-page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { get } = require('lodash')
const env = require('lil-env-thing')
const { liquid } = require('../lib/render-content')
const patterns = require('../lib/patterns')
const layouts = require('../lib/layouts')
Expand Down Expand Up @@ -64,7 +63,7 @@ module.exports = async function renderPage (req, res, next) {
}

// `?json` query param for debugging request context
if ('json' in req.query && !env.production) {
if ('json' in req.query && process.env.NODE_ENV !== 'production') {
if (req.query.json.length > 1) {
// deep reference: ?json=page.permalinks
return res.json(get(context, req.query.json))
Expand Down
29 changes: 12 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"is-url": "^1.2.4",
"js-cookie": "^2.2.1",
"js-yaml": "^3.14.0",
"lil-env-thing": "^1.0.0",
"liquid": "^5.1.0",
"lodash": "^4.17.19",
"mini-css-extract-plugin": "^0.9.0",
Expand Down
Loading

0 comments on commit f410fd1

Please sign in to comment.