Skip to content

Commit d585f35

Browse files
authored
Merge branch 'main' into patch-2
2 parents 7648206 + a4784f5 commit d585f35

File tree

1,618 files changed

+38688
-37679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,618 files changed

+38688
-37679
lines changed

.github/actions-scripts/enterprise-server-issue-templates/deprecation-issue.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ The day after a GHES version's [deprecation date](https://github.com/github/docs
1515

1616
- [ ] In your checkout of the [repo with archived GHES content](https://github.com/github/help-docs-archived-enterprise-versions), create a new branch: `git checkout -b deprecate-<version>`
1717
- [ ] In your `docs-internal` checkout, download the static files for the oldest supported version into your archival checkout:
18+
The archive script depends on an optional dependency so install optional dependencies first:
19+
```
20+
$ npm ci --include-optional
21+
```
22+
Then run the archive script:
1823
```
1924
$ script/enterprise-server-deprecations/archive-version.js -p <path-to-archive-repo-checkout>
2025
```
@@ -26,52 +31,50 @@ The day after a GHES version's [deprecation date](https://github.com/github/docs
2631
2732
## Step 2: Upload the assets directory to Azure storage
2833
29-
- [ ] Log in to the Azure portal from Okta. Navigate to the [githubdocs Azure Storage Blob resoruce](https://portal.azure.com/#@githubazure.onmicrosoft.com/resource/subscriptions/fa6134a7-f27e-4972-8e9f-0cedffa328f1/resourceGroups/docs-production/providers/Microsoft.Storage/storageAccounts/githubdocs/overview).
34+
- [ ] Log in to the Azure portal from Okta. Navigate to the [githubdocs Azure Storage Blob resource](https://portal.azure.com/#@githubazure.onmicrosoft.com/resource/subscriptions/fa6134a7-f27e-4972-8e9f-0cedffa328f1/resourceGroups/docs-production/providers/Microsoft.Storage/storageAccounts/githubdocs/overview).
3035
- [ ] Click the "Open in Explorer" button to the right of search box.If you haven't already, click the download link to download "Microsoft Azure Storage Explorer." To login to the app, click the plug icon in the left sidebar and click the option to "add an azure account." When you login, you'll need a yubikey to authenticate through Okta.
3136
- [ ] From the Microsoft Azure Storage Explorer app, select the `githubdocs` storage account resource and navigate to the `github-images` blob container.
3237
- [ ] Click "Upload" and select "Upload folder." Click the "Selected folder" input to navigate to the `help-docs-archived-enterprise-versions` repository and select the `assets` directory for the version you just generated. In the "Destination folder" input, add the version number. For example, `/enterprise/2.22/`.
3338
- [ ] Check the log to ensure all files were uploaded successfully.
34-
- [ ] Removed the `assets` directory from the `/help-docsc-archived-enterprise-versions` repository.
39+
- [ ] Remove the `assets` directory from your `help-docsc-archived-enterprise-versions` repository, we don't want to commit that directory in the next step.
3540
3641
## Step 3: Commit and push changes to help-docs-archived-enterprise-versions repo
3742
38-
- [ ] Search for `site-search-input` in the compressed Javascript files. When you find it, use something like https://beautifier.io/ to reformat it to be readable. Find `site-search-input` in the file, there will be something like... `1125: function () { return [SearchReactComponent] },` Delete the innards of this function, but leave the `function() {}` part.
43+
- [ ] Search for `site-search-input` in the compressed Javascript files (should find the file in the `_next` directory). When you find it, use something like https://beautifier.io/ to reformat it to be readable. Find `site-search-input` in the file, the result will be enclosed in a function that looks something like... `1125: function () { ... },` Delete the innards of this function, but leave the `function() {}` part.
44+
- [ ] Copy, paste, and save the updated file back into your local `help-docs-archived-enterprise-versions` repository.
3945
- [ ] In your archival checkout, `git add <version>`, commit, and push.
4046
- [ ] Open a PR and merge it in. Note that the version will _not_ be deprecated on the docs site until you do the next step.
4147
4248
## Step 4: Deprecate the version in docs-internal
4349
4450
In your `docs-internal` checkout:
4551
- [ ] Create a new branch: `git checkout -b deprecate-<version>`.
46-
- [ ] Edit `lib/enterprise-server-releases.js` by moving the number to be deprecated into the `deprecated` array.
52+
- [ ] Edit `lib/enterprise-server-releases.js` by removing the version number to be deprecated from the `supported` array and move it to the `deprecated` array.
4753
- [ ] Open a new PR. Make sure to check the following:
48-
- [ ] Tests are passing.
49-
- [ ] The deprecated version renders on staging as expected. You should be able to navigate to docs.github.com/enterprise/<DEPRECATED VERSION> to access the docs. You should also be able to navigate to a page that is available in the deprecated version and change the version in the URL to the deprecated version, to test redirects.
54+
- [ ] Tests are passing (you may need to include the changes in step 6 to get tests to pass).
55+
- [ ] The deprecated version renders in preview as expected. You should be able to navigate to `docs.github.com/enterprise/<DEPRECATED VERSION>` to access the docs. You should also be able to navigate to a page that is available in the deprecated version and change the version in the URL to the deprecated version, to test redirects.
5056
- [ ] The new oldest supported version renders on staging as expected. You should see a banner on the top of every page for the oldest supported version that notes when the version will be deprecated.
5157
52-
You may need to include the changes in step 6 to get tests to pass.
53-
5458
## Step 5: Remove static files for the version
5559
56-
- [ ] In your `docs-internal` checkout, from your `remove-<version>-static-files` branch: `git checkout -b remove-<version>-static-files`
60+
- [ ] In your `docs-internal` checkout, create a new branch `remove-<version>-static-files` branch: `git checkout -b remove-<version>-static-files` (you can branch off of `main` or from your `deprecate-<version>` branch, up to you).
5761
- [ ] Run `script/enterprise-server-deprecations/remove-static-files.js` and commit results.
5862
- [ ] Run `script/enterprise-server-deprecations/remove-redirects.js` and commit results.
59-
- [ ] `lib/rest/static` directory has deferenced and decorated directory underneath, remove the numbered version and all below from the list
6063
- [ ] Open a new PR.
6164
- [ ] Get a review from docs-engineering and merge. This step can be merged independently from step 6. The purpose of splitting up steps 5 and 6 is to focus the review on specific files.
6265
6366
## Step 6: Remove the liquid conditionals and content for the version
6467
65-
- [ ] In your `docs-internal` checkout, from your `remove-<version>-markup` branch: `git checkout -b remove-<version>-markup`
68+
- [ ] In your `docs-internal` checkout, create a new branch `remove-<version>-markup` branch: `git checkout -b remove-<version>-markup` (you can branch off of `main` or from your `deprecate-<version>` branch, up to you).
6669
- [ ] Remove the outdated Liquid markup and frontmatter.
6770
- [ ] Run the script: `script/enterprise-server-deprecations/remove-version-markup.js --release <number>`.
6871
- [ ] Spot check a few changes. Content, frontmatter, and data files should all have been updated.
6972
- [ ] Open a PR with the results. The diff may be large and complex, so make sure to get a review from `@github/docs-content`.
70-
- [ ] Debug any test failures or unexpected results.
73+
- [ ] Debug any test failures or unexpected results -- it's very likely manual updates will be necessary, the script does a lot of work but doesn't automate everything and can't 100% replace human intent.
7174
- [ ] When the PR is approved, merge it in to complete the deprecation. This can be merged independently from step 5.
7275
7376
## Step 7: Deprecate the OpenAPI description in `github/github`
7477
7578
- [ ] In `github/github`, edit the release's config file in `app/api/description/config/releases/`, and change `deprecated: false` to `deprecated: true`.
7679
- [ ] Open a new PR, and get the required code owner approvals. A docs-content team member can approve it for the docs team.
77-
- [ ] When the PR is approved, merge the `github/github` PR.
80+
- [ ] When the PR is approved, [deploy the `github/github` PR](https://thehub.github.com/engineering/devops/deployment/deploying-dotcom/). If you haven't deployed a `github/github` PR before, work with someone that has -- the process isn't too involved depending on how you deploy, but there are a lot of details that can potentially be confusing as you can see from the documentation.

components/article/ClientSideHighlightJS.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { useEffect } from 'react'
2+
import { useRouter } from 'next/router'
23
import hljs from 'highlight.js/lib/core'
34
import json from 'highlight.js/lib/languages/json'
5+
import javascript from 'highlight.js/lib/languages/javascript'
6+
import hljsCurl from 'highlightjs-curl'
47

58
// Add as needed. It's pretty cheap to add but please don't use
69
// highlight.js import that loads all and everything.
710
hljs.registerLanguage('json', json)
8-
const SUPPORTED_LANGUAGES = ['json']
11+
hljs.registerLanguage('javascript', javascript)
12+
hljs.registerLanguage('curl', hljsCurl)
13+
const SUPPORTED_LANGUAGES = ['json', 'javascript', 'curl']
914

1015
// This is the selector we use for the first document.querySelectorAll()
1116
// to find the containers for `<code>` tags. Because it's s dataset
@@ -24,6 +29,8 @@ const CODE_ELEMENTS_PARENT_SELECTOR = '[data-highlight]'
2429
const CODE_SELECTOR = 'pre code'
2530

2631
export default function ClientSideHighlightJS() {
32+
const { asPath } = useRouter()
33+
2734
useEffect(() => {
2835
// Hi Internet Explorer!
2936
// https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#browser_compatibility
@@ -59,7 +66,7 @@ export default function ClientSideHighlightJS() {
5966
intersectionObserver.observe(element)
6067
}
6168
}
62-
}, [])
69+
}, [asPath])
6370

6471
return null
6572
}

components/declarations.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ declare module '*.scss' {
22
const content: Record<string, string>
33
export default content
44
}
5+
6+
declare module 'highlightjs-curl'

components/page-header/LanguagePicker.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import { useRouter } from 'next/router'
2-
import Cookies from 'js-cookie'
3-
42
import { Link } from 'components/Link'
53
import { useLanguages } from 'components/context/LanguagesContext'
64
import { Picker } from 'components/ui/Picker'
75
import { useTranslation } from 'components/hooks/useTranslation'
86

9-
// This value is replicated in two places! See middleware/detect-language.js
10-
const PREFERRED_LOCALE_COOKIE_NAME = 'preferredlang'
11-
127
type Props = {
138
variant?: 'inline'
149
}
@@ -27,22 +22,6 @@ export const LanguagePicker = ({ variant }: Props) => {
2722
// in a "denormalized" way.
2823
const routerPath = router.asPath.split('#')[0]
2924

30-
function rememberPreferredLanguage(code: string) {
31-
try {
32-
Cookies.set(PREFERRED_LOCALE_COOKIE_NAME, code, {
33-
expires: 365,
34-
secure: document.location.protocol !== 'http:',
35-
})
36-
} catch (err) {
37-
// You can never be too careful because setting a cookie
38-
// can fail. For example, some browser
39-
// extensions disallow all setting of cookies and attempts
40-
// at the `document.cookie` setter could throw. Just swallow
41-
// and move on.
42-
console.warn('Unable to set preferred language cookie', err)
43-
}
44-
}
45-
4625
return (
4726
<Picker
4827
variant={variant}
@@ -54,13 +33,7 @@ export const LanguagePicker = ({ variant }: Props) => {
5433
text: lang.nativeName || lang.name,
5534
selected: lang === selectedLang,
5635
item: (
57-
<Link
58-
href={routerPath}
59-
locale={lang.code}
60-
onClick={() => {
61-
rememberPreferredLanguage(lang.code)
62-
}}
63-
>
36+
<Link href={routerPath} locale={lang.code}>
6437
{lang.nativeName ? (
6538
<>
6639
<span lang={lang.code}>{lang.nativeName}</span> (

components/rest/CodeBlock.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ import styles from './CodeBlock.module.scss'
55
type Props = {
66
verb?: string
77
codeBlock: string
8-
setHTML?: boolean
8+
highlight?: string
99
}
1010

11-
export function CodeBlock({ verb, codeBlock, setHTML = false }: Props) {
12-
return setHTML ? (
13-
<div
14-
className={cx(styles.codeBlock, 'rounded')}
15-
dangerouslySetInnerHTML={{ __html: codeBlock }}
16-
/>
17-
) : (
18-
<pre className={cx(styles.methodCodeBlock, 'rounded-1 border')}>
11+
export function CodeBlock({ verb, codeBlock, highlight }: Props) {
12+
return (
13+
<pre className={cx(styles.methodCodeBlock, 'rounded-1 border')} data-highlight={highlight}>
1914
<code>
2015
{verb && (
2116
<span className="color-bg-accent-emphasis color-fg-on-emphasis rounded-1 text-uppercase">

components/rest/RestCodeSamples.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { xCodeSample } from './types'
1+
import type { xCodeSample } from './types'
22
import { useTranslation } from 'components/hooks/useTranslation'
33
import { CodeBlock } from './CodeBlock'
44

@@ -34,8 +34,8 @@ export function RestCodeSamples({ slug, xCodeSamples }: Props) {
3434
sampleElements.push(
3535
<CodeBlock
3636
key={sample.lang + index}
37-
codeBlock={sample.sourceHTML}
38-
setHTML={true}
37+
codeBlock={sample.source}
38+
highlight={sample.lang === 'JavaScript' ? 'javascript' : 'curl'}
3939
></CodeBlock>
4040
)
4141
}

components/rest/RestResponse.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function RestResponse({ responses }: Props) {
1515
<CodeBlock
1616
codeBlock={`Status: ${response.httpStatusCode} ${response.httpStatusMessage}`}
1717
/>
18-
<CodeBlock codeBlock={response.payload} setHTML={true} />
18+
{response.payload ? <CodeBlock codeBlock={response.payload} highlight="json" /> : null}
1919
</div>
2020
)
2121
})}

components/rest/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface CodeResponse {
3939

4040
export interface xCodeSample {
4141
lang: string
42-
sourceHTML: string
42+
source: string
4343
}
4444

4545
export interface Preview {

lib/get-link-data.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,14 @@ export default async (
1717
return await processLink(rawLinks, context, option)
1818
}
1919

20-
const links = []
21-
22-
for (const link of rawLinks) {
23-
const linkObj = await processLink(link, context, option)
24-
if (!linkObj) {
25-
continue
26-
} else {
27-
links.push(linkObj)
28-
}
29-
}
20+
const links = (
21+
await Promise.all(rawLinks.map((link) => processLink(link, context, option)))
22+
).filter(Boolean)
3023

3124
return links
3225
}
3326

34-
const processLink = async (link, context, option) => {
27+
async function processLink(link, context, option) {
3528
const opts = { textOnly: true, encodeEntities: true }
3629
// Parse the link in case it includes Liquid conditionals
3730
const linkPath = await renderContent(link.href || link, context, opts)

lib/get-redirect.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const nonEnterpriseDefaultVersionPrefix = `/${nonEnterpriseDefaultVersion}`
99

1010
// Return the new URI if there is one, otherwise return undefined.
1111
export default function getRedirect(uri, context) {
12-
const { redirects, userLanguage } = context
12+
const { redirects, pages } = context
1313

14-
let language = userLanguage || 'en'
14+
let language = 'en'
1515
let withoutLanguage = uri
1616
if (languagePrefixRegex.test(uri)) {
1717
language = uri.match(languagePrefixRegex)[1]
@@ -109,7 +109,12 @@ export default function getRedirect(uri, context) {
109109
}
110110

111111
if (basicCorrection) {
112-
return getRedirect(basicCorrection, context) || basicCorrection
112+
return (
113+
getRedirect(basicCorrection, {
114+
redirects,
115+
pages,
116+
}) || basicCorrection
117+
)
113118
}
114119

115120
if (withoutLanguage.startsWith('/admin/')) {

0 commit comments

Comments
 (0)