@salesforce/pwa-kit-create-app 3.0.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -0
- package/README.md +44 -0
- package/assets/bootstrap/js/.eslintignore +4 -0
- package/assets/bootstrap/js/.eslintrc.js +10 -0
- package/assets/bootstrap/js/.prettierrc.yaml +7 -0
- package/assets/bootstrap/js/babel.config.js +7 -0
- package/assets/bootstrap/js/config/default.js.hbs +77 -0
- package/assets/bootstrap/js/config/sites.js.hbs +26 -0
- package/assets/bootstrap/js/overrides/app/assets/svg/brand-logo.svg +5 -0
- package/assets/bootstrap/js/overrides/app/main.jsx +14 -0
- package/assets/bootstrap/js/overrides/app/request-processor.js +118 -0
- package/assets/bootstrap/js/overrides/app/routes.jsx.hbs +19 -0
- package/assets/bootstrap/js/overrides/app/ssr.js +67 -0
- package/assets/bootstrap/js/overrides/app/static/ico/favicon.ico +0 -0
- package/assets/bootstrap/js/overrides/app/static/img/global/app-icon-192.png +0 -0
- package/assets/bootstrap/js/overrides/app/static/img/global/app-icon-512.png +0 -0
- package/assets/bootstrap/js/overrides/app/static/img/global/apple-touch-icon.png +0 -0
- package/assets/bootstrap/js/overrides/app/static/img/hero.png +0 -0
- package/assets/bootstrap/js/overrides/app/static/manifest.json.hbs +19 -0
- package/assets/bootstrap/js/overrides/app/static/robots.txt +2 -0
- package/assets/bootstrap/js/package.json.hbs +36 -0
- package/assets/bootstrap/js/worker/main.js +6 -0
- package/assets/templates/retail-react-app/app/static/manifest.json.hbs +19 -0
- package/assets/templates/retail-react-app/config/default.js.hbs +77 -0
- package/assets/templates/retail-react-app/config/sites.js.hbs +26 -0
- package/package.json +50 -0
- package/scripts/create-mobify-app.js +764 -0
- package/templates/express-minimal.tar.gz +0 -0
- package/templates/mrt-reference-app.tar.gz +0 -0
- package/templates/retail-react-app.tar.gz +0 -0
- package/templates/typescript-minimal.tar.gz +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021, Salesforce.com, Inc.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
11
|
+
|
|
12
|
+
3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# PWA Kit Create App
|
|
2
|
+
|
|
3
|
+
A tool for generating PWA Kit projects based on project templates, such as the [Retail React App](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/retail-react-app.html).
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node 16.11 or later
|
|
8
|
+
- npm 8 or later
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
To get started, open a terminal and run the following:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @salesforce/pwa-kit-create-app
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For help, run:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx @salesforce/pwa-kit-create-app --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
The full documentation for PWA Kit and Managed Runtime is hosted on the [Salesforce Developers](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/overview) portal.
|
|
27
|
+
|
|
28
|
+
### Useful Links:
|
|
29
|
+
|
|
30
|
+
- [Get Started](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/getting-started.html)
|
|
31
|
+
- [Skills for Success](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/skills-for-success.html)
|
|
32
|
+
- [Set Up API Access](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/setting-up-api-access.html)
|
|
33
|
+
- [Configuration Options](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/configuration-options.html)
|
|
34
|
+
- [Proxy Requests](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/proxying-requests.html)
|
|
35
|
+
- [Push and Deploy Bundles](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pushing-and-deploying-bundles.html)
|
|
36
|
+
- [The Retail React App](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/retail-react-app.html)
|
|
37
|
+
- [Rendering](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/rendering.html)
|
|
38
|
+
- [Routing](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/routing.html)
|
|
39
|
+
- [Phased Headless Rollouts](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/phased-headless-rollouts.html)
|
|
40
|
+
- [Launch Your Storefront](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/launching-your-storefront.html)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Support Policy
|
|
44
|
+
Security patches are provided for 24 months after the general availability of each major version of the SDK (1.0, 2.0, and so on).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
extends: [require.resolve('@salesforce/pwa-kit-dev/configs/eslint')]
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
module.exports = require('@salesforce/pwa-kit-dev/configs/babel/babel-config')
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
8
|
+
const sites = require('./sites.js')
|
|
9
|
+
module.exports = {
|
|
10
|
+
app: {
|
|
11
|
+
// Customize how your 'site' and 'locale' are displayed in the url.
|
|
12
|
+
url: {
|
|
13
|
+
// Determine where the siteRef is located. Valid values include 'path|query_param|none'. Defaults to: 'none'
|
|
14
|
+
// site: 'none',
|
|
15
|
+
// Determine where the localeRef is located. Valid values include 'path|query_param|none'. Defaults to: 'none'
|
|
16
|
+
locale: 'none'
|
|
17
|
+
// This boolean value dictates whether or not default site or locale values are shown in the url. Defaults to: false
|
|
18
|
+
// showDefaults: true
|
|
19
|
+
},
|
|
20
|
+
// The default site for your app. This value will be used when a siteRef could not be determined from the url
|
|
21
|
+
defaultSite: '{{answers.project.commerce.siteId}}',
|
|
22
|
+
// Provide aliases for your sites. These will be used in place of your site id when generating paths throughout the application.
|
|
23
|
+
// siteAliases: {
|
|
24
|
+
// RefArch: 'us'
|
|
25
|
+
// },
|
|
26
|
+
// The sites for your app, which is imported from sites.js
|
|
27
|
+
sites,
|
|
28
|
+
// Commerce api config
|
|
29
|
+
commerceAPI: {
|
|
30
|
+
proxyPath: '/mobify/proxy/api',
|
|
31
|
+
parameters: {
|
|
32
|
+
clientId: '{{answers.project.commerce.clientId}}',
|
|
33
|
+
organizationId: '{{answers.project.commerce.organizationId}}',
|
|
34
|
+
shortCode: '{{answers.project.commerce.shortCode}}',
|
|
35
|
+
siteId: '{{answers.project.commerce.siteId}}'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
// Einstein api config
|
|
39
|
+
einsteinAPI: {
|
|
40
|
+
host: 'https://api.cquotient.com',
|
|
41
|
+
einsteinId: '{{answers.project.einstein.clientId}}',
|
|
42
|
+
siteId: '{{answers.project.einstein.siteId}}',
|
|
43
|
+
// Flag Einstein activities as coming from a production environment.
|
|
44
|
+
// By setting this to true, the Einstein activities generated by the environment will appear
|
|
45
|
+
// in production environment reports
|
|
46
|
+
isProduction: false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
// This list contains server-side only libraries that you don't want to be compiled by webpack
|
|
50
|
+
externals: [],
|
|
51
|
+
// Page not found url for your app
|
|
52
|
+
pageNotFoundURL: '/page-not-found',
|
|
53
|
+
// Enables or disables building the files necessary for server-side rendering.
|
|
54
|
+
ssrEnabled: true,
|
|
55
|
+
// This list determines which files are available exclusively to the server-side rendering system
|
|
56
|
+
// and are not available through the /mobify/bundle/ path.
|
|
57
|
+
ssrOnly: ['ssr.js', 'ssr.js.map', 'node_modules/**/*.*'],
|
|
58
|
+
// This list determines which files are available to the server-side rendering system
|
|
59
|
+
// and available through the /mobify/bundle/ path.
|
|
60
|
+
ssrShared: [
|
|
61
|
+
'static/ico/favicon.ico',
|
|
62
|
+
'static/robots.txt',
|
|
63
|
+
'**/*.js',
|
|
64
|
+
'**/*.js.map',
|
|
65
|
+
'**/*.json'
|
|
66
|
+
],
|
|
67
|
+
// Additional parameters that configure Express app behavior.
|
|
68
|
+
ssrParameters: {
|
|
69
|
+
ssrFunctionNodeVersion: '16.x',
|
|
70
|
+
proxyConfigs: [
|
|
71
|
+
{
|
|
72
|
+
host: '{{answers.project.commerce.shortCode}}.api.commercecloud.salesforce.com',
|
|
73
|
+
path: 'api'
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Provide the sites for your app. Each site includes site id, and its localization configuration.
|
|
9
|
+
// You can also provide aliases for your locale. They will be used in place of your locale id when generating paths across the app
|
|
10
|
+
module.exports = [
|
|
11
|
+
{
|
|
12
|
+
id: '{{answers.project.commerce.siteId}}',
|
|
13
|
+
l10n: {
|
|
14
|
+
supportedCurrencies: ['USD'],
|
|
15
|
+
defaultCurrency: 'USD',
|
|
16
|
+
defaultLocale: 'en-US',
|
|
17
|
+
supportedLocales: [
|
|
18
|
+
{
|
|
19
|
+
id: 'en-US',
|
|
20
|
+
// alias: 'us',
|
|
21
|
+
preferredCurrency: 'USD'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="44" height="42" viewBox="0 0 46 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M1 1.94319C1 1.12982 1.91937 0.656693 2.58124 1.12946L42.5812 29.7009C42.844 29.8886 43 30.1917 43 30.5146V40.0568C43 40.8702 42.0806 41.3433 41.4188 40.8705L1.41876 12.2991C1.15597 12.1114 1 11.8083 1 11.4854V1.94319Z" fill="#0D9DDA"/>
|
|
3
|
+
<path d="M22 1.94319C22 1.12982 22.9194 0.656693 23.5812 1.12946L42.5812 14.7009C42.844 14.8886 43 15.1917 43 15.5146V25.0568C43 25.8702 42.0806 26.3433 41.4188 25.8705L22.4188 12.2991C22.156 12.1114 22 11.8083 22 11.4854V1.94319Z" fill="#8ECAE3"/>
|
|
4
|
+
<path d="M1 16.9432C1 16.1298 1.91937 15.6567 2.58124 16.1295L21.5812 29.7009C21.844 29.8886 22 30.1917 22 30.5146V40.0568C22 40.8702 21.0806 41.3433 20.4188 40.8705L1.41876 27.2991C1.15597 27.1114 1 26.8083 1 26.4854V16.9432Z" fill="#0B5473"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import {start, registerServiceWorker} from '@salesforce/pwa-kit-react-sdk/ssr/browser/main'
|
|
8
|
+
|
|
9
|
+
const main = () => {
|
|
10
|
+
// The path to your service worker should match what is set up in ssr.js
|
|
11
|
+
return Promise.all([start(), registerServiceWorker('/worker.js')])
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
main()
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// This is an EXAMPLE file. To enable request processing, rename it to
|
|
9
|
+
// 'request-processor.js' and update the processRequest function so that
|
|
10
|
+
// it processes requests in whatever way your project requires.
|
|
11
|
+
|
|
12
|
+
// Uncomment the following line for the example code to work.
|
|
13
|
+
import {QueryParameters} from '@salesforce/pwa-kit-runtime/utils/ssr-request-processing'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The processRequest function is called for *every* non-proxy, non-bundle
|
|
17
|
+
* request received. That is, all requests that will result in pages being
|
|
18
|
+
* rendered, or the Express app requestHook function being invoked. Because
|
|
19
|
+
* this function runs for every request, it is important that processing
|
|
20
|
+
* take as little time as possible. Do not make external requests from
|
|
21
|
+
* this code. Make your code error tolerant; throwing an error from
|
|
22
|
+
* this function will cause a 500 error response to be sent to the
|
|
23
|
+
* requesting client.
|
|
24
|
+
*
|
|
25
|
+
* The processRequest function is passed details of the incoming request,
|
|
26
|
+
* function to support request-class setting plus parameters that refer to
|
|
27
|
+
* the target for which this code is being run.
|
|
28
|
+
*
|
|
29
|
+
* The function must return an object with 'path' and 'querystring'. These
|
|
30
|
+
* may be the same values passed in, or modified values.
|
|
31
|
+
*
|
|
32
|
+
* Processing query strings can be challenging, because there are multiple
|
|
33
|
+
* formats in use, URL-quoting may be required, and the order of parameters
|
|
34
|
+
* in the URL may be important. To avoid issues, use the QueryParameters
|
|
35
|
+
* class from the SDK's 'utils/ssr-request-processing' module. This
|
|
36
|
+
* class will correctly preserve the order, case, values and encoding of
|
|
37
|
+
* the parameters. The QueryParameters class is documented in the SDK.
|
|
38
|
+
*
|
|
39
|
+
* @param path {String} the path part of the URL, beginning with a '/'
|
|
40
|
+
* @param querystring {String} the query string part of the URL, without
|
|
41
|
+
* any initial '?'
|
|
42
|
+
* @param headers {Headers} the headers of the incoming request. This should
|
|
43
|
+
* be considered read-only (although header values can be changed, most headers
|
|
44
|
+
* are not passed to the origin, so changes have no effect).
|
|
45
|
+
* @param setRequestClass {function} call this with a string to set the
|
|
46
|
+
* "class" of the incoming request. By default, requests have no class.
|
|
47
|
+
* @param parameters {Object}
|
|
48
|
+
* @param parameters.appHostname {String} the "application host name" is the
|
|
49
|
+
* hostname to which requests are sent for this target: the website's hostname.
|
|
50
|
+
* @param parameters.deployTarget {String} the target's id. Use this to have
|
|
51
|
+
* different processing for different targets.
|
|
52
|
+
* @param parameters.proxyConfigs {Object[]} an array of proxy configuration
|
|
53
|
+
* object, each one containing protocol, host and path for a proxy. Use this
|
|
54
|
+
* to have different processing for different backends.
|
|
55
|
+
* @returns {{path: String, querystring: String}}
|
|
56
|
+
*/
|
|
57
|
+
export const processRequest = ({
|
|
58
|
+
// Uncomment the following lines for the example code to work.
|
|
59
|
+
// headers,
|
|
60
|
+
// setRequestClass,
|
|
61
|
+
// parameters,
|
|
62
|
+
path,
|
|
63
|
+
querystring
|
|
64
|
+
}) => {
|
|
65
|
+
// This is an EXAMPLE processRequest implementation. You should
|
|
66
|
+
// replace it with code that processes your requests as needed.
|
|
67
|
+
|
|
68
|
+
// This example code will remove any of the parameters whose keys appear
|
|
69
|
+
// in the 'exclusions' array.
|
|
70
|
+
const exclusions = [
|
|
71
|
+
// 'gclid',
|
|
72
|
+
// 'utm_campaign',
|
|
73
|
+
// 'utm_content',
|
|
74
|
+
// 'utm_medium',
|
|
75
|
+
// 'utm_source'
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
// This is a performance optimization for SLAS.
|
|
79
|
+
// On client side, browser always follow the redirect
|
|
80
|
+
// to /callback but the response is always the same.
|
|
81
|
+
// We strip out the unique query parameters so this
|
|
82
|
+
// endpoint is cached at the CDN level
|
|
83
|
+
if (path === '/callback') {
|
|
84
|
+
exclusions.push('usid')
|
|
85
|
+
exclusions.push('code')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Build a first QueryParameters object from the given querystring
|
|
89
|
+
const incomingParameters = new QueryParameters(querystring)
|
|
90
|
+
|
|
91
|
+
// Build a second QueryParameters from the first, with all
|
|
92
|
+
// excluded parameters removed
|
|
93
|
+
const filteredParameters = QueryParameters.from(
|
|
94
|
+
incomingParameters.parameters.filter(
|
|
95
|
+
// parameter.key is always lower-case
|
|
96
|
+
(parameter) => !exclusions.includes(parameter.key)
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
// Re-generate the querystring
|
|
101
|
+
querystring = filteredParameters.toString()
|
|
102
|
+
|
|
103
|
+
/***************************************************************************
|
|
104
|
+
// This example code will detect bots by examining the user-agent,
|
|
105
|
+
// and will set the request class to 'bot' for all such requests.
|
|
106
|
+
const ua = headers.getHeader('user-agent')
|
|
107
|
+
// This check
|
|
108
|
+
const botcheck = /bot|crawler|spider|crawling/i
|
|
109
|
+
if (botcheck.test(ua)) {
|
|
110
|
+
setRequestClass('bot')
|
|
111
|
+
}
|
|
112
|
+
***************************************************************************/
|
|
113
|
+
// Return the path unchanged, and the updated query string
|
|
114
|
+
return {
|
|
115
|
+
path,
|
|
116
|
+
querystring
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {routes} from '{{preset.templateSource.id}}/app/routes'
|
|
9
|
+
{{!-- TODO: The configure routes should be an optional opt-in provided from the SDK. --}}
|
|
10
|
+
import {configureRoutes} from '{{preset.templateSource.id}}/app/utils/routes-utils'
|
|
11
|
+
import {getConfig} from '@salesforce/pwa-kit-runtime/utils/ssr-config'
|
|
12
|
+
|
|
13
|
+
{{!-- export default routes --}}
|
|
14
|
+
export default () => {
|
|
15
|
+
const config = getConfig()
|
|
16
|
+
return configureRoutes(routes, config, {
|
|
17
|
+
ignoredRoutes: ['/callback', '*']
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
8
|
+
'use strict'
|
|
9
|
+
|
|
10
|
+
const path = require('path')
|
|
11
|
+
const {getRuntime} = require('@salesforce/pwa-kit-runtime/ssr/server/express')
|
|
12
|
+
const {isRemote} = require('@salesforce/pwa-kit-runtime/utils/ssr-server')
|
|
13
|
+
const {getConfig} = require('@salesforce/pwa-kit-runtime/utils/ssr-config')
|
|
14
|
+
const helmet = require('helmet')
|
|
15
|
+
|
|
16
|
+
const options = {
|
|
17
|
+
// The build directory (an absolute path)
|
|
18
|
+
buildDir: path.resolve(process.cwd(), 'build'),
|
|
19
|
+
|
|
20
|
+
// The cache time for SSR'd pages (defaults to 600 seconds)
|
|
21
|
+
defaultCacheTimeSeconds: 600,
|
|
22
|
+
|
|
23
|
+
// This is the value of the 'mobify' object from package.json
|
|
24
|
+
mobify: getConfig(),
|
|
25
|
+
|
|
26
|
+
// The port that the local dev server listens on
|
|
27
|
+
port: 3000,
|
|
28
|
+
|
|
29
|
+
// The protocol on which the development Express app listens.
|
|
30
|
+
// Note that http://localhost is treated as a secure context for development.
|
|
31
|
+
protocol: 'http'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const runtime = getRuntime()
|
|
35
|
+
|
|
36
|
+
const {handler} = runtime.createHandler(options, (app) => {
|
|
37
|
+
// Set HTTP security headers
|
|
38
|
+
app.use(
|
|
39
|
+
helmet({
|
|
40
|
+
contentSecurityPolicy: {
|
|
41
|
+
useDefaults: true,
|
|
42
|
+
directives: {
|
|
43
|
+
'img-src': ["'self'", '*.commercecloud.salesforce.com', 'data:'],
|
|
44
|
+
'script-src': ["'self'", "'unsafe-eval'", 'storage.googleapis.com'],
|
|
45
|
+
'connect-src': ["'self'", 'api.cquotient.com'],
|
|
46
|
+
|
|
47
|
+
// Do not upgrade insecure requests for local development
|
|
48
|
+
'upgrade-insecure-requests': isRemote() ? [] : null
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
hsts: isRemote()
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
// Handle the redirect from SLAS as to avoid error
|
|
56
|
+
app.get('/callback?*', (req, res) => {
|
|
57
|
+
res.send()
|
|
58
|
+
})
|
|
59
|
+
app.get('/robots.txt', runtime.serveStaticFile('static/robots.txt'))
|
|
60
|
+
app.get('/favicon.ico', runtime.serveStaticFile('static/ico/favicon.ico'))
|
|
61
|
+
|
|
62
|
+
app.get('/worker.js(.map)?', runtime.serveServiceWorker)
|
|
63
|
+
app.get('*', runtime.render)
|
|
64
|
+
})
|
|
65
|
+
// SSR requires that we export a single handler function called 'get', that
|
|
66
|
+
// supports AWS use of the server that we created above.
|
|
67
|
+
exports.get = handler
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{preset.id}}",
|
|
3
|
+
"short_name": "{{preset.id}}",
|
|
4
|
+
"start_url": "/?homescreen=1",
|
|
5
|
+
"background_color": "#fff",
|
|
6
|
+
"theme_color": "#4e439b",
|
|
7
|
+
"display": "standalone",
|
|
8
|
+
"icons": [
|
|
9
|
+
{
|
|
10
|
+
"src": "./img/global/app-icon-192.png",
|
|
11
|
+
"sizes": "192x192"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"src": "./img/global/app-icon-512.png",
|
|
15
|
+
"sizes": "512x512"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{answers.project.name}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "See license in LICENSE",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": "^16.0.0 || ^18.0.0",
|
|
7
|
+
"npm": "^7.0.0 || ^8.0.0 || ^9.0.0"
|
|
8
|
+
},
|
|
9
|
+
"ccExtensibility": {
|
|
10
|
+
"extends": "{{preset.templateSource.id}}",
|
|
11
|
+
"overridesDir": "overrides"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"{{preset.templateSource.id}}": "{{answers.general.packageJSON.version}}"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
{{#each answers.general.packageJSON.scripts}}
|
|
18
|
+
"{{@key}}": "{{{script this}}}"{{#unless @last}},{{/unless}}
|
|
19
|
+
{{/each}}
|
|
20
|
+
},
|
|
21
|
+
"bundlesize": [
|
|
22
|
+
{
|
|
23
|
+
"path": "build/main.js",
|
|
24
|
+
"maxSize": "42 kB"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "build/vendor.js",
|
|
28
|
+
"maxSize": "320 kB"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"browserslist": [
|
|
32
|
+
"iOS >= 9.0",
|
|
33
|
+
"Android >= 4.4.4",
|
|
34
|
+
"last 4 ChromeAndroid versions"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{preset.id}}",
|
|
3
|
+
"short_name": "{{preset.id}}",
|
|
4
|
+
"start_url": "/?homescreen=1",
|
|
5
|
+
"background_color": "#fff",
|
|
6
|
+
"theme_color": "#4e439b",
|
|
7
|
+
"display": "standalone",
|
|
8
|
+
"icons": [
|
|
9
|
+
{
|
|
10
|
+
"src": "./img/global/app-icon-192.png",
|
|
11
|
+
"sizes": "192x192"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"src": "./img/global/app-icon-512.png",
|
|
15
|
+
"sizes": "512x512"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
8
|
+
const sites = require('./sites.js')
|
|
9
|
+
module.exports = {
|
|
10
|
+
app: {
|
|
11
|
+
// Customize how your 'site' and 'locale' are displayed in the url.
|
|
12
|
+
url: {
|
|
13
|
+
// Determine where the siteRef is located. Valid values include 'path|query_param|none'. Defaults to: 'none'
|
|
14
|
+
// site: 'none',
|
|
15
|
+
// Determine where the localeRef is located. Valid values include 'path|query_param|none'. Defaults to: 'none'
|
|
16
|
+
locale: 'none',
|
|
17
|
+
// This boolean value dictates whether or not default site or locale values are shown in the url. Defaults to: false
|
|
18
|
+
// showDefaults: true
|
|
19
|
+
},
|
|
20
|
+
// The default site for your app. This value will be used when a siteRef could not be determined from the url
|
|
21
|
+
defaultSite: '{{answers.project.commerce.siteId}}',
|
|
22
|
+
// Provide aliases for your sites. These will be used in place of your site id when generating paths throughout the application.
|
|
23
|
+
// siteAliases: {
|
|
24
|
+
// RefArch: 'us'
|
|
25
|
+
// },
|
|
26
|
+
// The sites for your app, which is imported from sites.js
|
|
27
|
+
sites,
|
|
28
|
+
// Commerce api config
|
|
29
|
+
commerceAPI: {
|
|
30
|
+
proxyPath: '/mobify/proxy/api',
|
|
31
|
+
parameters: {
|
|
32
|
+
clientId: '{{answers.project.commerce.clientId}}',
|
|
33
|
+
organizationId: '{{answers.project.commerce.organizationId}}',
|
|
34
|
+
shortCode: '{{answers.project.commerce.shortCode}}',
|
|
35
|
+
siteId: '{{answers.project.commerce.siteId}}'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
// Einstein api config
|
|
39
|
+
einsteinAPI: {
|
|
40
|
+
host: 'https://api.cquotient.com',
|
|
41
|
+
einsteinId: '{{answers.project.einstein.clientId}}',
|
|
42
|
+
siteId: '{{answers.project.einstein.siteId}}',
|
|
43
|
+
// Flag Einstein activities as coming from a production environment.
|
|
44
|
+
// By setting this to true, the Einstein activities generated by the environment will appear
|
|
45
|
+
// in production environment reports
|
|
46
|
+
isProduction: false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
// This list contains server-side only libraries that you don't want to be compiled by webpack
|
|
50
|
+
externals: [],
|
|
51
|
+
// Page not found url for your app
|
|
52
|
+
pageNotFoundURL: '/page-not-found',
|
|
53
|
+
// Enables or disables building the files necessary for server-side rendering.
|
|
54
|
+
ssrEnabled: true,
|
|
55
|
+
// This list determines which files are available exclusively to the server-side rendering system
|
|
56
|
+
// and are not available through the /mobify/bundle/ path.
|
|
57
|
+
ssrOnly: ['ssr.js', 'ssr.js.map', 'node_modules/**/*.*'],
|
|
58
|
+
// This list determines which files are available to the server-side rendering system
|
|
59
|
+
// and available through the /mobify/bundle/ path.
|
|
60
|
+
ssrShared: [
|
|
61
|
+
'static/ico/favicon.ico',
|
|
62
|
+
'static/robots.txt',
|
|
63
|
+
'**/*.js',
|
|
64
|
+
'**/*.js.map',
|
|
65
|
+
'**/*.json'
|
|
66
|
+
],
|
|
67
|
+
// Additional parameters that configure Express app behavior.
|
|
68
|
+
ssrParameters: {
|
|
69
|
+
ssrFunctionNodeVersion: '16.x',
|
|
70
|
+
proxyConfigs: [
|
|
71
|
+
{
|
|
72
|
+
host: '{{answers.project.commerce.shortCode}}.api.commercecloud.salesforce.com',
|
|
73
|
+
path: 'api'
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Provide the sites for your app. Each site includes site id, and its localization configuration.
|
|
9
|
+
// You can also provide aliases for your locale. They will be used in place of your locale id when generating paths across the app
|
|
10
|
+
module.exports = [
|
|
11
|
+
{
|
|
12
|
+
id: '{{answers.project.commerce.siteId}}',
|
|
13
|
+
l10n: {
|
|
14
|
+
supportedCurrencies: ['USD'],
|
|
15
|
+
defaultCurrency: 'USD',
|
|
16
|
+
defaultLocale: 'en-US',
|
|
17
|
+
supportedLocales: [
|
|
18
|
+
{
|
|
19
|
+
id: 'en-US',
|
|
20
|
+
// alias: 'us',
|
|
21
|
+
preferredCurrency: 'USD'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|