Skip to content

Commit

Permalink
NEXT-23904 - make admin compatible to node 18
Browse files Browse the repository at this point in the history
  • Loading branch information
jleifeld committed Dec 7, 2022
1 parent 86a8370 commit 93283b9
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitlab/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variables:
APP_SECRET: devsecret
OPENSEARCH_URL: elasticsearch:9200
BLUE_GREEN_DEPLOYMENT: 1
NODE_VERSION: 16
NODE_VERSION: 18
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'

# for jobs which should run on each MR/Pipeline
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/lib/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# install node $NODE_VERSION
install-node:
script:
- export NODE_VERSION="${NODE_VERSION:-16}"
- export NODE_VERSION="${NODE_VERSION:-18}"
- export NVM_DIR=/opt/nvm
# found no way to automatically load shell initialization scripts in gitlab
- bash -c '\. "$NVM_DIR/nvm.sh" && nvm install $NODE_VERSION'
Expand Down
4 changes: 1 addition & 3 deletions .gitlab/stages/10-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ NPM CI:
- JS_APP_DIR: "src/Administration/Resources/app/administration/"
NODE_IMAGE_TAG:
- "lts-alpine"
- "12-alpine"
- "14-alpine"
- "16-alpine"
- "18-alpine"
- JS_APP_DIR: "src/Storefront/Resources/app/storefront/"
NODE_IMAGE_TAG:
- "lts-alpine"
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/stages/50-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Component Library:
extends: .base
stage: build
image: node:14.18
image: node:18.12
before_script: []
variables:
PROJECT_ROOT: $CI_PROJECT_DIR
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/hydrogen
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Make administration compatible to node 18
issue: NEXT-23904
author: Jannis Leifeld
author_email: [email protected]
author_github: Jannis Leifeld
---
# Administration
* Added hack to webpack config to replace the crypto hash function with a "sha256" when "md4" is used
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ pkgs ? import <nixpkgs> {}}:

pkgs.mkShell {
nativeBuildInputs = [ pkgs.nodejs-16_x ];
nativeBuildInputs = [ pkgs.nodejs-18_x ];
}
3 changes: 1 addition & 2 deletions src/Administration/Resources/app/administration/.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Deprecated the engine will be strictly validated with the next major release
# engine-strict=true
engine-strict=true
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const path = require('path');

const fileParser = require(`${__dirname}/lib/file-parser`); // eslint-disable-line import/no-dynamic-require
const process = require('process');
const crypto = require("crypto");

/** HACK: OpenSSL 3 does not support md4 any more,
* but webpack hardcodes it all over the place: https://github.com/webpack/webpack/issues/13572
*/
const cryptoOrigCreateHash = crypto.createHash;
crypto.createHash = algorithm => cryptoOrigCreateHash(algorithm === 'md4' ? 'sha256' : algorithm);

function getPathFromRoot(directory) {
const projectRoot = process.env.PROJECT_ROOT;
Expand Down
20 changes: 10 additions & 10 deletions src/Administration/Resources/app/administration/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Administration/Resources/app/administration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"@babel/plugin-transform-runtime": "7.17.12",
"@babel/preset-env": "7.17.12",
"@babel/register": "7.17.7",
"@shopware-ag/jest-preset-sw6-admin": "4.0.0",
"@shopware-ag/jest-preset-sw6-admin": "4.0.1",
"@testing-library/jest-dom": "5.16.5",
"@types/lodash": "4.14.182",
"assets-webpack-plugin": "3.9.12",
Expand Down Expand Up @@ -189,7 +189,7 @@
"xml2js": "0.4.23"
},
"engines": {
"node": "^16.0.0",
"node": "^18.0.0",
"npm": "^8.0.0"
},
"browserslist": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl
const path = require('path');
const fs = require('fs');
const chalk = require('chalk');
const crypto = require('crypto');

/** HACK: OpenSSL 3 does not support md4 any more,
* but webpack hardcodes it all over the place: https://github.com/webpack/webpack/issues/13572
*/
const cryptoOrigCreateHash = crypto.createHash;
crypto.createHash = algorithm => cryptoOrigCreateHash(algorithm === 'md4' ? 'sha256' : algorithm);

/* eslint-disable */

Expand All @@ -33,10 +40,10 @@ if (featureFlags.hasOwnProperty('FEATURE_NEXT_11634')) {
}

// https://regex101.com/r/OGpZFt/1
const versionRegex = /16\.\d{1,2}\.\d{1,2}/;
const versionRegex = /18\.\d{1,2}\.\d{1,2}/;
if (!versionRegex.test(process.versions.node)) {
console.log();
console.log(chalk.red('@Deprecated: You are using an incompatible Node.js version. Supported version range: ^16.0.0'));
console.log(chalk.red('@Deprecated: You are using an incompatible Node.js version. Supported version range: ^18.0.0'));
console.log();
}

Expand Down
8 changes: 8 additions & 0 deletions src/Storefront/Resources/app/storefront/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const TerserPlugin = require('terser-webpack-plugin');
const WebpackBar = require('webpackbar');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const crypto = require("crypto");

/** HACK: OpenSSL 3 does not support md4 any more,
* but webpack hardcodes it all over the place: https://github.com/webpack/webpack/issues/13572
*/
const cryptoOrigCreateHash = crypto.createHash;
crypto.createHash = algorithm => cryptoOrigCreateHash(algorithm === 'md4' ? 'sha256' : algorithm);


const isProdMode = process.env.NODE_ENV === 'production';
const isHotMode = process.env.MODE === 'hot';
Expand Down

0 comments on commit 93283b9

Please sign in to comment.