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

Multi-site implementation - dynamic config approach #391

Merged
merged 230 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
0a1415a
url customization
alexvuong Nov 23, 2021
24aa2e8
lint
alexvuong Nov 23, 2021
15988ec
Merge branch 'develop' into feat/url-customisation-implementation
alexvuong Nov 23, 2021
91da27c
remove console
alexvuong Nov 23, 2021
22a03f2
add change log, remove console
alexvuong Nov 23, 2021
a57e546
Link the PR in change log
alexvuong Nov 24, 2021
e325e89
change the util name to `buildPathWithUrlConfig`
alexvuong Nov 24, 2021
f40df5d
PR feedback
alexvuong Nov 25, 2021
84bae4d
change urlParamTypes to urlPartPositions
alexvuong Nov 25, 2021
4b22d39
Merge branch 'develop' into feat/url-customisation-implementation
alexvuong Nov 25, 2021
e8bbbd8
add and fix tests
alexvuong Nov 26, 2021
db5b489
fix tests and adjust logic for rebuildPathWithParams
alexvuong Nov 26, 2021
6a609ca
linting
alexvuong Nov 26, 2021
1ca0869
fix tests
alexvuong Nov 26, 2021
f7c2416
remove console
alexvuong Nov 26, 2021
1279423
Merge branch 'develop' into feat/url-customisation-implementation
alexvuong Nov 26, 2021
c98d3f1
start multi site work
alexvuong Nov 29, 2021
0894f55
add useSite hook
alexvuong Nov 30, 2021
0946a18
adjust logic for useSite, fix tests for useNavigation
alexvuong Dec 1, 2021
f3d76bf
fix useNavigation tests
alexvuong Dec 1, 2021
488081f
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Dec 2, 2021
6679511
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Dec 6, 2021
3eb27a8
take site position into account for locale picker
alexvuong Dec 7, 2021
9386bd4
take site position into account for locale picker
alexvuong Dec 7, 2021
7e84482
move l10n config into multi site config because each will have differ…
alexvuong Dec 8, 2021
270f4ba
add en-us translation file
alexvuong Dec 8, 2021
e35b3ce
remove hostname
alexvuong Dec 8, 2021
872a076
small fix
alexvuong Dec 8, 2021
7d611d9
adjust useSite hook to check site by hostname first
alexvuong Dec 8, 2021
8e52ace
export funcs
alexvuong Dec 9, 2021
7b19498
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Dec 9, 2021
83c18e8
fix tests
alexvuong Dec 10, 2021
6faa539
As per feedback, use regexp to get the site id/alias value, make the …
alexvuong Dec 13, 2021
ddaddd9
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Dec 13, 2021
51a10ce
fix translation for refArch
alexvuong Dec 13, 2021
a7821ef
fix translation for refArch
alexvuong Dec 14, 2021
1a75c6e
add jsdoc and comments
alexvuong Dec 14, 2021
5c882df
replace getUrlConfig with getConfig, change pwa-kit-config.json to pw…
alexvuong Dec 14, 2021
d4186a1
replace getUrlConfig with getConfig
alexvuong Dec 15, 2021
0935d57
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Dec 15, 2021
c951f6e
rename getSite to resolveSiteFromUrl
alexvuong Dec 16, 2021
0eeea51
create util convert a partial url to fully url to simplify some logic…
alexvuong Dec 16, 2021
43a1e1e
move site utils into its own file and add unit tests
alexvuong Dec 16, 2021
6639812
add jsonpath-plus and use it
alexvuong Dec 17, 2021
07e2eff
some PR feedback
alexvuong Dec 17, 2021
68710bb
clean up getConfig
alexvuong Dec 17, 2021
2bcb067
Clean up
bendvc Dec 17, 2021
b7a3ed5
Merge branch 'feat/multi-site-implementation' of https://github.com/S…
bendvc Dec 17, 2021
3b3e4eb
Fix name
bendvc Dec 17, 2021
d3db5ed
pr feedback
alexvuong Dec 17, 2021
da0a70a
Merge branch 'feat/multi-site-implementation' of github.com:Salesforc…
alexvuong Dec 17, 2021
c09d150
linting
alexvuong Dec 17, 2021
abfa57e
add jsdoc
alexvuong Dec 17, 2021
5f6101f
adjust homeURlbuilder to show site and locale except when both are de…
alexvuong Dec 17, 2021
7e91690
clean up
alexvuong Dec 17, 2021
facf30e
PR feedback
alexvuong Dec 20, 2021
c4d12a9
fix tests
alexvuong Dec 20, 2021
7860ae4
fix getUrlWithLocal func
alexvuong Dec 21, 2021
793fd1f
fix tests
alexvuong Dec 21, 2021
6b4715e
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Dec 21, 2021
497a7ce
regenerate lock file
alexvuong Dec 21, 2021
f169427
PR feedback
alexvuong Dec 21, 2021
dadb8c2
fix getUrlWithLocale and tests
alexvuong Dec 21, 2021
9913cc1
simplify pathToUrl
alexvuong Dec 22, 2021
c49eec1
clean up
alexvuong Jan 3, 2022
196ebbc
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Jan 4, 2022
0d813d3
rebuild translation for en-US
alexvuong Jan 4, 2022
c40a5e3
compile messages
alexvuong Jan 4, 2022
8448550
Default locale in multisite setup (#276)
vmarta Jan 5, 2022
19cacd1
Fix translation scripts to adapt multi site implementation (#273)
alexvuong Jan 5, 2022
a6717ef
Remove jsonpath plus package (#277)
alexvuong Jan 6, 2022
8e3c1ee
configure Route to get all permutation of route array
alexvuong Jan 14, 2022
2eef942
small refactor
alexvuong Jan 14, 2022
e9df287
adjust logic inside resolver with new config,
alexvuong Jan 14, 2022
e3e0992
adjust the code to fit the new config
alexvuong Jan 14, 2022
9d121d7
remove custom getter
alexvuong Jan 15, 2022
82bf098
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Jan 19, 2022
e12d5cc
linting
alexvuong Jan 19, 2022
08ea9ee
Merge branch 'feat/multi-site-implementation' into feat/multi-site-al…
alexvuong Jan 19, 2022
ad9301e
use EXTERNAL_DOMAIN_NAME to determin current host on configureRoutes
alexvuong Jan 19, 2022
06dce2b
change comment
alexvuong Jan 19, 2022
891b529
add showDefault flag for url config
alexvuong Jan 20, 2022
1620ef6
fix jsdoc comment
alexvuong Jan 20, 2022
60a75f8
only use one showDefault flag for both config
alexvuong Jan 24, 2022
c56005b
fix buildPathWithUrlConfig and getUrlWithLocale when showDefault flag…
alexvuong Jan 25, 2022
d924183
add more comment into jsdoc
alexvuong Jan 25, 2022
6169ac0
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Jan 25, 2022
84570d9
Merge branch 'feat/multi-site-implementation' into feat/multi-site-al…
alexvuong Jan 25, 2022
8ca8d1f
add resolveConfigFromUrl
alexvuong Jan 25, 2022
147b4d1
change domain to be an array
alexvuong Jan 26, 2022
c4c3dbd
separate mulsite config into two section sites and routing for clarity
alexvuong Jan 29, 2022
eb1113b
Merge branch 'develop' into feat/multi-site-implementation
alexvuong Jan 29, 2022
3901116
Merge branch 'feat/multi-site-implementation' into feat/multi-site-al…
alexvuong Jan 29, 2022
60065ed
fix import path
alexvuong Jan 29, 2022
4acfe19
adjust logic for new config structure
alexvuong Jan 29, 2022
0abd611
fix homeUrlBuilder
alexvuong Jan 31, 2022
2e72939
fix getUrlWithLocale
alexvuong Feb 1, 2022
3f25dda
fix getUrlWithLocale
alexvuong Feb 1, 2022
8f950ef
Merge branch 'develop' into feat/multi-site-alternative-approach
alexvuong Feb 5, 2022
51ec332
try using node config
alexvuong Feb 8, 2022
268c2c5
use cosmic config
alexvuong Feb 10, 2022
13291f3
clean up
alexvuong Feb 10, 2022
27b7106
fix logic for new config structure
alexvuong Feb 10, 2022
caf8b12
fix logic for new config structure
alexvuong Feb 11, 2022
01c28c2
fix unit tests
alexvuong Feb 12, 2022
04462a9
fix logic for new config structure
alexvuong Feb 12, 2022
47eac52
remove console
alexvuong Feb 14, 2022
f4bb9b1
fix logic for new config structure
alexvuong Feb 14, 2022
63285ab
PR feedback on config structure and some related changes
alexvuong Feb 15, 2022
d312e54
remove pwa-kit config, minor adjustment
alexvuong Feb 15, 2022
833dcf4
delete unwanted code
alexvuong Feb 15, 2022
7db7309
clean up
alexvuong Feb 15, 2022
68dcba9
fix test for all util functions
alexvuong Feb 15, 2022
1dcb664
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 15, 2022
b8730e0
fix page not found failing test
alexvuong Feb 15, 2022
c972220
Merge branch 'develop' into feat/multi-site-config
alexvuong Feb 15, 2022
c94eb52
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 15, 2022
f6550cb
fix tests
alexvuong Feb 16, 2022
e41f907
minor fix
alexvuong Feb 16, 2022
b4c40f4
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 16, 2022
2d2235e
fix tests
alexvuong Feb 16, 2022
08ed829
fix tests
alexvuong Feb 17, 2022
f5ba3d6
fix configureRoute test
alexvuong Feb 17, 2022
5be4d76
lint
alexvuong Feb 17, 2022
b888cd1
fix tests
alexvuong Feb 17, 2022
fb7b218
fix tests
alexvuong Feb 17, 2022
fa6ee80
Merge branch 'develop' into feat/multi-site-config
alexvuong Feb 17, 2022
d2b5a8b
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 17, 2022
01dd75e
revert changes on test files as they are being fixed in different branch
alexvuong Feb 17, 2022
b272b6b
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 17, 2022
40a9943
fix tests
alexvuong Feb 17, 2022
ccbbab2
fix tests
alexvuong Feb 18, 2022
18b7bb9
lint
alexvuong Feb 18, 2022
bd8bf62
add mock config to window
alexvuong Feb 18, 2022
0db5088
fix tests
alexvuong Feb 23, 2022
ea61f81
PR feedback
alexvuong Feb 24, 2022
2c6f8b3
fix some tests for route-utils
alexvuong Feb 24, 2022
3bd74ec
fix some tests for site-utils
alexvuong Feb 24, 2022
5228d11
Merge branch 'develop' into feat/multi-site-config
alexvuong Feb 24, 2022
86116f7
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 24, 2022
6a9b10d
lint
alexvuong Feb 24, 2022
6ed8adc
fix tests
alexvuong Feb 24, 2022
341c1a5
adjust lighthouse
alexvuong Feb 24, 2022
ffcc5ff
get rid of getSupportedIds
alexvuong Feb 24, 2022
7a1237c
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 24, 2022
47b9a1c
remove console
alexvuong Feb 24, 2022
f2ba482
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 24, 2022
0f2e424
fix some more tests
alexvuong Feb 24, 2022
f202ae3
restore lighthouserc.js
alexvuong Feb 24, 2022
fe58628
apply getDefaultPath in some places
alexvuong Feb 24, 2022
3431d4c
remove console
alexvuong Feb 24, 2022
fce7687
minor adjustment
alexvuong Feb 25, 2022
f83a380
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Feb 25, 2022
579502c
change getDefaultPathname to createPathWithDefaults, and remove its u…
alexvuong Feb 26, 2022
798c18d
adjust the logic to only create routes for site and locale as a pair …
alexvuong Mar 1, 2022
7a9d0d6
use regexp to identify site and locale from url, add showDefaults log…
alexvuong Mar 2, 2022
e126734
clean up
alexvuong Mar 2, 2022
cc09daa
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 2, 2022
6745449
clean up
alexvuong Mar 2, 2022
b7b3555
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 2, 2022
cc67354
fix tests
alexvuong Mar 3, 2022
46850e3
add showDefaults flag to default.json
alexvuong Mar 3, 2022
dc33a0a
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 3, 2022
1e11e6f
git getLocale to get the locale id based on locale identifier in the url
alexvuong Mar 3, 2022
1162ef7
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 3, 2022
f4249d4
getLocale return id instead of an object
alexvuong Mar 3, 2022
c6c9c85
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 3, 2022
4558197
Merge branch 'develop' into feat/multi-site-config
alexvuong Mar 7, 2022
0439aab
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 7, 2022
65bf87a
Update with develop
bendvc Mar 8, 2022
2d18619
Fix config asset in generator
bendvc Mar 8, 2022
dbe7353
Site aliases should be nullable
bendvc Mar 8, 2022
e3fb5c6
add a guarding if there is not locale found in getLocale
alexvuong Mar 8, 2022
9299ca5
adjust configureRoute to take urlConfig into consideration
alexvuong Mar 9, 2022
559729d
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 9, 2022
1e2a961
Reduct regexp to just site and locale, add tests for getParamsFromPath
alexvuong Mar 9, 2022
deca12a
fix regex matcher
alexvuong Mar 9, 2022
ab4b24c
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 9, 2022
8e7ff1f
Merge branch 'develop' into feat/multi-site-config
alexvuong Mar 9, 2022
08ac252
lint
alexvuong Mar 9, 2022
b1a2d38
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 9, 2022
c4deb9e
fix tests
alexvuong Mar 9, 2022
f5fce69
fix tests
alexvuong Mar 9, 2022
6fd36db
Remove old serialization of config.
bendvc Mar 9, 2022
000e7af
Merge branch 'develop' into feat/multi-site-config
alexvuong Mar 9, 2022
5bdfe4f
add more test cases for getParamsFromPath
alexvuong Mar 9, 2022
9968159
PR feedback
alexvuong Mar 9, 2022
2208c56
Merge branch 'feat/multi-site-config' into multi-site-test-suites-fix
alexvuong Mar 9, 2022
424abfa
fix more tests
alexvuong Mar 9, 2022
7cbfea6
Fix failing tests for multi-site implementation (#396)
alexvuong Mar 9, 2022
b2afde6
Merge branch 'feat/multi-site-config' of github.com:SalesforceCommerc…
alexvuong Mar 9, 2022
68de4d8
[Multi-site] Change generator default project for two presets to sing…
alexvuong Mar 10, 2022
ebbffa3
Merge branch 'multi-site-test-suites-fix' into feat/multi-site-config
alexvuong Mar 10, 2022
88219c7
bring Redirect back to account page, create useLocale hook, remove sa…
alexvuong Mar 10, 2022
b05e67f
comment out some optional props for generated project default asset
alexvuong Mar 10, 2022
75303b0
locale.js: some refactoring for better clarity
vmarta Mar 10, 2022
80dbf5a
Merge branch 'feat/multi-site-config' of github.com:SalesforceCommerc…
alexvuong Mar 10, 2022
c0dfae7
PR feedback
alexvuong Mar 11, 2022
5b5e739
add more test cases for homeUrlBuilder
alexvuong Mar 11, 2022
c83262f
fix tests
alexvuong Mar 11, 2022
91f1aaf
fix comment
alexvuong Mar 11, 2022
a919bca
PR feedback
alexvuong Mar 11, 2022
08917b6
Merge branch 'develop' into feat/multi-site-config
alexvuong Mar 11, 2022
3a62984
fix tests
alexvuong Mar 11, 2022
f5585df
add more tests for site-utils
alexvuong Mar 12, 2022
4820afd
Minor tweaks for the recent PR feedback
vmarta Mar 12, 2022
777731b
change * to ? for pathPattern regex
alexvuong Mar 12, 2022
88cce7d
add tests for useSite, useLocale. Fix homeUrlBuilder
alexvuong Mar 12, 2022
c9345ef
Tweak siteMock to have correct key
vmarta Mar 12, 2022
7e6cdaf
PR feedback
alexvuong Mar 14, 2022
e1e04ca
Merge branch 'feat/multi-site-config' of github.com:SalesforceCommerc…
alexvuong Mar 14, 2022
3c2111e
Edit comment for generator default.js
alexvuong Mar 14, 2022
2cf4956
use clearAllMocks instead of resetMocks
alexvuong Mar 14, 2022
5e00f81
Add resolveLocaleFromUrl to resolve locale, remove getLocale, and get…
alexvuong Mar 14, 2022
e3369f2
change default locale of react-intl to en-US and npm script, fix erro…
alexvuong Mar 14, 2022
9ed9ffa
fix tests
alexvuong Mar 14, 2022
3af6bd7
add readme for multi-site config, fix tests
alexvuong Mar 14, 2022
1a59e8c
fix wordings
alexvuong Mar 14, 2022
5a7690f
Remove console, PR feedback for README
alexvuong Mar 15, 2022
f9acd81
Merge branch 'develop' into feat/multi-site-config
alexvuong Mar 15, 2022
fe18ee0
separate sites into a different file, fix wordings
alexvuong Mar 15, 2022
9dc606a
add file header
alexvuong Mar 15, 2022
0c1a227
adjust generator to create sites.js
alexvuong Mar 15, 2022
33c2dfe
adjust generator to create sites.js
alexvuong Mar 15, 2022
61fd0b0
locale.js: update its jsdoc
vmarta Mar 15, 2022
2c5d1a9
Merge branch 'feat/multi-site-config' of github.com:SalesforceCommerc…
alexvuong Mar 15, 2022
cab6eca
fix wording
alexvuong Mar 15, 2022
83529c3
use default locale if it is not defined in resolveLocaleFromUrl
alexvuong Mar 16, 2022
fd31d1d
Remove demo button on home page
alexvuong Mar 16, 2022
630be94
use default val when localeRef is not in the url
alexvuong Mar 16, 2022
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
29 changes: 27 additions & 2 deletions packages/pwa-kit-create-app/assets/pwa/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@
* 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
*/
exports.template = ({commerceApi, einsteinApi}) => `module.exports = {
exports.template = ({commerceApi, einsteinApi}) => `const sites = require('./sites.js')
module.exports = {
app: {
// Customize how your 'site' and 'locale' are displayed in the url.
url: {
locale: 'none'
// 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',
vmarta marked this conversation as resolved.
Show resolved Hide resolved
// 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/${commerceApi.proxyPath}\`,
parameters: {
Expand All @@ -18,23 +34,32 @@ exports.template = ({commerceApi, einsteinApi}) => `module.exports = {
siteId: '${commerceApi.siteId}'
}
},
// Einstein api config
einsteinAPI: {
proxyPath: \`/mobify/proxy/${einsteinApi.proxyPath}\`,
einsteinId: '${einsteinApi.einsteinId}',
siteId: '${einsteinApi.siteId}'
}
},
// 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: '14.x',
proxyConfigs: [
Expand Down
24 changes: 0 additions & 24 deletions packages/pwa-kit-create-app/assets/pwa/l10n.config.js

This file was deleted.

25 changes: 25 additions & 0 deletions packages/pwa-kit-create-app/assets/pwa/sites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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
*/
exports.template = () => `// 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'
}
]
}
}
]`
17 changes: 9 additions & 8 deletions packages/pwa-kit-create-app/scripts/create-mobify-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,28 +132,26 @@ const runGenerator = (answers, {outputDir}) => {

extractTemplate('pwa', outputDir)

const {pkgLocalizationConfig} = require(`../assets/pwa/l10n.config`)
const pkgJsonPath = p.resolve(outputDir, 'package.json')
const pkgJSON = readJson(pkgJsonPath)
const pkgDataWithAnswers = merge(pkgJSON, answers['scaffold-pwa'])
const finalPkgData = merge(pkgDataWithAnswers, pkgLocalizationConfig)

npmInstallables.forEach((pkgName) => {
const keys = ['dependencies', 'devDependencies']
keys.forEach((key) => {
const deps = finalPkgData[key]
const deps = pkgDataWithAnswers[key]
if (deps && deps[pkgName]) {
deps[pkgName] = SDK_VERSION
}
})
})

writeJson(pkgJsonPath, finalPkgData)
writeJson(pkgJsonPath, pkgDataWithAnswers)

const manifest = p.resolve(outputDir, 'app', 'static', 'manifest.json')
replaceJSON(manifest, {
name: finalPkgData.siteName,
short_name: finalPkgData.siteName,
name: pkgDataWithAnswers.siteName,
short_name: pkgDataWithAnswers.siteName,
start_url: '/?homescreen=1',
icons: [
{
Expand All @@ -167,7 +165,8 @@ const runGenerator = (answers, {outputDir}) => {
]
})

const PWAKitConfigJsonTemplate = require(`../assets/pwa/default`).template
const PWAKitConfigTemplate = require(`../assets/pwa/default`).template
const PWAKitSitesTemplate = require(`../assets/pwa/sites`).template

const commerceApi = {
proxyPath: answers['scaffold-pwa'].mobify.ssrParameters.proxyConfigs[0].path,
Expand All @@ -182,10 +181,12 @@ const runGenerator = (answers, {outputDir}) => {
siteId: answers['einstein-api'].siteId || answers['commerce-api'].siteId
}

new sh.ShellString(PWAKitConfigJsonTemplate({commerceApi, einsteinApi})).to(
new sh.ShellString(PWAKitConfigTemplate({commerceApi, einsteinApi})).to(
p.resolve(outputDir, 'config', 'default.js')
)

new sh.ShellString(PWAKitSitesTemplate()).to(p.resolve(outputDir, 'config', 'sites.js'))

npmInstall(outputDir)
}

Expand Down
Loading