Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract default messages script #1216

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
23699b8
replace relative with absolute path fetchTranslations
alexvuong May 18, 2023
696e3ef
build translations script
alexvuong May 18, 2023
771152f
fix relative path
alexvuong May 18, 2023
d401558
test generated project
alexvuong May 18, 2023
d709034
Merge branch 'generator/extensibility-support-new' into build-transla…
alexvuong May 18, 2023
f7b97b4
add description
alexvuong May 18, 2023
42b674c
only ignore if file exists in base template
alexvuong May 18, 2023
2b21595
change description
alexvuong May 18, 2023
0e7a69b
change description
alexvuong May 18, 2023
c14dd79
remove fils
alexvuong May 18, 2023
c09af46
remove fils
alexvuong May 19, 2023
6c84f61
remove fils
alexvuong May 19, 2023
4d51f80
remove generated project
alexvuong May 19, 2023
57e811f
minor fix
alexvuong May 19, 2023
b5ca7b7
remove translation in app folder
alexvuong May 19, 2023
46c6386
Merge branch 'generator/extensibility-support-new' into build-transla…
alexvuong May 19, 2023
56d466f
fix missing translation
alexvuong May 20, 2023
6101877
move restoring file into callback
alexvuong May 20, 2023
e35188c
Merge branch 'generator/extensibility-support-new' into build-transla…
alexvuong May 23, 2023
63e7f26
fix tests
alexvuong May 23, 2023
10f3ec3
Merge branch 'generator/extensibility-support-new' into build-transla…
alexvuong May 23, 2023
dc05c8e
lint fix
bfeister May 23, 2023
b5baadc
Merge branch 'generator/extensibility-support-new' into build-transla…
bfeister May 23, 2023
ba7c1e9
Merge branch 'generator/extensibility-support-new' into build-transla…
bfeister May 23, 2023
347cffa
fix psedo command
alexvuong May 23, 2023
11f7273
Merge branch 'build-translation-script' of github.com:SalesforceComme…
alexvuong May 23, 2023
8a52a7b
remove console
alexvuong May 23, 2023
43dfefd
comiple translations
alexvuong May 23, 2023
9535b70
PR feedback
alexvuong May 23, 2023
79666e1
PR feedback
alexvuong May 23, 2023
ca5e28a
Do not need to use --ignore
alexvuong May 23, 2023
ef9fe85
remove test.only
alexvuong May 23, 2023
037487a
Merge branch 'generator/extensibility-support-new' into build-transla…
alexvuong May 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions generated-project/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build
coverage
docs
app/static
jest.config.js
webpack
scripts/generator/assets
10 changes: 10 additions & 0 deletions generated-project/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

module.exports = {
extends: [require.resolve('pwa-kit-dev/configs/eslint')]
}
32 changes: 32 additions & 0 deletions generated-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.nyc_output
build.tar

coverage
tests/reports
tests/screenshots
tests/lighthouse-reports/
lighthouse/audit*
.lighthouseci

.tern-port
app/integration-manager/docs
messaging/*.csr

# Local App Configuration Files
config/local.*

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

build/
tmp/
*.log
node_modules

# Generated files
app/cache-hash-manifest.json
app/loader-cache-hash-manifest.json

.vscode
7 changes: 7 additions & 0 deletions generated-project/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
printWidth: 100
singleQuote: true
semi: false
bracketSpacing: false
tabWidth: 4
arrowParens: 'always'
trailingComma: 'none'
7 changes: 7 additions & 0 deletions generated-project/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
module.exports = require('pwa-kit-dev/configs/babel/babel-config')
76 changes: 76 additions & 0 deletions generated-project/config/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
const sites = require('./sites.js')
module.exports = {
app: {
// Customize how your 'site' and 'locale' are displayed in the url.
url: {
// Determine where the siteRef is located. Valid values include 'path|query_param|none'. Defaults to: 'none'
// site: 'none',
// Determine where the localeRef is located. Valid values include 'path|query_param|none'. Defaults to: 'none'
locale: 'none',
// This boolean value dictates whether or not default site or locale values are shown in the url. Defaults to: false
// showDefaults: true
},
// The default site for your app. This value will be used when a siteRef could not be determined from the url
defaultSite: 'RefArch',
// Provide aliases for your sites. These will be used in place of your site id when generating paths throughout the application.
// siteAliases: {
// RefArch: 'us'
// },
// The sites for your app, which is imported from sites.js
sites,
// Commerce api config
commerceAPI: {
proxyPath: '/mobify/proxy/api',
parameters: {
clientId: '1d763261-6522-4913-9d52-5d947d3b94c4',
organizationId: 'f_ecom_zzte_053',
shortCode: 'kv7kzm78',
siteId: 'RefArch'
}
},
// Einstein api config
einsteinAPI: {
host: 'https://api.cquotient.com',
einsteinId: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
siteId: '',
// Flag Einstein activities as coming from a production environment.
// By setting this to true, the Einstein activities generated by the environment will appear
// in production environment reports
isProduction: false
}
},
// This list contains server-side only libraries that you don't want to be compiled by webpack
externals: [],
// Page not found url for your app
pageNotFoundURL: '/page-not-found',
// Enables or disables building the files necessary for server-side rendering.
ssrEnabled: true,
// This list determines which files are available exclusively to the server-side rendering system
// and are not available through the /mobify/bundle/ path.
ssrOnly: ['ssr.js', 'ssr.js.map', 'node_modules/**/*.*'],
// This list determines which files are available to the server-side rendering system
// and available through the /mobify/bundle/ path.
ssrShared: [
'static/ico/favicon.ico',
'static/robots.txt',
'**/*.js',
'**/*.js.map',
'**/*.json'
],
// Additional parameters that configure Express app behavior.
ssrParameters: {
ssrFunctionNodeVersion: '16.x',
proxyConfigs: [
{
host: 'kv7kzm78.api.commercecloud.salesforce.com',
path: 'api'
}
]
}
}
26 changes: 26 additions & 0 deletions generated-project/config/sites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

// Provide the sites for your app. Each site includes site id, and its localization configuration.
// You can also provide aliases for your locale. They will be used in place of your locale id when generating paths across the app
module.exports = [
{
id: 'RefArch',
l10n: {
supportedCurrencies: ['USD'],
defaultCurrency: 'USD',
defaultLocale: 'en-US',
supportedLocales: [
{
id: 'en-US',
// alias: 'us',
preferredCurrency: 'USD'
}
]
}
}
]
5 changes: 5 additions & 0 deletions generated-project/overrides/app/assets/svg/brand-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions generated-project/overrides/app/main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import {start, registerServiceWorker} from 'pwa-kit-react-sdk/ssr/browser/main'

const main = () => {
// The path to your service worker should match what is set up in ssr.js
return Promise.all([start(), registerServiceWorker('/worker.js')])
}

main()
24 changes: 24 additions & 0 deletions generated-project/overrides/app/pages/home/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import React from 'react'
import {useIntl} from 'react-intl'

function Index() {
const intl = useIntl()
return (
<div>
<div>Modified home page Modified home page</div>
{intl.formatMessage({
defaultMessage: 'Features',
id: 'home.some_thing_test'
})}
</div>
)
}

export default Index
118 changes: 118 additions & 0 deletions generated-project/overrides/app/request-processor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

// This is an EXAMPLE file. To enable request processing, rename it to
// 'request-processor.js' and update the processRequest function so that
// it processes requests in whatever way your project requires.

// Uncomment the following line for the example code to work.
import {QueryParameters} from 'pwa-kit-runtime/utils/ssr-request-processing'

/**
* The processRequest function is called for *every* non-proxy, non-bundle
* request received. That is, all requests that will result in pages being
* rendered, or the Express app requestHook function being invoked. Because
* this function runs for every request, it is important that processing
* take as little time as possible. Do not make external requests from
* this code. Make your code error tolerant; throwing an error from
* this function will cause a 500 error response to be sent to the
* requesting client.
*
* The processRequest function is passed details of the incoming request,
* function to support request-class setting plus parameters that refer to
* the target for which this code is being run.
*
* The function must return an object with 'path' and 'querystring'. These
* may be the same values passed in, or modified values.
*
* Processing query strings can be challenging, because there are multiple
* formats in use, URL-quoting may be required, and the order of parameters
* in the URL may be important. To avoid issues, use the QueryParameters
* class from the SDK's 'utils/ssr-request-processing' module. This
* class will correctly preserve the order, case, values and encoding of
* the parameters. The QueryParameters class is documented in the SDK.
*
* @param path {String} the path part of the URL, beginning with a '/'
* @param querystring {String} the query string part of the URL, without
* any initial '?'
* @param headers {Headers} the headers of the incoming request. This should
* be considered read-only (although header values can be changed, most headers
* are not passed to the origin, so changes have no effect).
* @param setRequestClass {function} call this with a string to set the
* "class" of the incoming request. By default, requests have no class.
* @param parameters {Object}
* @param parameters.appHostname {String} the "application host name" is the
* hostname to which requests are sent for this target: the website's hostname.
* @param parameters.deployTarget {String} the target's id. Use this to have
* different processing for different targets.
* @param parameters.proxyConfigs {Object[]} an array of proxy configuration
* object, each one containing protocol, host and path for a proxy. Use this
* to have different processing for different backends.
* @returns {{path: String, querystring: String}}
*/
export const processRequest = ({
// Uncomment the following lines for the example code to work.
// headers,
// setRequestClass,
// parameters,
path,
querystring
}) => {
// This is an EXAMPLE processRequest implementation. You should
// replace it with code that processes your requests as needed.

// This example code will remove any of the parameters whose keys appear
// in the 'exclusions' array.
const exclusions = [
// 'gclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source'
]

// This is a performance optimization for SLAS.
// On client side, browser always follow the redirect
// to /callback but the response is always the same.
// We strip out the unique query parameters so this
// endpoint is cached at the CDN level
if (path === '/callback') {
exclusions.push('usid')
exclusions.push('code')
}

// Build a first QueryParameters object from the given querystring
const incomingParameters = new QueryParameters(querystring)

// Build a second QueryParameters from the first, with all
// excluded parameters removed
const filteredParameters = QueryParameters.from(
incomingParameters.parameters.filter(
// parameter.key is always lower-case
(parameter) => !exclusions.includes(parameter.key)
)
)

// Re-generate the querystring
querystring = filteredParameters.toString()

/***************************************************************************
// This example code will detect bots by examining the user-agent,
// and will set the request class to 'bot' for all such requests.
const ua = headers.getHeader('user-agent')
// This check
const botcheck = /bot|crawler|spider|crawling/i
if (botcheck.test(ua)) {
setRequestClass('bot')
}
***************************************************************************/
// Return the path unchanged, and the updated query string
return {
path,
querystring
}
}
32 changes: 32 additions & 0 deletions generated-project/overrides/app/routes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import {configureRoutes} from 'retail-react-app/app/utils/routes-utils'
import {getConfig} from 'pwa-kit-runtime/utils/ssr-config'
import loadable from '@loadable/component'
const fallback = <Skeleton height="75vh" width="100%" />
import {routes as _routes} from 'retail-react-app/app/routes'
import {Skeleton} from '@chakra-ui/react'

const Home = loadable(() => import('./pages/home'), {fallback})
const routes = [
{
path: '/',
component: Home,
exact: true
},
// NOTE: the final item in the array must be the { path: '*', component: PageNotFound } so
// routes added after re-inserting the base templates routes here might fail to
// show up unless the '*' route is filtered out and re-inserted
..._routes
]
export default () => {
const config = getConfig()
return configureRoutes(routes, config, {
ignoredRoutes: ['/callback', '*']
})
}
Loading