From 694d38ea2911b654dffd472b40bd8fa2b4d741a0 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Mon, 13 Nov 2023 09:07:52 -0800 Subject: [PATCH] Move server.js and start-server.js to src/frame (#45767) --- .../workflows/check-broken-links-github-github.yml | 2 +- Dockerfile | 4 +--- package.json | 12 ++++++------ server.js => src/frame/server.js | 0 start-server.js => src/frame/start-server.js | 0 src/tests/scripts/start-server-for-jest.js | 2 +- tests/README.md | 2 +- .../rendering-fixtures/playwright-rendering.spec.ts | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) rename server.js => src/frame/server.js (100%) rename start-server.js => src/frame/start-server.js (100%) diff --git a/.github/workflows/check-broken-links-github-github.yml b/.github/workflows/check-broken-links-github-github.yml index 86a027826bcf..9841aa68ab80 100644 --- a/.github/workflows/check-broken-links-github-github.yml +++ b/.github/workflows/check-broken-links-github-github.yml @@ -60,7 +60,7 @@ jobs: ENABLED_LANGUAGES: en run: | - node server.js & + node src/frame/server.js & sleep 5 curl --retry-connrefused --retry 3 -I http://localhost:4000/ diff --git a/Dockerfile b/Dockerfile index 60889fdfd307..44903905f8ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,12 +91,10 @@ COPY --chown=node:node src ./src COPY --chown=node:node .remotejson-cache* ./.remotejson-cache COPY --chown=node:node data ./data COPY --chown=node:node next.config.js ./ -COPY --chown=node:node server.js ./server.js -COPY --chown=node:node start-server.js ./start-server.js EXPOSE $PORT -CMD ["node", "server.js"] +CMD ["node", "src/frame/server.js"] # -------------------------------------------------------------------------------- # PRODUCTION IMAGE - includes all translations diff --git a/package.json b/package.json index ae077de57dad..e912ed2f3dde 100644 --- a/package.json +++ b/package.json @@ -14,10 +14,10 @@ "default": "./src/*" } }, - "exports": "./server.js", + "exports": "./src/frame/server.js", "scripts": { "build": "next build", - "debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect server.js", + "debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES=en nodemon --inspect src/frame/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", @@ -35,14 +35,14 @@ "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 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", + "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=tests/fixtures TRANSLATIONS_FIXTURE_ROOT=tests/fixtures/translations ENABLED_LANGUAGES=en,ja NODE_ENV=test node src/frame/server.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", "sync-search-indices": "node 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-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-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage", diff --git a/server.js b/src/frame/server.js similarity index 100% rename from server.js rename to src/frame/server.js diff --git a/start-server.js b/src/frame/start-server.js similarity index 100% rename from start-server.js rename to src/frame/start-server.js diff --git a/src/tests/scripts/start-server-for-jest.js b/src/tests/scripts/start-server-for-jest.js index 96b7b39deb00..5619dc704313 100755 --- a/src/tests/scripts/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 '#src/frame/start-server.js' import { PORT, START_JEST_SERVER, isServerHealthy, isPortRunning } from './server-for-jest.js' diff --git a/tests/README.md b/tests/README.md index 1d76f54eceeb..30bc8f839879 100644 --- a/tests/README.md +++ b/tests/README.md @@ -84,7 +84,7 @@ since the server won't need to start and stop every time you run tests. In one terminal, type: ```shell -NODE_ENV=test PORT=4000 node server.js +NODE_ENV=test PORT=4000 node src/frame/server.js ``` In another terminal, type: diff --git a/tests/rendering-fixtures/playwright-rendering.spec.ts b/tests/rendering-fixtures/playwright-rendering.spec.ts index ab04304d1d1f..f5653f7c8255 100644 --- a/tests/rendering-fixtures/playwright-rendering.spec.ts +++ b/tests/rendering-fixtures/playwright-rendering.spec.ts @@ -5,7 +5,7 @@ import { test, expect } from '@playwright/test' // In GitHub Actions, we rely on setting the environment variable directly // but for convenience, for local development, engineers might have a // .env file that can set environment variable. E.g. ELASTICSEARCH_URL. -// The `start-server.js` script uses dotenv too, but since Playwright +// The `src/frame/start-server.js` script uses dotenv too, but since Playwright // tests only interface with the server via HTTP, we too need to find // this out. dotenv.config()