@bigcommerce/stencil-cli 3.6.2 → 3.7.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 +27 -0
- package/lib/bundle-validator.js +59 -0
- package/lib/lang-assembler.js +1 -1
- package/lib/lang-helper.js +59 -0
- package/lib/stencil-start.js +63 -3
- package/lib/store-settings-api-client.js +34 -0
- package/lib/utils/frontmatter.js +33 -0
- package/package-lock.json +458 -23893
- package/package.json +3 -2
- package/server/index.js +3 -0
- package/server/plugins/renderer/renderer.module.js +22 -12
- package/server/plugins/router/router.module.js +11 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigcommerce/stencil-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"description": "CLI tool to run BigCommerce Stores locally for theme development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"package-lock.json"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@bigcommerce/stencil-paper": "^3.0.0-rc.
|
|
47
|
+
"@bigcommerce/stencil-paper": "^3.0.0-rc.52",
|
|
48
48
|
"@bigcommerce/stencil-styles": "2.1.0",
|
|
49
49
|
"@hapi/boom": "^8.0.1",
|
|
50
50
|
"@hapi/glue": "^6.2.0",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"graceful-fs": "^4.2.4",
|
|
68
68
|
"image-size": "^0.9.1",
|
|
69
69
|
"inquirer": "^8.1.5",
|
|
70
|
+
"js-yaml": "^4.1.0",
|
|
70
71
|
"lodash": "^4.17.20",
|
|
71
72
|
"memory-cache": "^0.2.0",
|
|
72
73
|
"npm-which": "^3.0.1",
|
package/server/index.js
CHANGED
|
@@ -19,6 +19,7 @@ function buildManifest(srcManifest, options) {
|
|
|
19
19
|
parsedNormalUrl.protocol + '//' + parsedNormalUrl.host;
|
|
20
20
|
pluginsByName['./plugins/router/router.module'].apiKey = options.dotStencilFile.apiKey;
|
|
21
21
|
pluginsByName['./plugins/router/router.module'].port = options.dotStencilFile.port;
|
|
22
|
+
pluginsByName['./plugins/router/router.module'].stencilCliVersion = options.stencilCliVersion;
|
|
22
23
|
pluginsByName['./plugins/renderer/renderer.module'].useCache = options.useCache;
|
|
23
24
|
pluginsByName['./plugins/renderer/renderer.module'].username = options.dotStencilFile.username;
|
|
24
25
|
pluginsByName['./plugins/renderer/renderer.module'].token = options.dotStencilFile.token;
|
|
@@ -28,6 +29,8 @@ function buildManifest(srcManifest, options) {
|
|
|
28
29
|
options.dotStencilFile.customLayouts;
|
|
29
30
|
pluginsByName['./plugins/renderer/renderer.module'].themePath = options.themePath;
|
|
30
31
|
pluginsByName['./plugins/renderer/renderer.module'].storeUrl = storeUrl;
|
|
32
|
+
pluginsByName['./plugins/renderer/renderer.module'].storeSettingsLocale =
|
|
33
|
+
options.storeSettingsLocale;
|
|
31
34
|
pluginsByName['./plugins/theme-assets/theme-assets.module'].themePath = options.themePath;
|
|
32
35
|
|
|
33
36
|
resManifest.register.plugins = _.reduce(
|
|
@@ -14,6 +14,11 @@ const { readFromStream } = require('../../../lib/utils/asyncUtils');
|
|
|
14
14
|
const NetworkUtils = require('../../../lib/utils/NetworkUtils');
|
|
15
15
|
const contentApiClient = require('../../../lib/content-api-client');
|
|
16
16
|
const { getPageType } = require('../../lib/page-type-util');
|
|
17
|
+
const {
|
|
18
|
+
frontmatterRegex,
|
|
19
|
+
getFrontmatterContent,
|
|
20
|
+
interpolateThemeSettings,
|
|
21
|
+
} = require('../../../lib/utils/frontmatter');
|
|
17
22
|
|
|
18
23
|
const networkUtils = new NetworkUtils();
|
|
19
24
|
|
|
@@ -262,7 +267,6 @@ internals.parseResponse = async (bcAppData, request, response, responseArgs) =>
|
|
|
262
267
|
* @returns {Object}
|
|
263
268
|
*/
|
|
264
269
|
internals.getResourceConfig = (data, request, configuration) => {
|
|
265
|
-
const frontmatterRegex = /---\r?\n(?:.|\s)*?\r?\n---\r?\n/g;
|
|
266
270
|
const missingThemeSettingsRegex = /{{\\s*?theme_settings\\..+?\\s*?}}/g;
|
|
267
271
|
let resourcesConfig = {};
|
|
268
272
|
const templatePath = data.template_file;
|
|
@@ -276,16 +280,12 @@ internals.getResourceConfig = (data, request, configuration) => {
|
|
|
276
280
|
templatePath,
|
|
277
281
|
);
|
|
278
282
|
|
|
279
|
-
|
|
280
|
-
if (
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
frontmatterContent = frontmatterContent.replace(new RegExp(regex, 'g'), val);
|
|
287
|
-
}
|
|
288
|
-
|
|
283
|
+
let frontmatterContent = getFrontmatterContent(rawTemplate);
|
|
284
|
+
if (frontmatterContent !== null) {
|
|
285
|
+
frontmatterContent = interpolateThemeSettings(
|
|
286
|
+
frontmatterContent,
|
|
287
|
+
configuration.settings,
|
|
288
|
+
);
|
|
289
289
|
// Remove any handlebars tags that weren't interpolated because there was no setting for it
|
|
290
290
|
frontmatterContent = frontmatterContent.replace(missingThemeSettingsRegex, '');
|
|
291
291
|
// Replace the frontmatter with the newly interpolated version
|
|
@@ -364,6 +364,16 @@ internals.getTemplatePath = (requestPath, data) => {
|
|
|
364
364
|
return templatePath || data.template_file;
|
|
365
365
|
};
|
|
366
366
|
|
|
367
|
+
function getAcceptLanguageHeader(request) {
|
|
368
|
+
if (
|
|
369
|
+
internals.options.storeSettingsLocale.shopper_language_selection_method ===
|
|
370
|
+
'default_shopper_language'
|
|
371
|
+
) {
|
|
372
|
+
return internals.options.storeSettingsLocale.default_shopper_language;
|
|
373
|
+
}
|
|
374
|
+
return request.headers['accept-language'];
|
|
375
|
+
}
|
|
376
|
+
|
|
367
377
|
/**
|
|
368
378
|
* Creates a new Pencil Response object and returns it.
|
|
369
379
|
*
|
|
@@ -400,7 +410,7 @@ internals.getPencilResponse = (data, request, response, configuration, renderedR
|
|
|
400
410
|
context,
|
|
401
411
|
translations: data.translations,
|
|
402
412
|
method: request.method,
|
|
403
|
-
acceptLanguage: request
|
|
413
|
+
acceptLanguage: getAcceptLanguageHeader(request),
|
|
404
414
|
headers: response.headers,
|
|
405
415
|
statusCode: response.status,
|
|
406
416
|
},
|
|
@@ -98,7 +98,6 @@ internals.registerRoutes = (server) => {
|
|
|
98
98
|
protocol: 'https',
|
|
99
99
|
port: 443,
|
|
100
100
|
passThrough: true,
|
|
101
|
-
xforward: false,
|
|
102
101
|
},
|
|
103
102
|
},
|
|
104
103
|
options: {
|
|
@@ -112,12 +111,18 @@ internals.registerRoutes = (server) => {
|
|
|
112
111
|
path: internals.paths.storefrontAPI,
|
|
113
112
|
handler: {
|
|
114
113
|
proxy: {
|
|
115
|
-
host: internals.options.storeUrl.replace(/http[s]?:\/\//, ''),
|
|
116
114
|
rejectUnauthorized: false,
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
mapUri: (req) => {
|
|
116
|
+
const host = `https://${internals.options.storeUrl.replace(
|
|
117
|
+
/http[s]?:\/\//,
|
|
118
|
+
'',
|
|
119
|
+
)}`;
|
|
120
|
+
const urlParams = req.url.search || '';
|
|
121
|
+
const uri = `${host}${req.path}${urlParams}`;
|
|
122
|
+
const headers = { 'stencil-cli': internals.options.stencilCliVersion };
|
|
123
|
+
return { uri, headers };
|
|
124
|
+
},
|
|
119
125
|
passThrough: true,
|
|
120
|
-
xforward: false,
|
|
121
126
|
},
|
|
122
127
|
},
|
|
123
128
|
options: {
|
|
@@ -165,6 +170,7 @@ internals.registerRoutes = (server) => {
|
|
|
165
170
|
},
|
|
166
171
|
),
|
|
167
172
|
}),
|
|
173
|
+
rejectUnauthorized: false,
|
|
168
174
|
passThrough: true,
|
|
169
175
|
},
|
|
170
176
|
},
|