From df512405dfb28a499d766e76e42e9272c9183aa8 Mon Sep 17 00:00:00 2001 From: Grace Park Date: Fri, 19 Jan 2024 10:26:56 -0800 Subject: [PATCH 1/2] Bug fix: remove `^` in regex for list-first-word-capitalization (#48764) --- .../lib/linting-rules/list-first-word-capitalization.js | 3 ++- .../tests/unit/list-first-word-captitalization.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/content-linter/lib/linting-rules/list-first-word-capitalization.js b/src/content-linter/lib/linting-rules/list-first-word-capitalization.js index 578d4eacb28d..f19b566b8958 100644 --- a/src/content-linter/lib/linting-rules/list-first-word-capitalization.js +++ b/src/content-linter/lib/linting-rules/list-first-word-capitalization.js @@ -33,7 +33,8 @@ export const listFirstWordCapitalization = { const firstWord = content.trim().split(' ')[0] // Liquid is considered a text node but we don't want to capitalize it - if (/^[{%|{{]/.test(content)) return + if (firstWord.startsWith('[{%') || firstWord.startsWith('{%') || firstWord.startsWith('{{')) + return // If the first letter is capitalized, it's not an error if (/[A-Z]/.test(firstWord[0])) return // There are items that start with a number or words that contain numbers diff --git a/src/content-linter/tests/unit/list-first-word-captitalization.js b/src/content-linter/tests/unit/list-first-word-captitalization.js index 6e72f0a99201..d596346b86dc 100644 --- a/src/content-linter/tests/unit/list-first-word-captitalization.js +++ b/src/content-linter/tests/unit/list-first-word-captitalization.js @@ -46,6 +46,8 @@ describe(listFirstWordCapitalization.names.join(' - '), () => { "- '[AUTOTITLE](/billing/managing-billing-for-github-marketplace-apps)'", '- [Viewing your sponsors and sponsorships](/sponsors/receiving-sponsorships-through-github-sponsors/viewing-your-sponsors-and-sponsorships)', '- macOS', + '- [{% data variables.actions.test %}](/apple/test)', + '- {{ foo }} for example', '- {% data variables.product.prodname_dotcom_the_website %} Services Continuity and Incident Management Plan', '- {% data variables.product.prodname_dotcom_the_website %} Services Continuity and Incident Management Plan', '- x64', From 8dd3a5adf983301d83c205a95d73b4455ad55299 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Fri, 19 Jan 2024 13:43:22 -0500 Subject: [PATCH 2/2] Stop indexing GHAE in Elasticsearch (#48694) --- src/search/scripts/index-elasticsearch.js | 10 +++++++++- src/search/scripts/sync-search-indices.js | 13 ++++++++++--- src/search/scripts/sync.js | 9 ++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/search/scripts/index-elasticsearch.js b/src/search/scripts/index-elasticsearch.js index cbcc92523fed..f2ddd52c6803 100755 --- a/src/search/scripts/index-elasticsearch.js +++ b/src/search/scripts/index-elasticsearch.js @@ -19,6 +19,14 @@ import { retryOnErrorTest } from './retry-on-error-test.js' import { languageKeys } from '#src/languages/lib/languages.js' import { allVersions } from '#src/versions/lib/all-versions.js' +const availableVersions = Object.fromEntries( + Object.entries(allVersions) + // GHAE is deprecated and not yet entirely deleted from all-versions + // Until so, we manually filter it out. + .filter(([version]) => version !== 'github-ae@latest') + .map(([key, value]) => [key, value]), +) + // Now you can optionally have set the ELASTICSEARCH_URL in your .env file. dotenv.config() @@ -38,7 +46,7 @@ dotenv.config() // We need this later to be able to map CLI arguments to what the // records are called when found on disk. const shortNames = Object.fromEntries( - Object.values(allVersions).map((info) => { + Object.values(availableVersions).map((info) => { const shortName = info.hasNumberedReleases ? info.miscBaseName + info.currentRelease : info.miscBaseName diff --git a/src/search/scripts/sync-search-indices.js b/src/search/scripts/sync-search-indices.js index 8f7f5e049c2b..40367febaf14 100755 --- a/src/search/scripts/sync-search-indices.js +++ b/src/search/scripts/sync-search-indices.js @@ -16,8 +16,15 @@ import { languageKeys } from '#src/languages/lib/languages.js' import { allVersions } from '#src/versions/lib/all-versions.js' import searchSync from './sync.js' +const availableVersions = Object.fromEntries( + Object.entries(allVersions) + // GHAE is deprecated and not yet entirely deleted from all-versions + // Until so, we manually filter it out. + .filter(([version]) => version !== 'github-ae@latest') + .map(([key, value]) => [key, value]), +) const shortNames = Object.fromEntries( - Object.values(allVersions).map((info) => { + Object.values(availableVersions).map((info) => { const shortName = info.hasNumberedReleases ? info.miscBaseName + info.currentRelease : info.miscBaseName @@ -25,7 +32,7 @@ const shortNames = Object.fromEntries( }), ) -const allVersionKeys = [...Object.keys(shortNames), ...Object.keys(allVersions)] +const allVersionKeys = [...Object.keys(shortNames), ...Object.keys(availableVersions)] program .description('Creates search records by scraping') @@ -133,9 +140,9 @@ async function main(opts, args) { const options = { language, notLanguage, - version: indexVersion, outDirectory, config, + versionsToBuild: indexVersion ? [indexVersion] : Object.keys(availableVersions), } await searchSync(options) } diff --git a/src/search/scripts/sync.js b/src/search/scripts/sync.js index c63ef71559d4..127a26bfcce3 100644 --- a/src/search/scripts/sync.js +++ b/src/search/scripts/sync.js @@ -12,9 +12,9 @@ import { writeIndexRecords } from './search-index-records.js' // e.g. `github-docs-dotcom-en.json` and `github-docs-2.14-ja.json` export default async function syncSearchIndexes({ language, - version, notLanguage, outDirectory, + versionsToBuild, config = {}, }) { const t0 = new Date() @@ -24,14 +24,9 @@ export default async function syncSearchIndexes({ notLanguage ? notLanguage !== lang : language ? language === lang : true, ) - // build indices for a specific version if provided; otherwise build indices for all versions - const versionsToBuild = Object.keys(allVersions).filter((ver) => - version ? version === ver : true, - ) - console.log( `Building indices for ${chalk.yellow(language || 'all languages')} and ${chalk.yellow( - version || 'all versions', + versionsToBuild.length === 1 ? versionsToBuild[0] : 'all versions', )}.\n`, )