diff --git a/script/README.md b/script/README.md index e11c0b615fcb..bb718663da24 100644 --- a/script/README.md +++ b/script/README.md @@ -39,13 +39,6 @@ Usage: script/anonymize-branch.js [base-branch] Example: sc --- -### [`archive-enterprise-version.js`](archive-enterprise-version.js) - -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. - ---- - - ### [`backfill-missing-localizations.js`](backfill-missing-localizations.js) This script copies any English files that are missing from the translations directory into the translations directory. We only need to run this if problems occur with Crowdin's automatic sync. @@ -64,11 +57,9 @@ The `ignore` array is for client-side or build-time stuff that doesn't get `requ --- -### [`check-external-links`](check-external-links) - -The script is run once per day via a scheduled GitHub Action to check all links in the site. It automatically opens an issue if it finds broken links. To exclude a URL from the link check, add it to `lib/excluded-links.js`. +### [`check-english-links.js`](check-english-links.js) -For checking internal links, see `script/check-internal-links`. +This script runs once per day via a scheduled GitHub Action to check all links in English content, not including deprecated Enterprise Server content. It opens an issue if it finds broken links. To exclude a link, add it to `lib/excluded-links.js`. --- @@ -80,37 +71,35 @@ This script is run automatically when you run the server locally. It checks whet --- -### [`check-internal-links`](check-internal-links) - -This script wraps tests/links-and-images.js and provides an option to output results to a file. +### [`check-s3-images.js`](check-s3-images.js) -For more information, see `tests/README.md#broken-link-test`. +Run this script in your branch to check whether any images referenced in content are not in an expected S3 bucket. You will need to authenticate to S3 via `awssume` to use this script. Instructions for the one-time setup are [here](https://github.com/github/product-documentation/blob/master/doc-team-workflows/workflow-information-for-all-writers/setting-up-awssume-and-s3cmd.md). --- -### [`check-s3-images.js`](check-s3-images.js) +### [`content-migrations/extended-markdown-tags.js`](content-migrations/extended-markdown-tags.js) + -Run this script in your branch to check whether any images referenced in Enterprise content are not in the expected S3 bucket. You will need to authenticate to S3 via `awssume` to use this script. Instructions for the one-time setup are [here](https://github.com/github/product-documentation/blob/master/doc-team-workflows/workflow-information-for-all-writers/setting-up-awssume-and-s3cmd.md). --- -### [`content-migrations/extended-markdown-tags.js`](content-migrations/extended-markdown-tags.js) +### [`content-migrations/octicon-tag.js`](content-migrations/octicon-tag.js) --- -### [`content-migrations/octicon-tag.js`](content-migrations/octicon-tag.js) +### [`content-migrations/site-data-tag.js`](content-migrations/site-data-tag.js) --- -### [`content-migrations/site-data-tag.js`](content-migrations/site-data-tag.js) +### [`content-migrations/update-developer-site-links.js`](content-migrations/update-developer-site-links.js) @@ -131,9 +120,37 @@ This script finds and lists all the Heroku staging apps and deletes any leftover --- -### [`get-blc-command.js`](get-blc-command.js) +### [`enterprise-server-deprecations/archive-version.js`](enterprise-server-deprecations/archive-version.js) + +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. + +--- + + +### [`enterprise-server-deprecations/remove-version-markup.js`](enterprise-server-deprecations/remove-version-markup.js) -This script parses options for `script/check-external-links`. +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. + +--- + + +### [`enterprise-server-releases/create-webhooks-for-new-version.js`](enterprise-server-releases/create-webhooks-for-new-version.js) + +This script creates new static webhook payload files for a new version. + +--- + + +### [`enterprise-server-releases/ghes-to-ghae-versioning.js`](enterprise-server-releases/ghes-to-ghae-versioning.js) + +Run this script to add versions frontmatter and Liquid conditionals for GitHub AE, based on anything currently versioned for the provided release of Enterprise Server. This script should be run as part of the Enterprise Server release process. + +--- + + +### [`enterprise-server-releases/release-banner.js`](enterprise-server-releases/release-banner.js) + +This script creates or removes a release candidate banner for a specified version. --- @@ -242,63 +259,6 @@ This script moves reusables out of YAML files into individual Markdown files. --- -### [`new-versioning/fixtures.js`](new-versioning/fixtures.js) - - - ---- - - -### [`new-versioning/main`](new-versioning/main) - -All the new versioning! - -Usage $ script/new-versioning/main - ---- - - -### [`new-versioning/move-admin-dir.js`](new-versioning/move-admin-dir.js) - - - ---- - - -### [`new-versioning/update-content.js`](new-versioning/update-content.js) - - - ---- - - -### [`new-versioning/update-frontmatter.js`](new-versioning/update-frontmatter.js) - - - ---- - - -### [`new-versioning/update-not-fpt-conditionals.js`](new-versioning/update-not-fpt-conditionals.js) - -Run this script to update these Liquid conditionals: - -{% if currentVersion != 'free-pro-team@latest' %} - -to: - -{% if enterpriseServerVersions contains currentVersion %} - ---- - - -### [`new-versioning/update-products-yml.js`](new-versioning/update-products-yml.js) - - - ---- - - ### [`pages-with-liquid-titles.js`](pages-with-liquid-titles.js) This is a temporary script to visualize which pages have liquid (and conditionals) in their `title` frontmatter @@ -368,20 +328,6 @@ An automated test checks for discrepancies between filenames and [autogenerated --- -### [`release-banner.js`](release-banner.js) - -This script creates or removes a release candidate banner for a specified version. - - ---- - -### [`remove-deprecated-enterprise-version-markup.js`](remove-deprecated-enterprise-version-markup.js) - -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. - ---- - - ### [`remove-extraneous-translation-files.js`](remove-extraneous-translation-files.js) An [automated test](/tests/extraneous-translation-files.js) checks for files in the `translations/` directory that do not have an equivalent English file in the `content/` directory, and fails if it finds extraneous files. When the test fails, a human needs to run this script to remove the files. @@ -488,9 +434,10 @@ This script is used by other scripts to update temporary AWS credentials and aut --- -### [`upload-enterprise-images-to-s3.js`](upload-enterprise-images-to-s3.js) +### [`upload-images-to-s3.js`](upload-images-to-s3.js) -Run this script to: [upload individual files to S3](https://github.com/github/product-documentation/blob/master/doc-team-workflows/workflow-information-for-all-writers/adding-individual-images-to-earlier-verisons-of-enterprise.md) or: [upload a batch of files to S3 for a new Enterprise release](https://github.com/github/product-documentation/blob/master/doc-team-workflows/working-on-enterprise-releases/information-for-all-writers/storing-a-batch-of-assets-on-s3-for-a-new-release.md). Run `upload-enterprise-images-to-s3.js --help` for usage details. +Use this script to upload individual or batched asset files to a versioned S3 bucket. Run `upload-images-to-s3.js --help` for usage details. --- + diff --git a/script/archive-enterprise-version.js b/script/enterprise-server-deprecations/archive-version.js similarity index 97% rename from script/archive-enterprise-version.js rename to script/enterprise-server-deprecations/archive-version.js index 88a4541181bd..633cc3fd4d9b 100755 --- a/script/archive-enterprise-version.js +++ b/script/enterprise-server-deprecations/archive-version.js @@ -10,10 +10,10 @@ const scrape = require('website-scraper') const program = require('commander') const rimraf = require('rimraf').sync const mkdirp = require('mkdirp').sync -const version = require('../lib/enterprise-server-releases').oldestSupported +const version = require('../../lib/enterprise-server-releases').oldestSupported const archivalRepoName = 'help-docs-archived-enterprise-versions' const archivalRepoUrl = `https://github.com/github/${archivalRepoName}` -const loadRedirects = require('../lib/redirects/precompile') +const loadRedirects = require('../../lib/redirects/precompile') // [start-readme] // @@ -95,7 +95,7 @@ async function main () { } console.log(`Enterprise version to archive: ${version}`) - const pages = await (require('../lib/pages')()) + const pages = await (require('../../lib/pages')()) const permalinksPerVersion = Object.keys(pages) .filter(key => key.includes(`/enterprise-server@${version}`)) diff --git a/script/remove-deprecated-enterprise-version-markup.js b/script/enterprise-server-deprecations/remove-version-markup.js similarity index 89% rename from script/remove-deprecated-enterprise-version-markup.js rename to script/enterprise-server-deprecations/remove-version-markup.js index 8a746c6d80c9..5fb539088152 100755 --- a/script/remove-deprecated-enterprise-version-markup.js +++ b/script/enterprise-server-deprecations/remove-version-markup.js @@ -6,11 +6,11 @@ const walk = require('walk-sync') const matter = require('gray-matter') const program = require('commander') const { indexOf, nth } = require('lodash') -const removeLiquidStatements = require('../lib/remove-liquid-statements') -const removeDeprecatedFrontmatter = require('../lib/remove-deprecated-frontmatter') -const enterpriseServerReleases = require('../lib/enterprise-server-releases') -const contentPath = path.join(__dirname, '../content') -const dataPath = path.join(__dirname, '../data') +const removeLiquidStatements = require('../../lib/remove-liquid-statements') +const removeDeprecatedFrontmatter = require('../../lib/remove-deprecated-frontmatter') +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 elseifRegex = /{-?% elsif/ @@ -62,7 +62,7 @@ const allFiles = contentFiles.concat(dataFiles) main() console.log(`\nRunning ${removeUnusedAssetsScript}...`) -require(`../${removeUnusedAssetsScript}`) +require(path.join(process.cwd(), removeUnusedAssetsScript)) function printElseIfFoundWarning (location) { console.log(`${location} has an 'elsif' condition! Resolve all elsifs by hand, then rerun the script.`) diff --git a/script/create-webhooks-for-new-version.js b/script/enterprise-server-releases/create-webhook-files.js similarity index 97% rename from script/create-webhooks-for-new-version.js rename to script/enterprise-server-releases/create-webhook-files.js index bcf0fa8b117a..c7a3373b498a 100755 --- a/script/create-webhooks-for-new-version.js +++ b/script/enterprise-server-releases/create-webhook-files.js @@ -4,7 +4,7 @@ const fs = require('fs') const mkdirp = require('mkdirp').sync const path = require('path') const program = require('commander') -const allVersions = require('../lib/all-versions') +const allVersions = require('../../lib/all-versions') // [start-readme] // diff --git a/script/new-versioning/github-ae.js b/script/enterprise-server-releases/ghes-to-ghae-versioning.js similarity index 100% rename from script/new-versioning/github-ae.js rename to script/enterprise-server-releases/ghes-to-ghae-versioning.js diff --git a/script/release-banner.js b/script/enterprise-server-releases/release-banner.js similarity index 97% rename from script/release-banner.js rename to script/enterprise-server-releases/release-banner.js index b5a1bd414a40..881e2488ac60 100755 --- a/script/release-banner.js +++ b/script/enterprise-server-releases/release-banner.js @@ -4,7 +4,7 @@ const fs = require('fs') const path = require('path') const program = require('commander') const yaml = require('js-yaml') -const allVersions = require('../lib/all-versions') +const allVersions = require('../../lib/all-versions') const releaseCandidateFile = 'data/variables/release_candidate.yml' const releaseCandidateYaml = path.join(process.cwd(), releaseCandidateFile) diff --git a/script/new-versioning/enterprise-ae.js b/script/new-versioning/enterprise-ae.js deleted file mode 100755 index cbe2c2ff2822..000000000000 --- a/script/new-versioning/enterprise-ae.js +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const walk = require('walk-sync') -const program = require('commander') -const { uniq, dropRight } = require('lodash') -const frontmatter = require('@github-docs/frontmatter') -const contentPath = path.join(process.cwd(), 'content') -const dataPath = path.join(process.cwd(), 'data') -const translationsPath = path.join(process.cwd(), 'translations') -const { latest } = require('../../lib/enterprise-server-releases') -const { getEnterpriseServerNumber } = require('../../lib/patterns') -const versionSatisfiesRange = require('../../lib/version-satisfies-range') -const getApplicableVersions = require('../../lib/get-applicable-versions') -const getDataReferences = require('../../lib/get-liquid-data-references') - -// [start-readme] -// -// Run this script to add versions frontmatter and Liquid conditionals for -// Enterprise AE, based on anything currently versioned for the latest release -// of Enterprise Server. This script should be run as part of the Enterprise -// Server release process. -// -// [end-readme] - -program - .description('Add versions frontmatter and Liquid conditionals for Enterprise AE based on the latest Enterprise Server release.') - .option('-p, --product ', 'Product ID. Example: admin') - .option('-t, --translations', 'Run the script on content and data in translations, too.') - .parse(process.argv) - -if (program.product) { - console.log(`✅ Running on the ${program.product} product only`) -} else { - console.log('✅ Running on all products') -} - -if (program.translations) { - console.log('✅ Running on both English and translated content and data\n') -} else { - console.log('✅ Running on English content and data\n') -} - -// The new conditional to add -const enterpriseAEConditional = 'currentVersion == "github-ae@latest"' - -// Match: currentVersion "enterprise-server@(\d+\.\d+)" -const getEnterpriseServerConditional = new RegExp(`currentVersion (\\S+?) "${getEnterpriseServerNumber.source}"`) - -console.log(`Adding versioning for Enterprise AE based on ${latest}!\n`) -console.log('Working...\n') - -const englishContentFiles = walkContent(contentPath) -const englishDataFiles = walkData(dataPath, englishContentFiles) - -function walkContent (dirPath) { - if (program.product) { - // Run on content/ only - dirPath = path.join(contentPath, program.product) - } - return walk(dirPath, { includeBasePath: true, directories: false }) - .filter(file => file.includes('/content/')) - .filter(file => file.endsWith('.md')) - .filter(file => !file.endsWith('README.md')) -} - -function walkData (dirPath, contentFiles) { - if (program.product) { - const dataFilesPerProductInContent = getReferencedDataFiles(contentFiles) - const dataFilesPerProductInData = getReferencedDataFiles(dataFilesPerProductInContent) - const dataFilesPerProduct = dataFilesPerProductInContent.concat(dataFilesPerProductInData) - return dataFilesPerProduct - } else { - return walk(dirPath, { includeBasePath: true, directories: false }) - .filter(file => file.includes('/data/reusables') || file.includes('/data/variables')) - .filter(file => !file.endsWith('README.md')) - } -} - -// Return an array of variable and reusable filenames referenced in a given set of files. -function getReferencedDataFiles (files) { - return uniq(files - .map(file => getDataReferences(fs.readFileSync(file, 'utf8'))).flat() - .map(dataRef => { - dataRef = dataRef.replace('site.', '').replace(/\./g, '/') - dataRef = dataRef.includes('variables') ? dropRight(dataRef.split('/')).join('/') : dataRef - dataRef = dataRef.includes('variables') ? `${dataRef}.yml` : `${dataRef}.md` - return path.join(process.cwd(), dataRef) - })) -} - -let allContentFiles, allDataFiles -if (program.translations) { - const translatedContentFiles = walkContent(translationsPath) - const translatedDataFiles = walkData(translationsPath, translatedContentFiles) - allContentFiles = englishContentFiles.concat(translatedContentFiles) - allDataFiles = englishDataFiles.concat(translatedDataFiles) -} else { - allContentFiles = englishContentFiles - allDataFiles = englishDataFiles -} - -// Map Liquid operators to semver operators -const operators = { - ver_gt: '>', - ver_lt: '<', - '==': '=' -} - -allDataFiles - .forEach(file => { - const dataContent = fs.readFileSync(file, 'utf8') - - // Update Liquid in data files - const newDataContent = updateLiquid(dataContent, file) - - fs.writeFileSync(file, newDataContent) - }) - -allContentFiles - .forEach(file => { - const { data, content } = frontmatter(fs.readFileSync(file, 'utf8')) - - const applicableVersions = getApplicableVersions(data.versions, file) - - // If the current page is not available in the latest version of GHES, nothing to do! - if (!applicableVersions.includes(`enterprise-server@${latest}`)) return - - // Add frontmatter version - data.versions['github-ae'] = '*' - - // Update Liquid in content files - const newContent = updateLiquid(content, file) - - // Update Liquid in frontmatter props - Object.keys(data) - .filter(key => typeof data[key] === 'string') - .forEach(key => { - data[key] = updateLiquid(data[key], file) - }) - - fs.writeFileSync(file, frontmatter.stringify(newContent, data, { lineWidth: 10000 })) - }) - -function updateLiquid (content, file) { - const allConditionals = content.match(/{% if .+?%}/g) - if (!allConditionals) return content - - let newContent = content - - allConditionals.forEach(conditional => { - // Do not process a conditional that already includes github-ae - if (conditional.includes('github-ae')) return - - // Example match: currentVersion ver_gt "enterprise-server@2.21" - const enterpriseServerMatch = conditional.match(getEnterpriseServerConditional) - if (!enterpriseServerMatch) return - - // Example liquid operator: ver_gt - const liquidOperator = enterpriseServerMatch[1] - - // Example semver operator: > - const semverOperator = operators[liquidOperator] - - // Example number: 2.21 - const number = enterpriseServerMatch[2] - - // Example range: >2.21 - const range = `${semverOperator}${number}` - - // Return early if the conditional does not apply to the latest GHES version; - // that means it will not apply to GHPI either - if (!versionSatisfiesRange(latest, range)) return - - // First do the replacement within the conditional - // Old: {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" %} - // New: {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %} - const newConditional = conditional.replace(enterpriseServerMatch[0], `${enterpriseServerMatch[0]} or ${enterpriseAEConditional}`) - - // Then replace all instances of the conditional in the content - newContent = newContent.replace(conditional, newConditional) - }) - - return newContent -} - -console.log('Done!') diff --git a/script/new-versioning/fixtures.js b/script/new-versioning/fixtures.js deleted file mode 100755 index c6895088cd24..000000000000 --- a/script/new-versioning/fixtures.js +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const walk = require('walk-sync') -const frontmatter = require('@github-docs/frontmatter') -const fixturesPath = path.join(process.cwd(), 'tests/fixtures') - -// NOTE this script does not run as part of script/new-versioning/main! -// It was a one-time-use script that can be removed soon - -const fixturesFiles = walk(fixturesPath, { includeBasePath: true, directories: false }) - .filter(file => file.endsWith('.md')) - .filter(file => !file.includes('tests/fixtures/remove-liquid-statements')) - -fixturesFiles - .forEach(file => { - const { data, content } = frontmatter(fs.readFileSync(file, 'utf8')) - - // Update Liquid in content - const newContent = content ? updateLiquid(content) : '' - - // Update versions frontmatter - if (data) { - if (!data.versions && data.productVersions) { - data.versions = data.productVersions - Object.keys(data.versions).forEach(version => { - // update dotcom, actions, rest, etc. - if (version !== 'enterprise') { - data.versions['free-pro-team'] = data.versions[version] - delete data.versions[version] - } else { - data.versions['enterprise-server'] = data.versions.enterprise - delete data.versions.enterprise - } - }) - } - - delete data.productVersions - - // Update Liquid in frontmatter props - Object.keys(data) - // Only process a subset of props - .filter(key => key === 'title' || key === 'intro' || key === 'product') - .forEach(key => { - data[key] = updateLiquid(data[key]) - }) - } - - fs.writeFileSync(file, frontmatter.stringify(newContent, data, { lineWidth: 10000 })) - }) - -function updateLiquid (content) { - return content - .replace(/page.version/g, 'currentVersion') - .replace(/["'](?:')?dotcom["'](?:')?/g, '"free-pro-team@latest"') - .replace(/["'](?:')?(2\.\d{2})["'](?:')?/g, '"enterprise-server@$1"') -} diff --git a/script/new-versioning/main b/script/new-versioning/main deleted file mode 100755 index 951d3b9eae62..000000000000 --- a/script/new-versioning/main +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -# [start-readme] -# -# All the new versioning! -# -# Usage -# $ script/new-versioning/main -# -# [end-readme] - -base="script/new-versioning/" - -scripts=( - "move-admin-dir.js" - "update-frontmatter.js" - "update-content.js" - "update-products-yml.js" -) - -for script in "${scripts[@]}" -do - fullPath="${base}${script}" - printf "\n" - echo "⭐ $script" - "${fullPath}" - - echo "${script} is done!" - printf "\n\n" -done - -echo "done with all scripts!" diff --git a/script/new-versioning/move-admin-dir.js b/script/new-versioning/move-admin-dir.js deleted file mode 100755 index f8ff7f101c21..000000000000 --- a/script/new-versioning/move-admin-dir.js +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const { execSync } = require('child_process') -const rimraf = require('rimraf').sync -const englishContentDir = 'content' -const walk = require('walk-sync') -const frontmatter = require('@github-docs/frontmatter') -const addRedirect = require('../../lib/redirects/add-redirect-to-frontmatter') - -execSync(`mv ${englishContentDir}/enterprise/admin/ ${englishContentDir}/admin`) -rimraf(`${englishContentDir}/enterprise`) - -fs.readdirSync('translations') - .filter(file => !file.endsWith('.md')) - .forEach(dir => { - const translatedContentDir = path.join('translations', dir, 'content') - execSync(`mv ${translatedContentDir}/enterprise/admin/ ${translatedContentDir}/admin`) - rimraf(`${translatedContentDir}/enterprise`) - }) - -const adminDir = path.join(process.cwd(), englishContentDir, 'admin') - -// Add redirects to English -walk(adminDir, { includeBasePath: true, directories: false }) - .filter(file => file.endsWith('.md')) - .forEach(file => { - const contents = fs.readFileSync(file, 'utf8') - const { data, content } = frontmatter(contents) - - const oldPath = file - .replace(adminDir, '/enterprise/admin') - .replace('.md', '') - .replace('/index', '') - - data.redirect_from = addRedirect(data.redirect_from, oldPath) - - fs.writeFileSync(file, frontmatter.stringify(content, data, { lineWidth: 10000 })) - }) - -// Add redirects to translations -const translationDirs = fs.readdirSync('translations') - .filter(file => !file.endsWith('.md')) - .map(dir => path.join('translations', dir, 'content/admin')) - -translationDirs - .forEach(translationDir => { - walk(translationDir, { includeBasePath: true, directories: false }) - .filter(file => file.endsWith('.md')) - .forEach(file => { - const contents = fs.readFileSync(file, 'utf8') - const { data, content } = frontmatter(contents) - - const oldPath = file - .replace(translationDir, '/enterprise/admin') - .replace('.md', '') - .replace('/index', '') - - data.redirect_from = addRedirect(data.redirect_from, oldPath) - - fs.writeFileSync(file, frontmatter.stringify(content, data, { lineWidth: 10000 })) - }) - }) diff --git a/script/new-versioning/update-content.js b/script/new-versioning/update-content.js deleted file mode 100755 index 3c635f636e47..000000000000 --- a/script/new-versioning/update-content.js +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const walk = require('walk-sync') -const { flatten } = require('lodash') -const dirsToProcess = ['content', 'data', 'translations'] -const allFiles = flatten(dirsToProcess.map(dir => { - return walk(path.join(process.cwd(), dir), { includeBasePath: true, directories: false }) - .filter(file => !file.endsWith('README.md')) -})) - -allFiles.forEach(file => { - let newContents = fs.readFileSync(file, 'utf8') - .replace(/page.version/g, 'currentVersion') - .replace(/["'](?:')?dotcom["'](?:')?/g, '"free-pro-team@latest"') - .replace(/["'](?:')?(2\.\d{2})["'](?:')?/g, '"enterprise-server@$1"') - // TODO handle this separately? requires a change in lib/rewrite-local-links.js - // .replace(/class="dotcom-only"/g, 'class="do-not-version"') - - // replace this one weird subtitle - if (file.endsWith('content/github/index.md')) { - newContents = newContents.replace(` -{% if currentVersion != "free-pro-team@latest" %} -

GitHub Enterprise Server {{ currentVersion }}

-{% endif %} -`, '') - } - - // update this one weird link - if (file.endsWith('content/graphql/overview/public-schema.md')) { - newContents = newContents.replace('(GitHub Enterprise {{ currentVersion }})', '({{ allVersions[currentVersion].versionTitle }})') - } - - fs.writeFileSync(file, newContents) -}) diff --git a/script/new-versioning/update-frontmatter.js b/script/new-versioning/update-frontmatter.js deleted file mode 100755 index f76379fd2064..000000000000 --- a/script/new-versioning/update-frontmatter.js +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const frontmatter = require('@github-docs/frontmatter') -const { flatten } = require('lodash') -const patterns = require('../../lib/patterns') -const walk = require('walk-sync') -const dirsToProcess = ['content', 'translations'] -const allFiles = flatten(dirsToProcess.map(dir => { - return walk(path.join(process.cwd(), dir), { includeBasePath: true, directories: false }) - .filter(file => !file.endsWith('README.md')) - .filter(file => !(file.endsWith('LICENSE') || file.endsWith('LICENSE-CODE'))) - // we only want to process frontmatter in content files in translations, so skip data files - // this is very brittle but works well enough for this script - // (note data files are updated in script/new-versioning/update-content.js) - .filter(file => !file.includes('/data/')) -})) - -allFiles.forEach(file => { - const contents = fs.readFileSync(file, 'utf8') - const { data, content } = frontmatter(contents) - - if (!data.versions) { - data.versions = data.productVersions - Object.keys(data.versions).forEach(version => { - // process dotcom, actions, rest, etc. - if (version !== 'enterprise') { - data.versions['free-pro-team'] = data.versions[version] - delete data.versions[version] - } else { - data.versions['enterprise-server'] = data.versions.enterprise - // TODO we are not adding these WIP versions yet - // we can run a modified version of this script later to add them - // data.versions['enterprise-cloud'] = '*' - // data.versions['private-instances'] = '*' - delete data.versions.enterprise - } - }) - } - - // remove hardcoded version numbers in redirect frontmatter - // fix for https://github.com/github/docs-internal/issues/10835 - if (data.redirect_from) { - data.redirect_from = Array.from([data.redirect_from]).flat().filter(oldPath => { - return !patterns.getEnterpriseVersionNumber.test(oldPath) - }) - } - - delete data.productVersions - - // update some oneoff content files - if (file.endsWith('content/index.md')) { - data.versions['enterprise-server'] = '*' - // TODO we are not adding these WIP versions yet - // we can run a modified version of this script later to add them - // data.versions['enterprise-cloud'] = '*' - // data.versions['private-instances'] = '*' - } - - if (file.endsWith('content/github/index.md')) { - data.title = 'GitHub.com' - delete data.shortTitle - } - - if (file.endsWith('content/admin/index.md')) { - data.title = 'Enterprise Administrators' - delete data.shortTitle - } - - fs.writeFileSync(file, frontmatter.stringify(content, data, { lineWidth: 10000 })) -}) diff --git a/script/new-versioning/update-not-fpt-conditionals.js b/script/new-versioning/update-not-fpt-conditionals.js deleted file mode 100755 index 5ab96ba3aa28..000000000000 --- a/script/new-versioning/update-not-fpt-conditionals.js +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const walk = require('walk-sync') -const frontmatter = require('@github-docs/frontmatter') -const contentPath = path.join(process.cwd(), 'content') -const dataPath = path.join(process.cwd(), 'data') - -// [start-readme] -// -// Run this script to update these Liquid conditionals: -// -// {% if currentVersion != 'free-pro-team@latest' %} -// -// to: -// -// {% if enterpriseServerVersions contains currentVersion %} -// -// [end-readme] - -// The new conditional to add -const newConditional = 'enterpriseServerVersions contains currentVersion' - -// The old conditional to replace -const oldConditional = /currentVersion != ["']free-pro-team@latest["']/g - -console.log('Working...\n') - -const englishContentFiles = walkContent(contentPath) -const englishDataFiles = walkData(dataPath, englishContentFiles) - -function walkContent (dirPath) { - return walk(dirPath, { includeBasePath: true, directories: false }) - .filter(file => file.includes('/content/')) - .filter(file => file.endsWith('.md')) - .filter(file => !file.endsWith('README.md')) -} - -function walkData (dirPath, contentFiles) { - return walk(dirPath, { includeBasePath: true, directories: false }) - .filter(file => file.includes('/data/reusables') || file.includes('/data/variables')) - .filter(file => !file.endsWith('README.md')) -} - -englishDataFiles - .forEach(file => { - const dataContent = fs.readFileSync(file, 'utf8') - - // Update Liquid in data files - const newDataContent = updateLiquid(dataContent, file) - - fs.writeFileSync(file, newDataContent) - }) - -englishContentFiles - .forEach(file => { - const { data, content } = frontmatter(fs.readFileSync(file, 'utf8')) - - // Update Liquid in content files - const newContent = updateLiquid(content, file) - - // Update Liquid in frontmatter props - Object.keys(data) - .filter(key => typeof data[key] === 'string') - .forEach(key => { - data[key] = updateLiquid(data[key], file) - }) - - fs.writeFileSync(file, frontmatter.stringify(newContent, data, { lineWidth: 10000 })) - }) - -function updateLiquid (content) { - return content.replace(oldConditional, newConditional) -} - -console.log('Done!') diff --git a/script/new-versioning/update-products-yml.js b/script/new-versioning/update-products-yml.js deleted file mode 100755 index 9469ad71678e..000000000000 --- a/script/new-versioning/update-products-yml.js +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const productsFile = path.join(process.cwd(), 'data/products.yml') - -const contents = `# this sequence sets the product order in the sidebar -# the product IDs match keys in lib/all-products.js -# note this file should not be translated -productsInOrder: - - github - - admin - - actions - - packages - - developers - - rest - - graphql - - insights - - desktop` - -fs.writeFileSync(productsFile, contents)