Skip to content

Commit

Permalink
Merge pull request #6740 from reactioncommerce/upgrade-node-to-18
Browse files Browse the repository at this point in the history
Upgrade Node to 18
  • Loading branch information
sujithvn authored May 23, 2023
2 parents 3a66df5 + b309747 commit 91a455f
Show file tree
Hide file tree
Showing 90 changed files with 1,254 additions and 1,381 deletions.
44 changes: 44 additions & 0 deletions .changeset/strange-terms-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
"@reactioncommerce/api-core": major
"@reactioncommerce/api-plugin-accounts": major
"@reactioncommerce/api-plugin-address-validation": major
"@reactioncommerce/api-plugin-address-validation-test": major
"@reactioncommerce/api-plugin-authentication": major
"@reactioncommerce/api-plugin-authorization-simple": major
"@reactioncommerce/api-plugin-carts": major
"@reactioncommerce/api-plugin-catalogs": major
"@reactioncommerce/api-plugin-discounts": major
"@reactioncommerce/api-plugin-discounts-codes": major
"@reactioncommerce/api-plugin-email": major
"@reactioncommerce/api-plugin-email-smtp": major
"@reactioncommerce/api-plugin-email-templates": major
"@reactioncommerce/api-plugin-files": major
"@reactioncommerce/api-plugin-i18n": major
"@reactioncommerce/api-plugin-inventory": major
"@reactioncommerce/api-plugin-inventory-simple": major
"@reactioncommerce/api-plugin-job-queue": major
"@reactioncommerce/api-plugin-navigation": major
"@reactioncommerce/api-plugin-notifications": major
"@reactioncommerce/api-plugin-orders": major
"@reactioncommerce/api-plugin-payments": major
"@reactioncommerce/api-plugin-payments-example": major
"@reactioncommerce/api-plugin-payments-stripe-sca": major
"@reactioncommerce/api-plugin-pricing-simple": major
"@reactioncommerce/api-plugin-products": major
"@reactioncommerce/api-plugin-sample-data": major
"@reactioncommerce/api-plugin-settings": major
"@reactioncommerce/api-plugin-shipments": major
"@reactioncommerce/api-plugin-shipments-flat-rate": major
"@reactioncommerce/api-plugin-shops": major
"@reactioncommerce/api-plugin-simple-schema": major
"@reactioncommerce/api-plugin-sitemap-generator": major
"@reactioncommerce/api-plugin-surcharges": major
"@reactioncommerce/api-plugin-system-information": major
"@reactioncommerce/api-plugin-tags": major
"@reactioncommerce/api-plugin-taxes": major
"@reactioncommerce/api-plugin-taxes-flat-rate": major
"@reactioncommerce/api-plugin-translations": major
"@reactioncommerce/api-utils": major
---

Node18 upgrade includes assert json
10 changes: 7 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defaults: &defaults
DOCKER_NAMESPACE: "reactioncommerce"
DOCKER_NAME: "reaction"
docker:
- image: cimg/node:14.20.0
- image: cimg/node:18.10.0

install_pnpm: &install_pnpm
- run:
Expand Down Expand Up @@ -91,12 +91,14 @@ jobs:
- <<: *pnpm_install
- run:
name: Test Unit
no_output_timeout: 30m
command: pnpm test
resource_class: large

test-integration-query:
<<: *defaults
docker:
- image: cimg/node:14.20.0
- image: cimg/node:18.10.0
# Integration tests need MongoDB server running and accessible on port 27017
- image: mongo:4.0
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
Expand All @@ -119,11 +121,12 @@ jobs:
sudo apt update && sudo apt-get install -y mongodb
mongo --eval "rs.initiate()"
pnpm run test:integration:query
resource_class: large

test-integration-mutation:
<<: *defaults
docker:
- image: cimg/node:14.20.0
- image: cimg/node:18.10.0
# Integration tests need MongoDB server running and accessible on port 27017
- image: mongo:4.0
command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
Expand All @@ -146,6 +149,7 @@ jobs:
sudo apt update && sudo apt-get install -y mongodb
mongo --eval "rs.initiate()"
pnpm run test:integration:mutation
resource_class: large

release:
<<: *defaults
Expand Down
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module.exports = {
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
babelOptions: {
plugins: ["@babel/plugin-syntax-import-assertions"]
},
ecmaFeatures: {
impliedStrict: true
},
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)

runs-on: ubuntu-latest
runs-on: ubuntu-focal

steps:
- uses: actions/checkout@v2
Expand All @@ -27,10 +27,10 @@ jobs:
key: reaction-v6-node-modules-${{ hashFiles('package.json') }}-${{ hashFiles('pnpm-lock.yaml') }}
path: "**/node_modules"

- name: Use Node.js 14.x
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 18

- name: Install pnpm
run: npm i -g pnpm@latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tagging-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
if: github.event.pull_request.merged == true && github.base_ref == 'trunk' && github.head_ref == 'changeset-release/trunk'
permissions:
contents: write # to create release (changesets/action)
runs-on: ubuntu-latest
runs-on: ubuntu-focal

steps:
- uses: actions/checkout@v2
Expand All @@ -22,10 +22,10 @@ jobs:
run: |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
- name: Use Node.js 14.x
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 18

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.20.0
18.10.0
4 changes: 2 additions & 2 deletions apps/reaction/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile for production builds
# syntax=docker/dockerfile:1.4

FROM node:14.20.0-alpine as deps
FROM node:18.10.0-alpine as deps

# hadolint ignore=DL3018
RUN apk --no-cache add bash less curl make g++ glib
Expand All @@ -17,7 +17,7 @@ RUN pnpm --filter=reaction --prod deploy deps --ignore-scripts
# hadolint ignore=DL3003,SC2015
RUN cd deps/node_modules/sharp && npm run install

FROM node:14.20.0-alpine
FROM node:18.10.0-alpine

# hadolint ignore=DL3018
RUN apk --no-cache add bash less tini vim curl
Expand Down
3 changes: 2 additions & 1 deletion apps/reaction/babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ module.exports = function (api) { // eslint-disable-line no-undef
"@babel/preset-env",
{
targets: {
node: "12"
node: "18"
}
}
]
],
plugins: [
"babel-plugin-transform-import-meta",
"@babel/plugin-syntax-import-assertions",
"module:@reactioncommerce/babel-remove-es-create-require",
"rewire-exports",
"transform-es2015-modules-commonjs"
Expand Down
7 changes: 6 additions & 1 deletion apps/reaction/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ const jestConfig = {
// testResultsProcessor: null,

// This option allows use of a custom test runner
// testRunner: "jasmine2",
testRunner: "jasmine2",

snapshotFormat: {
escapeString: true,
printBasicPrototype: true
},

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
Expand Down
10 changes: 5 additions & 5 deletions apps/reaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./src/index.js",
"type": "module",
"engines": {
"node": ">=14.18.1"
"node": ">=18.10.0"
},
"homepage": "https://github.com/reactioncommerce/reaction",
"url": "https://github.com/reactioncommerce/reaction",
Expand Down Expand Up @@ -90,12 +90,12 @@
"inspect:docker": "NODE_ENV=development nodemon --preserve-symlinks --experimental-modules --experimental-json-modules --inspect=0.0.0.0:9229 ./src/index.js",
"inspect-brk:docker": "NODE_ENV=development nodemon --preserve-symlinks --experimental-modules --experimental-json-modules --inspect-brk=0.0.0.0:9229 ./src/index.js",
"check-node-version": "node ./src/checkNodeVersion.cjs",
"test:integration": "node --max_old_space_size=10000 node_modules/jest/bin/jest --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/'",
"test:integration:watch": "node --max_old_space_size=10000 node_modules/jest/bin/jest --runInBand --watch --testPathIgnorePatterns '<rootDir>/src/'",
"test:integration": "node node_modules/jest/bin/jest --forceExit --testPathIgnorePatterns '<rootDir>/src/'",
"test:integration:watch": "node node_modules/jest/bin/jest --runInBand --watch --testPathIgnorePatterns '<rootDir>/src/'",
"test:integration:file": "jest --runInBand",
"test:integration:file:watch": "jest --runInBand --watch",
"test:integration:query": "node --max_old_space_size=4000 --expose-gc ../../node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/mutations/'",
"test:integration:mutation": "node --max_old_space_size=4000 --expose-gc ../../node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/queries/'",
"test:integration:query": "node --max-old-space-size=6144 --expose-gc ../../node_modules/jest/bin/jest.js --forceExit --runInBand --logHeapUsage --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/mutations/'",
"test:integration:mutation": "node --max_old_space_size=6144 --expose-gc ../../node_modules/jest/bin/jest.js --forceExit --runInBand --logHeapUsage --testPathIgnorePatterns '<rootDir>/src/' '<rootDir>/tests/integration/api/queries/'",
"lint": "eslint .",
"lint:gql": "graphql-schema-linter ./src/**/*.graphql",
"version": "echo $npm_package_version",
Expand Down
1 change: 0 additions & 1 deletion apps/reaction/src/checkNodeVersion.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// This must not be an ES module because we want
// this check to work on older Node versions that
// do not support ES modules.

const semver = require("semver");
const packageJson = require("../package.json");

Expand Down
2 changes: 1 addition & 1 deletion apps/reaction/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { importPluginsJSONFile, ReactionAPICore } from "@reactioncommerce/api-core";
import Logger from "@reactioncommerce/logger";
import packageJson from "../package.json";
import packageJson from "../package.json" assert { type: "json" };

const api = new ReactionAPICore({
serveStaticPaths: ["public"],
Expand Down
5 changes: 1 addition & 4 deletions apps/reaction/tests/util/setupJestTests.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* eslint-disable no-undef */
import { createRequire } from "module";

const require = createRequire(import.meta.url);
const jestProcessEnv = require("./jestProcessEnv.json");
import jestProcessEnv from "./jestProcessEnv.json" assert { type: "json" };

process.env = Object.assign(process.env, {
...jestProcessEnv
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Reaction is a modern reactive, real-time event driven ecommerce platform.",
"main": "index.js",
"engines": {
"node": ">=14.18.1",
"node": ">=18.10.0",
"npm": ">=7"
},
"engineStrict": true,
Expand Down Expand Up @@ -44,6 +44,7 @@
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.10",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-syntax-import-assertions": "^7.20.0",
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@babel/preset-env": "^7.19.0",
"@commitlint/config-conventional": "^17.0.3",
Expand All @@ -65,7 +66,8 @@
"husky": "^5.0.8",
"is-ci": "^2.0.0",
"is-docker": "^2.1.1",
"jest": "^25.5.4",
"jest": "^29.4.3",
"jest-jasmine2": "^29.4.3",
"nodemon": "~1.19.2"
},
"graphql-schema-linter": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-core/src/importPluginsJSONFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function importPluginsJSONFile(pluginsFile, transformPlugin
absolutePluginsFile = path.join(path.dirname(callerFileName), pluginsFile);
}

let { default: pluginRefs } = await import(absolutePluginsFile);
let { default: pluginRefs } = await import(`${absolutePluginsFile}`, { assert: { type: "json" } });

if (typeof transformPlugins === "function") {
// allow plugins to be added and removed
Expand Down
48 changes: 24 additions & 24 deletions packages/api-plugin-accounts/src/i18n/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import ar from "./ar.json";
import bg from "./bg.json";
import cs from "./cs.json";
import de from "./de.json";
import el from "./el.json";
import en from "./en.json";
import es from "./es.json";
import fr from "./fr.json";
import he from "./he.json";
import hr from "./hr.json";
import hu from "./hu.json";
import it from "./it.json";
import my from "./my.json";
import nb from "./nb.json";
import nl from "./nl.json";
import pl from "./pl.json";
import pt from "./pt.json";
import ro from "./ro.json";
import ru from "./ru.json";
import sl from "./sl.json";
import sv from "./sv.json";
import tr from "./tr.json";
import vi from "./vi.json";
import zh from "./zh.json";
import ar from "./ar.json" assert { type: "json" };
import bg from "./bg.json" assert { type: "json" };
import cs from "./cs.json" assert { type: "json" };
import de from "./de.json" assert { type: "json" };
import el from "./el.json" assert { type: "json" };
import en from "./en.json" assert { type: "json" };
import es from "./es.json" assert { type: "json" };
import fr from "./fr.json" assert { type: "json" };
import he from "./he.json" assert { type: "json" };
import hr from "./hr.json" assert { type: "json" };
import hu from "./hu.json" assert { type: "json" };
import it from "./it.json" assert { type: "json" };
import my from "./my.json" assert { type: "json" };
import nb from "./nb.json" assert { type: "json" };
import nl from "./nl.json" assert { type: "json" };
import pl from "./pl.json" assert { type: "json" };
import pt from "./pt.json" assert { type: "json" };
import ro from "./ro.json" assert { type: "json" };
import ru from "./ru.json" assert { type: "json" };
import sl from "./sl.json" assert { type: "json" };
import sv from "./sv.json" assert { type: "json" };
import tr from "./tr.json" assert { type: "json" };
import vi from "./vi.json" assert { type: "json" };
import zh from "./zh.json" assert { type: "json" };

//
// we want all the files in individual
Expand Down
4 changes: 2 additions & 2 deletions packages/api-plugin-accounts/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pkg from "../package.json";
import pkg from "../package.json" assert { type: "json" };
import i18n from "./i18n/index.js";
import mutations from "./mutations/index.js";
import policies from "./policies.json";
import policies from "./policies.json" assert { type: "json" };
import queries from "./queries/index.js";
import resolvers from "./resolvers/index.js";
import schemas from "./schemas/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/api-plugin-address-validation-test/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg from "../package.json";
import pkg from "../package.json" assert { type: "json" };
import addressValidation from "./addressValidation.js";

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/api-plugin-address-validation/src/i18n/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import en from "./en.json";
import es from "./es.json";
import en from "./en.json" assert { type: "json" };
import es from "./es.json" assert { type: "json" };

//
// we want all the files in individual
Expand Down
4 changes: 2 additions & 2 deletions packages/api-plugin-address-validation/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pkg from "../package.json";
import pkg from "../package.json" assert { type: "json" };
import i18n from "./i18n/index.js";
import mutations from "./mutations/index.js";
import policies from "./policies.json";
import policies from "./policies.json" assert { type: "json" };
import queries from "./queries/index.js";
import { registerPluginHandlerForAddress } from "./registration.js";
import resolvers from "./resolvers/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/api-plugin-authentication/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg from "../package.json";
import pkg from "../package.json" assert { type: "json" };
import tokenMiddleware from "./util/tokenMiddleware.js";
import getAccounts from "./util/accountServer.js";
import wsAuthenticate from "./util/wsAuthenticate.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/api-plugin-authorization-simple/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg from "../package.json";
import pkg from "../package.json" assert { type: "json" };
import { getHasPermissionFunctionForUser } from "./util/hasPermission.js";
import permissionsByUserId from "./util/permissionsByUserId.js";
import preStartup from "./preStartup.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/api-plugin-carts/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pkg from "../package.json";
import pkg from "../package.json" assert { type: "json" };
import mutations from "./mutations/index.js";
import policies from "./policies.json";
import policies from "./policies.json" assert { type: "json" };
import queries from "./queries/index.js";
import resolvers from "./resolvers/index.js";
import schemas from "./schemas/index.js";
Expand Down
Loading

0 comments on commit 91a455f

Please sign in to comment.