From b0734a8d835f7463d58572af277a579d7ed58184 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Tue, 5 Sep 2023 14:01:14 -0600 Subject: [PATCH 001/310] set engine to node 18 and set compatibility flags --- .github/workflows/build-and-test.yml | 4 ++-- .github/workflows/build-test-deploy.yml | 4 ++-- Dockerfile | 5 +++-- client/package-lock.json | 23 +++++++++++++++-------- client/package.json | 14 +++++++------- server/package-lock.json | 4 ++-- server/package.json | 16 ++++++++-------- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fb5e8be124..ef9144a165 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -43,10 +43,10 @@ jobs: name: Define SHORT_SHA with commit short sha run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - - name: Setup Node14.x + name: Setup Node18.x uses: actions/setup-node@v3 with: - node-version: '14.x' + node-version: '18.16.x' - name: Install npm 8 run: npm i -g npm@8.0.0 --registry=https://registry.npmjs.org diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index 2eb89a97d8..e1e71961fd 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -51,10 +51,10 @@ jobs: name: Define RC_TAG run: echo "RC_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Setup Node14.x + name: Setup Node18.x uses: actions/setup-node@v3 with: - node-version: '14.x' + node-version: '18.16.x' - name: Install npm 8 run: npm i -g npm@8.0.0 --registry=https://registry.npmjs.org diff --git a/Dockerfile b/Dockerfile index 1a56483220..d91c921d1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,10 @@ -FROM node:14-alpine +FROM node:18-alpine ENV NODE_OPTIONS=--max-old-space-size=8192 # Install build dependancies. -RUN apk --no-cache add git python3 +RUN apk --no-cache --update add g++ make git python3 \ + && rm -rf /var/cache/apk/* RUN npm install -g npm@8.0.0 diff --git a/client/package-lock.json b/client/package-lock.json index 7e84d62ee4..209f7b8e52 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -113,7 +113,7 @@ "@babel/preset-typescript": "^7.10.1", "@babel/runtime-corejs3": "^7.10.3", "@coralproject/npm-run-all": "^4.1.5", - "@coralproject/rte": "^2.2.2", + "@coralproject/rte": "^2.2.4", "@fluent/react": "^0.12.0", "@giphy/js-fetch-api": "^4.1.2", "@giphy/react-components": "^5.4.0", @@ -352,8 +352,8 @@ "whatwg-fetch": "^3.4.0" }, "engines": { - "node": "^14.18", - "npm": "^8.0.0" + "node": "^18.16.0", + "npm": "8.0.0" } }, "../common/dist": {}, @@ -2633,16 +2633,21 @@ } }, "node_modules/@coralproject/rte": { - "version": "2.2.2", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@coralproject/rte/-/rte-2.2.4.tgz", + "integrity": "sha512-neIIoH6BarMZPzLGqVW4CkzD1t+CZrhvcQWjwMIW/Jv9txwSL7jCL/dMRysvXX+yXB7IJ5Pot57VI0SVQxFUEg==", "dev": true, - "license": "Apache-2.0", "dependencies": { "classnames": "^2.2.6", "squire-rte": "1.11.0" }, + "engines": { + "node": "^18.16.0", + "npm": "^8.0.0" + }, "peerDependencies": { - "react": "^16.0.0", - "react-dom": "^16.0.0" + "react": "^18.2.0", + "react-dom": "^18.2.0" } }, "node_modules/@csstools/convert-colors": { @@ -51218,7 +51223,9 @@ } }, "@coralproject/rte": { - "version": "2.2.2", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@coralproject/rte/-/rte-2.2.4.tgz", + "integrity": "sha512-neIIoH6BarMZPzLGqVW4CkzD1t+CZrhvcQWjwMIW/Jv9txwSL7jCL/dMRysvXX+yXB7IJ5Pot57VI0SVQxFUEg==", "dev": true, "requires": { "classnames": "^2.2.6", diff --git a/client/package.json b/client/package.json index 8603f37f1f..b5e544b393 100644 --- a/client/package.json +++ b/client/package.json @@ -12,8 +12,8 @@ "url": "git://github.com/coralproject/talk.git" }, "engines": { - "node": "^14.18", - "npm": "^8.0.0" + "node": "^18.16.0", + "npm": "8.0.0" }, "bugs": "https://github.com/coralproject/talk/issues", "contributors": [ @@ -21,10 +21,10 @@ ], "description": "A better commenting experience from Vox Media.", "scripts": { - "build:client": "ts-node --transpile-only ./scripts/build.ts", - "build:development": "NODE_ENV=development npm-run-all generate --parallel build:client", + "build:client": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" ts-node --transpile-only ./scripts/build.ts", + "build:development": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development npm-run-all generate --parallel build:client", "build:withProfiler": "NODE_ENV=production REACT_PROFILER=true npm-run-all generate --parallel build:client", - "build": "NODE_ENV=production npm-run-all generate-persist --parallel build:client", + "build": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=production npm-run-all generate-persist --parallel build:client", "docs:css-variables": "ts-node ./scripts/generateCSSVariablesDocs.ts ./src/core/client/ui/theme/streamVariables.ts ./CSS_VARIABLES.md", "docs:events": "ts-node ./scripts/generateEventDocs.ts ./src/core/client/stream/events.ts ./CLIENT_EVENTS.md", "doctoc": "doctoc --maxlevel=3 --title '## Table of Contents' CLIENT_EVENTS.md ../CONTRIBUTING.md", @@ -54,7 +54,7 @@ "tscheck:client": "tsc --project ./src/core/client/tsconfig.json --noEmit", "tscheck:scripts": "tsc --project ./tsconfig.json --noEmit", "tscheck": "npm-run-all --parallel tscheck:*", - "watch": "NODE_ENV=development ts-node --transpile-only ./scripts/watcher/bin/watcher.ts --config ./config/watcher.ts" + "watch": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development ts-node --transpile-only ./scripts/watcher/bin/watcher.ts --config ./config/watcher.ts" }, "license": "Apache-2.0", "dependencies": { @@ -162,7 +162,7 @@ "@babel/preset-typescript": "^7.10.1", "@babel/runtime-corejs3": "^7.10.3", "@coralproject/npm-run-all": "^4.1.5", - "@coralproject/rte": "^2.2.2", + "@coralproject/rte": "^2.2.4", "@fluent/react": "^0.12.0", "@giphy/js-fetch-api": "^4.1.2", "@giphy/react-components": "^5.4.0", diff --git a/server/package-lock.json b/server/package-lock.json index edf78558fa..fb1e91ec77 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -350,8 +350,8 @@ "whatwg-fetch": "^3.4.0" }, "engines": { - "node": "^14.18", - "npm": "^8.0.0" + "node": "^18.16.0", + "npm": "8.0.0" } }, "../common/dist": {}, diff --git a/server/package.json b/server/package.json index 367951ea5f..4deacf5899 100644 --- a/server/package.json +++ b/server/package.json @@ -12,8 +12,8 @@ "url": "git://github.com/coralproject/talk.git" }, "engines": { - "node": "^14.18", - "npm": "^8.0.0" + "node": "^18.16.0", + "npm": "8.0.0" }, "bugs": "https://github.com/coralproject/talk/issues", "contributors": [ @@ -21,10 +21,10 @@ ], "description": "A better commenting experience from Vox Media.", "scripts": { - "build:development": "NODE_ENV=development npm-run-all generate --parallel build:server", + "build:development": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development npm-run-all generate --parallel build:server", "build:server": "gulp server", "build:withProfiler": "NODE_ENV=production REACT_PROFILER=true npm-run-all generate --parallel build:server", - "build": "NODE_ENV=production npm-run-all generate-persist --parallel build:server", + "build": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=production npm-run-all generate-persist --parallel build:server", "clean": "gulp clean", "doctoc": "doctoc --maxlevel=3 --title '## Table of Contents' WEBHOOKS.md EXTERNAL_MODERATION_PHASES.md", "generate-persist": "npm-run-all generate:schema", @@ -39,16 +39,16 @@ "lint:server": "eslint 'src/**/*.{js,ts,tsx}'", "lint": "npm-run-all lint:* tscheck:*", "migration:create": "ts-node --transpile-only ./scripts/migration/create.ts", - "start:development": "NODE_ENV=development TS_NODE_PROJECT=./src/tsconfig.json DISABLE_JOB_PROCESSORS=true ts-node-dev --inspect --transpile-only --no-notify -r tsconfig-paths/register --ignore-watch ./docs/ ./src/index.ts", - "start:development:withJobs": "NODE_ENV=development TS_NODE_PROJECT=./src/tsconfig.json ts-node-dev --inspect --transpile-only --no-notify -r tsconfig-paths/register --ignore-watch ./docs/ ./src/index.ts", - "start": "NODE_ENV=production node dist/index.js", + "start:development": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development TS_NODE_PROJECT=./src/tsconfig.json DISABLE_JOB_PROCESSORS=true ts-node-dev --inspect --transpile-only --no-notify -r tsconfig-paths/register --ignore-watch ./docs/ ./src/index.ts", + "start:development:withJobs": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development TS_NODE_PROJECT=./src/tsconfig.json ts-node-dev --inspect --transpile-only --no-notify -r tsconfig-paths/register --ignore-watch ./docs/ ./src/index.ts", + "start": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=production node dist/index.js", "test": "node --trace-warnings scripts/test.js --watch", "test:server": "node --trace-warnings scripts/testServer.js", "test:cache": "node --trace-warnings scripts/test.cache.js --env=jsdom", "tscheck:scripts": "tsc --project ./tsconfig.json --noEmit", "tscheck:server": "tsc --project ./src/tsconfig.json --noEmit", "tscheck": "npm-run-all --parallel tscheck:*", - "watch": "NODE_ENV=development ts-node --transpile-only ./scripts/watcher/bin/watcher.ts --config ./config/watcher.ts" + "watch": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development ts-node --transpile-only ./scripts/watcher/bin/watcher.ts --config ./config/watcher.ts" }, "license": "Apache-2.0", "dependencies": { From 2601d1fe515a038ab8fafcdedcace91610366074 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Thu, 14 Sep 2023 12:21:46 -0600 Subject: [PATCH 002/310] make npm run watch work with node 18 --- client/config/webpackDevServer.config.ts | 7 ++++--- client/scripts/start.ts | 20 +++++++++---------- client/src/core/client/embed/amp.html | 2 +- client/src/core/client/embed/index.html | 8 ++++---- client/src/core/client/embed/story.html | 6 +++--- client/src/core/client/embed/storyAMP.html | 2 +- client/src/core/client/embed/storyButton.html | 4 ++-- server/package.json | 2 +- .../core/server/app/helpers/manifestLoader.ts | 2 +- 9 files changed, 26 insertions(+), 27 deletions(-) diff --git a/client/config/webpackDevServer.config.ts b/client/config/webpackDevServer.config.ts index dff9ea177a..58dc2d92d4 100644 --- a/client/config/webpackDevServer.config.ts +++ b/client/config/webpackDevServer.config.ts @@ -69,7 +69,7 @@ export default function ({ publicPath, // WebpackDevServer is noisy by default so we emit custom message instead // by listening to the compiler events with `compiler.plugin` calls above. - quiet: true, + quiet: false, // Reportedly, this avoids CPU overload on some systems. // https://github.com/facebookincubator/create-react-app/issues/293 // src/node_modules is not ignored to support absolute imports @@ -82,7 +82,8 @@ export default function ({ disableDotRule: true, rewrites: [], }, - public: allowedHost, + allowedHosts: ["127.0.0.1:8080", "127.0.0.1:3000"], + public: "127.0.0.1:8080", index: "embed.html", sockPort: devPort, proxy: [ @@ -105,7 +106,7 @@ export default function ({ "/graphiql", ].some((p) => p === lc || lc.startsWith(`${p}/`)); }, - target: `http://localhost:${serverPort}`, + target: `127.0.0.1:${serverPort}`, onError: (err, req, res) => { res.writeHead(500, { "Content-Type": "text/html", diff --git a/client/scripts/start.ts b/client/scripts/start.ts index 26656a4678..348b4dc2bb 100644 --- a/client/scripts/start.ts +++ b/client/scripts/start.ts @@ -1,19 +1,18 @@ #!/usr/bin/env ts-node -import dotenv from "dotenv"; - -// Apply all the configuration provided in the .env file if it isn't already in -// the environment. -dotenv.config(); - import chalk from "chalk"; +import dotenv from "dotenv"; import webpack from "webpack"; import WebpackDevServer from "webpack-dev-server"; -import { createCompiler, prepareUrls } from "./WebpackDevServerUtils"; import createDevServerConfig from "../config/webpackDevServer.config"; import config from "../src/core/build/config"; import createWebpackConfig from "../src/core/build/createWebpackConfig"; +import { createCompiler, prepareUrls } from "./WebpackDevServerUtils"; + +// Apply all the configuration provided in the .env file if it isn't already in +// the environment. +dotenv.config(); /* eslint-disable no-console */ @@ -32,6 +31,7 @@ process.on("unhandledRejection", (err) => { }); const PORT = config.get("dev_port"); +const SERVER_PORT = 3000; const HOST = "0.0.0.0"; if (process.env.HOST) { @@ -78,7 +78,7 @@ const compiler = createCompiler({ // Serve webpack assets generated by the compiler over a web sever. const serverConfig = createDevServerConfig({ allowedHost: urls.lanUrlForConfig, - serverPort: config.get("port"), + serverPort: SERVER_PORT, devPort: PORT, publicPath: webpackConfig[0].output!.publicPath!, }); @@ -94,9 +94,7 @@ devServer.listen(PORT, HOST, (err: Error) => { return console.log(err); } console.log(chalk.cyan("Starting the development server...\n")); - console.log( - chalk.yellow(`devPort: ${PORT}, serverPort: ${serverConfig.port}`) - ); + console.log(chalk.yellow(`devPort: ${PORT}, serverPort: ${SERVER_PORT}`)); }); ["SIGINT", "SIGTERM"].forEach((sig: any) => { diff --git a/client/src/core/client/embed/amp.html b/client/src/core/client/embed/amp.html index 6dfe2c1d5c..1e361ef214 100644 --- a/client/src/core/client/embed/amp.html +++ b/client/src/core/client/embed/amp.html @@ -16,7 +16,7 @@