Skip to content

Commit

Permalink
Move files out of script/ (#45454)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Bengtsson <[email protected]>
  • Loading branch information
heiskr and peterbe authored Nov 2, 2023
1 parent 3ecf408 commit 748d1e3
Show file tree
Hide file tree
Showing 86 changed files with 121 additions and 111 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/warmup-remotejson-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-broken-links-github-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/triage-unallowed-contributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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/**',
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-asset-images.yml
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +30,7 @@ lib/redirects/.redirects-cache*.json
user-code/

# Logs from scripts
script/logs/
*/logs/
external-link-checker-db.json

# Playwright related
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data/release-notes/
script/bookmarklets/
src/bookmarklets/
src/open-source/scripts/add-pr-links.js
/.next/

Expand Down
2 changes: 1 addition & 1 deletion content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 %}
Expand Down
2 changes: 1 addition & 1 deletion contributing/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions contributing/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions contributing/working-in-docs-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
2 changes: 1 addition & 1 deletion middleware/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/assets/scripts/deleted-assets-pr-comment-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion src/assets/scripts/find-orphaned-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion src/audit-logs/scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
12 changes: 6 additions & 6 deletions script/bookmarklets/README.md → src/bookmarklets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<USERNAME>/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).
Expand All @@ -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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/content-linter/scripts/disable-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/content-linter/scripts/lint-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions src/content-linter/scripts/post-lints.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
//
Expand Down
2 changes: 1 addition & 1 deletion src/content-linter/tests/category-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
Loading

0 comments on commit 748d1e3

Please sign in to comment.