Import from the src directory in Node using `#src` (#37578)

This commit is contained in:
Kevin Heis 2023-06-05 14:44:20 -07:00 коммит произвёл GitHub
Родитель 0e8cd6f8f4
Коммит ac38ab609e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
27 изменённых файлов: 98 добавлений и 96 удалений

Просмотреть файл

@ -2,7 +2,7 @@ import cx from 'classnames'
import { useMainContext } from 'components/context/MainContext'
import { SidebarProduct } from 'src/landings/components/SidebarProduct'
import { SidebarHomepage } from '../../src/landings/components/SidebarHomepage'
import { SidebarHomepage } from 'src/landings/components/SidebarHomepage'
import { AllProductsLink } from './AllProductsLink'
import { ApiVersionPicker } from 'src/rest/components/ApiVersionPicker'
import { Link } from 'components/Link'

Просмотреть файл

@ -15,7 +15,7 @@ import { productMap } from './all-products.js'
import slash from 'slash'
import readFileContents from './read-file-contents.js'
import getLinkData from './get-link-data.js'
import getDocumentType from '../src/events/lib/get-document-type.js'
import getDocumentType from '#src/events/lib/get-document-type.js'
import { union } from 'lodash-es'
import { allTools } from './all-tools.js'
import { renderContentWithFallback } from './render-with-fallback.js'

Просмотреть файл

@ -1,4 +1,4 @@
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
import { loadUnversionedTree, loadSiteTree, loadPages, loadPageMap } from './page-data.js'
import loadRedirects from './redirects/precompile.js'

Просмотреть файл

@ -1,4 +1,4 @@
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
export default function abort(req, res, next) {
// If the client aborts the connection, send an error

Просмотреть файл

@ -1,11 +1,11 @@
import express from 'express'
import { createProxyMiddleware } from 'http-proxy-middleware'
import events from '../../src/events/middleware.js'
import anchorRedirect from '../../src/rest/api/anchor-redirect.js'
import search from '../../src/search/middleware/search.js'
import pageInfo from '../../src/pageinfo/middleware.js'
import webhooks from '../../src/webhooks/middleware/webhooks.js'
import events from '#src/events/middleware.js'
import anchorRedirect from '#src/rest/api/anchor-redirect.js'
import search from '#src/search/middleware/search.js'
import pageInfo from '#src/pageinfo/middleware.js'
import webhooks from '#src/webhooks/middleware/webhooks.js'
const router = express.Router()

Просмотреть файл

@ -1,6 +1,6 @@
import path from 'path'
import slash from 'slash'
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
import {
firstVersionDeprecatedOnNewSite,
lastVersionWithoutArchivedRedirectsFile,

Просмотреть файл

@ -3,7 +3,7 @@ import fs from 'fs'
import crypto from 'crypto'
import got from 'got'
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
// The only reason this is exported is for the sake of the unit tests'
// ability to test in-memory miss after purging this with a mutation

Просмотреть файл

@ -3,20 +3,20 @@ import path from 'path'
import express from 'express'
import instrument from '../src/observability/lib/instrument-middleware.js'
import instrument from '#src/observability/lib/instrument-middleware.js'
import haltOnDroppedConnection from './halt-on-dropped-connection.js'
import abort from './abort.js'
import timeout from './timeout.js'
import morgan from 'morgan'
import datadog from '../src/observability/middleware/connect-datadog.js'
import datadog from '#src/observability/middleware/connect-datadog.js'
import helmet from './helmet.js'
import cookieParser from './cookie-parser.js'
import {
setDefaultFastlySurrogateKey,
setLanguageFastlySurrogateKey,
} from './set-fastly-surrogate-key.js'
import handleErrors from '../src/observability/middleware/handle-errors.js'
import handleInvalidPaths from '../src/observability/middleware/handle-invalid-paths.js'
import handleErrors from '#src/observability/middleware/handle-errors.js'
import handleInvalidPaths from '#src/observability/middleware/handle-invalid-paths.js'
import handleNextDataPath from './handle-next-data-path.js'
import detectLanguage from './detect-language.js'
import reloadTree from './reload-tree.js'
@ -37,7 +37,7 @@ import archivedEnterpriseVersions from './archived-enterprise-versions.js'
import robots from './robots.js'
import earlyAccessLinks from './contextualizers/early-access-links.js'
import categoriesForSupport from './categories-for-support.js'
import triggerError from '../src/observability/middleware/trigger-error.js'
import triggerError from '#src/observability/middleware/trigger-error.js'
import secretScanning from './contextualizers/secret-scanning.js'
import ghesReleaseNotes from './contextualizers/ghes-release-notes.js'
import ghaeReleaseNotes from './contextualizers/ghae-release-notes.js'
@ -51,7 +51,7 @@ import features from './contextualizers/features.js'
import productExamples from './contextualizers/product-examples.js'
import productGroups from './contextualizers/product-groups.js'
import homepageLinks from './contextualizers/homepage-links.js'
import featuredLinks from '../src/landings/middleware/featured-links.js'
import featuredLinks from '#src/landings/middleware/featured-links.js'
import learningTrack from './learning-track.js'
import next from './next.js'
import renderPage from './render-page.js'
@ -65,9 +65,9 @@ import trailingSlashes from './trailing-slashes.js'
import fastlyBehavior from './fastly-behavior.js'
import mockVaPortal from './mock-va-portal.js'
import dynamicAssets from './dynamic-assets.js'
import contextualizeSearch from '../src/search/middleware/contextualize.js'
import contextualizeSearch from '#src/search/middleware/contextualize.js'
import rateLimit from './rate-limit.js'
import handleInvalidQuerystrings from '../src/observability/middleware/handle-invalid-query-strings.js'
import handleInvalidQuerystrings from '#src/observability/middleware/handle-invalid-query-strings.js'
const { DEPLOYMENT_ENV, NODE_ENV } = process.env
const isTest = NODE_ENV === 'test' || process.env.GITHUB_ACTIONS === 'true'

Просмотреть файл

@ -1,6 +1,6 @@
import rateLimit from 'express-rate-limit'
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
import { noCacheControl } from './cache-control.js'
const EXPIRES_IN_AS_SECONDS = 60

Просмотреть файл

@ -1,10 +1,10 @@
import { get } from 'lodash-es'
import FailBot from '../src/observability/lib/failbot.js'
import FailBot from '#src/observability/lib/failbot.js'
import patterns from '../lib/patterns.js'
import getMiniTocItems from '../lib/get-mini-toc-items.js'
import Page from '../lib/page.js'
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
import { allVersions } from '../lib/all-versions.js'
import { isConnectionDropped } from './halt-on-dropped-connection.js'
import { nextApp, nextHandleRequest } from './next.js'

Просмотреть файл

@ -1,6 +1,6 @@
import timeout from 'express-timeout-handler'
import statsd from '../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
import { MAX_REQUEST_TIMEOUT } from '../lib/constants.js'
export default timeout.handler({

Просмотреть файл

@ -1,13 +1,58 @@
{
"name": "docs.github.com",
"private": true,
"repository": "https://github.com/github/docs",
"license": "(MIT AND CC-BY-4.0)",
"author": {
"email": "opensource+docs@github.com",
"name": "GitHub",
"email": "opensource+docs@github.com",
"url": "https://github.com/github/docs"
},
"cacheDirectories": [
"node_modules",
".next/cache"
],
"type": "module",
"imports": {
"#src/*": {
"default": "./src/*"
}
},
"exports": "./server.js",
"scripts": {
"build": "next build",
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect server.js",
"dev": "cross-env npm start",
"fixture-dev": "cross-env ROOT=tests/fixtures npm start",
"fixture-test": "cross-env ROOT=tests/fixtures npm test -- tests/rendering-fixtures",
"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",
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
"lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules jest src/content-linter/tests/lint-files.js",
"openapi-docs": "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",
"rest-dev": "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",
"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",
"sync-rest": "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",
"sync-search-indices": "src/search/scripts/sync-search-indices.js",
"sync-search-server": "cross-env NODE_ENV=production PORT=4002 MINIMAL_RENDER=true CHANGELOG_DISABLED=true node 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-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage",
"translation-check": "start-server-and-test translation-check-server 4002 translation-check-test",
"translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.js",
"translation-check-test": "script/i18n/test-html-pages.js",
"tsc": "tsc --noEmit"
},
"lint-staged": {
"*.{js,mjs,ts,tsx}": "eslint --cache --fix",
"*.{js,mjs,scss,ts,tsx,yml,yaml}": "prettier --write"
},
"dependencies": {
"@elastic/elasticsearch": "7.11.0",
"@github/failbot": "0.8.3",
@ -168,55 +213,15 @@
"unist-util-visit-parents": "5.1.3",
"website-scraper": "^5.3.1"
},
"engines": {
"node": "^16 || ^18"
},
"exports": "./server.js",
"license": "(MIT AND CC-BY-4.0)",
"name": "docs.github.com",
"optionalDependencies": {
"esm": "^3.2.25",
"website-scraper": "^5.3.1"
},
"private": true,
"repository": "https://github.com/github/docs",
"scripts": {
"build": "next build",
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect server.js",
"dev": "cross-env npm start",
"fixture-dev": "cross-env ROOT=tests/fixtures npm start",
"fixture-test": "cross-env ROOT=tests/fixtures npm test -- tests/rendering-fixtures",
"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",
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
"lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules jest src/content-linter/tests/lint-files.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",
"rest-dev": "src/rest/scripts/update-files.js",
"openapi-docs": "src/rest/docs.js",
"sync-rest": "src/rest/scripts/update-files.js",
"sync-webhooks": "src/rest/scripts/update-files.js -o webhooks",
"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",
"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",
"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",
"sync-search-indices": "src/search/scripts/sync-search-indices.js",
"sync-search-server": "cross-env NODE_ENV=production PORT=4002 MINIMAL_RENDER=true CHANGELOG_DISABLED=true node server.js",
"translation-check": "start-server-and-test translation-check-server 4002 translation-check-test",
"translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.js",
"translation-check-test": "script/i18n/test-html-pages.js",
"test": "cross-env NODE_OPTIONS='--max_old_space_size=4096 --experimental-vm-modules' jest --logHeapUsage",
"test-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage",
"tsc": "tsc --noEmit"
"engines": {
"node": "^16 || ^18"
},
"lint-staged": {
"*.{js,mjs,ts,tsx}": "eslint --cache --fix",
"*.{js,mjs,scss,ts,tsx,yml,yaml}": "prettier --write"
},
"type": "module"
"cacheDirectories": [
"node_modules",
".next/cache"
]
}

Просмотреть файл

@ -1 +1 @@
export { default, getServerSideProps } from '../../../../src/graphql/pages/breaking-changes'
export { default, getServerSideProps } from 'src/graphql/pages/breaking-changes'

Просмотреть файл

@ -1 +1 @@
export { default, getServerSideProps } from '../../../../src/graphql/pages/changelog'
export { default, getServerSideProps } from 'src/graphql/pages/changelog'

Просмотреть файл

@ -1 +1 @@
export { default, getServerSideProps } from '../../../../src/graphql/pages/explorer'
export { default, getServerSideProps } from 'src/graphql/pages/explorer'

Просмотреть файл

@ -1 +1 @@
export { default, getServerSideProps } from '../../../../src/graphql/pages/schema-previews'
export { default, getServerSideProps } from 'src/graphql/pages/schema-previews'

Просмотреть файл

@ -1 +1 @@
export { default, getServerSideProps } from '../../../../src/graphql/pages/reference'
export { default, getServerSideProps } from 'src/graphql/pages/reference'

Просмотреть файл

@ -1,4 +1 @@
export {
default,
getServerSideProps,
} from '../../../../src/webhooks/pages/webhook-events-and-payloads'
export { default, getServerSideProps } from 'src/webhooks/pages/webhook-events-and-payloads'

Просмотреть файл

@ -1 +1 @@
export { default, getServerSideProps } from '../src/search/pages/search'
export { default, getServerSideProps } from 'src/search/pages/search'

Просмотреть файл

@ -2,8 +2,8 @@ import { createHmac } from 'crypto'
import { Agent } from 'node:https'
import got from 'got'
import { isNil } from 'lodash-es'
import statsd from '../../../src/observability/lib/statsd.js'
import { report } from '../../../src/observability/lib/failbot.js'
import statsd from '#src/observability/lib/statsd.js'
import { report } from '#src/observability/lib/failbot.js'
import { MAX_REQUEST_TIMEOUT } from '../../../lib/constants.js'
const TIME_OUT_TEXT = 'ms has passed since batch creation'

Просмотреть файл

@ -3,7 +3,7 @@ import { omit, without, mapValues } from 'lodash-es'
import Ajv from 'ajv'
import addFormats from 'ajv-formats'
import { schemas, hydroNames } from './lib/schema.js'
import catchMiddlewareError from '../../src/observability/middleware/catch-middleware-error.js'
import catchMiddlewareError from '#src/observability/middleware/catch-middleware-error.js'
import { noCacheControl } from '../../middleware/cache-control.js'
import { formatErrors } from './lib/middleware-errors.js'
import { publish as _publish } from './lib/hydro.js'

Просмотреть файл

@ -1,8 +1,8 @@
import express from 'express'
import statsd from '../../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
import { defaultCacheControl } from '../../middleware/cache-control.js'
import catchMiddlewareError from '../../src/observability/middleware/catch-middleware-error.js'
import catchMiddlewareError from '#src/observability/middleware/catch-middleware-error.js'
import {
SURROGATE_ENUMS,
setFastlySurrogateKey,

Просмотреть файл

@ -1,9 +1,9 @@
import express from 'express'
import FailBot from '../../../src/observability/lib/failbot.js'
import statsd from '../../../src/observability/lib/statsd.js'
import FailBot from '#src/observability/lib/failbot.js'
import statsd from '#src/observability/lib/statsd.js'
import { searchCacheControl } from '../../../middleware/cache-control.js'
import catchMiddlewareError from '../../../src/observability/middleware/catch-middleware-error.js'
import catchMiddlewareError from '#src/observability/middleware/catch-middleware-error.js'
import { setFastlySurrogateKey } from '../../../middleware/set-fastly-surrogate-key.js'
import { getSearchResults } from './es-search.js'
import { getSearchFromRequest } from './get-search-request.js'

Просмотреть файл

@ -18,7 +18,7 @@ import dotenv from 'dotenv'
import { retryOnErrorTest } from '../../../script/helpers/retry-on-error-test.js'
import { languageKeys } from '../../../lib/languages.js'
import { allVersions } from '../../../lib/all-versions.js'
import statsd from '../../../src/observability/lib/statsd.js'
import statsd from '#src/observability/lib/statsd.js'
// Now you can optionally have set the ELASTICSEARCH_URL in your .env file.
dotenv.config()

Просмотреть файл

@ -5,7 +5,7 @@ import languages from '../../../lib/languages.js'
import buildRecords from './build-records.js'
import findIndexablePages from './find-indexable-pages.js'
import { allVersions } from '../../../lib/all-versions.js'
import { namePrefix } from '../../../src/search/lib/config.js'
import { namePrefix } from '#src/search/lib/config.js'
import { writeIndexRecords } from './search-index-records.js'
// Build a search data file for every combination of product version and language

Просмотреть файл

@ -1,6 +1,6 @@
import dotenv from 'dotenv'
import './lib/check-node-version.js'
import './src/observability/lib/handle-exceptions.js'
import '#src/observability/lib/handle-exceptions.js'
import portUsed from 'port-used'
import createApp from './lib/app.js'
import warmServer from './lib/warm-server.js'

Просмотреть файл

@ -4,7 +4,7 @@ import { get } from '../helpers/e2etest.js'
import {
MAX_UNFAMILIAR_KEYS_BAD_REQUEST,
MAX_UNFAMILIAR_KEYS_REDIRECT,
} from '../../src/observability/middleware/handle-invalid-query-strings.js'
} from '#src/observability/middleware/handle-invalid-query-strings.js'
const alpha = Array.from(Array(26)).map((e, i) => i + 65)
const alphabet = alpha.map((x) => String.fromCharCode(x))