diff --git a/.github/workflows/check-broken-links-github-github.yml b/.github/workflows/check-broken-links-github-github.yml index a21a6628eb..e0fe49d49f 100644 --- a/.github/workflows/check-broken-links-github-github.yml +++ b/.github/workflows/check-broken-links-github-github.yml @@ -52,7 +52,7 @@ jobs: - name: Run broken github/github link check run: | - src/links/scripts/check-github-github-links.js broken_github_github_links.md + npm run check-github-github-links -- 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/lint-entire-content-data-markdown.yml b/.github/workflows/lint-entire-content-data-markdown.yml index cae494e077..22f6a049b1 100644 --- a/.github/workflows/lint-entire-content-data-markdown.yml +++ b/.github/workflows/lint-entire-content-data-markdown.yml @@ -41,7 +41,7 @@ jobs: REPORT_AUTHOR: docs-bot REPORT_LABEL: broken content markdown report REPORT_REPOSITORY: github/docs-content - run: node src/content-linter/scripts/post-lints.js --path /tmp/error-lints.json + run: npm run post-lints -- --path /tmp/error-lints.json - uses: ./.github/actions/slack-alert if: ${{ failure() && github.event_name != 'workflow_dispatch' }} diff --git a/.github/workflows/move-content.yml b/.github/workflows/move-content.yml index b5c0d1cc46..12ddbaef4d 100644 --- a/.github/workflows/move-content.yml +++ b/.github/workflows/move-content.yml @@ -40,7 +40,7 @@ jobs: src/fixtures/fixtures/content/get-started/quickstart/hello-world.md \ src/fixtures/fixtures/content/get-started/quickstart/hello-wurld.md - node src/content-render/scripts/test-moved-content.js \ + npm run test-moved-content -- \ src/fixtures/fixtures/content/get-started/quickstart/hello-world.md \ src/fixtures/fixtures/content/get-started/quickstart/hello-wurld.md @@ -55,7 +55,7 @@ jobs: src/fixtures/fixtures/content/code-security/getting-started \ src/fixtures/fixtures/content/code-security/got-started - node src/content-render/scripts/test-moved-content.js \ + npm run test-moved-content -- \ src/fixtures/fixtures/content/code-security/getting-started \ src/fixtures/fixtures/content/code-security/got-started diff --git a/.github/workflows/orphaned-assets-check.yml b/.github/workflows/orphaned-assets-check.yml index 24c7d61a4e..fd218d2ffd 100644 --- a/.github/workflows/orphaned-assets-check.yml +++ b/.github/workflows/orphaned-assets-check.yml @@ -41,7 +41,7 @@ jobs: run: | set -e - filesToRemove=`./src/assets/scripts/find-orphaned-assets.js` + filesToRemove=`npm run find-orphaned-assets` [ -z "$filesToRemove" ] && exit 0 echo $filesToRemove | xargs git rm @@ -64,7 +64,7 @@ jobs: gh pr create \ --title "Delete orphaned assets ($date)" \ - --body "Found with the find-orphaned-assets.js script.\n\nFor more info see https://github.com/github/docs-engineering/blob/main/docs/orphaned-assets.md" \ + --body "Found with the 'npm run find-orphaned-assets' script.\n\nFor more info see https://github.com/github/docs-engineering/blob/main/docs/orphaned-assets.md" \ --repo github/docs-internal \ --label docs-content-fr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 190a17055f..dba0c07c7d 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 == 'fixtures' }} - run: ./src/tests/scripts/copy-fixture-data.js --check + run: npm run copy-fixture-data -- --check # This keeps our fixture content/data in check - name: Check the test fixture content (if applicable) @@ -114,11 +114,11 @@ jobs: run: | # If either of these fail, it means our fixture content's internal # links can and should be updated. - ./src/links/scripts/update-internal-links.js --dry-run --check --strict \ + npm run update-internal-links -- --dry-run --check --strict \ src/fixtures/fixtures/content \ --exclude src/fixtures/fixtures/content/get-started/foo/typo-autotitling.md \ --exclude src/fixtures/fixtures/content/get-started/foo/anchor-autotitling.md - ./src/links/scripts/update-internal-links.js --dry-run --check --strict \ + npm run update-internal-links -- --dry-run --check --strict \ src/fixtures/fixtures/data - name: Clone all translations diff --git a/.github/workflows/translation-health-report.yml b/.github/workflows/translation-health-report.yml index 9dcd11974b..216df2c39e 100644 --- a/.github/workflows/translation-health-report.yml +++ b/.github/workflows/translation-health-report.yml @@ -85,7 +85,7 @@ jobs: env: POPULAR_PAGES_JSON: popular-pages/records/popular-pages.json run: | - node src/languages/scripts/create-translation-health-report.js \ + npm run create-translation-health-report -- \ --language ${{ matrix.language }} \ --gitref ${{ env.gitref }} \ >> $GITHUB_WORKSPACE/translation-health-report.json diff --git a/package.json b/package.json index b7822dddf0..58c1fa0a79 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,15 @@ }, "exports": "./src/frame/server.js", "scripts": { + "analyze-text": "node src/search/scripts/analyze-text.js", + "archive-version": "node src/ghes-releases/scripts/archive-version.js", "build": "next build", + "check-github-github-links": "node src/links/scripts/check-github-github-links.js", + "copy-fixture-data": "node src/tests/scripts/copy-fixture-data.js", + "create-translation-health-report": "node src/languages/scripts/create-translation-health-report.js", "debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect src/frame/server.js", "dev": "cross-env npm start", + "find-orphaned-assets": "node src/assets/scripts/find-orphaned-assets.js", "fixture-dev": "cross-env ROOT=src/fixtures/fixtures npm start", "fixture-test": "cross-env ROOT=src/fixtures/fixtures npm test -- src/fixtures/tests", "index-test-fixtures": "node src/search/scripts/index-elasticsearch.js -l en -l ja -V ghae -V dotcom --index-prefix tests -- src/search/tests/fixtures/search-indexes", @@ -28,16 +34,21 @@ "move-content": "node src/content-render/scripts/move-content.js", "openapi-docs": "node src/rest/docs.js", "playwright-test": "playwright test --config src/fixtures/playwright.config.ts --project=\"Google Chrome\"", + "post-lints": "node src/content-linter/scripts/post-lints.js", "postinstall": "cp package-lock.json .installed.package-lock.json && echo \"Updated .installed.package-lock.json\" # see husky/post-checkout and husky/post-merge", "prepare": "husky install src/workflows/husky", "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 src/workflows/prevent-pushes-to-main.js", + "release-banner": "node src/ghes-releases/scripts/release-banner.js", + "remove-version-markup": "node src/ghes-releases/scripts/remove-version-markup.js", + "rendered-content-link-checker-cli": "node src/links/scripts/rendered-content-link-checker-cli.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-", "start": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon src/frame/server.js", "start-all-languages": "cross-env NODE_ENV=development nodemon src/frame/server.js", "start-for-playwright": "cross-env ROOT=src/fixtures/fixtures TRANSLATIONS_FIXTURE_ROOT=src/fixtures/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test node src/frame/server.js", + "symlink-from-local-repo": "node src/early-access/scripts/symlink-from-local-repo.js", "sync-rest": "node src/rest/scripts/update-files.js", "sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices", "sync-search-ghes-release": "cross-env GHES_RELEASE=1 start-server-and-test sync-search-server 4002 sync-search-indices", @@ -45,8 +56,14 @@ "sync-search-server": "cross-env NODE_ENV=production PORT=4002 MINIMAL_RENDER=true CHANGELOG_DISABLED=true node src/frame/server.js", "sync-webhooks": "src/rest/scripts/update-files.js -o webhooks", "test": "cross-env NODE_OPTIONS='--max_old_space_size=4096 --experimental-vm-modules' jest --logHeapUsage", + "test-moved-content": "node src/content-render/scripts/test-moved-content.js", "test-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage", - "tsc": "tsc --noEmit" + "toggle-ghae-feature-flags": "node src/versions/scripts/toggle-ghae-feature-flags.js", + "tsc": "tsc --noEmit", + "update-data-and-image-paths": "node src/early-access/scripts/update-data-and-image-paths.js", + "update-internal-links": "node src/links/scripts/update-internal-links.js", + "validate-asset-images": "node src/assets/scripts/validate-asset-images.js", + "warmup-remotejson": "node src/archives/scripts/warmup-remotejson.js" }, "lint-staged": { "*.{js,mjs,ts,tsx}": "eslint --cache --fix", diff --git a/src/early-access/scripts/clone-locally b/src/early-access/scripts/clone-locally index 93443c3575..ac6d135c15 100755 --- a/src/early-access/scripts/clone-locally +++ b/src/early-access/scripts/clone-locally @@ -24,6 +24,6 @@ git clone https://github.com/github/docs-early-access.git popd > /dev/null # Symlink the local docs-early-access repo into this repo -node src/early-access/scripts/symlink-from-local-repo.js -p ../docs-early-access +npm run symlink-from-local-repo -- -p ../docs-early-access echo -e '\nDone!' diff --git a/src/ghes-releases/lib/deprecation-steps.md b/src/ghes-releases/lib/deprecation-steps.md index 11c715645c..23c110f93d 100644 --- a/src/ghes-releases/lib/deprecation-steps.md +++ b/src/ghes-releases/lib/deprecation-steps.md @@ -60,7 +60,7 @@ The dates we use for Enterprise releases and deprecations are stored in [release 1. Do a dry run by scraping a small amount of files to test locally on your machine. This command does not overwrite the references to asset files so they will render on your machine. ```shell - node --max-old-space-size=8192 src/ghes-releases/scripts/archive-version.js --dry-run --local-dev + npm run archive-version -- --dry-run --local-dev ``` 1. Navigate to the scraped files directory (`tmpArchivalDir_`) inside your docs-internal checkout. Open a few HTML files and ensure they render and drop-down pickers work correctly. @@ -68,7 +68,7 @@ The dates we use for Enterprise releases and deprecations are stored in [release 1. If the dry-run looks good, scrape all content files. This will take about 20-30 minutes. **Note:** This will overwrite the directory that was previously generated with new files. You can also create a specific output directory using the `--output` flag. ```shell - node --max-old-space-size=8192 src/ghes-releases/scripts/archive-version.js + npm run archive-version ``` 1. Revert changes to `src/search/components/Search.tsx`. @@ -90,7 +90,7 @@ The dates we use for Enterprise releases and deprecations are stored in [release 1. Click `Containers` in the left sidebar, then click the `enterprise` container. 1. Click `Upload` in the top bar. Drag and drop or click `Browse for files` to select the directory inside of `tmpArchivalDir_`. For example, at the time of this writing, the directory name was `3.5`. The upload will take several minutes and the UI may not give feedback immediately. Don't close the browser tab or navigate away from the page until the upload is complete. - + App method: 1. Open the Microsoft Azure Storage Explorer app from the `Overview` tab [githubdocs Azure Storage Blob resource page](https://portal.azure.com/#@githubazure.onmicrosoft.com/resource/subscriptions/fa6134a7-f27e-4972-8e9f-0cedffa328f1/resourceGroups/docs-production/providers/Microsoft.Storage/storageAccounts/githubdocs/overview). @@ -144,7 +144,7 @@ This step will remove the version from the drop-down picker, effectively depreca 1. Manually delete the deprecated directory in `data/graphql`. For example, if you are deprecating the 3.5 release, you'd delete the `data/graphql/ghes-3.5` directory. -1. Open a new PR. Reviewers will be automatically assigned. +1. Open a new PR. Reviewers will be automatically assigned. 1. When the PR is approved, merge it in. 🚢 @@ -157,7 +157,7 @@ This step will remove the version from the drop-down picker, effectively depreca 1. Remove the outdated Liquid markup and frontmatter. ```shell - src/ghes-releases/scripts/remove-version-markup.js --release + npm run remove-version-markup -- --release ``` 1. If data resuables were deleted automatically, you'll need to remove references to the deleted reusable in the content. Using VSCode to find the occurrences is quick and there are typically only a few to update. If you have any questions, reach out to the docs-content team in #docs-content to ask for help updating the Markdown files. @@ -178,7 +178,7 @@ This step will remove the version from the drop-down picker, effectively depreca ## Re-scraping a page or all pages -Occasionally, a change will need to be added to our archived enterprise versions. If this occurs, you can check out the `enterprise--release` branch and re-scrape the page or all pages using `src/ghes-releases/scripts/archive-version.js`. To scrape a single page you can use the `—page ` option. +Occasionally, a change will need to be added to our archived enterprise versions. If this occurs, you can check out the `enterprise--release` branch and re-scrape the page or all pages using `npm run archive-version`. To scrape a single page you can use the `—page ` option. For each language, upload the new file to Azure blob storage in the `enterprise` container. diff --git a/src/ghes-releases/lib/release-steps.md b/src/ghes-releases/lib/release-steps.md index 3e4fff9344..be32404b5e 100644 --- a/src/ghes-releases/lib/release-steps.md +++ b/src/ghes-releases/lib/release-steps.md @@ -31,7 +31,7 @@ If you aren't comfortable going through the steps alone, sync up with a docs eng - [ ] If this is a release candidate release, add a Release Candidate banner: ``` - src/ghes-releases/scripts/release-banner.js --action create --version + npm run release-banner -- --action create --version ``` - [ ] 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. @@ -73,7 +73,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 `/src/links/scripts/rendered-content-link-checker-cli.js` in a local copy of the megabranch. +- [ ] A few days before shipping, check for broken links. Run `npm run rendered-content-link-checker-cli` 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/src/ghes-releases/scripts/remove-liquid-statements.js b/src/ghes-releases/scripts/remove-liquid-statements.js index 8969302c7f..328b189146 100644 --- a/src/ghes-releases/scripts/remove-liquid-statements.js +++ b/src/ghes-releases/scripts/remove-liquid-statements.js @@ -17,7 +17,7 @@ const tokenize = (str) => { return tokenizer.readTopLevelTokens() } // This module is used by -// src/ghes-releases/scripts/remove-version-markup.js to remove +// `npm run remove-version-markup` to remove // and update Liquid conditionals when a GHES release is being deprecated. It is also used by // src/ghes-releases/tests/remove-liquid-statements.js. export default function removeLiquidStatements(content, release, nextOldestRelease, file) { diff --git a/src/languages/scripts/create-translation-health-report.js b/src/languages/scripts/create-translation-health-report.js index 4a5cb6c9aa..74847991c6 100755 --- a/src/languages/scripts/create-translation-health-report.js +++ b/src/languages/scripts/create-translation-health-report.js @@ -8,7 +8,7 @@ /* Nota bene: If you are getting more errors all the sudden, try running this: - $ src/languages/scripts/create-translation-health-report.js -l en -r 000 + $ npm run create-translation-health-report -- -l en -r 000 If there's any errors before getting the JSON output, const context = { ... } probably needs more data. */ diff --git a/src/search/scripts/analyze-text.js b/src/search/scripts/analyze-text.js index 6e545739ae..17e6e0e122 100755 --- a/src/search/scripts/analyze-text.js +++ b/src/search/scripts/analyze-text.js @@ -8,7 +8,7 @@ // // Example: // -// ./src/search/scripts/analyze-text.js my words to tokenize +// npm run analyze-text "my words" to tokenize // // [end-readme]