This directory follows the Scripts to Rule Them All pattern:
Installs/updates all dependencies necessary for the docs environment. Equivalent of npm install
.
Starts the local development server. Equivalent of npm start
.
To keep things snappy, only English and Japanese are enabled. To run the server with all languages enabled, run script/server-all-languages
Runs tests. Equivalent of npm test
.
Flatten all the commits in the current branch into a single anonymized @Octomerger commit
Usage: script/anonymize-branch.js [base-branch] Example: script/anonymize-branch.js "nothing to see here" If the optional [base-branch] argument is omitted, it will default to main
This script is run automatically when you run the server locally. It checks whether Node.js is installed.
Run this script to get all broken docs.github.com links in github/github
A one-time use script to add GHEC to the REST schema on github/github.
Run this one time script to add max mini toc to rest reference documentation
This script finds all open PRs from active branches that touch content files, and adds a comment with steps to run some commands. The idea is to help writers and other Hubbers update their open branches and mitigate conflicts with the main branch.
Run this one-time script to convert if <feature name>
Liquid tags to ifversion <feature name>
.
Run this one time script to update headers for accessibility Changing H3 to H2, H4 to H3, H5 to H4, and H6 to H5
Run this script to convert long form Liquid conditionals (e.g., {% if currentVersion == "free-pro-team" %}) to the new custom tag (e.g., {% ifversion fpt %}) and also use the short names in versions frontmatter.
This script turns a Google Sheets CSV spreadsheet into a YAML file.
This script is run on a writer's machine to begin developing Early Access content locally.
This script is run on a writer's machine to create an Early Access branch that matches the current docs-internal branch.
This script is run on a writer's machine while developing Early Access content locally. You must pass the script the location of your local copy of the github/docs-early-access
git repo as the first argument.
This script is run on a writer's machine while developing Early Access content locally. It updates the data and image paths to either include early-access
or remove it.
Run this script during the Enterprise deprecation process to download static copies of all pages for the oldest supported Enterprise version. See the Enterprise deprecation issue template for instructions.
NOTE: If you get this error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'website-scraper' ...
it's because you haven't installed all the optional dependencies. To do that, run:
npm install --include=optional
This script removes the static GraphQL, REST, and webhook files for any deprecated GHES versions.
Run this script after an Enterprise deprecation to remove Liquid statements and frontmatter that contain the deprecated Enterprise version. See the Enterprise deprecation issue template for instructions.
Run this script to add versions frontmatter and Liquid conditionals for GitHub Enterprise Cloud, based on anything currently versioned for the specified release of free-pro-team.
This script creates the static GraphQL files for a new version.
This script first copies the dereferenced schema from the previous GHES version for the new one. It then replaces references to the previous version's docs URL (e.g., [email protected]) with the new version (e.g., [email protected]). Finally, it generates a new decorated file from the new dereferenced file to ensure that the dereferenced and decorated files match.
This script creates new static webhook payload files for a new version.
This script creates or removes a release candidate banner for a specified version.
Print a list of all the asset files that can't be found mentioned in any of the source files (content & code).
Pass this script any old dotcom path (e.g., articles/foo
or foo.md
) and it will output the new path in the content/github directory.
Return a function that you can use to run any code within and if it throws you get a chance to say whether to sleep + retry. Example:
async function mainFunction() { if (Math.random() > 0.9) throw new Error('too large') return 'OK' }
const errorTest = (err) => err instanceof Error && err.message.includes('too large') const config = { // all optional attempts: 3, sleepTime: 800, onError: (err, attempts) => console.warn(Failed ${attempts} attempts
) } const ok = await retry(errorTest, mainFunction, config)
A helper that returns an array of files for a given path and file extension.
Run this script to fix known frontmatter errors by copying values from english file Currently only fixing errors in: 'type', 'changelog' Please double check the changes created by this script before committing.
Run this script to fix known frontmatter errors by copying values from english file Translatable properties are designated in the frontmatter JSON schema
Use this script as part of the translation merge process to output a list of either parsing or rendering errors in translated files and run script/i18n/reset-translated-file.js on them.
This is a convenience script for replacing the contents of translated files with the English content from their corresponding source file.
Usage: script/i18n/reset-translated-file.js
Examples:
$ script/i18n/reset-translated-file.js translations/es-XL/content/actions/index.md
Run this script to test-render all the translation files that have been changed (when compared to the main
branch).
This script lists all local image files, sorted by their dimensions.
NOTE: If you get this error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'image-size' ...
it's because you haven't installed all the optional dependencies. To do that, run:
npm install --include=optional
Move the files from a category directory to a top-level product and add redirects.
Helps you move (a.k.a. rename) a file or a folder and does what's needed with frontmatter redirect_from.
This is a temporary script to visualize which pages have liquid (and conditionals) in their title
frontmatter
This script is intended to be used as a git "prepush" hook. If the current branch is main, it will exit unsuccessfully and prevent the push.
This script is run as a git precommit hook (installed by husky after npm install). It detects changes to files the in the translations folder and prevents the commit if any changes exist.
Run this script to manually purge the Fastly cache. Note this script requires a FASTLY_SERVICE_ID
and FASTLY_TOKEN
in your .env
file.
Run this script to manually purge the Fastly cache for all language variants of a single URL or for a batch of URLs in a file. This script does not require authentication.
An automated test checks for discrepancies between category directory names and slugified category titles as IDs.
If the test fails, a human needs to run this script to update the directory names and add appropriate redirects.
This script is not currently supported on Windows.
An automated test checks for discrepancies between filenames and autogenerated heading IDs. If the test fails, a human needs to run this script to update the filenames.
This script is not currently supported on Windows.
This script goes through all content and renders their HTML and from there can analyze for various flaws (e.g. broken links)
Run this script to check if OpenAPI files can be decorated successfully.
Run this script to check if OpenAPI operations match versions in content/rest operations
Run this script to pull openAPI files from github/github, dereference them, and decorate them.
See how a piece of text gets turned into tokens by the different analyzers. Requires that the index exists in Elasticsearch.
Example:
./script/search/analyze-text.js my words to tokenize
Creates Elasticsearch index, populates from records, moves the index alias, deletes old indexes.
This script is run automatically via GitHub Actions on every push to main
to generate searchable data. It can also be run manually. For more info see contributing/search.md
Starts the local development server with all of the available languages enabled.
Run this script to standardize frontmatter fields in all content files, per the order: - title - intro - product callout - productVersion - map topic status - hidden status - layout - redirect
List all the TODOs in our JavaScript files and stylesheets.
Find and replace lightweight feature flags for GitHub AE content.
This script fetches data from https://github.com/github/enterprise-releases/blob/master/releases.json and updates lib/enterprise-dates.json
, which the site uses for various functionality.
Run this script to find internal links in all content and data Markdown files, check if either the title or link (or both) are outdated, and automatically update them if so.
Exceptions: * Links with fragments (e.g., Bar) will get their root links updated if necessary, but the fragment and title will be unchanged (e.g., Bar). * Links with hardcoded versions (e.g., Foo) will get their root links updated if necessary, but the hardcoded versions will be preserved (e.g., Foo). * Links with Liquid in the titles will have their root links updated if necessary, but the titles will be preserved.
This script crawls the script directory, hooks on special comment markers in each script, and adds the comment to script/README.md
.