@bigcommerce/stencil-cli 5.1.0 → 5.2.1
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/CHANGELOG.md +9 -0
- package/README.md +9 -5
- package/bin/stencil.js +1 -0
- package/package-lock.json +3773 -3596
- package/package.json +2 -2
- package/server/index.js +2 -0
- package/server/plugins/renderer/renderer.module.js +17 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigcommerce/stencil-cli",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "CLI tool to run BigCommerce Stores locally for theme development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@commitlint/cli": "^11.0.0",
|
|
90
90
|
"@commitlint/config-conventional": "^11.0.0",
|
|
91
|
-
"axios-mock-adapter": "^1.
|
|
91
|
+
"axios-mock-adapter": "^1.21.2",
|
|
92
92
|
"conventional-changelog-cli": "^2.2.2",
|
|
93
93
|
"eslint": "^7.10.0",
|
|
94
94
|
"eslint-config-airbnb-base": "^14.2.0",
|
package/server/index.js
CHANGED
|
@@ -33,6 +33,8 @@ function buildManifest(srcManifest, options) {
|
|
|
33
33
|
pluginsByName['./plugins/renderer/renderer.module'].storeUrl = storeUrl;
|
|
34
34
|
pluginsByName['./plugins/renderer/renderer.module'].storeSettingsLocale =
|
|
35
35
|
options.storeSettingsLocale;
|
|
36
|
+
pluginsByName['./plugins/renderer/renderer.module'].customLayouts =
|
|
37
|
+
options.dotStencilFile.customLayouts;
|
|
36
38
|
pluginsByName['./plugins/theme-assets/theme-assets.module'].themePath = options.themePath;
|
|
37
39
|
|
|
38
40
|
resManifest.register.plugins = _.reduce(
|
|
@@ -21,6 +21,7 @@ const {
|
|
|
21
21
|
} = require('../../../lib/utils/frontmatter');
|
|
22
22
|
|
|
23
23
|
const networkUtils = new NetworkUtils();
|
|
24
|
+
const { DEFAULT_CUSTOM_LAYOUTS_CONFIG } = require('../../../constants');
|
|
24
25
|
|
|
25
26
|
const internals = {
|
|
26
27
|
options: {},
|
|
@@ -70,6 +71,7 @@ internals.sha1sum = (input) => {
|
|
|
70
71
|
*/
|
|
71
72
|
internals.getResponse = async (request) => {
|
|
72
73
|
const storeUrlObj = new URL(request.app.storeUrl);
|
|
74
|
+
const { customLayouts } = internals.options;
|
|
73
75
|
|
|
74
76
|
const httpOpts = {
|
|
75
77
|
url: Object.assign(new URL(request.url.toString()), {
|
|
@@ -80,7 +82,7 @@ internals.getResponse = async (request) => {
|
|
|
80
82
|
headers: internals.buildReqHeaders({
|
|
81
83
|
request,
|
|
82
84
|
stencilOptions: { get_template_file: true, get_data_only: true },
|
|
83
|
-
extraHeaders: { host: storeUrlObj.host },
|
|
85
|
+
extraHeaders: { host: storeUrlObj.host, stencil_custom_templates: customLayouts },
|
|
84
86
|
}),
|
|
85
87
|
accessToken: internals.options.accessToken,
|
|
86
88
|
data: request.payload,
|
|
@@ -140,7 +142,6 @@ internals.getResponse = async (request) => {
|
|
|
140
142
|
},
|
|
141
143
|
internals.cacheTTL,
|
|
142
144
|
);
|
|
143
|
-
|
|
144
145
|
return internals.parseResponse(bcAppData, request, response, responseArgs);
|
|
145
146
|
};
|
|
146
147
|
|
|
@@ -151,10 +152,13 @@ internals.getResponse = async (request) => {
|
|
|
151
152
|
* @param request
|
|
152
153
|
* @param response
|
|
153
154
|
* @param responseArgs
|
|
155
|
+
* @param customLayouts
|
|
154
156
|
* @returns {*}
|
|
155
157
|
*/
|
|
156
158
|
internals.parseResponse = async (bcAppData, request, response, responseArgs) => {
|
|
157
159
|
const { httpOpts, storeUrlObj } = responseArgs;
|
|
160
|
+
// eslint-disable-next-line camelcase
|
|
161
|
+
const { stencil_custom_templates } = httpOpts.headers;
|
|
158
162
|
|
|
159
163
|
if (typeof bcAppData !== 'object' || !('pencil_response' in bcAppData)) {
|
|
160
164
|
delete response.headers['x-frame-options'];
|
|
@@ -175,7 +179,10 @@ internals.parseResponse = async (bcAppData, request, response, responseArgs) =>
|
|
|
175
179
|
request,
|
|
176
180
|
stencilOptions: { get_data_only: true },
|
|
177
181
|
stencilConfig: internals.getResourceConfig(bcAppData, request, configuration),
|
|
178
|
-
extraHeaders: {
|
|
182
|
+
extraHeaders: {
|
|
183
|
+
host: storeUrlObj.host,
|
|
184
|
+
stencil_custom_templates,
|
|
185
|
+
},
|
|
179
186
|
});
|
|
180
187
|
httpOpts.responseType = 'json'; // In the second request we always expect json
|
|
181
188
|
|
|
@@ -440,14 +447,21 @@ internals.buildReqHeaders = ({
|
|
|
440
447
|
? JSON.parse(request.headers['stencil-options'])
|
|
441
448
|
: {};
|
|
442
449
|
|
|
450
|
+
const templates =
|
|
451
|
+
JSON.stringify(extraHeaders.stencil_custom_templates) ||
|
|
452
|
+
JSON.stringify(DEFAULT_CUSTOM_LAYOUTS_CONFIG);
|
|
453
|
+
|
|
443
454
|
const headers = {
|
|
444
455
|
'stencil-options': JSON.stringify({ ...stencilOptions, ...currentOptions }),
|
|
445
456
|
'accept-encoding': 'identity',
|
|
457
|
+
'stencil-custom-templates': templates,
|
|
446
458
|
};
|
|
447
459
|
|
|
448
460
|
if (!request.headers['stencil-config'] && stencilConfig) {
|
|
449
461
|
headers['stencil-config'] = JSON.stringify(stencilConfig);
|
|
450
462
|
}
|
|
463
|
+
// eslint-disable-next-line no-param-reassign
|
|
464
|
+
delete extraHeaders.stencil_custom_templates;
|
|
451
465
|
|
|
452
466
|
return { ...request.headers, ...headers, ...extraHeaders };
|
|
453
467
|
};
|