8
.github/workflows/staging-deploy-pr.yml
vendored
8
.github/workflows/staging-deploy-pr.yml
vendored
@@ -36,14 +36,6 @@ env:
|
||||
BUILD_ACTIONS_RUN_LOG: https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}
|
||||
|
||||
jobs:
|
||||
debug:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Dump full context for debugging
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJSON(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
|
||||
pr-metadata:
|
||||
# This is needed because the workflow we depend on
|
||||
# (see on.workflow_run.workflows) might be running from pushes on
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
@@ -1,9 +1,8 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { useState } from 'react'
|
||||
import cx from 'classnames'
|
||||
import { ActionList, Heading } from '@primer/components'
|
||||
|
||||
import { ChevronDownIcon, ZapIcon, InfoIcon, ShieldLockIcon } from '@primer/octicons-react'
|
||||
import { ZapIcon, InfoIcon, ShieldLockIcon } from '@primer/octicons-react'
|
||||
import { Callout } from 'components/ui/Callout'
|
||||
|
||||
import { Link } from 'components/Link'
|
||||
@@ -61,9 +60,8 @@ export const ArticlePage = () => {
|
||||
} = useArticleContext()
|
||||
const { t } = useTranslation('pages')
|
||||
const currentPath = router.asPath.split('?')[0]
|
||||
const [isActive, setActive] = useState(-1)
|
||||
|
||||
const renderTocItem = (item: MiniTocItem, index: number) => {
|
||||
const renderTocItem = (item: MiniTocItem) => {
|
||||
return (
|
||||
<ActionList.Item
|
||||
as="li"
|
||||
@@ -72,19 +70,9 @@ export const ArticlePage = () => {
|
||||
sx={{ listStyle: 'none', padding: '2px' }}
|
||||
>
|
||||
<div className={cx('lh-condensed d-block width-full')}>
|
||||
<div className="d-inline-flex" dangerouslySetInnerHTML={{ __html: item.contents }} />
|
||||
{item.items && item.items.length > 0 && (
|
||||
<button
|
||||
className="color-bg-default border-0 ml-1"
|
||||
onClick={() => setActive(index === isActive ? -1 : index)}
|
||||
>
|
||||
{<ChevronDownIcon />}
|
||||
</button>
|
||||
)}
|
||||
<div dangerouslySetInnerHTML={{ __html: item.contents }} />
|
||||
{item.items && item.items.length > 0 ? (
|
||||
<ul className={index === isActive ? 'ml-3' : 'd-none'}>
|
||||
{item.items.map(renderTocItem)}
|
||||
</ul>
|
||||
<ul className="ml-3">{item.items.map(renderTocItem)}</ul>
|
||||
) : null}
|
||||
</div>
|
||||
</ActionList.Item>
|
||||
@@ -158,7 +146,7 @@ export const ArticlePage = () => {
|
||||
return {
|
||||
key: title + i,
|
||||
text: title,
|
||||
renderItem: () => <ul>{renderTocItem(items, i)}</ul>,
|
||||
renderItem: () => <ul>{renderTocItem(items)}</ul>,
|
||||
}
|
||||
})}
|
||||
/>
|
||||
|
||||
@@ -37,10 +37,19 @@ By default, a codespace can only access the repository from which it was created
|
||||
{% data reusables.organizations.click-codespaces %}
|
||||
1. Under "User permissions", select one of the following options:
|
||||
|
||||
* **Allow for all users** to allow all your organization members to use {% data variables.product.prodname_codespaces %}.
|
||||
* **Selected users** to select specific organization members to use {% data variables.product.prodname_codespaces %}.
|
||||
* **Allow for all members** to allow all your organization members to use {% data variables.product.prodname_codespaces %}.
|
||||
* **Allow for all members and outside collaborators** to allow all your organization members as well as outside collaborators to use {% data variables.product.prodname_codespaces %}.
|
||||
|
||||

|
||||

|
||||
|
||||
{% note %}
|
||||
|
||||
**Note:** When you select **Allow for all members and outside collaborators**, all outside collaborators who have been added to specific repositories can create and use {% data variables.product.prodname_codespaces %}. Your organization will be billed for all usage incurred by outside collaborators. For more information on managing outside collaborators, see "[About outside collaborators](/organizations/managing-access-to-your-organizations-repositories/adding-outside-collaborators-to-repositories-in-your-organization#about-outside-collaborators)."
|
||||
|
||||
{% endnote %}
|
||||
|
||||
1. Click **Save**.
|
||||
|
||||
## Disabling {% data variables.product.prodname_codespaces %} for your organization
|
||||
|
||||
|
||||
@@ -18,6 +18,5 @@ Every GraphQL schema has a root type for both queries and mutations. The [mutati
|
||||
|
||||
For more information, see "[About mutations](/graphql/guides/forming-calls-with-graphql#about-mutations)."
|
||||
|
||||
{% for item in graphql.schemaForCurrentVersion.mutations %}
|
||||
{% include graphql-mutation %}
|
||||
{% endfor %}
|
||||
<!-- this page is pre-rendered by scripts because it's too big to load dynamically -->
|
||||
<!-- see lib/graphql/static/prerendered-mutations.json -->
|
||||
|
||||
7198
lib/graphql/static/prerendered-mutations.json
Normal file
7198
lib/graphql/static/prerendered-mutations.json
Normal file
File diff suppressed because one or more lines are too long
@@ -9,6 +9,9 @@ const prerenderedObjects = readCompressedJsonFileFallback(
|
||||
const prerenderedInputObjects = readCompressedJsonFileFallback(
|
||||
'./lib/graphql/static/prerendered-input-objects.json'
|
||||
)
|
||||
const prerenderedMutations = readCompressedJsonFileFallback(
|
||||
'./lib/graphql/static/prerendered-mutations.json'
|
||||
)
|
||||
|
||||
const explorerUrl =
|
||||
process.env.NODE_ENV === 'production'
|
||||
@@ -36,6 +39,7 @@ export default function graphqlContext(req, res, next) {
|
||||
upcomingChangesForCurrentVersion: upcomingChanges[graphqlVersion],
|
||||
prerenderedObjectsForCurrentVersion: prerenderedObjects[graphqlVersion],
|
||||
prerenderedInputObjectsForCurrentVersion: prerenderedInputObjects[graphqlVersion],
|
||||
prerenderedMutationsForCurrentVersion: prerenderedMutations[graphqlVersion],
|
||||
explorerUrl,
|
||||
changelog,
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import helpToDocs from './redirects/help-to-docs.js'
|
||||
import languageCodeRedirects from './redirects/language-code-redirects.js'
|
||||
import handleRedirects from './redirects/handle-redirects.js'
|
||||
import findPage from './find-page.js'
|
||||
import spotContentFlaws from './spot-content-flaws.js'
|
||||
import blockRobots from './block-robots.js'
|
||||
import archivedEnterpriseVersionsAssets from './archived-enterprise-versions-assets.js'
|
||||
import events from './events.js'
|
||||
@@ -173,6 +174,7 @@ export default function (app) {
|
||||
|
||||
// *** Config and context for rendering ***
|
||||
app.use(asyncMiddleware(instrument(findPage, './find-page'))) // Must come before archived-enterprise-versions, breadcrumbs, featured-links, products, render-page
|
||||
app.use(asyncMiddleware(instrument(spotContentFlaws, './spot-content-flaws'))) // Must come after findPage
|
||||
app.use(instrument(blockRobots, './block-robots'))
|
||||
|
||||
// Check for a dropped connection before proceeding
|
||||
|
||||
@@ -81,6 +81,16 @@ export default async function renderPage(req, res, next) {
|
||||
context.renderedPage + req.context.graphql.prerenderedInputObjectsForCurrentVersion.html
|
||||
}
|
||||
|
||||
// handle special-case prerendered GraphQL mutations page
|
||||
if (req.pagePath.endsWith('graphql/reference/mutations')) {
|
||||
// concat the markdown source miniToc items and the prerendered miniToc items
|
||||
context.miniTocItems = context.miniTocItems.concat(
|
||||
req.context.graphql.prerenderedMutationsForCurrentVersion.miniToc
|
||||
)
|
||||
context.renderedPage =
|
||||
context.renderedPage + req.context.graphql.prerenderedMutationsForCurrentVersion.html
|
||||
}
|
||||
|
||||
// Create string for <title> tag
|
||||
context.page.fullTitle = context.page.titlePlainText
|
||||
|
||||
|
||||
32
middleware/spot-content-flaws.js
Normal file
32
middleware/spot-content-flaws.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// This middleware, exclusively in 'development' tries to spot flaws in
|
||||
// the content you're actively viewing.
|
||||
// The hopeful assumption is that if you're actively viewing this
|
||||
// page on localhost, you're actively working on its content.
|
||||
|
||||
import path from 'path'
|
||||
|
||||
import kleur from 'kleur'
|
||||
|
||||
export default async function spotContentFlaws(req, res, next) {
|
||||
const { page } = req.context
|
||||
if (process.env.NODE_ENV === 'development' && page) {
|
||||
const trailingSlashRedirects = (page.redirect_from || []).filter(
|
||||
(uri) => uri.endsWith('/') && uri.startsWith('/')
|
||||
)
|
||||
if (trailingSlashRedirects.length > 0) {
|
||||
console.warn(
|
||||
`The page ${kleur.bold(path.relative(process.cwd(), page.fullPath))} has ${
|
||||
trailingSlashRedirects.length
|
||||
} redirect_from entries that have a trailing slash\n ${kleur.yellow(
|
||||
trailingSlashRedirects.join('\n ')
|
||||
)}`
|
||||
)
|
||||
console.log(
|
||||
"If you're actively working on this page, consider",
|
||||
kleur.bold('deleting all trailing slashes in redirect_from.\n')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
47
package-lock.json
generated
47
package-lock.json
generated
@@ -47,6 +47,7 @@
|
||||
"imurmurhash": "^0.1.4",
|
||||
"js-cookie": "^3.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"kleur": "4.1.4",
|
||||
"liquidjs": "^9.22.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
@@ -13371,10 +13372,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/kleur": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
|
||||
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
|
||||
"devOptional": true,
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz",
|
||||
"integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
@@ -17831,6 +17831,15 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/prompts/node_modules/kleur": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
|
||||
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
|
||||
"devOptional": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types": {
|
||||
"version": "15.7.2",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
||||
@@ -22247,14 +22256,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/uvu/node_modules/kleur": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz",
|
||||
"integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-compile-cache": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
||||
@@ -33493,10 +33494,9 @@
|
||||
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="
|
||||
},
|
||||
"kleur": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
|
||||
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
|
||||
"devOptional": true
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz",
|
||||
"integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA=="
|
||||
},
|
||||
"language-subtag-registry": {
|
||||
"version": "0.3.21",
|
||||
@@ -36869,6 +36869,14 @@
|
||||
"requires": {
|
||||
"kleur": "^3.0.3",
|
||||
"sisteransi": "^1.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"kleur": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
|
||||
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
|
||||
"devOptional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"prop-types": {
|
||||
@@ -40276,13 +40284,6 @@
|
||||
"kleur": "^4.0.3",
|
||||
"sade": "^1.7.3",
|
||||
"totalist": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"kleur": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz",
|
||||
"integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"v8-compile-cache": {
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"imurmurhash": "^0.1.4",
|
||||
"js-cookie": "^3.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"kleur": "4.1.4",
|
||||
"liquidjs": "^9.22.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
||||
@@ -9,8 +9,7 @@ import { allVersions } from '../../lib/all-versions.js'
|
||||
import processPreviews from './utils/process-previews.js'
|
||||
import processUpcomingChanges from './utils/process-upcoming-changes.js'
|
||||
import processSchemas from './utils/process-schemas.js'
|
||||
import prerenderObjects from './utils/prerender-objects.js'
|
||||
import prerenderInputObjects from './utils/prerender-input-objects.js'
|
||||
import prerender from './utils/prerender-graphql.js'
|
||||
import { prependDatedEntry, createChangelogEntry } from './build-changelog.js'
|
||||
import loadData from '../../lib/site-data.js'
|
||||
|
||||
@@ -36,6 +35,7 @@ async function main() {
|
||||
const upcomingChangesJson = {}
|
||||
const prerenderedObjects = {}
|
||||
const prerenderedInputObjects = {}
|
||||
const prerenderedMutations = {}
|
||||
|
||||
const siteData = loadData()
|
||||
|
||||
@@ -83,11 +83,22 @@ async function main() {
|
||||
|
||||
// 4. PRERENDER OBJECTS HTML
|
||||
// because the objects page is too big to render on page load
|
||||
prerenderedObjects[graphqlVersion] = await prerenderObjects(context)
|
||||
prerenderedObjects[graphqlVersion] = await prerender(context, 'objects', 'graphql-object.html')
|
||||
|
||||
// 5. PRERENDER INPUT OBJECTS HTML
|
||||
// because the objects page is too big to render on page load
|
||||
prerenderedInputObjects[graphqlVersion] = await prerenderInputObjects(context)
|
||||
prerenderedInputObjects[graphqlVersion] = await prerender(
|
||||
context,
|
||||
'inputObjects',
|
||||
'graphql-input-object.html'
|
||||
)
|
||||
|
||||
// Prerender mutations
|
||||
prerenderedMutations[graphqlVersion] = await prerender(
|
||||
context,
|
||||
'mutations',
|
||||
'graphql-mutation.html'
|
||||
)
|
||||
|
||||
// 6. UPDATE CHANGELOG
|
||||
if (allVersions[version].nonEnterpriseDefault) {
|
||||
@@ -118,6 +129,10 @@ async function main() {
|
||||
prerenderedInputObjects,
|
||||
path.join(graphqlStaticDir, 'prerendered-input-objects.json')
|
||||
)
|
||||
await updateStaticFile(
|
||||
prerenderedMutations,
|
||||
path.join(graphqlStaticDir, 'prerendered-mutations.json')
|
||||
)
|
||||
|
||||
// Ensure the YAML linter runs before checkinging in files
|
||||
execSync('npx prettier -w "**/*.{yml,yaml}"')
|
||||
|
||||
30
script/graphql/utils/prerender-graphql.js
Normal file
30
script/graphql/utils/prerender-graphql.js
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import cheerio from 'cheerio'
|
||||
import { liquid } from '../../../lib/render-content/index.js'
|
||||
import getMiniTocItems from '../../../lib/get-mini-toc-items.js'
|
||||
import rewriteLocalLinks from '../../../lib/rewrite-local-links.js'
|
||||
const includes = path.join(process.cwd(), 'includes')
|
||||
|
||||
export default async function prerender(context, type, includeFilename) {
|
||||
const htmlArray = []
|
||||
|
||||
const includeFile = await fs.readFile(path.join(includes, includeFilename), 'utf8')
|
||||
// render the layout for every object
|
||||
for (const item of context.graphql.schemaForCurrentVersion[type]) {
|
||||
context.item = item
|
||||
const itemHtml = await liquid.parseAndRender(includeFile, context)
|
||||
const $ = cheerio.load(itemHtml, { xmlMode: true })
|
||||
rewriteLocalLinks($, context.currentVersion, context.currentLanguage)
|
||||
const htmlWithVersionedLinks = $.html()
|
||||
htmlArray.push(htmlWithVersionedLinks)
|
||||
}
|
||||
|
||||
const html = htmlArray.join('\n')
|
||||
|
||||
return {
|
||||
html: html,
|
||||
miniToc: getMiniTocItems(html),
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,7 @@ describe('server', () => {
|
||||
)
|
||||
expect($('h2#in-this-article').length).toBe(1)
|
||||
expect($('h2#in-this-article + div div ul').length).toBeGreaterThan(0) // non-indented items
|
||||
expect($('h2#in-this-article + div div ul li div div div ul li').length).toBeGreaterThan(0) // indented items
|
||||
expect($('h2#in-this-article + div div ul li div div div ul.ml-3').length).toBeGreaterThan(0) // indented items
|
||||
})
|
||||
|
||||
test('does not render mini TOC in articles with only one heading', async () => {
|
||||
|
||||
Reference in New Issue
Block a user