Skip to content

Commit

Permalink
Support Node 16 (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
raiyaj authored Feb 27, 2023
1 parent 4ce5869 commit b743269
Show file tree
Hide file tree
Showing 42 changed files with 184 additions and 329 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ jobs:
pwa-kit:
strategy:
matrix:
node: [14]
node: [14, 16]
npm: [6, 7, 8]
exclude:
- node: 16
npm: 6
runs-on: ubuntu-latest
env:
# The "default" npm is the one that ships with a given version of node
# node v14 uses npm@6, latest node v16 uses npm@8
# The "default" npm is the one that ships with a given version of node.
# For more: https://nodejs.org/en/download/releases/
IS_DEFAULT_NPM: ${{ matrix.npm == 6 }}
IS_DEFAULT_NPM: ${{ matrix.node == 14 && matrix.npm == 6 || matrix.node == 16 && matrix.npm == 8 }}
IS_LATEST_NPM: ${{ matrix.node == 16 && matrix.npm == 8 }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -68,28 +71,28 @@ jobs:
uses: "./.github/actions/smoke_tests"

- name: Create MRT credentials file
if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' && env.DEVELOP == 'true'
if: env.IS_NOT_FORK == 'true' && env.IS_LATEST_NPM == 'true' && env.DEVELOP == 'true'
uses: "./.github/actions/create_mrt"
with:
mobify_user: ${{ secrets.MOBIFY_CLIENT_USER }}
mobify_api_key: ${{ secrets.MOBIFY_CLIENT_API_KEY }}

- name: Push Bundle to MRT (Development)
if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' && env.DEVELOP == 'true'
if: env.IS_NOT_FORK == 'true' && env.IS_LATEST_NPM == 'true' && env.DEVELOP == 'true'
uses: "./.github/actions/push_to_mrt"
with:
CWD: "./packages/template-retail-react-app"
TARGET: staging

- name: Push Bundle to MRT (Production)
if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' && env.RELEASE == 'true'
if: env.IS_NOT_FORK == 'true' && env.IS_LATEST_NPM == 'true' && env.RELEASE == 'true'
uses: "./.github/actions/push_to_mrt"
with:
CWD: "./packages/template-retail-react-app"
TARGET: production

- name: Push Bundle to MRT (Commerce SDK React)
if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' && env.DEVELOPMENT == 'true'
if: env.IS_NOT_FORK == 'true' && env.IS_LATEST_NPM == 'true' && env.DEVELOPMENT == 'true'
uses: "./.github/actions/push_to_mrt"
with:
CWD: "./packages/test-commerce-sdk-react"
Expand All @@ -100,7 +103,7 @@ jobs:
uses: "./.github/actions/check_clean"

- name: Publish to NPM
if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' && env.RELEASE == 'true'
if: env.IS_NOT_FORK == 'true' && env.IS_LATEST_NPM == 'true' && env.RELEASE == 'true'
uses: "./.github/actions/publish_to_npm"
with:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
Expand All @@ -118,11 +121,16 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
pwa-kit-windows:
strategy:
# TODO: We don't *need* a matrix with single values,
# but is it worth keeping for supporting multiple versions in the future?
matrix:
node: [14]
npm: [6]
matrix:
node: [14, 16]
npm: [6, 7, 8]
exclude:
- node: 16
npm: 6
env:
# The "default" npm is the one that ships with a given version of node.
# For more: https://nodejs.org/en/download/releases/
IS_DEFAULT_NPM: ${{ matrix.node == 14 && matrix.npm == 6 || matrix.node == 16 && matrix.npm == 8 }}
runs-on: windows-latest
steps:
- name: Checkout
Expand All @@ -134,6 +142,11 @@ jobs:
node-version: ${{ matrix.node }}
cache: npm

- name: Update NPM version
if: env.IS_DEFAULT_NPM == 'false'
run: |-
npm install -g npm@${{ matrix.npm }}
- name: Setup Windows Machine
uses: "./.github/actions/setup_windows"

Expand All @@ -157,7 +170,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- name: Setup Ubuntu Machine
uses: "./.github/actions/setup_ubuntu"
Expand Down Expand Up @@ -247,7 +260,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- name: Setup Windows Machine
uses: "./.github/actions/setup_windows"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pwa-kit",
"version": "2.7.0-dev",
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce-sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "[email protected]",
"license": "See license in LICENSE",
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/internal-lib-build/configs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = {
require('@babel/preset-env'),
{
targets: {
node: 14
node: 16
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion packages/internal-lib-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "internal-lib-build",
"version": "2.7.0-dev",
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-create-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A tool for generating PWA Kit projects based on project templates, such as the [

## Requirements

- Node 14
- Node 14.17.0 or later
- npm 6.14.4 or later

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-create-app/assets/pwa/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = {
],
// Additional parameters that configure Express app behavior.
ssrParameters: {
ssrFunctionNodeVersion: '14.x',
ssrFunctionNodeVersion: '16.x',
proxyConfigs: [
{
host: '${commerceApi.shortCode}.api.commercecloud.salesforce.com',
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"test": "internal-lib-build test"
},
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"dependencies": {
Expand Down
8 changes: 7 additions & 1 deletion packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const p = require('path')
const sh = require('shelljs')
const fs = require('fs')
const cp = require('child_process')
const semver = require('semver')

sh.set('-e')

Expand Down Expand Up @@ -147,7 +148,12 @@ const runGenerator = () => {
// Shelljs can't run interactive programs, so we have to switch to child_process.
// See https://github.com/shelljs/shelljs/wiki/FAQ#running-interactive-programs-with-exec

cp.execSync(`npx pwa-kit-create-app ${process.argv.slice(2).join(' ')}`, {
const extension = process.platform === 'win32' ? '.cmd' : ''
const npm = `npm${extension}`
const foundNpm = cp.spawnSync(npm, ['-v']).stdout.toString().trim()
const flags = semver.satisfies(foundNpm, '>=7') ? '-y' : ''

cp.execSync(`npx ${flags} pwa-kit-create-app@latest ${process.argv.slice(2).join(' ')}`, {
stdio: 'inherit'
})
}
Expand Down
2 changes: 2 additions & 0 deletions packages/pwa-kit-dev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## v2.7.0-dev (Jan 25, 2023)
- Add explicit `ws` dependency [#865](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/865)

## v2.6.0 (Jan 25, 2023)
- Upgrade prettier to v2 [#926](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/926)
- Security package updates
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A command-line tool to develop, build, and deploy PWA Kit projects.

## Requirements

- Node 14
- Node 14.17.0 or later
- npm 6.14.4 or later

To see all the available commands, run:
Expand Down
18 changes: 15 additions & 3 deletions packages/pwa-kit-dev/package-lock.json

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

5 changes: 3 additions & 2 deletions packages/pwa-kit-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
"webpack-dev-middleware": "^5.2.2",
"webpack-hot-middleware": "^2.25.1",
"webpack-hot-server-middleware": "^0.6.1",
"webpack-notifier": "^1.12.0"
"webpack-notifier": "^1.12.0",
"ws": "^8.12.0"
},
"devDependencies": {
"@loadable/component": "^5.15.0",
Expand All @@ -117,7 +118,7 @@
"@loadable/component": "^5.15.0"
},
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-dev/src/configs/babel/babel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const config = {
require('@babel/preset-env'),
{
targets: {
node: 14
node: 16
}
}
],
Expand Down
20 changes: 16 additions & 4 deletions packages/pwa-kit-dev/src/configs/webpack/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// For more information on these settings, see https://webpack.js.org/configuration
import fs from 'fs'
import path, {resolve} from 'path'
import {resolve} from 'path'

import webpack from 'webpack'
import WebpackNotifierPlugin from 'webpack-notifier'
Expand All @@ -23,7 +23,6 @@ import {createModuleReplacementPlugin} from './plugins'
import {CLIENT, SERVER, CLIENT_OPTIONAL, SSR, REQUEST_PROCESSOR} from './config-names'

const projectDir = process.cwd()
const sdkDir = resolve(path.join(__dirname, '..', '..', '..'))

const pkg = require(resolve(projectDir, 'package.json'))
const buildDir = process.env.PWA_KIT_BUILD_DIR
Expand Down Expand Up @@ -65,8 +64,21 @@ const entryPointExists = (segments) => {
}

const findInProjectThenSDK = (pkg) => {
const projectPath = resolve(projectDir, 'node_modules', pkg)
return fs.existsSync(projectPath) ? projectPath : resolve(sdkDir, 'node_modules', pkg)
// Look for the SDK node_modules in two places because in CI,
// pwa-kit-dev is published under a 'dist' directory, which
// changes this file's location relative to the package root.
const candidates = [
resolve(projectDir, 'node_modules', pkg),
resolve(__dirname, '..', '..', 'node_modules', pkg),
resolve(__dirname, '..', '..', '..', 'node_modules', pkg)
]
let candidate
for (candidate of candidates) {
if (fs.existsSync(candidate)) {
return candidate
}
}
return candidate
}

const baseConfig = (target) => {
Expand Down
5 changes: 5 additions & 0 deletions packages/pwa-kit-dev/src/utils/script-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export class CloudAPIClient {
error = {} // Cloud doesn't always return JSON
}

if (res.status === 403) {
error.docs_url =
'https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/mrt-overview.html#users,-abilities,-and-roles'
}

throw new Error(
[
`HTTP ${res.status}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-react-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A library of components and utilities that supports the rendering pipeline for t

## Requirements

- Node 14
- Node 14.17.0 or later
- npm 6.14.4 or later

## Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-react-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.7.0-dev",
"description": "A library that supports the isomorphic React rendering pipeline for Commerce Cloud Managed Runtime apps",
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-react-sdk/setup-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock('pwa-kit-runtime/utils/ssr-config', () => {
'**/*.json'
],
ssrParameters: {
ssrFunctionNodeVersion: '14.x',
ssrFunctionNodeVersion: '16.x',
proxyConfigs: [
{
host: 'kv7kzm78.api.commercecloud.salesforce.com',
Expand Down
2 changes: 2 additions & 0 deletions packages/pwa-kit-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## v2.7.0-dev (Jan 25, 2023)
- Support Node 16 [#965](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/965)

## v2.6.0 (Jan 25, 2023)
- Security package updates

Expand Down
2 changes: 1 addition & 1 deletion packages/pwa-kit-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}
},
"engines": {
"node": "^14.0.0",
"node": "^14.0.0 || ^16.0.0",
"npm": "^6.14.4 || ^7.0.0 || ^8.0.0"
},
"publishConfig": {
Expand Down
Loading

0 comments on commit b743269

Please sign in to comment.