diff --git a/.dockerignore b/.dockerignore index c345ced1a2b8..0fabbd3418ab 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,7 +5,6 @@ contributing/ docs/ node_modules/ -script/ tests/ # Folder is cloned during the preview + prod workflows, the assets are merged into other locations for use before the build docs-early-access/ diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 4bda23ec201d..6d7c74f5d732 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -20,7 +20,7 @@ module.exports = { "tmp/*", "!/.*", "/.next/", - "script/bookmarklets/*", + "src/bookmarklets/*", "src/open-source/scripts/add-pr-links.js", "src/open-source/scripts/pr-link-source.js", "rest-api-description/", diff --git a/.github/actions/warmup-remotejson-cache/action.yml b/.github/actions/warmup-remotejson-cache/action.yml index 02b1c916fe9c..04d039c68f05 100644 --- a/.github/actions/warmup-remotejson-cache/action.yml +++ b/.github/actions/warmup-remotejson-cache/action.yml @@ -33,7 +33,7 @@ runs: - name: Run script if: ${{ inputs.restore-only == '' }} shell: bash - run: node script/warmup-remotejson.js + run: node src/archives/scripts/warmup-remotejson.js - name: Cache .remotejson-cache (save) if: ${{ inputs.restore-only == '' }} diff --git a/.github/workflows/check-broken-links-github-github.yml b/.github/workflows/check-broken-links-github-github.yml index e416075dc624..86a027826bcf 100644 --- a/.github/workflows/check-broken-links-github-github.yml +++ b/.github/workflows/check-broken-links-github-github.yml @@ -66,7 +66,7 @@ jobs: - name: Run broken github/github link check run: | - script/check-github-github-links.js broken_github_github_links.md + src/links/scripts/check-github-github-links.js broken_github_github_links.md - name: Get title for issue # If the file 'broken_github_github_links.md' got created, diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37aed123178d..7021d76a79ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,7 @@ jobs: - name: Check the test fixture data (if applicable) if: ${{ matrix.name == 'rendering-fixtures' }} - run: ./script/copy-fixture-data.js --check + run: ./src/tests/scripts/copy-fixture-data.js --check # This keeps our fixture content/data in check - name: Check the test fixture content (if applicable) diff --git a/.github/workflows/triage-unallowed-contributions.yml b/.github/workflows/triage-unallowed-contributions.yml index 5c5657395dd1..c4c91d2f05e5 100644 --- a/.github/workflows/triage-unallowed-contributions.yml +++ b/.github/workflows/triage-unallowed-contributions.yml @@ -13,10 +13,11 @@ on: - 'assets/fonts/**' - 'data/graphql/**' - 'Dockerfile*' - - 'src/**' + - 'src/*/scripts/**' + - 'src/**.json' + - 'src/workflows/**' - 'lib/redirects/**' - 'package*.json' - - 'script/**' - 'content/actions/deployment/security-hardening-your-deployments/**' permissions: @@ -55,10 +56,11 @@ jobs: - 'assets/fonts/**' - 'data/graphql/**' - 'Dockerfile*' - - 'src/**' + - 'src/*/scripts/**' + - 'src/**.json' + - 'src/workflows/**' - 'lib/redirects/**' - 'package*.json' - - 'scripts/**' - 'content/actions/deployment/security-hardening-your-deployments/**' # When there are changes to files we can't accept, leave a comment @@ -75,10 +77,11 @@ jobs: 'assets/fonts/**', 'data/graphql/**', 'Dockerfile*', - 'src/**', + 'src/*/scripts/**', + 'src/**.json', + 'src/workflows/**', 'lib/redirects/**', 'package*.json', - 'scripts/**', 'content/actions/deployment/security-hardening-your-deployments/**', ] diff --git a/.github/workflows/validate-asset-images.yml b/.github/workflows/validate-asset-images.yml index 1d345d834a84..724f204e2922 100644 --- a/.github/workflows/validate-asset-images.yml +++ b/.github/workflows/validate-asset-images.yml @@ -1,6 +1,6 @@ name: Validate asset images -# **What it does**: Run ./script/validate-asset-images.js on all images in assets/ +# **What it does**: Run ./src/assets/scripts/validate-asset-images.js on all images in assets/ # **Why we have it**: To protect from innocent and potentially malicious bad image assets # **Who does it impact**: Docs content. diff --git a/.gitignore b/.gitignore index 157461cbc0d1..9f881f4b70f2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ coverage/ /assets/images/early-access /content/early-access /data/early-access -/script/dev-toc/static +/src/dev-toc/static .next .eslintcache *.tsbuildinfo @@ -30,7 +30,7 @@ lib/redirects/.redirects-cache*.json user-code/ # Logs from scripts -script/logs/ +*/logs/ external-link-checker-db.json # Playwright related diff --git a/.prettierignore b/.prettierignore index e235401a9dc9..0960072ee318 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,5 @@ data/release-notes/ -script/bookmarklets/ +src/bookmarklets/ src/open-source/scripts/add-pr-links.js /.next/ diff --git a/content/README.md b/content/README.md index 43e5760d16be..4ba76b5f9826 100644 --- a/content/README.md +++ b/content/README.md @@ -196,7 +196,7 @@ featuredLinks: ### `allowTitleToDifferFromFilename` -- Purpose: Indicates whether a page is allowed to have a title that differs from its filename. Pages with this frontmatter set to `true` will not be flagged in tests or updated by `script/reconcile-ids-with-filenames.js`. Use this value if a file's `title` frontmatter includes Liquid or punctuation that cannot be part of the filename. For example, the article "[About Enterprise Managed Users](https://docs.github.com/en/enterprise-cloud@latest/admin/identity-and-access-management/using-enterprise-managed-users-for-iam/about-enterprise-managed-users)" uses a Liquid reusable in its title, `'About {% data variables.product.prodname_emus %}'`, which cannot be in the filename, `about-enterprise-managed-users.md`, so the `allowTitleToDifferFromFilename` frontmatter is set to `true`. +- Purpose: Indicates whether a page is allowed to have a title that differs from its filename. Pages with this frontmatter set to `true` will not be flagged in tests or updated by `src/content-render/scripts/reconcile-filenames-with-ids.js`. Use this value if a file's `title` frontmatter includes Liquid or punctuation that cannot be part of the filename. For example, the article "[About Enterprise Managed Users](https://docs.github.com/en/enterprise-cloud@latest/admin/identity-and-access-management/using-enterprise-managed-users-for-iam/about-enterprise-managed-users)" uses a Liquid reusable in its title, `'About {% data variables.product.prodname_emus %}'`, which cannot be in the filename, `about-enterprise-managed-users.md`, so the `allowTitleToDifferFromFilename` frontmatter is set to `true`. - Type: `Boolean`. Default is `false`. - Optional. diff --git a/content/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment.md b/content/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment.md index 69a34998e13c..aca9e4048e51 100644 --- a/content/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment.md +++ b/content/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment.md @@ -67,7 +67,7 @@ If you would like to read more about debugging and troubleshooting the {% data v ### Using browser shortcuts -The [`script/bookmarklets`](https://github.com/github/docs/tree/main/script/bookmarklets) directory in the {% data variables.product.prodname_docs %} repository contains browser shortcuts that can help with reviewing {% data variables.product.company_short %} documentation. For more information, see the directory's [`README`](https://github.com/github/docs/tree/main/script/bookmarklets/README.md). +The [`src/bookmarklets`](https://github.com/github/docs/tree/main/src/bookmarklets) directory in the {% data variables.product.prodname_docs %} repository contains browser shortcuts that can help with reviewing {% data variables.product.company_short %} documentation. For more information, see the directory's [`README`](https://github.com/github/docs/tree/main/src/bookmarklets/README.md). ### Enabling different languages diff --git a/content/contributing/setting-up-your-environment-to-work-on-github-docs/troubleshooting-your-environment.md b/content/contributing/setting-up-your-environment-to-work-on-github-docs/troubleshooting-your-environment.md index 0253a04b6b67..bb9eb1413e8f 100644 --- a/content/contributing/setting-up-your-environment-to-work-on-github-docs/troubleshooting-your-environment.md +++ b/content/contributing/setting-up-your-environment-to-work-on-github-docs/troubleshooting-your-environment.md @@ -34,7 +34,7 @@ git push ## Troubleshooting local server problems -If you are running `script/server` and get a `Cannot find module` error, try the following command before restarting the server. +If you are running `npm start` and get a `Cannot find module` error, try the following command before restarting the server. ```shell npm install @@ -52,7 +52,7 @@ npm install If you are having trouble with the staging server, you should see more information about the error in your browser or on the command line if you run the site locally. Check out your branch locally and use the following command to launch the local server. ```shell -script/server +npm start ``` When the server is running, navigate to the problematic article on `https://localhost:4000` in your browser. The staging server will just show an "Oops" error, but the local server should show a stack trace for debugging. diff --git a/content/contributing/writing-for-github-docs/using-yaml-frontmatter.md b/content/contributing/writing-for-github-docs/using-yaml-frontmatter.md index 0d85d3570d97..3b417186584c 100644 --- a/content/contributing/writing-for-github-docs/using-yaml-frontmatter.md +++ b/content/contributing/writing-for-github-docs/using-yaml-frontmatter.md @@ -188,7 +188,7 @@ featuredLinks: ### `allowTitleToDifferFromFilename` -- Purpose: Indicates whether a page is allowed to have a title that differs from its filename. For example, `content/rest/reference/orgs.md` has a title of `Organizations` instead of `Orgs`. Pages with this frontmatter set to `true` will not be flagged in tests or updated by `script/reconcile-ids-with-filenames.js`. +- Purpose: Indicates whether a page is allowed to have a title that differs from its filename. For example, `content/rest/reference/orgs.md` has a title of `Organizations` instead of `Orgs`. Pages with this frontmatter set to `true` will not be flagged in tests or updated by `src/content-render/scripts/reconcile-filenames-with-ids.js`. - Type: `Boolean`. Default is `false`. - Optional. @@ -225,7 +225,7 @@ defaultTool: cli ### `learningTracks` - Purpose: Render a list of learning tracks on a product's sub-landing page. -- type: `String`. This should reference learning tracks' names defined in [`data/learning-tracks/*.yml`](https://github.com/github/docs/tree/main/data/learning-tracks). +- Type: `String`. This should reference learning tracks' names defined in [`data/learning-tracks/*.yml`](https://github.com/github/docs/tree/main/data/learning-tracks). - Optional {% note %} diff --git a/contributing/development.md b/contributing/development.md index dea8f0492239..d033e5575bbe 100644 --- a/contributing/development.md +++ b/contributing/development.md @@ -38,7 +38,7 @@ In a matter of minutes, you will be ready to edit, preview and test your changes ### Using browser shortcuts -The [`script/bookmarklets`](../script/bookmarklets) directory contains some browser shortcuts that can help with reviewing GitHub documentation. See [`script/bookmarklets/README.md`](../script/bookmarklets/README.md) for details. +The [`src/bookmarklets`](../src/bookmarklets) directory contains some browser shortcuts that can help with reviewing GitHub documentation. See [`src/bookmarklets/README.md`](../src/bookmarklets/README.md) for details. ### Enabling different languages diff --git a/contributing/troubleshooting.md b/contributing/troubleshooting.md index ea5e876f39ac..6a80bc52b34f 100644 --- a/contributing/troubleshooting.md +++ b/contributing/troubleshooting.md @@ -27,35 +27,35 @@ If a staging deployment is pending for more than 5-10min, try the following: 2. If that doesn't work, trigger a new staging deployment by pushing an empty commit on the command line: ``` -$ git commit --allow-empty -m 'empty commit to redeploy staging' +git commit --allow-empty -m 'empty commit to redeploy staging' ``` ### CI stalled or stuck :yellow_heart: If tests are stuck yellow for more than an hour, rerun CI by pushing an empty commit on the command line: ``` -$ git commit --allow-empty -m 'empty commit to rerun CI' +git commit --allow-empty -m 'empty commit to rerun CI' ``` ### Can't run the site locally -If you are running `script/server` and get a `Cannot find module` error, try: +If you are running `npm start` and get a `Cannot find module` error, try: ``` -$ npm install +npm install ``` If that doesn't fix it, try: ``` -$ rm -rf node_modules -$ npm install +rm -rf node_modules +npm install ``` ### Failed staging deployment Check out the branch and run the site locally: ``` -$ script/server +npm start ``` Go to https://localhost:4000 @@ -77,7 +77,7 @@ make sure single quotes are properly escaped in the frontmatter. Also, check the Check out the branch and run the site locally: ``` -$ script/server +npm start ``` Go to whatever page is 500ing on staging on your local server: https://localhost:4000/page-with-error diff --git a/contributing/working-in-docs-repository.md b/contributing/working-in-docs-repository.md index 7b961df7d859..1575f7710097 100644 --- a/contributing/working-in-docs-repository.md +++ b/contributing/working-in-docs-repository.md @@ -16,6 +16,4 @@ Here's some information that might be helpful while working on a Docs PR: - [Liquid](/contributing/liquid-helpers.md) - We use liquid helpers to create different versions of our content. -- [Scripts](/script/README.md) - The scripts directory is the home for all of the scripts you can run locally. - - [Tests](/tests/README.md) - We use tests to ensure content will render correctly on the site. Tests run automatically in your PR, and sometimes it's also helpful to run them locally. diff --git a/jest.config.js b/jest.config.js index 6202eeb47308..dc8836e1e335 100644 --- a/jest.config.js +++ b/jest.config.js @@ -25,6 +25,6 @@ export default { testPathIgnorePatterns: ['node_modules/', 'vendor/', 'tests/fixtures/', 'tests/helpers/'], testMatch: ['**/tests/**/*.js'], testLocationInResults: isActions, - globalSetup: './script/start-server-for-jest.js', - globalTeardown: './script/kill-server-for-jest.js', + globalSetup: './src/tests/scripts/start-server-for-jest.js', + globalTeardown: './src/tests/scripts/kill-server-for-jest.js', } diff --git a/middleware/context.js b/middleware/context.js index 45faf2e7f6ca..cc5b96fb12ab 100644 --- a/middleware/context.js +++ b/middleware/context.js @@ -11,7 +11,7 @@ import { } from '../lib/path-utils.js' import productNames from '../lib/product-names.js' import warmServer from '../lib/warm-server.js' -import searchVersions from '../src/search/lib/versions.js' +import searchVersions from '#src/search/lib/versions.js' import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js' import { getDataByLanguage, getUIDataMerged } from '../lib/get-data.js' diff --git a/package.json b/package.json index 358aab6a50bc..1b5ce0c0ea6c 100644 --- a/package.json +++ b/package.json @@ -25,15 +25,16 @@ "lint": "eslint '**/*.{js,mjs,ts,tsx}'", "lint-content": "node src/content-linter/scripts/lint-content.js", "lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules jest src/content-linter/tests/lint-files.js", + "move-content": "node src/content-render/scripts/move-content.js", "openapi-docs": "node src/rest/docs.js", "playwright-test": "playwright test --project=\"Google Chrome\"", "prepare": "husky install", "prettier": "prettier -w \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"", "prettier-check": "prettier -c \"**/*.{ts,tsx,js,mjs,scss,yml,yaml}\"", - "prevent-pushes-to-main": "node script/prevent-pushes-to-main.js", + "prevent-pushes-to-main": "node src/workflows/prevent-pushes-to-main.js", "rest-dev": "node src/rest/scripts/update-files.js", "show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-", - "prestart": "node script/cmp-files.js package-lock.json .installed.package-lock.json || npm install && cp package-lock.json .installed.package-lock.json", + "prestart": "node src/workflows/cmp-files.js package-lock.json .installed.package-lock.json || npm install && cp package-lock.json .installed.package-lock.json", "start": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon server.js", "start-all-languages": "cross-env NODE_ENV=development nodemon server.js", "start-for-playwright": "cross-env ROOT=tests/fixtures TRANSLATIONS_FIXTURE_ROOT=tests/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test node server.js", diff --git a/script/warmup-remotejson.js b/src/archives/scripts/warmup-remotejson.js similarity index 96% rename from script/warmup-remotejson.js rename to src/archives/scripts/warmup-remotejson.js index 237701bd9403..2269cf492212 100755 --- a/script/warmup-remotejson.js +++ b/src/archives/scripts/warmup-remotejson.js @@ -21,7 +21,7 @@ import { program } from 'commander' import semver from 'semver' -import getRemoteJSON from '../middleware/get-remote-json.js' +import getRemoteJSON from '../../../middleware/get-remote-json.js' import { deprecated, firstReleaseStoredInBlobStorage, diff --git a/src/assets/scripts/deleted-assets-pr-comment-1.js b/src/assets/scripts/deleted-assets-pr-comment-1.js index dddb9264e2fa..0adc48c7264d 100755 --- a/src/assets/scripts/deleted-assets-pr-comment-1.js +++ b/src/assets/scripts/deleted-assets-pr-comment-1.js @@ -13,7 +13,7 @@ // Example use: // // export GITHUB_TOKEN=github_pat_11AAAG..... -// ./script/deleted-assets-pr-comment.js github docs-internal main 4a0b0f2 +// ./src/assets/scripts/deleted-assets-pr-comment.js github docs-internal main 4a0b0f2 // // [end-readme] diff --git a/src/assets/scripts/find-orphaned-assets.js b/src/assets/scripts/find-orphaned-assets.js index 37ba7c0b8939..75f00d39e4e2 100755 --- a/src/assets/scripts/find-orphaned-assets.js +++ b/src/assets/scripts/find-orphaned-assets.js @@ -12,7 +12,7 @@ import path from 'path' import { program } from 'commander' import walk from 'walk-sync' -import walkFiles from '../../../script/helpers/walk-files.js' +import walkFiles from '#src/workflows/walk-files.js' import languages from '#src/languages/lib/languages.js' const EXCEPTIONS = new Set([ diff --git a/src/audit-logs/scripts/sync.js b/src/audit-logs/scripts/sync.js index 497be04c41a1..0a2c9dc9f1b2 100755 --- a/src/audit-logs/scripts/sync.js +++ b/src/audit-logs/scripts/sync.js @@ -14,7 +14,7 @@ import { readFile, writeFile } from 'fs/promises' import { mkdirp } from 'mkdirp' import path from 'path' -import { getContents, getCommitSha } from '../../../script/helpers/git-utils.js' +import { getContents, getCommitSha } from '#src/workflows/git-utils.js' if (!process.env.GITHUB_TOKEN) { throw new Error('GITHUB_TOKEN environment variable must be set to run this script') diff --git a/script/bookmarklets/README.md b/src/bookmarklets/README.md similarity index 82% rename from script/bookmarklets/README.md rename to src/bookmarklets/README.md index d931cf524883..1283b1170177 100644 --- a/script/bookmarklets/README.md +++ b/src/bookmarklets/README.md @@ -15,25 +15,25 @@ Clicking the bookmark will then execute the JavaScript. ## "View in development" toggle -[`script/bookmarklets/view-in-development.js`](./view-in-development.js) +[`src/bookmarklets/view-in-development.js`](./view-in-development.js) When you're looking at a page on docs.github.com or a preview server at preview.ghdocs.com, clicking this bookmarklet will load the same path you're viewing but on your local server running at localhost:4000. ## "View in production" toggle -[`script/bookmarklets/view-in-production.js`](./view-in-production.js) +[`src/bookmarklets/view-in-production.js`](./view-in-production.js) When you're looking at a page on a preview server at preview.ghdocs.com or your local server running at localhost:4000, clicking this bookmarklet will load the same path you're viewing but on the live documentation site at docs.github.com. ## Open a docs article in VS Code -[`script/bookmarklets/open-in-vscode.js`](./open-in-vscode.js) +[`src/bookmarklets/open-in-vscode.js`](./open-in-vscode.js) When you're looking at a page on either docs.github.com, preview.ghdocs.com, or localhost:4000, clicking this bookmarklet will open the source Markdown file from your local checkout in VS Code. The installation requires a few steps: -1. Copy the contents of [`script/bookmarklets/open-in-vscode.js`](./open-in-vscode.js). +1. Copy the contents of [`src/bookmarklets/open-in-vscode.js`](./open-in-vscode.js). 1. Browse to https://chriszarate.github.io/bookmarkleter/ and paste the code into the box. 1. Find the path of **your local checkout** of the docs repo you want to open files from (for example, `/Users//repos/docs`). 1. Paste the path in place of where it says `REPLACE_ME` in line 1 (make sure to leave the single quotes around it). @@ -42,8 +42,8 @@ The installation requires a few steps: ## Add preview links to PRs -[`script/bookmarklets/add-pr-links.js`](./add-pr-links.js) +[`src/bookmarklets/add-pr-links.js`](./add-pr-links.js) This bookmarklet modifies the `Files changed` page of a GitHub pull request that has a current staging deployment. For each Markdown file in the diff view, it adds links to the preview deployment of the file for each version: `FPT / GHEC / GHES / AE`. (Some of these may redirect to another version or 404 if that version of the page doesn't exist.) -Note: readable JavaScript source lives in `script/bookmarklets/pr-link-source.js`. The bookmarklet code was generated via https://chriszarate.github.io/bookmarkleter. +Note: readable JavaScript source lives in `src/bookmarklets/pr-link-source.js`. The bookmarklet code was generated via https://chriszarate.github.io/bookmarkleter. diff --git a/script/bookmarklets/open-in-vscode.js b/src/bookmarklets/open-in-vscode.js similarity index 100% rename from script/bookmarklets/open-in-vscode.js rename to src/bookmarklets/open-in-vscode.js diff --git a/script/bookmarklets/view-in-development.js b/src/bookmarklets/view-in-development.js similarity index 100% rename from script/bookmarklets/view-in-development.js rename to src/bookmarklets/view-in-development.js diff --git a/script/bookmarklets/view-in-production.js b/src/bookmarklets/view-in-production.js similarity index 100% rename from script/bookmarklets/view-in-production.js rename to src/bookmarklets/view-in-production.js diff --git a/src/content-linter/scripts/disable-rules.js b/src/content-linter/scripts/disable-rules.js index bd54e74eb4f6..7c06105c19b8 100755 --- a/src/content-linter/scripts/disable-rules.js +++ b/src/content-linter/scripts/disable-rules.js @@ -5,7 +5,7 @@ // // Usage: // -// script/markdownlint-disable.js no-generic-link-text +// src/content-linter/scripts/disable-rules.js no-generic-link-text import fs from 'fs' import { spawn } from 'child_process' diff --git a/src/content-linter/scripts/lint-content.js b/src/content-linter/scripts/lint-content.js index 79876a09d2b0..f13f872ee892 100755 --- a/src/content-linter/scripts/lint-content.js +++ b/src/content-linter/scripts/lint-content.js @@ -9,7 +9,7 @@ import { applyFixes } from 'markdownlint-rule-helpers' import boxen from 'boxen' import ora from 'ora' -import walkFiles from '../../../script/helpers/walk-files.js' +import walkFiles from '#src/workflows/walk-files.js' import { allConfig, allRules, customRules } from '../lib/helpers/get-rules.js' import { customConfig, githubDocsFrontmatterConfig } from '../style/github-docs.js' import { defaultConfig } from '../lib/default-markdownlint-options.js' diff --git a/src/content-linter/scripts/post-lints.js b/src/content-linter/scripts/post-lints.js index a0d3dfbd9a4b..e534ece50d41 100644 --- a/src/content-linter/scripts/post-lints.js +++ b/src/content-linter/scripts/post-lints.js @@ -4,9 +4,9 @@ import { program } from 'commander' import fs from 'fs' import coreLib from '@actions/core' -import github from '../../../script/helpers/github.js' -import { getEnvInputs } from '../../../src/workflows/get-env-inputs.js' -import { createReportIssue, linkReports } from '../../../src/workflows/issue-report.js' +import github from '#src/workflows/github.js' +import { getEnvInputs } from '#src/workflows/get-env-inputs.js' +import { createReportIssue, linkReports } from '#src/workflows/issue-report.js' // [start-readme] // diff --git a/src/content-linter/tests/category-pages.js b/src/content-linter/tests/category-pages.js index ebc7e23c1ba8..e116e8132e65 100644 --- a/src/content-linter/tests/category-pages.js +++ b/src/content-linter/tests/category-pages.js @@ -223,7 +223,7 @@ describe('category pages', () => { indexShortTitle ? ` or shortTitle "${indexShortTitle}"` : ' (no shortTitle)' }` const newCategoryDirPath = path.join(path.dirname(categoryDirPath), expectedSlugs.at(-1)) - customMessage += `\nTo resolve this consider running:\n ./script/move-content.js ${categoryDirPath} ${newCategoryDirPath}\n` + customMessage += `\nTo resolve this consider running:\n ./src/content-render/scripts/move-content.js ${categoryDirPath} ${newCategoryDirPath}\n` // Check if the directory name matches the expected slug expect(expectedSlugs.includes(categoryDirName), customMessage).toBeTruthy() }) diff --git a/script/move-category-to-product.js b/src/content-render/scripts/move-category-to-product.js similarity index 93% rename from script/move-category-to-product.js rename to src/content-render/scripts/move-category-to-product.js index 88b901d0b100..ea4f323c44c3 100755 --- a/script/move-category-to-product.js +++ b/src/content-render/scripts/move-category-to-product.js @@ -11,9 +11,9 @@ import path from 'path' import { mkdirp } from 'mkdirp' import { program } from 'commander' import { execSync } from 'child_process' -import frontmatter from '../lib/read-frontmatter.js' -import addRedirectToFrontmatter from '../src/redirects/scripts/helpers/add-redirect-to-frontmatter.js' -import walkFiles from './helpers/walk-files.js' +import frontmatter from '../../../lib/read-frontmatter.js' +import addRedirectToFrontmatter from '#src/redirects/scripts/helpers/add-redirect-to-frontmatter.js' +import walkFiles from '#src/workflows/walk-files.js' const contentFiles = walkFiles('content', '.md') const contentDir = path.posix.join(process.cwd(), 'content') diff --git a/script/move-content.js b/src/content-render/scripts/move-content.js similarity index 97% rename from script/move-content.js rename to src/content-render/scripts/move-content.js index eba0620f7bdf..c4d31736d9e9 100755 --- a/script/move-content.js +++ b/src/content-render/scripts/move-content.js @@ -6,16 +6,16 @@ // // By default, the `move-content.js` script will commit the changes it makes. If you don't want the script to run any git commands for you, run it with the `--no-git` flag. Note: In most cases it will be easier and safer to let the script run the git commands for you, since git can get confused when a file is both renamed and edited. // -// To learn more about the script, you can run `script/move-content.js --help`. +// To learn more about the script, you can run `npm run move-content --help`. // // To run the script for a file: -// - `script/move-content.js PATH/TO/CURRENT-FILE.md PATH/TO/DESIRED-FILE-LOCATION-OR-NAME.md` +// - `npm run move-content PATH/TO/CURRENT-FILE.md PATH/TO/DESIRED-FILE-LOCATION-OR-NAME.md` // // To run the script for a folder: -// - `script/move-content.js PATH/TO/CURRENT-FOLDER PATH/TO/DESIRED-FOLDER-LOCATION-OR-NAME` +// - `npm run move-content PATH/TO/CURRENT-FOLDER PATH/TO/DESIRED-FOLDER-LOCATION-OR-NAME` // // To undo the script, run the same command that you used to run the script, but add an `--undo` flag: -// - `script/move-content.js --undo PATH/TO/OLD PATH/TO/NEW` +// - `npm run move-content --undo PATH/TO/OLD PATH/TO/NEW` // // [end-readme] @@ -28,8 +28,8 @@ import chalk from 'chalk' import walk from 'walk-sync' import yaml from 'js-yaml' -import fm from '../lib/frontmatter.js' -import readFrontmatter from '../lib/read-frontmatter.js' +import fm from '../../../lib/frontmatter.js' +import readFrontmatter from '../../../lib/read-frontmatter.js' const CONTENT_ROOT = path.resolve('content') const DATA_ROOT = path.resolve('data') diff --git a/script/reconcile-category-dirs-with-ids.js b/src/content-render/scripts/reconcile-category-dirs-with-ids.js similarity index 93% rename from script/reconcile-category-dirs-with-ids.js rename to src/content-render/scripts/reconcile-category-dirs-with-ids.js index c8b1fd140b3d..7c7b3b15b0e5 100755 --- a/script/reconcile-category-dirs-with-ids.js +++ b/src/content-render/scripts/reconcile-category-dirs-with-ids.js @@ -16,10 +16,10 @@ import chalk from 'chalk' import GithubSlugger from 'github-slugger' import { decode } from 'html-entities' -import frontmatter from '../lib/read-frontmatter.js' +import frontmatter from '../../../lib/read-frontmatter.js' import { renderContent } from '#src/content-render/index.js' import { allVersions } from '#src/versions/lib/all-versions.js' -import { ROOT } from '../lib/constants.js' +import { ROOT } from '../../../lib/constants.js' const slugger = new GithubSlugger() @@ -86,7 +86,9 @@ async function main() { console.log(chalk.dim('Run the following commands to rename them:')) for (const { oldRelativePath, newRelativePath } of shouldRename) { - console.log(`./script/move-content.js ${oldRelativePath} ${newRelativePath}`) + console.log( + `./src/content-render/scripts/move-content.js ${oldRelativePath} ${newRelativePath}`, + ) } } else { console.log(chalk.green('No categories need to be renamed! 🎉')) diff --git a/script/reconcile-filenames-with-ids.js b/src/content-render/scripts/reconcile-filenames-with-ids.js similarity index 94% rename from script/reconcile-filenames-with-ids.js rename to src/content-render/scripts/reconcile-filenames-with-ids.js index de5d695b706d..a5073e42d7ae 100755 --- a/script/reconcile-filenames-with-ids.js +++ b/src/content-render/scripts/reconcile-filenames-with-ids.js @@ -14,9 +14,9 @@ import path from 'path' import walk from 'walk-sync' import GithubSlugger from 'github-slugger' import { decode } from 'html-entities' -import frontmatter from '../lib/read-frontmatter.js' +import frontmatter from '../../../lib/read-frontmatter.js' import { execSync } from 'child_process' -import addRedirectToFrontmatter from '../src/redirects/scripts/helpers/add-redirect-to-frontmatter.js' +import addRedirectToFrontmatter from '#src/redirects/scripts/helpers/add-redirect-to-frontmatter.js' const slugger = new GithubSlugger() diff --git a/script/render-content-markdown.js b/src/content-render/scripts/render-content-markdown.js similarity index 97% rename from script/render-content-markdown.js rename to src/content-render/scripts/render-content-markdown.js index a2327fe97539..44a5dfb52443 100755 --- a/script/render-content-markdown.js +++ b/src/content-render/scripts/render-content-markdown.js @@ -6,7 +6,7 @@ import { execSync } from 'child_process' import { renderLiquid } from '#src/content-render/liquid/index.js' import shortVersionsMiddleware from '#src/versions/middleware/short-versions.js' -const { loadPages } = await import('../lib/page-data.js') +const { loadPages } = await import('../../../lib/page-data.js') const { allVersions } = await import('#src/versions/lib/all-versions.js') const contentCopilotDir = path.join(process.cwd(), 'content-copilot') diff --git a/src/dev-toc/README.md b/src/dev-toc/README.md new file mode 100644 index 000000000000..f0b42a3d83ad --- /dev/null +++ b/src/dev-toc/README.md @@ -0,0 +1,3 @@ +# Developer table of contents + +This directory generates a full table of contents for the docs.github.com site. diff --git a/script/dev-toc/generate.js b/src/dev-toc/generate.js similarity index 92% rename from script/dev-toc/generate.js rename to src/dev-toc/generate.js index 802321b9d784..4bc85ce5aae6 100755 --- a/script/dev-toc/generate.js +++ b/src/dev-toc/generate.js @@ -9,10 +9,10 @@ import { allVersionKeys } from '#src/versions/lib/all-versions.js' import { liquid } from '#src/content-render/index.js' import contextualize from '../../middleware/context.js' -const layoutFilename = path.posix.join(process.cwd(), 'script/dev-toc/layout.html') +const layoutFilename = path.posix.join(process.cwd(), 'src/dev-toc/layout.html') const layout = fs.readFileSync(layoutFilename, 'utf8') -const staticDirName = 'script/dev-toc/static' +const staticDirName = 'src/dev-toc/static' const staticDir = path.posix.join(process.cwd(), staticDirName) if (!fs.existsSync(staticDir)) fs.mkdirSync(staticDir) @@ -67,7 +67,7 @@ async function main() { // Add any defaultOpenSections to the context. req.context.defaultOpenSections = defaultOpenSections - // Parse the layout in script/dev-toc/layout.html with the context we created above. + // Parse the layout in src/dev-toc/layout.html with the context we created above. const outputHtml = await liquid.parseAndRender(layout, Object.assign({}, req.context)) // Write a static file for each version. diff --git a/script/dev-toc/index.js b/src/dev-toc/index.js similarity index 100% rename from script/dev-toc/index.js rename to src/dev-toc/index.js diff --git a/script/dev-toc/layout.html b/src/dev-toc/layout.html similarity index 100% rename from script/dev-toc/layout.html rename to src/dev-toc/layout.html diff --git a/src/early-access/scripts/create-branch b/src/early-access/scripts/create-branch index f2cc17b0b0b8..c984267aff5c 100755 --- a/src/early-access/scripts/create-branch +++ b/src/early-access/scripts/create-branch @@ -20,7 +20,7 @@ fi pushd .. > /dev/null if [ ! -d "docs-early-access" ]; then - echo "A 'docs-early-access' directory does not exist! Run script/early-access/clone-locally first." + echo "A 'docs-early-access' directory does not exist! Run src/early-access/scripts/clone-locally first." popd > /dev/null exit 0 fi diff --git a/src/early-access/scripts/migrate-early-access-product.js b/src/early-access/scripts/migrate-early-access-product.js index f1c847ab14eb..30a35e04debb 100755 --- a/src/early-access/scripts/migrate-early-access-product.js +++ b/src/early-access/scripts/migrate-early-access-product.js @@ -15,7 +15,7 @@ import { execFileSync } from 'child_process' import frontmatter from '../../../lib/read-frontmatter.js' import patterns from '../../../lib/patterns.js' import addRedirectToFrontmatter from '#src/redirects/scripts/helpers/add-redirect-to-frontmatter.js' -import walkFiles from '../../../script/helpers/walk-files.js' +import walkFiles from '#src/workflows/walk-files.js' const contentFiles = walkFiles('content', '.md', { includeEarlyAccess: true }) const contentDir = path.posix.join(process.cwd(), 'content') @@ -133,7 +133,7 @@ execFileSync('src/links/scripts/update-internal-links.js') console.log(` Done! Did the following: - Moved content/${oldPathId} files to content/${newPathId} -- Ran script/early-access/update-data-and-images-paths.js +- Ran ./src/early-access/scripts/update-data-and-images-paths.js - Added redirects to the moved files - Updated children frontmatter entries in index.md files - Ran ./src/links/scripts/update-internal-links.js diff --git a/src/early-access/scripts/update-data-and-image-paths.js b/src/early-access/scripts/update-data-and-image-paths.js index 6d9049cabfcb..9229fe063414 100755 --- a/src/early-access/scripts/update-data-and-image-paths.js +++ b/src/early-access/scripts/update-data-and-image-paths.js @@ -10,7 +10,7 @@ import fs from 'fs' import path from 'path' import { program } from 'commander' -import walkFiles from '../../../script/helpers/walk-files.js' +import walkFiles from '#src/workflows/walk-files.js' import { escapeRegExp } from 'lodash-es' import patterns from '../../../lib/patterns.js' diff --git a/src/ghes-releases/lib/release-steps.md b/src/ghes-releases/lib/release-steps.md index 9f2eb0eb42ab..9db1fc52e5ba 100644 --- a/src/ghes-releases/lib/release-steps.md +++ b/src/ghes-releases/lib/release-steps.md @@ -32,7 +32,7 @@ If you aren't comfortable going through the steps alone, sync up with a docs eng ``` src/ghes-releases/scripts/release-banner.js --action create --version - script/copy-fixture-data.js // This updates the fixtures to match the updated data/variables/release_candidate.yml file + src/tests/scripts/copy-fixture-data.js // This updates the fixtures to match the updated data/variables/release_candidate.yml file ``` - [ ] Create a PR with the above changes. This PR is used to track all docs changes and smoke tests associated with the release. For example https://github.com/github/docs-internal/pull/22286. @@ -74,7 +74,7 @@ This file should be automatically updated, but you can also run `src/ghes-releas - [ ] Add any required smoke tests to the opening post in the megabranch PR. Usually, we should smoke test any new GHES admin guides, any large features landing in this GHES version for the first time, and the REST and GraphQL API references. -- [ ] A few days before shipping, check for broken links. Run `script/check-english-links.js` in a local copy of the megabranch. +- [ ] A few days before shipping, check for broken links. Run `/src/links/scripts/rendered-content-link-checker-cli.js` in a local copy of the megabranch. - [ ] [Freeze the repos](https://github.com/github/docs-content/blob/main/docs-content-docs/docs-content-workflows/freezing.md) at least 1-2 days before the release, and post an announcement in Slack so everybody knows. It's helpful to freeze the repos before doing the OpenAPI merges to avoid changes to the megabranch while preparing and deploying. - [ ] Alert the Neon Squad (formally docs-ecosystem team) 1-2 days before the release to deploy to `github/github`. A PR should already be open in `github/github` to change the OpenAPI schema config `published` to `true` in `app/api/description/config/releases/ghes-.yaml`. They will need to: - [ ] Get the required approval from `@github/ecosystem-api-reviewers` then deploy the PR to dotcom. This process generally takes 30-90 minutes. diff --git a/script/helpers/get-liquid-conditionals.js b/src/ghes-releases/scripts/get-liquid-conditionals.js similarity index 100% rename from script/helpers/get-liquid-conditionals.js rename to src/ghes-releases/scripts/get-liquid-conditionals.js diff --git a/src/ghes-releases/scripts/remove-liquid-statements.js b/src/ghes-releases/scripts/remove-liquid-statements.js index 42803afde34f..8969302c7f5c 100644 --- a/src/ghes-releases/scripts/remove-liquid-statements.js +++ b/src/ghes-releases/scripts/remove-liquid-statements.js @@ -1,6 +1,6 @@ import { Tokenizer } from 'liquidjs' -import { getLiquidConditionalsWithContent } from '../../../script/helpers/get-liquid-conditionals.js' +import { getLiquidConditionalsWithContent } from './get-liquid-conditionals.js' import getVersionBlocks from './get-version-blocks.js' import { allVersions } from '#src/versions/lib/all-versions.js' import supportedOperators from '#src/content-render/liquid/ifversion-supported-operators.js' diff --git a/src/ghes-releases/scripts/remove-version-markup.js b/src/ghes-releases/scripts/remove-version-markup.js index 3bccb1c3f27f..0c7c859d9d17 100755 --- a/src/ghes-releases/scripts/remove-version-markup.js +++ b/src/ghes-releases/scripts/remove-version-markup.js @@ -14,7 +14,7 @@ import frontmatter from '../../../lib/read-frontmatter.js' import removeLiquidStatements from './remove-liquid-statements.js' import removeDeprecatedFrontmatter from './remove-deprecated-frontmatter.js' import { all, getNextReleaseNumber } from '#src/versions/lib/enterprise-server-releases.js' -import walkFiles from '../../../script/helpers/walk-files.js' +import walkFiles from '#src/workflows/walk-files.js' program .description( diff --git a/src/ghes-releases/scripts/update-enterprise-dates.js b/src/ghes-releases/scripts/update-enterprise-dates.js index d0f594a30e8e..a5d6575e188b 100755 --- a/src/ghes-releases/scripts/update-enterprise-dates.js +++ b/src/ghes-releases/scripts/update-enterprise-dates.js @@ -11,7 +11,7 @@ import { fileURLToPath } from 'url' import path from 'path' import fs from 'fs/promises' -import { getContents } from '../../../script/helpers/git-utils.js' +import { getContents } from '#src/workflows/git-utils.js' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const enterpriseDatesFile = path.join(__dirname, '../lib/enterprise-dates.json') diff --git a/src/github-apps/scripts/sync.js b/src/github-apps/scripts/sync.js index 306e7a414a6c..d735fc787068 100755 --- a/src/github-apps/scripts/sync.js +++ b/src/github-apps/scripts/sync.js @@ -7,7 +7,7 @@ import path from 'path' import { slug } from 'github-slugger' import yaml from 'js-yaml' -import { getContents } from '../../../script/helpers/git-utils.js' +import { getContents } from '#src/workflows/git-utils.js' import permissionSchema from './permission-list-schema.js' import enabledSchema from './enabled-list-schema.js' import { validateData } from '../../rest/scripts/utils/validate-data.js' diff --git a/src/graphql/scripts/sync.js b/src/graphql/scripts/sync.js index 55951a755eb3..c420e998baf4 100755 --- a/src/graphql/scripts/sync.js +++ b/src/graphql/scripts/sync.js @@ -4,7 +4,7 @@ import path from 'path' import { mkdirp } from 'mkdirp' import yaml from 'js-yaml' import { execSync } from 'child_process' -import { getContents, listMatchingRefs } from '../../../script/helpers/git-utils.js' +import { getContents, listMatchingRefs } from '#src/workflows/git-utils.js' import { allVersions } from '#src/versions/lib/all-versions.js' import processPreviews from './utils/process-previews.js' import processUpcomingChanges from './utils/process-upcoming-changes.js' diff --git a/src/languages/scripts/create-translation-health-report.js b/src/languages/scripts/create-translation-health-report.js index 9b0114eb9ff0..93617a0e2c18 100755 --- a/src/languages/scripts/create-translation-health-report.js +++ b/src/languages/scripts/create-translation-health-report.js @@ -61,7 +61,7 @@ console.warn = console.error = (...args) => { // Weird import syntax, but forces it to load after process.env... changes const { languageKeys } = await import('#src/languages/lib/languages.js') const { loadPages, loadPageMap } = await import('../../../lib/page-data.js') -const { precompileRedirects } = await import('../../../src/redirects/lib/precompile.js') +const { precompileRedirects } = await import('#src/redirects/lib/precompile.js') const { allVersions, allVersionKeys } = await import('#src/versions/lib/all-versions.js') const { getProductStringFromPath } = await import('../../../lib/path-utils.js') diff --git a/src/languages/scripts/purge-fastly-edge-cache-per-language.js b/src/languages/scripts/purge-fastly-edge-cache-per-language.js index ab9a84894c94..22ff005dd090 100755 --- a/src/languages/scripts/purge-fastly-edge-cache-per-language.js +++ b/src/languages/scripts/purge-fastly-edge-cache-per-language.js @@ -3,7 +3,7 @@ import { languageKeys } from '#src/languages/lib/languages.js' import { makeLanguageSurrogateKey } from '../../../middleware/set-fastly-surrogate-key.js' -import purgeEdgeCache from '../../../script/deployment/purge-edge-cache.js' +import purgeEdgeCache from '#src/workflows/purge-edge-cache.js' /** * In simple terms, this script sends purge commands for... diff --git a/src/links/lib/excluded-links.js b/src/links/lib/excluded-links.js index cc321ea086f2..0b8edc85f33d 100644 --- a/src/links/lib/excluded-links.js +++ b/src/links/lib/excluded-links.js @@ -1,6 +1,6 @@ /** * This file exports a mix of strings and of regexes. Linkinator relies - * on this in `script/check-english-links.js` when we encounter external + * on this in `src/links/scripts/rendered-content-link-checker-cli.js` when we encounter external * links that we *specifically ignore*. That means, that URLs or patterns * mentioned in this file might appear within our content but we don't * bother checking that they actually work. diff --git a/script/helpers/action-injections.js b/src/links/scripts/action-injections.js similarity index 97% rename from script/helpers/action-injections.js rename to src/links/scripts/action-injections.js index 6c48235b436e..c4837de49dcd 100644 --- a/script/helpers/action-injections.js +++ b/src/links/scripts/action-injections.js @@ -7,7 +7,7 @@ import fs from 'fs' import path from 'path' import chalk from 'chalk' -import github from './github.js' +import github from '#src/workflows/github.js' // Directs core logging to console export function getCoreInject(debug) { diff --git a/script/check-github-github-links.js b/src/links/scripts/check-github-github-links.js similarity index 98% rename from script/check-github-github-links.js rename to src/links/scripts/check-github-github-links.js index 6c59379f13a5..fe4d1629b2b7 100755 --- a/script/check-github-github-links.js +++ b/src/links/scripts/check-github-github-links.js @@ -17,7 +17,7 @@ import fs from 'fs/promises' import got, { RequestError } from 'got' import { program } from 'commander' -import { getContents, getPathsWithMatchingStrings } from './helpers/git-utils.js' +import { getContents, getPathsWithMatchingStrings } from '#src/workflows/git-utils.js' if (!process.env.GITHUB_TOKEN) { throw new Error('Error! You must have a GITHUB_TOKEN set in an .env file to run this script.') diff --git a/src/links/scripts/rendered-content-link-checker-cli.js b/src/links/scripts/rendered-content-link-checker-cli.js index e8bc68a0e04a..a98c331f7dc9 100755 --- a/src/links/scripts/rendered-content-link-checker-cli.js +++ b/src/links/scripts/rendered-content-link-checker-cli.js @@ -11,12 +11,9 @@ import fs from 'fs' import path from 'path' import { program, Option, InvalidArgumentError } from 'commander' import renderedContentLinkChecker from '#src/links/scripts/rendered-content-link-checker.js' -import { - getCoreInject, - getUploadArtifactInject, -} from '../../../script/helpers/action-injections.js' +import { getCoreInject, getUploadArtifactInject } from '#src/links/scripts/action-injections.js' import { allVersions } from '#src/versions/lib/all-versions.js' -import github from '../../../script/helpers/github.js' +import github from '#src/workflows/github.js' const STATIC_PREFIXES = { assets: path.resolve('assets'), diff --git a/src/links/scripts/rendered-content-link-checker.js b/src/links/scripts/rendered-content-link-checker.js index 61d807e36fea..23465ab13ddc 100755 --- a/src/links/scripts/rendered-content-link-checker.js +++ b/src/links/scripts/rendered-content-link-checker.js @@ -17,13 +17,13 @@ import warmServer from '../../../lib/warm-server.js' import { liquid } from '#src/content-render/index.js' import { deprecated } from '#src/versions/lib/enterprise-server-releases.js' import excludedLinks from '#src/links/lib/excluded-links.js' -import { getEnvInputs, boolEnvVar } from '../../../src/workflows/get-env-inputs.js' +import { getEnvInputs, boolEnvVar } from '#src/workflows/get-env-inputs.js' import { debugTimeEnd, debugTimeStart } from './debug-time-taken.js' import { uploadArtifact as uploadArtifactLib } from './upload-artifact.js' -import github from '../../../script/helpers/github.js' -import { getActionContext } from '../../../src/workflows/action-context.js' +import github from '#src/workflows/github.js' +import { getActionContext } from '#src/workflows/action-context.js' import { createMinimalProcessor } from '#src/content-render/unified/processor.js' -import { createReportIssue, linkReports } from '../../../src/workflows/issue-report.js' +import { createReportIssue, linkReports } from '#src/workflows/issue-report.js' const STATIC_PREFIXES = { assets: path.resolve('assets'), diff --git a/src/links/scripts/update-internal-links.js b/src/links/scripts/update-internal-links.js index 89b569b88fb5..ba821fa329b3 100755 --- a/src/links/scripts/update-internal-links.js +++ b/src/links/scripts/update-internal-links.js @@ -18,7 +18,7 @@ import yaml from 'js-yaml' 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' +import walkFiles from '#src/workflows/walk-files.js' program .description('Update internal links in content files') diff --git a/src/rest/scripts/test-open-api-schema.js b/src/rest/scripts/test-open-api-schema.js index afadcc186f65..ebce23abf2cd 100755 --- a/src/rest/scripts/test-open-api-schema.js +++ b/src/rest/scripts/test-open-api-schema.js @@ -15,7 +15,7 @@ import { allVersions, getDocsVersion } from '#src/versions/lib/all-versions.js' import { REST_DATA_DIR, REST_SCHEMA_FILENAME } from '../lib/index.js' import { nonAutomatedRestPaths } from '../lib/config.js' import { deprecated } from '#src/versions/lib/enterprise-server-releases.js' -import walkFiles from '../../../script/helpers/walk-files.js' +import walkFiles from '#src/workflows/walk-files.js' export async function getDiffOpenAPIContentRest() { const contentFiles = getAutomatedMarkdownFiles('content/rest') diff --git a/src/search/README.md b/src/search/README.md index 2dfabacc71cc..cbf80db5b148 100644 --- a/src/search/README.md +++ b/src/search/README.md @@ -85,7 +85,7 @@ Why do we need this? For our daily shipping needs, it's tolerable that search up - [components/lib/search.ts](components/lib/search.ts) - The browser-side code that enables search. - [lib/search/client.js](lib/search/client.js) - A thin wrapper around the Node.js module for interacting with the search API. - [lib/search/search-index.js](lib/search/search-index.js) - A class for generating structured search data from repository content and syncing it. This class has built-in validation to ensure that all records are valid before they're uploaded. This class also takes care of removing deprecated records, and compares existing remote records with the latest local records to avoid uploading records that haven't changed. -- [script/sync-search-indices.js](script/sync-search-indices.js) - The script used by the Actions workflow to update search indices. This can also be [run in the development environment](#development). +- [src/search/scripts/sync-search-indices.js](src/search/scripts/sync-search-indices.js) - The script used by the Actions workflow to update search indices. This can also be [run in the development environment](#development). - [tests/content/search.js](tests/content/search.js) - Tests! ## Indices diff --git a/src/search/scripts/build-records.js b/src/search/scripts/build-records.js index 227d2ade32f2..2ca121517f6d 100644 --- a/src/search/scripts/build-records.js +++ b/src/search/scripts/build-records.js @@ -8,7 +8,7 @@ import { HTTPError } from 'got' import parsePageSectionsIntoRecords from './parse-page-sections-into-records.js' import getPopularPages from './popular-pages.js' import languages from '#src/languages/lib/languages.js' -import domwaiter from '../../../script/domwaiter.js' +import domwaiter from './domwaiter.js' const pageMarker = chalk.green('|') const recordMarker = chalk.grey('.') diff --git a/script/domwaiter.js b/src/search/scripts/domwaiter.js similarity index 100% rename from script/domwaiter.js rename to src/search/scripts/domwaiter.js diff --git a/src/search/scripts/index-elasticsearch.js b/src/search/scripts/index-elasticsearch.js index 64a0432c00a4..292f2a090bac 100755 --- a/src/search/scripts/index-elasticsearch.js +++ b/src/search/scripts/index-elasticsearch.js @@ -15,7 +15,7 @@ import { program, Option, InvalidArgumentError } from 'commander' import chalk from 'chalk' import dotenv from 'dotenv' -import { retryOnErrorTest } from '../../../script/helpers/retry-on-error-test.js' +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' diff --git a/script/helpers/retry-on-error-test.js b/src/search/scripts/retry-on-error-test.js similarity index 100% rename from script/helpers/retry-on-error-test.js rename to src/search/scripts/retry-on-error-test.js diff --git a/src/tests/README.md b/src/tests/README.md new file mode 100644 index 000000000000..74b28deac8d2 --- /dev/null +++ b/src/tests/README.md @@ -0,0 +1,5 @@ +# Tests + +This directory contains utilities to support our automated testing efforts. + +**This directory should not include test suites.** Please use the best subject folder available. diff --git a/script/copy-fixture-data.js b/src/tests/scripts/copy-fixture-data.js similarity index 100% rename from script/copy-fixture-data.js rename to src/tests/scripts/copy-fixture-data.js diff --git a/script/copy-to-test-repo.sh b/src/tests/scripts/copy-to-test-repo.sh similarity index 100% rename from script/copy-to-test-repo.sh rename to src/tests/scripts/copy-to-test-repo.sh diff --git a/script/kill-server-for-jest.js b/src/tests/scripts/kill-server-for-jest.js similarity index 100% rename from script/kill-server-for-jest.js rename to src/tests/scripts/kill-server-for-jest.js diff --git a/script/server-for-jest.js b/src/tests/scripts/server-for-jest.js similarity index 100% rename from script/server-for-jest.js rename to src/tests/scripts/server-for-jest.js diff --git a/script/start-server-for-jest.js b/src/tests/scripts/start-server-for-jest.js similarity index 95% rename from script/start-server-for-jest.js rename to src/tests/scripts/start-server-for-jest.js index 921184ee6ebc..96b7b39deb00 100755 --- a/script/start-server-for-jest.js +++ b/src/tests/scripts/start-server-for-jest.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { main } from '../start-server.js' +import { main } from '../../../start-server.js' import { PORT, START_JEST_SERVER, isServerHealthy, isPortRunning } from './server-for-jest.js' diff --git a/src/versions/scripts/create-enterprise-issue.js b/src/versions/scripts/create-enterprise-issue.js index fcf45ef4963f..72dad571d1e3 100755 --- a/src/versions/scripts/create-enterprise-issue.js +++ b/src/versions/scripts/create-enterprise-issue.js @@ -38,7 +38,7 @@ async function run() { const milestone = process.argv[2] if (!acceptedMilestones.includes(milestone)) { console.log("Please specify either 'release' or 'deprecation'\n") - console.log('Example: script/open-enterprise-issue.js release') + console.log('Example: src/versions/scripts/create-enterprise-issue.js release') process.exit(1) } diff --git a/src/workflows/README.md b/src/workflows/README.md index 1ec35abbec91..7a870fcd7303 100644 --- a/src/workflows/README.md +++ b/src/workflows/README.md @@ -1,3 +1,5 @@ # Workflows This directory contains workflow scripts that cannot otherwise be in other subject folders. + +This directory does not contain a `scripts/` folder, as every file in here would belong in `scripts/`. diff --git a/script/cmp-files.js b/src/workflows/cmp-files.js similarity index 100% rename from script/cmp-files.js rename to src/workflows/cmp-files.js diff --git a/script/content-changes-table-comment.js b/src/workflows/content-changes-table-comment-1.js similarity index 93% rename from script/content-changes-table-comment.js rename to src/workflows/content-changes-table-comment-1.js index 7171c2da312f..4b976e47a0ca 100755 --- a/script/content-changes-table-comment.js +++ b/src/workflows/content-changes-table-comment-1.js @@ -18,7 +18,7 @@ // // export GITHUB_TOKEN=github_pat_11AAAG..... // export APP_URL=https://docs.github.com -// ./script/content-changes-table-comment.js github docs-internal main 4a0b0f2 +// ./src/workflows/content-changes-table-comment.js github docs-internal main 4a0b0f2 // // [end-readme] diff --git a/src/workflows/content-changes-table-comment.js b/src/workflows/content-changes-table-comment.js index faba75ca4d87..9079306d5346 100755 --- a/src/workflows/content-changes-table-comment.js +++ b/src/workflows/content-changes-table-comment.js @@ -3,7 +3,7 @@ import * as github from '@actions/github' import core from '@actions/core' -import { getContents } from '../../script/helpers/git-utils.js' +import { getContents } from './git-utils.js' import parse from '../../lib/read-frontmatter.js' import getApplicableVersions from '#src/versions/lib/get-applicable-versions.js' import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js' diff --git a/src/workflows/find-past-built-pr.js b/src/workflows/find-past-built-pr.js index af0c7d1b6d65..8c3d3e7dcac1 100755 --- a/src/workflows/find-past-built-pr.js +++ b/src/workflows/find-past-built-pr.js @@ -3,7 +3,7 @@ import got from 'got' import { setOutput } from '@actions/core' -import github from '../../script/helpers/github.js' +import github from './github.js' import { getActionContext } from './action-context.js' async function main() { diff --git a/script/helpers/git-utils.js b/src/workflows/git-utils.js similarity index 100% rename from script/helpers/git-utils.js rename to src/workflows/git-utils.js diff --git a/script/helpers/github.js b/src/workflows/github.js similarity index 100% rename from script/helpers/github.js rename to src/workflows/github.js diff --git a/script/prevent-pushes-to-main.js b/src/workflows/prevent-pushes-to-main.js similarity index 100% rename from script/prevent-pushes-to-main.js rename to src/workflows/prevent-pushes-to-main.js diff --git a/script/deployment/purge-edge-cache.js b/src/workflows/purge-edge-cache.js similarity index 100% rename from script/deployment/purge-edge-cache.js rename to src/workflows/purge-edge-cache.js diff --git a/src/workflows/purge-fastly-edge-cache.js b/src/workflows/purge-fastly-edge-cache.js index 0c6a5f3931d7..2f9639e20360 100755 --- a/src/workflows/purge-fastly-edge-cache.js +++ b/src/workflows/purge-fastly-edge-cache.js @@ -1,6 +1,6 @@ #!/usr/bin/env node import { SURROGATE_ENUMS } from '../../middleware/set-fastly-surrogate-key.js' -import purgeEdgeCache from '../../script/deployment/purge-edge-cache.js' +import purgeEdgeCache from './purge-edge-cache.js' // This will purge every response that *contains* // `process.env.FASTLY_SURROGATE_KEY || SURROGATE_ENUMS.DEFAULT`. diff --git a/script/helpers/walk-files.js b/src/workflows/walk-files.js similarity index 100% rename from script/helpers/walk-files.js rename to src/workflows/walk-files.js diff --git a/tests/README.md b/tests/README.md index bc40ea7de352..1d76f54eceeb 100644 --- a/tests/README.md +++ b/tests/README.md @@ -26,7 +26,7 @@ Once you've followed the development instructions above, you can run the entire test suite locally: ```shell -script/test # or `npm test` +npm test ``` ### Watching all the tests diff --git a/tests/fixtures/README.md b/tests/fixtures/README.md index bbea36157669..2872ee7d7161 100644 --- a/tests/fixtures/README.md +++ b/tests/fixtures/README.md @@ -73,7 +73,7 @@ There's a script you can always run that makes sure all and any of these files are up to do: ```shell -./script/copy-fixture-data.js +./src/tests/scripts/copy-fixture-data.js ``` It's safe to run any time. And it might be necessary to run so that diff --git a/tests/routing/redirects.js b/tests/routing/redirects.js index 8fd5228e3eba..0486f3cc097d 100644 --- a/tests/routing/redirects.js +++ b/tests/routing/redirects.js @@ -8,7 +8,7 @@ import enterpriseServerReleases, { } from '#src/versions/lib/enterprise-server-releases.js' import Page from '../../lib/page.js' import { get, head } from '../helpers/e2etest.js' -import versionSatisfiesRange from '../../src/versions/lib/version-satisfies-range.js' +import versionSatisfiesRange from '#src/versions/lib/version-satisfies-range.js' const __dirname = path.dirname(fileURLToPath(import.meta.url)) diff --git a/tests/unit/pages.js b/tests/unit/pages.js index bde20820b235..e9123fd741cf 100644 --- a/tests/unit/pages.js +++ b/tests/unit/pages.js @@ -103,7 +103,7 @@ describe('pages module', () => { nonMatches.length === 1 ? 'file' : 'files' } that do not match their slugified titles.\n ${nonMatches.join('\n')}\n - To fix, run script/reconcile-filenames-with-ids.js\n\n` + To fix, run src/content-render/scripts/reconcile-filenames-with-ids.js\n\n` expect(nonMatches.length, message).toBe(0) })