@bigcommerce/stencil-cli 5.3.3 → 5.3.5

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.
@@ -5,6 +5,7 @@ const path = require('path');
5
5
  const upath = require('upath');
6
6
 
7
7
  const partialRegex = /\{\{>\s*([_|\-|a-zA-Z0-9@'"/]+)[^{]*?}}/g;
8
+ const partialWithoutBracketsRegex = /[^>{{}}\s*]+/g;
8
9
  const dynamicComponentRegex = /\{\{\s*?dynamicComponent\s*(?:'|")([_|\-|a-zA-Z0-9/]+)(?:'|").*?}}/g;
9
10
  const includeRegex = /{{2}>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}{2}/g;
10
11
  const pathStringRegex = /^["'].+["']$/;
@@ -23,12 +24,24 @@ const defineBaseRoute = (route) => route.split('/').slice(0, 3).join('/');
23
24
  const applyExternalPath = (templateName, templates) => {
24
25
  return templates.map((t) => `${defineBaseRoute(templateName)}/${t}`);
25
26
  };
27
+ const modifyNestedPartial = (partial) => {
28
+ const partialFragments = partial.match(partialWithoutBracketsRegex);
29
+
30
+ if (partialFragments) {
31
+ return [`${partialFragments.shift()}'`, ...partialFragments].join(' ');
32
+ }
33
+
34
+ return partialFragments;
35
+ };
36
+
26
37
  const replacePartialNames = (content, partialRoute) => {
27
38
  return content.replace(
28
39
  includeRegex,
29
- (__, partialName) => `{{> '${defineBaseRoute(partialRoute)}/${partialName}' }}`,
40
+ (partialName) =>
41
+ `{{> '${defineBaseRoute(partialRoute)}/${modifyNestedPartial(partialName)} }}`,
30
42
  );
31
43
  };
44
+
32
45
  const trimPartial = (partial) => {
33
46
  if (pathStringRegex.test(partial)) {
34
47
  return partial.slice(1, -1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcommerce/stencil-cli",
3
- "version": "5.3.3",
3
+ "version": "5.3.5",
4
4
  "description": "CLI tool to run BigCommerce Stores locally for theme development.",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -133,7 +133,6 @@ internals.getResponse = async (request) => {
133
133
  ? JSON.parse(await readFromStream(response.data))
134
134
  : response.data;
135
135
 
136
- internals.updateTemplatePath(request.path, bcAppData);
137
136
  // cache response
138
137
  cache.put(
139
138
  requestSignature,
@@ -273,7 +272,7 @@ internals.parseResponse = async (bcAppData, request, response, responseArgs) =>
273
272
  internals.getResourceConfig = (data, request, configuration) => {
274
273
  const missingThemeSettingsRegex = /{{\\s*?theme_settings\\..+?\\s*?}}/g;
275
274
  let resourcesConfig = {};
276
- const templatePath = data.template_file;
275
+ const templatePath = internals.getTemplatePath(request.path, data);
277
276
 
278
277
  // If the requested template is not an array, we parse the Frontmatter
279
278
  // If it is an array, then it's an ajax request using `render_with` with multiple components
@@ -337,9 +336,9 @@ internals.redirect = async (response, request) => {
337
336
  *
338
337
  * @param {string} requestPath
339
338
  * @param {Object} data
340
- * @returns {void}
339
+ * @returns {string}
341
340
  */
342
- internals.updateTemplatePath = (requestPath, data) => {
341
+ internals.getTemplatePath = (requestPath, data) => {
343
342
  const customLayouts = internals.options.customLayouts || {};
344
343
  const pageType = data.page_type;
345
344
  let templatePath;
@@ -362,10 +361,9 @@ internals.updateTemplatePath = (requestPath, data) => {
362
361
 
363
362
  if (templatePath) {
364
363
  templatePath = path.join('pages/custom', pageType, templatePath.replace(/\.html$/, ''));
365
- // eslint-disable-next-line no-param-reassign
366
- data.template_file = templatePath;
367
364
  }
368
365
  }
366
+ return templatePath || data.template_file;
369
367
  };
370
368
 
371
369
  function getAcceptLanguageHeader(request) {
@@ -406,7 +404,7 @@ internals.getPencilResponse = (data, request, response, configuration, renderedR
406
404
 
407
405
  return new PencilResponse(
408
406
  {
409
- template_file: data.template_file,
407
+ template_file: internals.getTemplatePath(request.path, data),
410
408
  templates: data.templates,
411
409
  remote: data.remote,
412
410
  remote_data: data.remote_data,