@bigcommerce/stencil-cli 3.6.3 → 3.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcommerce/stencil-cli",
3
- "version": "3.6.3",
3
+ "version": "3.8.0",
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.51",
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",
@@ -55,9 +55,9 @@
55
55
  "ajv": "^6.12.5",
56
56
  "archiver": "^5.0.2",
57
57
  "async": "^3.2.0",
58
- "axios": "^0.21.0",
58
+ "axios": "^0.24.0",
59
59
  "browser-sync": "^2.26.12",
60
- "cheerio": "^0.22.0",
60
+ "cheerio": "^1.0.0-rc.10",
61
61
  "colors": "^1.4.0",
62
62
  "commander": "^6.1.0",
63
63
  "confidence": "^4.0.2",
@@ -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",
@@ -94,13 +95,6 @@
94
95
  "eslint-plugin-jest": "^24.0.2",
95
96
  "eslint-plugin-node": "^11.1.0",
96
97
  "eslint-plugin-prettier": "^3.1.4",
97
- "gulp": "^4.0.2",
98
- "gulp-bump": "^3.2.0",
99
- "gulp-exec": "^5.0.0",
100
- "gulp-git-streamed": "^2.10.1",
101
- "gulp-if": "^3.0.0",
102
- "gulp-prompt": "^1.2.0",
103
- "gulp-util": "^3.0.8",
104
98
  "husky": "^4.3.0",
105
99
  "jest": "^26.4.2",
106
100
  "lint-staged": "^10.4.0",
package/server/index.js CHANGED
@@ -29,6 +29,8 @@ function buildManifest(srcManifest, options) {
29
29
  options.dotStencilFile.customLayouts;
30
30
  pluginsByName['./plugins/renderer/renderer.module'].themePath = options.themePath;
31
31
  pluginsByName['./plugins/renderer/renderer.module'].storeUrl = storeUrl;
32
+ pluginsByName['./plugins/renderer/renderer.module'].storeSettingsLocale =
33
+ options.storeSettingsLocale;
32
34
  pluginsByName['./plugins/theme-assets/theme-assets.module'].themePath = options.themePath;
33
35
 
34
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
- const frontmatterMatch = rawTemplate.match(frontmatterRegex);
280
- if (frontmatterMatch !== null) {
281
- let frontmatterContent = frontmatterMatch[0];
282
- // Interpolate theme settings for frontmatter
283
- for (const [key, val] of Object.entries(configuration.settings)) {
284
- const regex = `{{\\s*?theme_settings\\.${key}\\s*?}}`;
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.headers['accept-language'],
413
+ acceptLanguage: getAcceptLanguageHeader(request),
404
414
  headers: response.headers,
405
415
  statusCode: response.status,
406
416
  },
@@ -170,6 +170,7 @@ internals.registerRoutes = (server) => {
170
170
  },
171
171
  ),
172
172
  }),
173
+ rejectUnauthorized: false,
173
174
  passThrough: true,
174
175
  },
175
176
  },