Skip to content

Commit d3b026c

Browse files
authored
Merge branch 'develop' into W-18685522-reset-and-passwordless-integration-test
2 parents 0123c9e + bf59a88 commit d3b026c

File tree

4 files changed

+76
-24
lines changed

4 files changed

+76
-24
lines changed

packages/pwa-kit-create-app/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
- Add `program.json` + Support for Agent-Friendly CLI Input via stdio [#2662](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2662)
44
- Change the default ECOM instance in the generated application [#2610](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2610)
55
- Load active data scripts on demand only [#2623](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2623)
6-
- Introduce the cursor rules to assist storefront project developers [#2578] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2578)
6+
- Introduce the cursor rules to assist storefront project developers [#2578](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2578) [#2754](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2754)
7+
- Add `StoreLocatorProvider` to the `AppConfig` template to support BOPIS [#2753](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2753)
78

89
## v3.10.0 (May 22, 2025)
910
- Add Data Cloud API configuration to `default.js`. [#2318](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2318)

packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/components/_app-config/index.jsx.hbs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {ChakraProvider} from '@salesforce/retail-react-app/app/components/shared
1212
import 'focus-visible/dist/focus-visible'
1313

1414
import theme from '@salesforce/retail-react-app/app/theme'
15-
import {MultiSiteProvider} from '@salesforce/retail-react-app/app/contexts'
15+
import {MultiSiteProvider, StoreLocatorProvider} from '@salesforce/retail-react-app/app/contexts'
1616
import {
1717
resolveSiteFromUrl,
1818
resolveLocaleFromUrl
@@ -27,7 +27,16 @@ import {withReactQuery} from '@salesforce/pwa-kit-react-sdk/ssr/universal/compon
2727
import {useCorrelationId} from '@salesforce/pwa-kit-react-sdk/ssr/universal/hooks'
2828
import {getAppOrigin} from '@salesforce/pwa-kit-react-sdk/utils/url'
2929
import {ReactQueryDevtools} from '@tanstack/react-query-devtools'
30-
import {DEFAULT_DNT_STATE} from '@salesforce/retail-react-app/app/constants'
30+
import {
31+
DEFAULT_DNT_STATE,
32+
STORE_LOCATOR_RADIUS,
33+
STORE_LOCATOR_RADIUS_UNIT,
34+
STORE_LOCATOR_DEFAULT_COUNTRY,
35+
STORE_LOCATOR_DEFAULT_COUNTRY_CODE,
36+
STORE_LOCATOR_DEFAULT_POSTAL_CODE,
37+
STORE_LOCATOR_DEFAULT_PAGE_SIZE,
38+
STORE_LOCATOR_SUPPORTED_COUNTRIES
39+
} from '@salesforce/retail-react-app/app/constants'
3140

3241
/**
3342
* Use the AppConfig component to inject extra arguments into the getProps
@@ -49,6 +58,16 @@ const AppConfig = ({children, locals = {}}) => {
4958

5059
const passwordlessCallback = locals.appConfig.login?.passwordless?.callbackURI
5160

61+
const storeLocatorConfig = {
62+
radius: STORE_LOCATOR_RADIUS,
63+
radiusUnit: STORE_LOCATOR_RADIUS_UNIT,
64+
defaultCountry: STORE_LOCATOR_DEFAULT_COUNTRY,
65+
defaultCountryCode: STORE_LOCATOR_DEFAULT_COUNTRY_CODE,
66+
defaultPostalCode: STORE_LOCATOR_DEFAULT_POSTAL_CODE,
67+
defaultPageSize: STORE_LOCATOR_DEFAULT_PAGE_SIZE,
68+
supportedCountries: STORE_LOCATOR_SUPPORTED_COUNTRIES
69+
}
70+
5271
return (
5372
<CommerceApiProvider
5473
shortCode={commerceApiConfig.parameters.shortCode}
@@ -70,7 +89,9 @@ const AppConfig = ({children, locals = {}}) => {
7089
{{/if}}
7190
>
7291
<MultiSiteProvider site={locals.site} locale={locals.locale} buildUrl={locals.buildUrl}>
73-
<ChakraProvider theme={theme}>{children}</ChakraProvider>
92+
<StoreLocatorProvider config={storeLocatorConfig}>
93+
<ChakraProvider theme={theme}>{children}</ChakraProvider>
94+
</StoreLocatorProvider>
7495
</MultiSiteProvider>
7596
<ReactQueryDevtools />
7697
</CommerceApiProvider>

packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/components/_app-config/index.jsx.hbs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {ChakraProvider} from '@salesforce/retail-react-app/app/components/shared
1212
import 'focus-visible/dist/focus-visible'
1313

1414
import theme from '@salesforce/retail-react-app/app/theme'
15-
import {MultiSiteProvider} from '@salesforce/retail-react-app/app/contexts'
15+
import {MultiSiteProvider, StoreLocatorProvider} from '@salesforce/retail-react-app/app/contexts'
1616
import {useAppOrigin} from '@salesforce/retail-react-app/app/hooks/use-app-origin'
1717
import {
1818
resolveSiteFromUrl,
@@ -28,6 +28,15 @@ import {withReactQuery} from '@salesforce/pwa-kit-react-sdk/ssr/universal/compon
2828
import {useCorrelationId} from '@salesforce/pwa-kit-react-sdk/ssr/universal/hooks'
2929
import {ReactQueryDevtools} from '@tanstack/react-query-devtools'
3030
import {DEFAULT_DNT_STATE} from '@salesforce/retail-react-app/app/constants'
31+
import {
32+
STORE_LOCATOR_RADIUS,
33+
STORE_LOCATOR_RADIUS_UNIT,
34+
STORE_LOCATOR_DEFAULT_COUNTRY,
35+
STORE_LOCATOR_DEFAULT_COUNTRY_CODE,
36+
STORE_LOCATOR_DEFAULT_POSTAL_CODE,
37+
STORE_LOCATOR_DEFAULT_PAGE_SIZE,
38+
STORE_LOCATOR_SUPPORTED_COUNTRIES
39+
} from '@salesforce/retail-react-app/app/constants'
3140

3241
/**
3342
* Use the AppConfig component to inject extra arguments into the getProps
@@ -49,6 +58,16 @@ const AppConfig = ({children, locals = {}}) => {
4958

5059
const passwordlessCallback = locals.appConfig.login?.passwordless?.callbackURI
5160

61+
const storeLocatorConfig = {
62+
radius: STORE_LOCATOR_RADIUS,
63+
radiusUnit: STORE_LOCATOR_RADIUS_UNIT,
64+
defaultCountry: STORE_LOCATOR_DEFAULT_COUNTRY,
65+
defaultCountryCode: STORE_LOCATOR_DEFAULT_COUNTRY_CODE,
66+
defaultPostalCode: STORE_LOCATOR_DEFAULT_POSTAL_CODE,
67+
defaultPageSize: STORE_LOCATOR_DEFAULT_PAGE_SIZE,
68+
supportedCountries: STORE_LOCATOR_SUPPORTED_COUNTRIES
69+
}
70+
5271
return (
5372
<CommerceApiProvider
5473
shortCode={commerceApiConfig.parameters.shortCode}
@@ -70,7 +89,9 @@ const AppConfig = ({children, locals = {}}) => {
7089
{{/if}}
7190
>
7291
<MultiSiteProvider site={locals.site} locale={locals.locale} buildUrl={locals.buildUrl}>
73-
<ChakraProvider theme={theme}>{children}</ChakraProvider>
92+
<StoreLocatorProvider config={storeLocatorConfig}>
93+
<ChakraProvider theme={theme}>{children}</ChakraProvider>
94+
</StoreLocatorProvider>
7495
</MultiSiteProvider>
7596
<ReactQueryDevtools />
7697
</CommerceApiProvider>

packages/pwa-kit-create-app/scripts/create-mobify-app.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -352,35 +352,28 @@ const runGenerator = (context, {outputDir, templateVersion, verbose}) => {
352352
assets.forEach((asset) => {
353353
sh.cp('-rf', p.join(packagePath, asset), outputDir)
354354
})
355-
356-
// Copy the .cursor/rules directory if it exists
357-
if (sh.test('-e', CURSOR_RULES_FROM_DIR)) {
358-
const outputCursorRulesDir = p.join(outputDir, '.cursor', 'rules')
359-
360-
// Create the directory if it doesn't exist
361-
if (!sh.test('-e', outputCursorRulesDir)) {
362-
fs.mkdirSync(outputCursorRulesDir, {recursive: true})
363-
}
364-
365-
// Copy the contents of CURSOR_RULES_FROM_DIR to outputCursorRulesDir
366-
const files = fs.readdirSync(CURSOR_RULES_FROM_DIR)
367-
files.forEach((file) => {
368-
sh.cp('-rf', p.join(CURSOR_RULES_FROM_DIR, file), outputCursorRulesDir)
369-
})
370-
}
371355
} else {
372356
console.log('Copying base template from package or npm: ', packagePath, outputDir)
373357
// Copy the base template either from the package or npm.
374358
sh.cp('-rf', packagePath, outputDir)
375359

376-
// Copy template specific assets over.
377-
const assetsDir = p.join(ASSETS_TEMPLATES_DIR, id)
360+
// Copy template specific assets over, if they exist.
361+
const assetsDir = p.join(ASSETS_TEMPLATES_DIR, source.name || id)
378362
if (sh.test('-e', assetsDir)) {
363+
console.log(`Copying template-specific assets from ${assetsDir}`)
379364
getFiles(assetsDir)
380365
.map((file) => file.replace(assetsDir, ''))
381366
.forEach((relFilePath) =>
382367
processTemplate(relFilePath, assetsDir, outputDir, context)
383368
)
369+
} else {
370+
// However, we expected to see assetsDir for retail-react-app template
371+
if (source.name === '@salesforce/retail-react-app') {
372+
console.error(
373+
`Error: cannot find template-specific assets for retail-react-app in directory ${assetsDir}`
374+
)
375+
process.exit(1)
376+
}
384377
}
385378

386379
// Update the generated projects version. NOTE: For bootstrapped projects this
@@ -398,6 +391,22 @@ const runGenerator = (context, {outputDir, templateVersion, verbose}) => {
398391
sh.rm('-rf', tmp)
399392
}
400393

394+
// Copy the .cursor/rules directory if it exists
395+
if (sh.test('-e', CURSOR_RULES_FROM_DIR)) {
396+
const outputCursorRulesDir = p.join(outputDir, '.cursor', 'rules')
397+
398+
// Create the directory if it doesn't exist
399+
if (!sh.test('-e', outputCursorRulesDir)) {
400+
fs.mkdirSync(outputCursorRulesDir, {recursive: true})
401+
}
402+
403+
// Copy the contents of CURSOR_RULES_FROM_DIR to outputCursorRulesDir
404+
const files = fs.readdirSync(CURSOR_RULES_FROM_DIR)
405+
files.forEach((file) => {
406+
sh.cp('-rf', p.join(CURSOR_RULES_FROM_DIR, file), outputCursorRulesDir)
407+
})
408+
}
409+
401410
// Install dependencies for the newly minted project.
402411
npmInstall(outputDir, {verbose})
403412
}

0 commit comments

Comments
 (0)