diff --git a/.github/actions/create_mrt/action.yml b/.github/actions/create_mrt/action.yml
index 9c9f153884..6c03698c2a 100644
--- a/.github/actions/create_mrt/action.yml
+++ b/.github/actions/create_mrt/action.yml
@@ -4,10 +4,14 @@ inputs:
description: "Mobify user email"
mobify_api_key:
description: "Mobify user API key"
+ cwd:
+ required: false
+ default: ${PWD}
runs:
using: composite
steps:
- name: Create MRT credentials file
+ working-directory: ${{ inputs.cwd }}
run: |-
# Add credentials file at ~/.mobify so we can upload to Mobify Cloud
npm run save-credentials --prefix packages/template-retail-react-app -- --user "${{inputs.mobify_user}}" --key "${{inputs.mobify_api_key}}"
diff --git a/.github/actions/e2e_generate_app/action.yml b/.github/actions/e2e_generate_app/action.yml
index 4916840373..113d127323 100644
--- a/.github/actions/e2e_generate_app/action.yml
+++ b/.github/actions/e2e_generate_app/action.yml
@@ -4,9 +4,13 @@ inputs:
description: Project key to specify project to generate ("retail-app-demo", "retail-app-ext" or "retail-app-no-ext")
required: true
type: string
+ cwd:
+ required: false
+ default: ${PWD}
runs:
using: composite
steps:
- name: Generate new project based on project-key
+ working-directory: ${{ inputs.cwd }}
run: node e2e/scripts/generate-project.js ${{ inputs.PROJECT_KEY }}
shell: bash
diff --git a/.github/actions/e2e_validate_generated_app/action.yml b/.github/actions/e2e_validate_generated_app/action.yml
index 8531ad2edb..77b44a12de 100644
--- a/.github/actions/e2e_validate_generated_app/action.yml
+++ b/.github/actions/e2e_validate_generated_app/action.yml
@@ -4,9 +4,13 @@ inputs:
description: Project key to specify project to validate ("retail-app-demo", "retail-app-ext" or "retail-app-no-ext")
required: true
type: string
+ cwd:
+ required: false
+ default: ${PWD}
runs:
using: composite
steps:
- name: Validate generated project based on project-key
+ working-directory: ${{ inputs.cwd }}
run: node e2e/scripts/validate-generated-project.js ${{ inputs.PROJECT_KEY }}
shell: bash
diff --git a/.github/actions/push_to_mrt/action.yml b/.github/actions/push_to_mrt/action.yml
index c1aa7b6b4a..50b0873861 100644
--- a/.github/actions/push_to_mrt/action.yml
+++ b/.github/actions/push_to_mrt/action.yml
@@ -4,6 +4,8 @@ inputs:
description: Project directory
TARGET:
description: MRT target
+ FLAGS:
+ description: Push flags
runs:
using: composite
steps:
diff --git a/.github/actions/setup_ubuntu/action.yml b/.github/actions/setup_ubuntu/action.yml
index 3a5b29efc7..91f0dd0f60 100644
--- a/.github/actions/setup_ubuntu/action.yml
+++ b/.github/actions/setup_ubuntu/action.yml
@@ -2,12 +2,13 @@ name: setup_ubuntu
inputs:
cwd:
required: false
- default: "${PWD}"
+ default: ${{ github.workspace }}
description: "Setup Ubuntu Machine"
runs:
using: composite
steps:
- name: Install Dependencies
+ working-directory: ${{ inputs.cwd }}
run: |-
# Install system dependencies
sudo apt-get update -yq
@@ -28,7 +29,7 @@ runs:
npm run check-dep-version
# Install Snyk CLI
- # TODO: Ticket W-12425059. Revisit Snyk CLI integration to monitor manifest files on generated projects.
+ # TODO: Ticket W-12425059. Revisit Snyk CLI integration to monitor manifest files on generated projects.
# TODO: Latest Snyk CLI version is currently failing on npm i. We use the alternative Snyk GitHub integration.
# sudo npm install -g snyk
diff --git a/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/routes.jsx.hbs b/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/routes.jsx.hbs
index 10e7640118..0133cefdf3 100644
--- a/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/routes.jsx.hbs
+++ b/packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/routes.jsx.hbs
@@ -5,7 +5,12 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
+{{#if answers.project.hybrid}}
+import React, { useEffect } from 'react'
+import { withRouter } from 'react-router-dom'
+{{else}}
import React from 'react'
+{{/if}}
import loadable from '@loadable/component'
import {getConfig} from '@salesforce/pwa-kit-runtime/utils/ssr-config'
@@ -18,8 +23,15 @@ const fallback =
// Create your pages here and add them to the routes array
// Use loadable to split code into smaller js chunks
+{{#if answers.project.hybrid}}
+const Home = loadable(() => import('@salesforce/retail-react-app/app/pages/home'), { fallback })
+{{else}}
const Home = loadable(() => import('./pages/home'), {fallback})
+{{/if}}
const MyNewRoute = loadable(() => import('./pages/my-new-route'))
+{{#if answers.project.hybrid}}
+const PageNotFound = loadable(() => import('@salesforce/retail-react-app/app/pages/page-not-found'))
+{{/if}}
const routes = [
{
@@ -27,11 +39,44 @@ const routes = [
component: Home,
exact: true
},
+ {{#if answers.project.hybrid}}
+ {
+ path: '/home',
+ component: Home,
+ exact: true
+ },
+ {{/if}}
{
path: '/my-new-route',
component: MyNewRoute
},
+ {{#if answers.project.hybrid}}
+ // remove routes from the base template that we want to go to SFRA
+ ..._routes.filter((route) => {
+ return !(route.path === '/cart' || route.path === '/checkout' || route.path === '*')
+ }),
+ {
+ path: '*',
+ component: withRouter((props) => {
+ const { location, history } = props
+ const urlParams = new URLSearchParams(location.search)
+
+ useEffect(() => {
+ const newURL = new URL(window.location)
+ if (!urlParams.has('redirected')) {
+ newURL.searchParams.append('redirected', '1')
+ window.location.href = newURL
+ }
+ }, [location.pathname])
+ if (urlParams.has('redirected')) {
+ return
+ }
+ return null
+ })
+ }
+ {{else}}
..._routes
+ {{/if}}
]
{{!-- export default routes --}}
diff --git a/packages/pwa-kit-create-app/scripts/create-mobify-app.js b/packages/pwa-kit-create-app/scripts/create-mobify-app.js
index 46d272c8d5..0f82ed6cee 100755
--- a/packages/pwa-kit-create-app/scripts/create-mobify-app.js
+++ b/packages/pwa-kit-create-app/scripts/create-mobify-app.js
@@ -129,6 +129,24 @@ const EXTENSIBILITY_QUESTIONS = [
}
]
+const HYBRID_QUESTIONS = [
+ {
+ name: 'project.hybrid',
+ message: 'Do you wish to set up a phased headless rollout?',
+ type: 'list',
+ choices: [
+ {
+ name: 'No',
+ value: false
+ },
+ {
+ name: 'Yes',
+ value: true
+ }
+ ]
+ }
+]
+
const MRT_REFERENCE_QUESTIONS = [
{
name: 'project.name',
@@ -223,6 +241,7 @@ const PRESETS = [
questions: [...EXTENSIBILITY_QUESTIONS, ...RETAIL_REACT_APP_QUESTIONS],
answers: {
['project.extend']: true,
+ ['project.hybrid']: false,
['project.name']: 'demo-storefront',
['project.commerce.instanceUrl']: 'https://zzte-053.dx.commercecloud.salesforce.com',
['project.commerce.clientId']: '1d763261-6522-4913-9d52-5d947d3b94c4',
@@ -246,6 +265,7 @@ const PRESETS = [
questions: [...EXTENSIBILITY_QUESTIONS, ...RETAIL_REACT_APP_QUESTIONS],
answers: {
['project.extend']: true,
+ ['project.hybrid']: false,
['project.name']: 'retail-react-app',
['project.commerce.instanceUrl']: 'https://zzrf-001.dx.commercecloud.salesforce.com',
['project.commerce.clientId']: 'c9c45bfd-0ed3-4aa2-9971-40f88962b836',
@@ -258,6 +278,30 @@ const PRESETS = [
assets: ['translations'],
private: true
},
+ {
+ id: 'retail-react-app-hybrid-test-project',
+ name: 'Retail React App Hybrid Test Project',
+ description: '',
+ templateSource: {
+ type: TEMPLATE_SOURCE_NPM,
+ id: '@salesforce/retail-react-app'
+ },
+ questions: [...EXTENSIBILITY_QUESTIONS, ...HYBRID_QUESTIONS, ...RETAIL_REACT_APP_QUESTIONS],
+ answers: {
+ ['project.extend']: true,
+ ['project.hybrid']: true,
+ ['project.name']: 'retail-react-app',
+ ['project.commerce.instanceUrl']: 'https://test.phased-launch-testing.com/',
+ ['project.commerce.clientId']: '50b359ea-4224-4125-b75d-dd80ff4b0f00',
+ ['project.commerce.siteId']: 'RefArch',
+ ['project.commerce.organizationId']: 'f_ecom_bdpx_dev',
+ ['project.commerce.shortCode']: 'xitgmcd3',
+ ['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
+ ['project.einstein.siteId']: 'aaij-MobileFirst'
+ },
+ assets: ['translations'],
+ private: true
+ },
{
id: 'typescript-minimal-test-project',
name: 'Template Minimal Test Project',
diff --git a/packages/pwa-kit-dev/bin/pwa-kit-dev.js b/packages/pwa-kit-dev/bin/pwa-kit-dev.js
index 64b9082da2..2189cf36f1 100755
--- a/packages/pwa-kit-dev/bin/pwa-kit-dev.js
+++ b/packages/pwa-kit-dev/bin/pwa-kit-dev.js
@@ -358,7 +358,7 @@ const main = async () => {
warnings.forEach(warn)
if (wait) {
success('Bundle Uploaded - waiting for deployment to complete')
- await client.waitForDeploy()
+ await client.waitForDeploy(projectSlug, target)
} else {
success('Bundle Uploaded')
}