From 0ef156d84e257e9d2897eedd603b7907daa4fd90 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Thu, 31 Aug 2023 10:29:20 -0700 Subject: [PATCH] Create links src directory (#41733) --- .github/workflows/link-check-daily.yml | 4 +-- .github/workflows/link-check-on-pr.yml | 2 +- .github/workflows/test.yml | 4 +-- components/article/ArticlePage.tsx | 2 +- src/links/README.md | 19 ++++++++++++ .../links/components}/LinkPreviewPopover.tsx | 0 {lib => src/links/lib}/excluded-links.js | 0 .../links/lib}/update-internal-links.js | 12 +++---- .../rendered-content-link-checker-1.js | 11 ++++--- .../scripts}/rendered-content-link-checker.js | 31 ++++++++++--------- .../scripts}/update-developer-site-links.js | 10 +++--- .../links/scripts}/update-internal-links.js | 6 ++-- 12 files changed, 63 insertions(+), 38 deletions(-) create mode 100644 src/links/README.md rename {components => src/links/components}/LinkPreviewPopover.tsx (100%) rename {lib => src/links/lib}/excluded-links.js (100%) rename {lib => src/links/lib}/update-internal-links.js (97%) rename script/rendered-content-link-checker.js => src/links/scripts/rendered-content-link-checker-1.js (93%) rename {.github/actions-scripts => src/links/scripts}/rendered-content-link-checker.js (97%) rename {script/content-migrations => src/links/scripts}/update-developer-site-links.js (88%) rename {script => src/links/scripts}/update-internal-links.js (98%) diff --git a/.github/workflows/link-check-daily.yml b/.github/workflows/link-check-daily.yml index beb9b7b530..2d907eec31 100644 --- a/.github/workflows/link-check-daily.yml +++ b/.github/workflows/link-check-daily.yml @@ -52,7 +52,7 @@ jobs: uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 with: path: external-link-checker-db.json - key: external-link-checker-${{ hashFiles('.github/actions/rendered-content-link-checker.js') }} + key: external-link-checker-${{ hashFiles('src/links/scripts/rendered-content-link-checker.js') }} - name: Run link checker env: @@ -76,7 +76,7 @@ jobs: # treat it as a warning and not as a broken link. EXTERNAL_SERVER_ERRORS_AS_WARNINGS: true timeout-minutes: 30 - run: node .github/actions-scripts/rendered-content-link-checker.js + run: node src/links/scripts/rendered-content-link-checker.js - name: Upload artifact(s) uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 diff --git a/.github/workflows/link-check-on-pr.yml b/.github/workflows/link-check-on-pr.yml index 31ab43fbde..b6af4f1e73 100644 --- a/.github/workflows/link-check-on-pr.yml +++ b/.github/workflows/link-check-on-pr.yml @@ -49,7 +49,7 @@ jobs: # we're filtering on anyway once the list of all pages has # been loaded. ENABLED_LANGUAGES: en - run: node .github/actions-scripts/rendered-content-link-checker.js + run: node src/links/scripts/rendered-content-link-checker.js - name: Upload artifact(s) uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a37ff1a637..92e24791fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,11 +109,11 @@ jobs: run: | # If either of these fail, it means our fixture content's internal # links can and should be updated. - ./script/update-internal-links.js --dry-run --check --strict \ + ./src/links/scripts/update-internal-links.js --dry-run --check --strict \ tests/fixtures/content \ --exclude tests/fixtures/content/get-started/foo/typo-autotitling.md \ --exclude tests/fixtures/content/get-started/foo/anchor-autotitling.md - ./script/update-internal-links.js --dry-run --check --strict \ + ./src/links/scripts/update-internal-links.js --dry-run --check --strict \ tests/fixtures/data - name: Clone all translations diff --git a/components/article/ArticlePage.tsx b/components/article/ArticlePage.tsx index 9b6ef62e40..22cde36f2f 100644 --- a/components/article/ArticlePage.tsx +++ b/components/article/ArticlePage.tsx @@ -21,7 +21,7 @@ import { RestRedirect } from 'src/rest/components/RestRedirect' import { Breadcrumbs } from 'components/page-header/Breadcrumbs' import { Link } from 'components/Link' import { useTranslation } from 'src/languages/components/useTranslation' -import { LinkPreviewPopover } from 'components/LinkPreviewPopover' +import { LinkPreviewPopover } from 'src/links/components/LinkPreviewPopover' const ClientSideRefresh = dynamic(() => import('components/ClientSideRefresh'), { ssr: false, diff --git a/src/links/README.md b/src/links/README.md new file mode 100644 index 0000000000..aa410a2a6f --- /dev/null +++ b/src/links/README.md @@ -0,0 +1,19 @@ +# LINKS + +TBD what is LINKS + +## What LINKS does + +TBD why is LINKS on the docs + +## How LINKS works + +TBD step-by-step instructions to work on LINKS + +## How to work on LINKS + +TBD step-by-step instructions on how to work on LINKS + +## How to get help for LINKS + +TBD reference material diff --git a/components/LinkPreviewPopover.tsx b/src/links/components/LinkPreviewPopover.tsx similarity index 100% rename from components/LinkPreviewPopover.tsx rename to src/links/components/LinkPreviewPopover.tsx diff --git a/lib/excluded-links.js b/src/links/lib/excluded-links.js similarity index 100% rename from lib/excluded-links.js rename to src/links/lib/excluded-links.js diff --git a/lib/update-internal-links.js b/src/links/lib/update-internal-links.js similarity index 97% rename from lib/update-internal-links.js rename to src/links/lib/update-internal-links.js index 03c9097329..e0e876f921 100644 --- a/lib/update-internal-links.js +++ b/src/links/lib/update-internal-links.js @@ -6,19 +6,19 @@ import { fromMarkdown } from 'mdast-util-from-markdown' import { toMarkdown } from 'mdast-util-to-markdown' import yaml from 'js-yaml' -import frontmatter from './read-frontmatter.js' +import frontmatter from '../../../lib/read-frontmatter.js' import { getPathWithLanguage, getPathWithoutLanguage, getPathWithoutVersion, getVersionStringFromPath, -} from './path-utils.js' +} from '../../../lib/path-utils.js' import loadRedirects from '#src/redirects/lib/precompile.js' -import patterns from './patterns.js' -import { loadUnversionedTree, loadPages, loadPageMap } from './page-data.js' +import patterns from '../../../lib/patterns.js' +import { loadUnversionedTree, loadPages, loadPageMap } from '../../../lib/page-data.js' import getRedirect, { splitPathByLanguage } from '#src/redirects/lib/get-redirect.js' -import nonEnterpriseDefaultVersion from './non-enterprise-default-version.js' -import { deprecated } from './enterprise-server-releases.js' +import nonEnterpriseDefaultVersion from '../../../lib/non-enterprise-default-version.js' +import { deprecated } from '../../../lib/enterprise-server-releases.js' function objectClone(obj) { try { diff --git a/script/rendered-content-link-checker.js b/src/links/scripts/rendered-content-link-checker-1.js similarity index 93% rename from script/rendered-content-link-checker.js rename to src/links/scripts/rendered-content-link-checker-1.js index 2bdd45e32b..751a765ae0 100755 --- a/script/rendered-content-link-checker.js +++ b/src/links/scripts/rendered-content-link-checker-1.js @@ -10,10 +10,13 @@ import fs from 'fs' import path from 'path' import { program, Option, InvalidArgumentError } from 'commander' -import renderedContentLinkChecker from '../.github/actions-scripts/rendered-content-link-checker.js' -import { getCoreInject, getUploadArtifactInject } from './helpers/action-injections.js' -import { allVersions } from '../lib/all-versions.js' -import github from './helpers/github.js' +import renderedContentLinkChecker from '#src/links/scripts/rendered-content-link-checker.js' +import { + getCoreInject, + getUploadArtifactInject, +} from '../../../script/helpers/action-injections.js' +import { allVersions } from '../../../lib/all-versions.js' +import github from '../../../script/helpers/github.js' const STATIC_PREFIXES = { assets: path.resolve('assets'), diff --git a/.github/actions-scripts/rendered-content-link-checker.js b/src/links/scripts/rendered-content-link-checker.js similarity index 97% rename from .github/actions-scripts/rendered-content-link-checker.js rename to src/links/scripts/rendered-content-link-checker.js index 260f91bd3c..5c2c3f6565 100755 --- a/.github/actions-scripts/rendered-content-link-checker.js +++ b/src/links/scripts/rendered-content-link-checker.js @@ -9,20 +9,23 @@ import chalk from 'chalk' import { Low } from 'lowdb' import { JSONFile } from 'lowdb/node' -import shortVersions from '../../middleware/contextualizers/short-versions.js' -import contextualize from '../../middleware/context.js' -import features from '../../middleware/contextualizers/features.js' -import getRedirect from '../../src/redirects/lib/get-redirect.js' -import warmServer from '../../lib/warm-server.js' -import { liquid } from '../../src/content-render/index.js' -import { deprecated } from '../../lib/enterprise-server-releases.js' -import excludedLinks from '../../lib/excluded-links.js' -import { getEnvInputs, boolEnvVar } from './lib/get-env-inputs.js' -import { debugTimeEnd, debugTimeStart } from './lib/debug-time-taken.js' -import { uploadArtifact as uploadArtifactLib } from './lib/upload-artifact.js' -import github from '../../script/helpers/github.js' -import { getActionContext } from './lib/action-context.js' -import { createMinimalProcessor } from '../../src/content-render/unified/processor.js' +import shortVersions from '../../../middleware/contextualizers/short-versions.js' +import contextualize from '../../../middleware/context.js' +import features from '../../../middleware/contextualizers/features.js' +import getRedirect from '#src/redirects/lib/get-redirect.js' +import warmServer from '../../../lib/warm-server.js' +import { liquid } from '#src/content-render/index.js' +import { deprecated } from '../../../lib/enterprise-server-releases.js' +import excludedLinks from '#src/links/lib/excluded-links.js' +import { getEnvInputs, boolEnvVar } from '../../../.github/actions-scripts/lib/get-env-inputs.js' +import { + debugTimeEnd, + debugTimeStart, +} from '../../../.github/actions-scripts/lib/debug-time-taken.js' +import { uploadArtifact as uploadArtifactLib } from '../../../.github/actions-scripts/lib/upload-artifact.js' +import github from '../../../script/helpers/github.js' +import { getActionContext } from '../../../.github/actions-scripts/lib/action-context.js' +import { createMinimalProcessor } from '#src/content-render/unified/processor.js' const STATIC_PREFIXES = { assets: path.resolve('assets'), diff --git a/script/content-migrations/update-developer-site-links.js b/src/links/scripts/update-developer-site-links.js similarity index 88% rename from script/content-migrations/update-developer-site-links.js rename to src/links/scripts/update-developer-site-links.js index 83453f04df..da9042f74a 100755 --- a/script/content-migrations/update-developer-site-links.js +++ b/src/links/scripts/update-developer-site-links.js @@ -2,11 +2,11 @@ import fs from 'fs' import path from 'path' import walk from 'walk-sync' -import frontmatter from '../../lib/read-frontmatter.js' -import { loadPages, loadPageMap } from '../../lib/page-data.js' -import patterns from '../../lib/patterns.js' -import loadRedirects from '../../src/redirects/lib/precompile.js' -import { allVersionKeys } from '../../lib/all-versions.js' +import frontmatter from '../../../lib/read-frontmatter.js' +import { loadPages, loadPageMap } from '../../../lib/page-data.js' +import patterns from '../../../lib/patterns.js' +import loadRedirects from '#src/redirects/lib/precompile.js' +import { allVersionKeys } from '../../../lib/all-versions.js' // get all content and data files const files = ['content', 'data'] diff --git a/script/update-internal-links.js b/src/links/scripts/update-internal-links.js similarity index 98% rename from script/update-internal-links.js rename to src/links/scripts/update-internal-links.js index 42cef77ae4..89b569b88f 100755 --- a/script/update-internal-links.js +++ b/src/links/scripts/update-internal-links.js @@ -16,9 +16,9 @@ import { program } from 'commander' import chalk from 'chalk' import yaml from 'js-yaml' -import { updateInternalLinks } from '../lib/update-internal-links.js' -import frontmatter from '../lib/read-frontmatter.js' -import walkFiles from './helpers/walk-files.js' +import { updateInternalLinks } from '#src/links/lib/update-internal-links.js' +import frontmatter from '../../../lib/read-frontmatter.js' +import walkFiles from '../../../script/helpers/walk-files.js' program .description('Update internal links in content files')