@salesforce/storefront-next-dev 0.1.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.txt +181 -0
- package/README.md +302 -0
- package/dist/cartridge-services/index.d.ts +60 -0
- package/dist/cartridge-services/index.d.ts.map +1 -0
- package/dist/cartridge-services/index.js +954 -0
- package/dist/cartridge-services/index.js.map +1 -0
- package/dist/cli.js +3373 -0
- package/dist/configs/react-router.config.d.ts +13 -0
- package/dist/configs/react-router.config.d.ts.map +1 -0
- package/dist/configs/react-router.config.js +36 -0
- package/dist/configs/react-router.config.js.map +1 -0
- package/dist/extensibility/templates/install-instructions.mdc.hbs +192 -0
- package/dist/extensibility/templates/uninstall-instructions.mdc.hbs +137 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2606 -0
- package/dist/index.js.map +1 -0
- package/dist/mrt/sfnext-server-chunk-DUt5XHAg.mjs +1 -0
- package/dist/mrt/sfnext-server-jiti-DjnmHo-6.mjs +10 -0
- package/dist/mrt/sfnext-server-jiti-DjnmHo-6.mjs.map +1 -0
- package/dist/mrt/ssr.d.ts +19 -0
- package/dist/mrt/ssr.d.ts.map +1 -0
- package/dist/mrt/ssr.mjs +246 -0
- package/dist/mrt/ssr.mjs.map +1 -0
- package/dist/mrt/streamingHandler.d.ts +11 -0
- package/dist/mrt/streamingHandler.d.ts.map +1 -0
- package/dist/mrt/streamingHandler.mjs +255 -0
- package/dist/mrt/streamingHandler.mjs.map +1 -0
- package/dist/react-router/Scripts.d.ts +36 -0
- package/dist/react-router/Scripts.d.ts.map +1 -0
- package/dist/react-router/Scripts.js +68 -0
- package/dist/react-router/Scripts.js.map +1 -0
- package/package.json +157 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Preset } from "@react-router/dev/config";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/react-router.config.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Storefront Next preset for React Router configuration.
|
|
7
|
+
* This preset enforces standard configuration for SFCC Storefront Next applications.
|
|
8
|
+
* Users cannot override these values - they will be validated and an error will be thrown if modified.
|
|
9
|
+
*/
|
|
10
|
+
declare function storefrontNextPreset(): Preset;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { storefrontNextPreset };
|
|
13
|
+
//# sourceMappingURL=react-router.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router.config.d.ts","names":[],"sources":["../../src/configs/react-router.config.ts"],"sourcesContent":[],"mappings":";;;;;;;;;iBAsBgB,oBAAA,CAAA,GAAwB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/configs/react-router.config.ts
|
|
2
|
+
/**
|
|
3
|
+
* Storefront Next preset for React Router configuration.
|
|
4
|
+
* This preset enforces standard configuration for SFCC Storefront Next applications.
|
|
5
|
+
* Users cannot override these values - they will be validated and an error will be thrown if modified.
|
|
6
|
+
*/
|
|
7
|
+
function storefrontNextPreset() {
|
|
8
|
+
const presetConfig = {
|
|
9
|
+
appDirectory: "./src",
|
|
10
|
+
buildDirectory: "build",
|
|
11
|
+
routeDiscovery: { mode: "initial" },
|
|
12
|
+
serverModuleFormat: "cjs",
|
|
13
|
+
ssr: true,
|
|
14
|
+
future: {
|
|
15
|
+
v8_middleware: true,
|
|
16
|
+
v8_viteEnvironmentApi: true
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
name: "storefront-next-preset",
|
|
21
|
+
reactRouterConfig: () => presetConfig,
|
|
22
|
+
reactRouterConfigResolved: ({ reactRouterConfig }) => {
|
|
23
|
+
const errors = [];
|
|
24
|
+
if (reactRouterConfig.routeDiscovery?.mode !== presetConfig.routeDiscovery.mode) errors.push(`routeDiscovery.mode: expected "${presetConfig.routeDiscovery.mode}", got "${reactRouterConfig.routeDiscovery?.mode}"`);
|
|
25
|
+
if (reactRouterConfig.serverModuleFormat !== presetConfig.serverModuleFormat) errors.push(`serverModuleFormat: expected "${presetConfig.serverModuleFormat}", got "${reactRouterConfig.serverModuleFormat}"`);
|
|
26
|
+
if (reactRouterConfig.ssr !== presetConfig.ssr) errors.push(`ssr: expected ${presetConfig.ssr}, got ${reactRouterConfig.ssr}`);
|
|
27
|
+
if (reactRouterConfig.future?.v8_middleware !== presetConfig.future.v8_middleware) errors.push(`future.v8_middleware: expected ${presetConfig.future.v8_middleware}, got ${reactRouterConfig.future?.v8_middleware}`);
|
|
28
|
+
if (reactRouterConfig.future?.v8_viteEnvironmentApi !== presetConfig.future.v8_viteEnvironmentApi) errors.push(`future.v8_viteEnvironmentApi: expected ${presetConfig.future.v8_viteEnvironmentApi}, got ${reactRouterConfig.future?.v8_viteEnvironmentApi}`);
|
|
29
|
+
if (errors.length > 0) throw new Error(`Storefront Next preset configuration was overridden. The following values must not be modified:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { storefrontNextPreset };
|
|
36
|
+
//# sourceMappingURL=react-router.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router.config.js","names":["errors: string[]"],"sources":["../../src/configs/react-router.config.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { Preset } from '@react-router/dev/config';\n\n/**\n * Storefront Next preset for React Router configuration.\n * This preset enforces standard configuration for SFCC Storefront Next applications.\n * Users cannot override these values - they will be validated and an error will be thrown if modified.\n */\nexport function storefrontNextPreset(): Preset {\n const presetConfig = {\n appDirectory: './src',\n buildDirectory: 'build',\n routeDiscovery: { mode: 'initial' as const },\n serverModuleFormat: 'cjs' as const,\n ssr: true,\n future: {\n v8_middleware: true,\n v8_viteEnvironmentApi: true,\n },\n };\n\n return {\n name: 'storefront-next-preset',\n reactRouterConfig: () => presetConfig,\n reactRouterConfigResolved: ({ reactRouterConfig }) => {\n // Validate that critical config values have not been overridden\n // Note: We don't validate appDirectory and buildDirectory because they get resolved\n // to absolute paths and we can't reliably determine the correct absolute path\n const errors: string[] = [];\n\n if (reactRouterConfig.routeDiscovery?.mode !== presetConfig.routeDiscovery.mode) {\n errors.push(\n `routeDiscovery.mode: expected \"${presetConfig.routeDiscovery.mode}\", got \"${reactRouterConfig.routeDiscovery?.mode}\"`\n );\n }\n\n if (reactRouterConfig.serverModuleFormat !== presetConfig.serverModuleFormat) {\n errors.push(\n `serverModuleFormat: expected \"${presetConfig.serverModuleFormat}\", got \"${reactRouterConfig.serverModuleFormat}\"`\n );\n }\n\n if (reactRouterConfig.ssr !== presetConfig.ssr) {\n errors.push(`ssr: expected ${presetConfig.ssr}, got ${reactRouterConfig.ssr}`);\n }\n\n if (reactRouterConfig.future?.v8_middleware !== presetConfig.future.v8_middleware) {\n errors.push(\n `future.v8_middleware: expected ${presetConfig.future.v8_middleware}, got ${reactRouterConfig.future?.v8_middleware}`\n );\n }\n\n if (reactRouterConfig.future?.v8_viteEnvironmentApi !== presetConfig.future.v8_viteEnvironmentApi) {\n errors.push(\n `future.v8_viteEnvironmentApi: expected ${presetConfig.future.v8_viteEnvironmentApi}, got ${reactRouterConfig.future?.v8_viteEnvironmentApi}`\n );\n }\n\n if (errors.length > 0) {\n throw new Error(\n `Storefront Next preset configuration was overridden. The following values must not be modified:\\n${errors.map((e) => ` - ${e}`).join('\\n')}`\n );\n }\n },\n };\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,uBAA+B;CAC3C,MAAM,eAAe;EACjB,cAAc;EACd,gBAAgB;EAChB,gBAAgB,EAAE,MAAM,WAAoB;EAC5C,oBAAoB;EACpB,KAAK;EACL,QAAQ;GACJ,eAAe;GACf,uBAAuB;GAC1B;EACJ;AAED,QAAO;EACH,MAAM;EACN,yBAAyB;EACzB,4BAA4B,EAAE,wBAAwB;GAIlD,MAAMA,SAAmB,EAAE;AAE3B,OAAI,kBAAkB,gBAAgB,SAAS,aAAa,eAAe,KACvE,QAAO,KACH,kCAAkC,aAAa,eAAe,KAAK,UAAU,kBAAkB,gBAAgB,KAAK,GACvH;AAGL,OAAI,kBAAkB,uBAAuB,aAAa,mBACtD,QAAO,KACH,iCAAiC,aAAa,mBAAmB,UAAU,kBAAkB,mBAAmB,GACnH;AAGL,OAAI,kBAAkB,QAAQ,aAAa,IACvC,QAAO,KAAK,iBAAiB,aAAa,IAAI,QAAQ,kBAAkB,MAAM;AAGlF,OAAI,kBAAkB,QAAQ,kBAAkB,aAAa,OAAO,cAChE,QAAO,KACH,kCAAkC,aAAa,OAAO,cAAc,QAAQ,kBAAkB,QAAQ,gBACzG;AAGL,OAAI,kBAAkB,QAAQ,0BAA0B,aAAa,OAAO,sBACxE,QAAO,KACH,0CAA0C,aAAa,OAAO,sBAAsB,QAAQ,kBAAkB,QAAQ,wBACzH;AAGL,OAAI,OAAO,SAAS,EAChB,OAAM,IAAI,MACN,oGAAoG,OAAO,KAAK,MAAM,OAAO,IAAI,CAAC,KAAK,KAAK,GAC/I;;EAGZ"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
These are the steps to update an existing store front application (currently opened project) with the "{{extensionName}}" extension by installing the necessary code to the destination application.
|
|
2
|
+
- Follow these instructions carefully and precisely, do NOT deviate from them.
|
|
3
|
+
- Mark the time it takes for each step and report them in the end.
|
|
4
|
+
|
|
5
|
+
# Step 1. Prerequisites: First make sure the current project has all the necessary files. If any requirement in the prerequisite is not met, abort the rest of this instruction.
|
|
6
|
+
<Prerequisites>
|
|
7
|
+
{{#if dependencies.length}}
|
|
8
|
+
## Dependencies Check
|
|
9
|
+
The following extensions must be installed before {{extensionName}}:
|
|
10
|
+
{{#each dependencies}}
|
|
11
|
+
- {{this.name}} ({{this.key}})
|
|
12
|
+
{{/each}}
|
|
13
|
+
|
|
14
|
+
Check if each dependency is present in `src/extensions/config.json`. If any dependency is missing, inform the user: "The extension '{{dependencies.[0].name}}' is required but not installed. Please install {{dependencies.[0].name}} first before installing {{extensionName}}." and abort this instruction.
|
|
15
|
+
{{/if}}
|
|
16
|
+
|
|
17
|
+
## Required Files
|
|
18
|
+
{{#each mergeFiles as |mergeFile|}}
|
|
19
|
+
- The file `{{mergeFile}}` exists
|
|
20
|
+
{{/each}}
|
|
21
|
+
</Prerequisites>
|
|
22
|
+
|
|
23
|
+
# Step 2. Preparations: Clone the pwa-kit repo for the specific branch into the tmp folder
|
|
24
|
+
<Preparations>
|
|
25
|
+
- Create a folder `pwa-kit-tmp` under the system's temp folder, e.g., `/tmp/pwa-kit-tmp` or 'C:/temp/pwa-kit-tmp'
|
|
26
|
+
- Clone the pwa-kit repo for the specific branch into the tmp folder: Run `git clone -b {{branch}} {{pwaRepo}} /tmp/pwa-kit-tmp`
|
|
27
|
+
</Preparations>
|
|
28
|
+
|
|
29
|
+
# Step 3. Copy:
|
|
30
|
+
<Copy>
|
|
31
|
+
{{#each copy as |copy|}}
|
|
32
|
+
{{#if copy.isDirectory}}
|
|
33
|
+
- From the cloned pwa-kit folder, copy `{{copy.src}}` folder into the current directory's `{{copy.dest}}` folder.
|
|
34
|
+
{{else}}
|
|
35
|
+
- From the cloned pwa-kit folder, copy `{{copy.src}}` file into the current directory's `{{copy.dest}}` file.
|
|
36
|
+
{{/if}}
|
|
37
|
+
{{/each}}
|
|
38
|
+
</Copy>
|
|
39
|
+
|
|
40
|
+
# Step 4. Merge. Apply the following code changes to the files specified. Skip a step if the code change has already been applied.
|
|
41
|
+
<Merge>
|
|
42
|
+
- Go through the following source files in /tmp/pwa-kit-tmp one by one, then perform the following instructions with the marker value "{{markerValue}}":
|
|
43
|
+
{{#each mergeFiles as |mergeFile|}}
|
|
44
|
+
- `{{mergeFile}}`
|
|
45
|
+
{{/each}}
|
|
46
|
+
|
|
47
|
+
<MergeInstructions>
|
|
48
|
+
Your job is find ALL the code snippets marked by special comment markers from a source file, and insert them into the destination file, which is the same file under the current project.
|
|
49
|
+
|
|
50
|
+
There are two types of comment markers:
|
|
51
|
+
1. A single line comment marker: "@sfdc-extension-line <marker value>". It is a single line comment that contains the string "@sfdc-extension-line" and a marker value, separated by a space, for example, "@sfdc-extension-line SFDC_EXT_STORE_LOCATOR".
|
|
52
|
+
2. A pair of block comment markers: "@sfdc-extension-block-start <marker value>" and "@sfdc-extension-block-end <marker value>". They are two separate comment lines that marks the start and end of a code block, with the same marker value, for example, "@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR" and "@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR".
|
|
53
|
+
|
|
54
|
+
# Step 1
|
|
55
|
+
1.1 Make a copy of the original source file before it's modified, with the ".original" extension. For example "src/components/footer/index.tsx" is copied to "src/components/footer/index.tsx.original"
|
|
56
|
+
|
|
57
|
+
# Step 2
|
|
58
|
+
There may be multiple code snippets marked by the same line marker value. Perform the action in these steps from the beginning of the source file:
|
|
59
|
+
2.1. Search for the line marker with the given marker value, e.g., "@sfdc-extension-line SFDC_EXT_STORE_LOCATOR".
|
|
60
|
+
2.2. If found, copy the comment line and the immediate line below it,
|
|
61
|
+
2.3. Insert them into the destination file at the same or similar location where the code was found in the source file.
|
|
62
|
+
2.4. Repeat the steps 2.1-2.3 from the next line until no more matching comment markers are found.
|
|
63
|
+
|
|
64
|
+
# Step 3
|
|
65
|
+
There may be multiple code snippets marked by the same block marker value. Perform the action in these steps from the beginning of the source file:
|
|
66
|
+
3.1. Search for the beginning comment marker with the given marker value, e.g., "@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR".
|
|
67
|
+
3.2. If found, search for the ending comment marker with the given marker value, e.g., "@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR".
|
|
68
|
+
3.3. If found, copy the comment lines and the code block between them,
|
|
69
|
+
3.4. Insert them into the destination file at the same or similar location where the code was found in the source file.
|
|
70
|
+
3.5. Repeat the steps 3.1-3.4 from the next line until no more matching block comment markers are found.
|
|
71
|
+
|
|
72
|
+
Do NOT include code marked by a different marker.
|
|
73
|
+
Do NOT modify any code unrelated to the marked code.
|
|
74
|
+
|
|
75
|
+
For example, when the comment marker is "@sfdc-extension-line SFDC_EXT_STORE_LOCATOR".
|
|
76
|
+
|
|
77
|
+
Source file:
|
|
78
|
+
```javascript
|
|
79
|
+
const Header = ({
|
|
80
|
+
children,
|
|
81
|
+
onMenuClick = noop,
|
|
82
|
+
onMyAccountClick = noop,
|
|
83
|
+
onLogoClick = noop,
|
|
84
|
+
onMyCartClick = noop,
|
|
85
|
+
//@sfdc-extension-line SFDC_EXT_WISHLIST
|
|
86
|
+
onWishlistClick = noop,
|
|
87
|
+
// @sfdc-extension-line SFDC_EXT_STORE_LOCATOR
|
|
88
|
+
onStoreLocatorClick = noop,
|
|
89
|
+
...props
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Destination file:
|
|
94
|
+
```javascript
|
|
95
|
+
const Header = ({
|
|
96
|
+
children,
|
|
97
|
+
onMenuClick = noop,
|
|
98
|
+
onMyAccountClick = noop,
|
|
99
|
+
onLogoClick = noop,
|
|
100
|
+
onMyCartClick = noop,
|
|
101
|
+
...props
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Output:
|
|
106
|
+
```javascript
|
|
107
|
+
const Header = ({
|
|
108
|
+
children,
|
|
109
|
+
onMenuClick = noop,
|
|
110
|
+
onMyAccountClick = noop,
|
|
111
|
+
onLogoClick = noop,
|
|
112
|
+
onMyCartClick = noop,
|
|
113
|
+
// @sfdc-extension-line SFDC_EXT_STORE_LOCATOR
|
|
114
|
+
onStoreLocatorClick = noop,
|
|
115
|
+
...props
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
Note that in the destination file, there is no code snippet marked by the comment marker "@sfdc-extension-line SFDC_EXT_WISHLIST", because the marker value is SFDC_EXT_STORE_LOCATOR, not SFDC_EXT_WISHLIST.
|
|
119
|
+
|
|
120
|
+
Another example, when a block of code is marked with the beginning comment marker "@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR" and ending marker "@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR".
|
|
121
|
+
|
|
122
|
+
Source file:
|
|
123
|
+
```javascript
|
|
124
|
+
logOut: formatMessage( {
|
|
125
|
+
defaultMessage: 'Log out',
|
|
126
|
+
id: 'header.popover.action.log_out'
|
|
127
|
+
})
|
|
128
|
+
//@sfdc-extension-block-start SFDC_EXT_WISHLIST
|
|
129
|
+
wishlist: formatMessage( {
|
|
130
|
+
defaultMessage: 'Wishlist',
|
|
131
|
+
id: 'header.button.assistive_msg.wishlist'
|
|
132
|
+
})
|
|
133
|
+
//@sfdc-extension-block-end SFDC_EXT_WISHLIST
|
|
134
|
+
//@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR
|
|
135
|
+
storeLocator: formatMessage( {
|
|
136
|
+
defaultMessage: 'Store Locator',
|
|
137
|
+
id: 'header.button.assistive_msg.store_locator'
|
|
138
|
+
})
|
|
139
|
+
//@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR
|
|
140
|
+
myCartWithItems: formatMessage( {
|
|
141
|
+
{
|
|
142
|
+
id: 'header.button.assistive_msg.my_cart_with_num_items',
|
|
143
|
+
defaultMessage: 'My cart, number of items: {numItems}'
|
|
144
|
+
},
|
|
145
|
+
{numItems: totalItems}
|
|
146
|
+
})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Destination file:
|
|
150
|
+
```javascript
|
|
151
|
+
logOut: formatMessage({
|
|
152
|
+
defaultMessage: 'Log out',
|
|
153
|
+
id: 'header.popover.action.log_out'
|
|
154
|
+
})
|
|
155
|
+
myCartWithItems: formatMessage( {
|
|
156
|
+
{
|
|
157
|
+
id: 'header.button.assistive_msg.my_cart_with_num_items',
|
|
158
|
+
defaultMessage: 'My cart, number of items: {numItems}'
|
|
159
|
+
},
|
|
160
|
+
{numItems: totalItems}
|
|
161
|
+
})
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Output:
|
|
165
|
+
```javascript
|
|
166
|
+
logOut: formatMessage({
|
|
167
|
+
defaultMessage: 'Log out',
|
|
168
|
+
id: 'header.popover.action.log_out'
|
|
169
|
+
})
|
|
170
|
+
//@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR
|
|
171
|
+
storeLocator: formatMessage({
|
|
172
|
+
defaultMessage: 'Store Locator',
|
|
173
|
+
id: 'header.button.assistive_msg.store_locator'
|
|
174
|
+
})
|
|
175
|
+
//@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR
|
|
176
|
+
myCartWithItems: formatMessage( {
|
|
177
|
+
{
|
|
178
|
+
id: 'header.button.assistive_msg.my_cart_with_num_items',
|
|
179
|
+
defaultMessage: 'My cart, number of items: {numItems}'
|
|
180
|
+
},
|
|
181
|
+
{numItems: totalItems}
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Note that in the destination file, there is no code snippet marked by the comment markers "@sfdc-extension-block-start SFDC_EXT_WISHLIST" and "@sfdc-extension-block-end SFDC_EXT_WISHLIST", because the marker value is SFDC_EXT_STORE_LOCATOR, not SFDC_EXT_WISHLIST.
|
|
186
|
+
</MergeInstructions>
|
|
187
|
+
</Merge>
|
|
188
|
+
|
|
189
|
+
# Step 5. Cleanup: Delete the `pwa-kit-tmp` folder and its contents.
|
|
190
|
+
<Cleanup>
|
|
191
|
+
From under the temp folder, delete the `pwa-kit-tmp` folder and its contents.
|
|
192
|
+
</Cleanup>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
These are the steps to remove the "{{extensionName}}" extension from an existing store front application (currently opened project). Follow these instructions carefully and precisely, do NOT deviate from them.
|
|
2
|
+
|
|
3
|
+
# Step 1. Prerequisites: First make sure the current project has all the necessary files. If any requirement in the prerequisite is not met, abort the rest of this instruction.
|
|
4
|
+
<Prerequisites>
|
|
5
|
+
{{#each mergeFiles as |mergeFile|}}
|
|
6
|
+
- The file `{{mergeFile}}` exists
|
|
7
|
+
{{/each}}
|
|
8
|
+
</Prerequisites>
|
|
9
|
+
|
|
10
|
+
# Step 2. Delete files.
|
|
11
|
+
<Delete>
|
|
12
|
+
{{#each copy as |copy|}}
|
|
13
|
+
{{#if copy.isDirectory}}
|
|
14
|
+
- Delete the `{{copy.dest}}` folder and all its contents.
|
|
15
|
+
{{else}}
|
|
16
|
+
- Delete the `{{copy.dest}}` file.
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{/each}}
|
|
19
|
+
</Delete>
|
|
20
|
+
|
|
21
|
+
# Step 3. Merge. Apply the following code changes to the files specified.
|
|
22
|
+
<Merge>
|
|
23
|
+
- Go through the following source files one by one, then perform the following instructions with the marker value "{{markerValue}}":
|
|
24
|
+
{{#each mergeFiles as |mergeFile|}}
|
|
25
|
+
- `{{mergeFile}}`
|
|
26
|
+
{{/each}}
|
|
27
|
+
|
|
28
|
+
<MergeInstructions>
|
|
29
|
+
Your job is find ALL the code snippets marked by special comment markers in the given source file and remove them.
|
|
30
|
+
|
|
31
|
+
There are two types of comment markers:
|
|
32
|
+
1. A single line comment marker: "@sfdc-extension-line <marker value>". It is a single line comment that contains the string "@sfdc-extension-line" and a marker value, separated by a space, for example, "@sfdc-extension-line SFDC_EXT_STORE_LOCATOR".
|
|
33
|
+
2. A pair of block comment markers: "@sfdc-extension-block-start <marker value>" and "@sfdc-extension-block-end <marker value>". They are two separate comment lines that marks the start and end of a code block, with the same marker value, for example, "@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR" and "@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR".
|
|
34
|
+
|
|
35
|
+
# Step 1
|
|
36
|
+
There may be multiple code snippets marked by the same line marker value. Perform the action in these steps from the beginning of the source file:
|
|
37
|
+
1.1. Search for the line marker with the given marker value, e.g., "@sfdc-extension-line SFDC_EXT_STORE_LOCATOR".
|
|
38
|
+
1.2. If found, remove the comment line and the immediate line below it,
|
|
39
|
+
1.3. Repeat the steps 1.1-1.2 from the next line until no more matching comment markers are found.
|
|
40
|
+
|
|
41
|
+
# Step 2
|
|
42
|
+
There may be multiple code snippets marked by the same block marker value. Perform the action in these steps from the beginning of the source file:
|
|
43
|
+
2.1. Search for the beginning comment marker with the given marker value, e.g., "@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR".
|
|
44
|
+
2.2. If found, search for the ending comment marker with the given marker value, e.g., "@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR".
|
|
45
|
+
2.3. If found, remove the comment lines and the code block between them.
|
|
46
|
+
2.4. Repeat the steps 2.1-2.3 from the next line until no more matching block comment markers are found.
|
|
47
|
+
|
|
48
|
+
Do NOT remove code marked by a different marker.
|
|
49
|
+
Do NOT modify any code unrelated to the marked code.
|
|
50
|
+
|
|
51
|
+
For example, when the comment marker is "@sfdc-extension-line SFDC_EXT_STORE_LOCATOR".
|
|
52
|
+
|
|
53
|
+
Input:
|
|
54
|
+
```javascript
|
|
55
|
+
const Header = ({
|
|
56
|
+
children,
|
|
57
|
+
onMenuClick = noop,
|
|
58
|
+
onMyAccountClick = noop,
|
|
59
|
+
onLogoClick = noop,
|
|
60
|
+
onMyCartClick = noop,
|
|
61
|
+
//@sfdc-extension-line SFDC_EXT_WISHLIST
|
|
62
|
+
onWishlistClick = noop,
|
|
63
|
+
// @sfdc-extension-line SFDC_EXT_STORE_LOCATOR
|
|
64
|
+
onStoreLocatorClick = noop,
|
|
65
|
+
...props
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Output:
|
|
70
|
+
```javascript
|
|
71
|
+
const Header = ({
|
|
72
|
+
children,
|
|
73
|
+
onMenuClick = noop,
|
|
74
|
+
onMyAccountClick = noop,
|
|
75
|
+
onLogoClick = noop,
|
|
76
|
+
onMyCartClick = noop,
|
|
77
|
+
//@sfdc-extension-line SFDC_EXT_WISHLIST
|
|
78
|
+
onWishlistClick = noop,
|
|
79
|
+
...props
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Note that in the output file, the code snippet marked by the comment marker "@sfdc-extension-line SFDC_EXT_WISHLIST" is not removed, because the marker value is SFDC_EXT_STORE_LOCATOR, not SFDC_EXT_WISHLIST.
|
|
84
|
+
|
|
85
|
+
Another example, when a block of code is marked with the beginning comment marker "@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR" and ending marker "@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR".
|
|
86
|
+
|
|
87
|
+
Input:
|
|
88
|
+
```javascript
|
|
89
|
+
logOut: formatMessage( {
|
|
90
|
+
defaultMessage: 'Log out',
|
|
91
|
+
id: 'header.popover.action.log_out'
|
|
92
|
+
})
|
|
93
|
+
//@sfdc-extension-block-start SFDC_EXT_WISHLIST
|
|
94
|
+
wishlist: formatMessage( {
|
|
95
|
+
defaultMessage: 'Wishlist',
|
|
96
|
+
id: 'header.button.assistive_msg.wishlist'
|
|
97
|
+
})
|
|
98
|
+
//@sfdc-extension-block-end SFDC_EXT_WISHLIST
|
|
99
|
+
//@sfdc-extension-block-start SFDC_EXT_STORE_LOCATOR
|
|
100
|
+
storeLocator: formatMessage( {
|
|
101
|
+
defaultMessage: 'Store Locator',
|
|
102
|
+
id: 'header.button.assistive_msg.store_locator'
|
|
103
|
+
})
|
|
104
|
+
//@sfdc-extension-block-end SFDC_EXT_STORE_LOCATOR
|
|
105
|
+
myCartWithItems: formatMessage( {
|
|
106
|
+
{
|
|
107
|
+
id: 'header.button.assistive_msg.my_cart_with_num_items',
|
|
108
|
+
defaultMessage: 'My cart, number of items: {numItems}'
|
|
109
|
+
},
|
|
110
|
+
{numItems: totalItems}
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Output:
|
|
115
|
+
```javascript
|
|
116
|
+
logOut: formatMessage({
|
|
117
|
+
defaultMessage: 'Log out',
|
|
118
|
+
id: 'header.popover.action.log_out'
|
|
119
|
+
})
|
|
120
|
+
//@sfdc-extension-block-start SFDC_EXT_WISHLIST
|
|
121
|
+
wishlist: formatMessage( {
|
|
122
|
+
defaultMessage: 'Wishlist',
|
|
123
|
+
id: 'header.button.assistive_msg.wishlist'
|
|
124
|
+
})
|
|
125
|
+
//@sfdc-extension-block-end SFDC_EXT_WISHLIST
|
|
126
|
+
myCartWithItems: formatMessage( {
|
|
127
|
+
{
|
|
128
|
+
id: 'header.button.assistive_msg.my_cart_with_num_items',
|
|
129
|
+
defaultMessage: 'My cart, number of items: {numItems}'
|
|
130
|
+
},
|
|
131
|
+
{numItems: totalItems}
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Note that in the destination file, the code snippet marked by the comment markers "@sfdc-extension-block-start SFDC_EXT_WISHLIST" and "@sfdc-extension-block-end SFDC_EXT_WISHLIST" is not removed, because the marker value is SFDC_EXT_STORE_LOCATOR, not SFDC_EXT_WISHLIST.
|
|
136
|
+
</MergeInstructions>
|
|
137
|
+
</Merge>
|