@bigcommerce/stencil-cli 8.2.0 → 8.4.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.
Files changed (71) hide show
  1. package/bin/stencil-bundle.js +7 -18
  2. package/bin/stencil-debug.js +5 -9
  3. package/bin/stencil-download.js +7 -19
  4. package/bin/stencil-init.js +4 -8
  5. package/bin/stencil-pull.js +5 -11
  6. package/bin/stencil-push.js +5 -8
  7. package/bin/stencil-release.js +5 -10
  8. package/bin/stencil-scss-autofix.js +6 -11
  9. package/bin/stencil-start.js +6 -9
  10. package/bin/stencil.js +2 -3
  11. package/constants.js +9 -9
  12. package/lib/BuildConfigManager.js +25 -23
  13. package/lib/Cycles.js +3 -12
  14. package/lib/ScssValidator.js +5 -9
  15. package/lib/StencilCLISettings.js +1 -3
  16. package/lib/StencilConfigManager.js +6 -22
  17. package/lib/StencilDebug.js +7 -10
  18. package/lib/archiveManager.js +7 -23
  19. package/lib/bundle-validator.js +28 -64
  20. package/lib/cliCommon.js +11 -21
  21. package/lib/commander.js +2 -3
  22. package/lib/content-api-client.js +5 -13
  23. package/lib/css/compile.js +5 -11
  24. package/lib/graphql/query.js +5 -8
  25. package/lib/lang/validator.js +5 -11
  26. package/lib/lang-assembler.js +4 -10
  27. package/lib/lang-helper.js +3 -6
  28. package/lib/nodeSass/AutoFixer.js +10 -19
  29. package/lib/nodeSass/BaseFixer.js +5 -7
  30. package/lib/nodeSass/BaseRulesFixer.js +3 -8
  31. package/lib/nodeSass/CommaRemovalFixer.js +3 -8
  32. package/lib/nodeSass/ConditionalImportFixer.js +3 -9
  33. package/lib/nodeSass/UndefinedVariableFixer.js +3 -6
  34. package/lib/parse-json.js +10 -9
  35. package/lib/regions.js +3 -23
  36. package/lib/release/questions.js +3 -13
  37. package/lib/release/release.js +16 -55
  38. package/lib/spinner.js +1 -2
  39. package/lib/stencil-bundle.js +19 -78
  40. package/lib/stencil-download.js +5 -6
  41. package/lib/stencil-download.utils.js +5 -18
  42. package/lib/stencil-init.js +8 -24
  43. package/lib/stencil-pull.js +4 -5
  44. package/lib/stencil-pull.utils.js +5 -28
  45. package/lib/stencil-push.js +3 -4
  46. package/lib/stencil-push.utils.js +12 -102
  47. package/lib/stencil-start.js +19 -48
  48. package/lib/store-settings-api-client.js +4 -7
  49. package/lib/template-assembler.js +6 -45
  50. package/lib/theme-api-client.js +7 -30
  51. package/lib/theme-config.js +16 -59
  52. package/lib/utils/NetworkUtils.js +6 -16
  53. package/lib/utils/asyncUtils.js +2 -3
  54. package/lib/utils/frontmatter.js +4 -5
  55. package/lib/utils/fsUtils.js +6 -10
  56. package/lib/validator/schema-translations.js +5 -7
  57. package/package.json +12 -9
  58. package/server/config.js +3 -7
  59. package/server/index.js +29 -29
  60. package/server/lib/page-type-util.js +2 -5
  61. package/server/lib/show-logo.js +3 -3
  62. package/server/lib/utils.js +6 -11
  63. package/server/manifest.js +7 -11
  64. package/server/plugins/renderer/renderer.module.js +38 -100
  65. package/server/plugins/renderer/responses/index.js +7 -4
  66. package/server/plugins/renderer/responses/pencil-response.js +4 -32
  67. package/server/plugins/renderer/responses/raw-response.js +6 -14
  68. package/server/plugins/renderer/responses/redirect-response.js +1 -4
  69. package/server/plugins/router/router.module.js +9 -14
  70. package/server/plugins/theme-assets/theme-assets.module.js +15 -27
  71. package/lib/css-assembler.js +0 -99
@@ -1,9 +1,9 @@
1
- const _ = require('lodash');
2
- const fs = require('fs');
3
- const Path = require('path');
4
- const glob = require('glob');
5
- const { promisify } = require('util');
6
- const { parseJsonFile } = require('./utils/fsUtils');
1
+ import { defaultsDeep, cloneDeep, omit, inRange, isObject } from 'lodash-es';
2
+ import fs from 'fs';
3
+ import Path from 'path';
4
+ import glob from 'glob';
5
+ import { promisify } from 'util';
6
+ import { parseJsonFile } from './utils/fsUtils.js';
7
7
 
8
8
  class ThemeConfig {
9
9
  /**
@@ -16,7 +16,6 @@ class ThemeConfig {
16
16
  if (themePath) {
17
17
  this.setThemePath(themePath);
18
18
  }
19
-
20
19
  this.currentVariationSettings = null;
21
20
  this.globalSettings = null;
22
21
  this.variationIndex = 0;
@@ -31,13 +30,10 @@ class ThemeConfig {
31
30
  async getConfig() {
32
31
  const config = await this.getRawConfig();
33
32
  const variation = this._getVariation(config, this.variationIndex);
34
-
35
- this.globalSettings = _.cloneDeep(config.settings);
36
-
33
+ this.globalSettings = cloneDeep(config.settings);
37
34
  if (!this.currentVariationSettings) {
38
35
  this.currentVariationSettings = variation.settings;
39
36
  }
40
-
41
37
  // Set some defaults
42
38
  config.css_compiler = config.css_compiler || 'scss';
43
39
  config.autoprefixer_cascade = config.autoprefixer_cascade || true;
@@ -46,12 +42,10 @@ class ThemeConfig {
46
42
  'last 2 versions',
47
43
  'Firefox ESR',
48
44
  ];
49
-
50
45
  // Merge in the variation settings and images objects
51
- config.settings = _.defaultsDeep(this.currentVariationSettings, config.settings || {});
52
- config.images = _.defaultsDeep(variation.images, config.images || {});
46
+ config.settings = defaultsDeep(this.currentVariationSettings, config.settings || {});
47
+ config.images = defaultsDeep(variation.images, config.images || {});
53
48
  config.variationName = variation.name;
54
-
55
49
  return config;
56
50
  }
57
51
 
@@ -65,27 +59,22 @@ class ThemeConfig {
65
59
  async updateConfig(newSettings, saveToFile) {
66
60
  let rawConfig;
67
61
  let variation;
68
-
69
62
  // Remove all variation settings that match theme's settings
70
- this.currentVariationSettings = _.omit(
63
+ this.currentVariationSettings = omit(
71
64
  newSettings,
72
65
  (value, key) => this.globalSettings[key] === value,
73
66
  this,
74
67
  );
75
-
76
68
  if (saveToFile) {
77
69
  // Resetting the global settings so the only data saved to the file are the changes
78
70
  // from a specific variation's settings.
79
71
  rawConfig = await this.getRawConfig();
80
72
  variation = this._getVariation(rawConfig, this.variationIndex);
81
-
82
73
  variation.settings = this.currentVariationSettings;
83
-
84
74
  fs.writeFileSync(this.configPath, JSON.stringify(rawConfig, null, 2), {
85
75
  encoding: 'utf-8',
86
76
  });
87
77
  }
88
-
89
78
  return this;
90
79
  }
91
80
 
@@ -101,7 +90,6 @@ class ThemeConfig {
101
90
  this.schemaPath = Path.join(themePath, 'schema.json');
102
91
  this.schemaTranslationsPath = Path.join(themePath, 'schemaTranslations.json');
103
92
  this.variationIndex = 0;
104
-
105
93
  return this;
106
94
  }
107
95
 
@@ -125,7 +113,6 @@ class ThemeConfig {
125
113
  this.variationIndex = variationIndex;
126
114
  this.currentVariationSettings = null;
127
115
  }
128
-
129
116
  return this;
130
117
  }
131
118
 
@@ -147,22 +134,18 @@ class ThemeConfig {
147
134
  async setVariationByName(variationName) {
148
135
  const config = await this.getRawConfig();
149
136
  let variationIndex = 0;
150
-
151
137
  if (variationName) {
152
138
  variationIndex = config.variations.findIndex(
153
139
  (variation) => variation.name === variationName,
154
140
  );
155
-
156
141
  if (variationIndex === -1) {
157
142
  throw new Error(
158
143
  `Variation: ${variationName} is not defined in the theme's config.json`,
159
144
  );
160
145
  }
161
146
  }
162
-
163
147
  this.variationIndex = variationIndex;
164
148
  this.currentVariationSettings = null;
165
-
166
149
  return this;
167
150
  }
168
151
 
@@ -190,11 +173,9 @@ class ThemeConfig {
190
173
  */
191
174
  async getVariationCount() {
192
175
  const { variations } = await this.getConfig();
193
-
194
176
  if (!Array.isArray(variations)) {
195
177
  return 0;
196
178
  }
197
-
198
179
  return variations.length;
199
180
  }
200
181
 
@@ -203,7 +184,7 @@ class ThemeConfig {
203
184
  * @returns {boolean}
204
185
  */
205
186
  async variationExists(variationIndex) {
206
- return _.inRange(variationIndex, 0, await this.getVariationCount());
187
+ return inRange(variationIndex, 0, await this.getVariationCount());
207
188
  }
208
189
 
209
190
  /**
@@ -239,19 +220,13 @@ class ThemeConfig {
239
220
  if (!fs.existsSync(this.schemaPath)) {
240
221
  return [];
241
222
  }
242
-
243
223
  const themeSchema = await parseJsonFile(this.schemaPath);
244
-
245
224
  if (!Array.isArray(themeSchema)) {
246
225
  return [];
247
226
  }
248
-
249
227
  const files = await promisify(glob)(Path.join(this.themePath, 'templates/**/*.html'));
250
-
251
228
  const themeSettings = await Promise.all(files.map(this._fetchThemeSettings));
252
-
253
229
  const forceReloadIds = themeSettings.reduce((res, item) => ({ ...res, ...item }), {});
254
-
255
230
  for (const themeSchemaItem of themeSchema) {
256
231
  for (const item of themeSchemaItem.settings) {
257
232
  if (forceReloadIds[item.id]) {
@@ -259,7 +234,6 @@ class ThemeConfig {
259
234
  }
260
235
  }
261
236
  }
262
-
263
237
  return themeSchema;
264
238
  }
265
239
 
@@ -272,10 +246,8 @@ class ThemeConfig {
272
246
  if (!fs.existsSync(this.schemaTranslationsPath)) {
273
247
  return {};
274
248
  }
275
-
276
249
  const schemaTranslations = await parseJsonFile(this.schemaTranslationsPath);
277
-
278
- return _.isObject(schemaTranslations) ? schemaTranslations : {};
250
+ return isObject(schemaTranslations) ? schemaTranslations : {};
279
251
  }
280
252
 
281
253
  /**
@@ -316,33 +288,26 @@ class ThemeConfig {
316
288
  */
317
289
  _getVariation(config, variationIndex) {
318
290
  let variation;
319
-
320
291
  if (!Array.isArray(config.variations) || config.variations.length === 0) {
321
292
  throw new Error('Your theme must have at least one variation in the config.json file.');
322
293
  }
323
-
324
294
  if (!variationIndex) {
325
295
  [variation] = config.variations;
326
296
  } else {
327
297
  variation = config.variations[variationIndex];
328
-
329
298
  if (!variation) {
330
299
  throw new Error(`Variation index: ${variationIndex} not found theme's config.json`);
331
300
  }
332
301
  }
333
-
334
- if (!_.isObject(variation.settings)) {
302
+ if (!isObject(variation.settings)) {
335
303
  variation.settings = {};
336
304
  }
337
-
338
- if (!_.isObject(variation.images)) {
305
+ if (!isObject(variation.images)) {
339
306
  variation.images = {};
340
307
  }
341
-
342
- if (!_.isObject(variation.meta)) {
308
+ if (!isObject(variation.meta)) {
343
309
  variation.meta = {};
344
310
  }
345
-
346
311
  return variation;
347
312
  }
348
313
 
@@ -356,20 +321,15 @@ class ThemeConfig {
356
321
  const themeSettingsRegexPattern = /\Wtheme_settings\.(.+?)\W/g;
357
322
  const themeSettings = {};
358
323
  let match;
359
-
360
324
  const content = await fs.promises.readFile(path, 'utf8');
361
-
362
325
  // eslint-disable-next-line
363
326
  while ((match = themeSettingsRegexPattern.exec(content))) {
364
327
  themeSettings[match[1]] = true;
365
328
  }
366
-
367
329
  return themeSettings;
368
330
  }
369
331
  }
370
-
371
332
  let themeConfigInstance;
372
-
373
333
  /**
374
334
  * Grabs the currently set instance or creates one if it doesn't exist. If called
375
335
  * a second time with params, it will set those specific params and return the instance.
@@ -380,17 +340,14 @@ let themeConfigInstance;
380
340
  function getInstance(themePath) {
381
341
  if (!themeConfigInstance) {
382
342
  themeConfigInstance = new ThemeConfig(themePath);
383
-
384
343
  return themeConfigInstance;
385
344
  }
386
-
387
345
  if (themePath) {
388
346
  themeConfigInstance.setThemePath(themePath);
389
347
  }
390
-
391
348
  return themeConfigInstance;
392
349
  }
393
350
 
394
- module.exports = {
351
+ export default {
395
352
  getInstance,
396
353
  };
@@ -1,16 +1,10 @@
1
- /**
2
- * @module Contains helpers functions for working with network requests
3
- */
4
-
5
- const https = require('https');
6
- const fsModule = require('fs');
7
- const axios = require('axios');
8
-
9
- const { PACKAGE_INFO } = require('../../constants');
10
- const stencilCLISettings = require('../StencilCLISettings');
1
+ import https from 'https';
2
+ import fsModule from 'fs';
3
+ import axios from 'axios';
4
+ import { PACKAGE_INFO } from '../../constants.js';
5
+ import stencilCLISettings from '../StencilCLISettings.js';
11
6
 
12
7
  const defaultHttpsAgent = new https.Agent({ rejectUnauthorized: false });
13
-
14
8
  class NetworkUtils {
15
9
  constructor({
16
10
  fs = fsModule,
@@ -52,11 +46,9 @@ class NetworkUtils {
52
46
  if (accessToken) {
53
47
  reqConfig.headers['x-auth-token'] = accessToken;
54
48
  }
55
-
56
49
  if (stencilCLISettings.isVerbose()) {
57
50
  this.log(reqConfig);
58
51
  }
59
-
60
52
  return this._reqLibrary(reqConfig);
61
53
  }
62
54
 
@@ -70,7 +62,6 @@ class NetworkUtils {
70
62
  url,
71
63
  responseType: 'stream',
72
64
  });
73
-
74
65
  return new Promise((resolve, reject) => {
75
66
  response.data
76
67
  .pipe(this._fs.createWriteStream(outputPath))
@@ -84,5 +75,4 @@ class NetworkUtils {
84
75
  this._logger.info(`Upcoming request ${method.green}: ${config.url.green}`);
85
76
  }
86
77
  }
87
-
88
- module.exports = NetworkUtils;
78
+ export default NetworkUtils;
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @module Contains helpers functions for working with async stuff and streams
3
3
  */
4
-
5
4
  /**
6
5
  * WARNING! Can be used with text content only. Binary data (e.g. images) will get broken!
7
6
  *
@@ -15,7 +14,7 @@ async function readFromStream(stream) {
15
14
  }
16
15
  return result;
17
16
  }
18
-
19
- module.exports = {
17
+ export { readFromStream };
18
+ export default {
20
19
  readFromStream,
21
20
  };
@@ -1,5 +1,4 @@
1
1
  const frontmatterRegex = /---[\s\S]+?---/g;
2
-
3
2
  /**
4
3
  *
5
4
  * @param {String} file
@@ -9,7 +8,6 @@ function getFrontmatterContent(file) {
9
8
  const frontmatterMatch = file.match(frontmatterRegex);
10
9
  return frontmatterMatch !== null ? frontmatterMatch[0] : null;
11
10
  }
12
-
13
11
  /**
14
12
  *
15
13
  * @param {String} frontmatter
@@ -22,11 +20,12 @@ function interpolateThemeSettings(frontmatter, settings) {
22
20
  // eslint-disable-next-line no-param-reassign
23
21
  frontmatter = frontmatter.replace(new RegExp(regex, 'g'), val);
24
22
  }
25
-
26
23
  return frontmatter;
27
24
  }
28
-
29
- module.exports = {
25
+ export { frontmatterRegex };
26
+ export { getFrontmatterContent };
27
+ export { interpolateThemeSettings };
28
+ export default {
30
29
  frontmatterRegex,
31
30
  getFrontmatterContent,
32
31
  interpolateThemeSettings,
@@ -1,11 +1,6 @@
1
- /**
2
- * @module Contains helpers functions for working with file system
3
- */
4
-
5
- const fs = require('fs');
6
- const recursiveReadDir = require('recursive-readdir');
7
- const { parse } = require('../parse-json');
8
-
1
+ import fs from 'fs';
2
+ import recursiveReadDir from 'recursive-readdir';
3
+ import { parse } from '../parse-json.js';
9
4
  /**
10
5
  * @param {string} filePath
11
6
  * @returns {Promise<Object>} - parsed JSON content of the file
@@ -15,8 +10,9 @@ async function parseJsonFile(filePath) {
15
10
  // We use parse-json instead of JSON.parse because it throws errors with better explanations what is wrong
16
11
  return parse(contentStr, filePath);
17
12
  }
18
-
19
- module.exports = {
13
+ export { parseJsonFile };
14
+ export { recursiveReadDir };
15
+ export default {
20
16
  ...fs,
21
17
  parseJsonFile,
22
18
  recursiveReadDir,
@@ -1,4 +1,7 @@
1
- const schemaTranslations = require('../schemas/schemaTranslations.json');
1
+ import { readFileSync } from 'fs';
2
+
3
+ const fileUrl = new URL('../schemas/schemaTranslations.json', import.meta.url);
4
+ const schemaTranslations = JSON.parse(readFileSync(fileUrl));
2
5
 
3
6
  class ValidatorSchemaTranslations {
4
7
  constructor() {
@@ -23,7 +26,6 @@ class ValidatorSchemaTranslations {
23
26
  */
24
27
  setTranslations(translations) {
25
28
  this.translations = translations;
26
-
27
29
  this.getTranslationsKeys();
28
30
  }
29
31
 
@@ -79,11 +81,9 @@ class ValidatorSchemaTranslations {
79
81
  if (!this.trackedKeys.includes(key)) {
80
82
  continue;
81
83
  }
82
-
83
84
  if (Array.isArray(value)) {
84
85
  this.getTranslatableStrings(value);
85
86
  }
86
-
87
87
  this.setSchemaKeys(value);
88
88
  }
89
89
  }
@@ -100,7 +100,6 @@ class ValidatorSchemaTranslations {
100
100
  if (translationMatch) {
101
101
  return false;
102
102
  }
103
-
104
103
  return !this.schemaKeys.includes(key);
105
104
  });
106
105
  }
@@ -113,5 +112,4 @@ class ValidatorSchemaTranslations {
113
112
  return this.schemaKeys.filter((key) => !this.translationsKeys.includes(key));
114
113
  }
115
114
  }
116
-
117
- module.exports = ValidatorSchemaTranslations;
115
+ export default ValidatorSchemaTranslations;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@bigcommerce/stencil-cli",
3
- "version": "8.2.0",
3
+ "version": "8.4.0",
4
+ "type": "module",
4
5
  "description": "CLI tool to run BigCommerce Stores locally for theme development.",
5
6
  "main": "index.js",
6
7
  "engines": {
@@ -10,8 +11,8 @@
10
11
  "scripts": {
11
12
  "lint": "eslint . && prettier --check . --ignore-unknown",
12
13
  "lint-and-fix": "eslint . --fix && prettier --write . --ignore-unknown",
13
- "test": "jest",
14
- "test-with-coverage": "jest --coverage --verbose",
14
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
15
+ "test-with-coverage": "npm run test --coverage --verbose",
15
16
  "release": "semantic-release"
16
17
  },
17
18
  "bin": {
@@ -49,13 +50,14 @@
49
50
  ],
50
51
  "dependencies": {
51
52
  "@bigcommerce/stencil-paper": "5.0.0",
52
- "@bigcommerce/stencil-styles": "5.3.3",
53
+ "@bigcommerce/stencil-styles": "^6.1.1",
53
54
  "@hapi/boom": "^10.0.0",
54
- "@hapi/glue": "^8.0.0",
55
+ "@hapi/glue": "^9.0.1",
55
56
  "@hapi/h2o2": "^9.1.0",
56
57
  "@hapi/hapi": "^20.2.2",
57
58
  "@hapi/inert": "^6.0.5",
58
- "@octokit/rest": "^18.0.6",
59
+ "@jest/globals": "^29.7.0",
60
+ "@octokit/rest": "^21.0.2",
59
61
  "ajv": "^6.12.5",
60
62
  "archiver": "^5.0.2",
61
63
  "async": "^3.2.3",
@@ -74,6 +76,7 @@
74
76
  "inquirer": "^8.1.5",
75
77
  "js-yaml": "^4.1.0",
76
78
  "lodash": "^4.17.20",
79
+ "lodash-es": "^4.17.21",
77
80
  "memory-cache": "^0.2.0",
78
81
  "npm-which": "^3.0.1",
79
82
  "nypm": "^0.3.8",
@@ -86,7 +89,7 @@
86
89
  "progress": "^2.0.3",
87
90
  "recursive-readdir": "^2.2.2",
88
91
  "semver": "^7.3.2",
89
- "simple-git": "^3.7.1",
92
+ "simple-git": "^3.26.0",
90
93
  "tarjan-graph": "^2.0.0",
91
94
  "tmp-promise": "^3.0.2",
92
95
  "upath": "^1.2.0",
@@ -99,7 +102,7 @@
99
102
  "@semantic-release/changelog": "^6.0.1",
100
103
  "@semantic-release/commit-analyzer": "^9.0.2",
101
104
  "@semantic-release/git": "^10.0.1",
102
- "@semantic-release/github": "^8.0.6",
105
+ "@semantic-release/github": "^11.0.0",
103
106
  "@semantic-release/npm": "^9.0.1",
104
107
  "@semantic-release/release-notes-generator": "^10.0.3",
105
108
  "axios-mock-adapter": "^1.21.2",
@@ -113,7 +116,7 @@
113
116
  "eslint-plugin-prettier": "^3.1.4",
114
117
  "jest": "^29.7.0",
115
118
  "prettier": "2.1.2",
116
- "semantic-release": "^19.0.5",
119
+ "semantic-release": "^24.1.1",
117
120
  "semantic-release-github-pullrequest": "^1.3.0"
118
121
  }
119
122
  }
package/server/config.js CHANGED
@@ -1,4 +1,4 @@
1
- const Confidence = require('confidence');
1
+ import Confidence from 'confidence';
2
2
 
3
3
  const config = {
4
4
  $meta: 'Config file',
@@ -7,13 +7,9 @@ const config = {
7
7
  port: 3000,
8
8
  },
9
9
  };
10
-
11
10
  const criteria = {
12
11
  env: process.env.NODE_ENV || 'development',
13
12
  };
14
-
15
13
  const store = new Confidence.Store(config);
16
-
17
- exports.get = (key) => store.get(key, criteria);
18
-
19
- exports.meta = (key) => store.meta(key, criteria);
14
+ export const get = (key) => store.get(key, criteria);
15
+ export const meta = (key) => store.meta(key, criteria);
package/server/index.js CHANGED
@@ -1,58 +1,58 @@
1
- const Glue = require('@hapi/glue');
2
- const _ = require('lodash');
3
- const manifest = require('./manifest');
4
- const logo = require('./lib/show-logo');
1
+ import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import Glue from '@hapi/glue';
4
+ import * as _ from 'lodash-es';
5
+ import * as manifest from './manifest.js';
6
+ import logo from './lib/show-logo.js';
7
+ import 'colors';
5
8
 
6
- require('colors');
9
+ const getDirname = dirname(fileURLToPath(import.meta.url));
7
10
 
8
11
  function buildManifest(srcManifest, options) {
9
12
  const resManifest = _.cloneDeep(srcManifest);
10
13
  const pluginsByName = resManifest.register.plugins;
11
-
12
14
  const parsedSecureUrl = new URL(options.dotStencilFile.storeUrl); // The url to a secure page (prompted as login page)
13
15
  const parsedNormalUrl = new URL(options.dotStencilFile.normalStoreUrl); // The host url of the homepage;
14
16
  const storeUrl = parsedSecureUrl.protocol + '//' + parsedSecureUrl.host;
15
-
16
17
  resManifest.server.port = options.dotStencilFile.port;
17
- pluginsByName['./plugins/router/router.module'].storeUrl = storeUrl;
18
- pluginsByName['./plugins/router/router.module'].normalStoreUrl =
18
+ pluginsByName['./plugins/router/router.module.js'].storeUrl = storeUrl;
19
+ pluginsByName['./plugins/router/router.module.js'].normalStoreUrl =
19
20
  parsedNormalUrl.protocol + '//' + parsedNormalUrl.host;
20
- pluginsByName['./plugins/router/router.module'].apiKey = options.dotStencilFile.apiKey;
21
- pluginsByName['./plugins/router/router.module'].port = options.dotStencilFile.port;
22
- pluginsByName['./plugins/router/router.module'].stencilCliVersion = options.stencilCliVersion;
23
- pluginsByName['./plugins/router/router.module'].accessToken =
21
+ pluginsByName['./plugins/router/router.module.js'].apiKey = options.dotStencilFile.apiKey;
22
+ pluginsByName['./plugins/router/router.module.js'].port = options.dotStencilFile.port;
23
+ pluginsByName['./plugins/router/router.module.js'].stencilCliVersion =
24
+ options.stencilCliVersion;
25
+ pluginsByName['./plugins/router/router.module.js'].accessToken =
24
26
  options.dotStencilFile.accessToken;
25
- pluginsByName['./plugins/renderer/renderer.module'].useCache = options.useCache;
26
- pluginsByName['./plugins/renderer/renderer.module'].username = options.dotStencilFile.username;
27
- pluginsByName['./plugins/renderer/renderer.module'].token = options.dotStencilFile.token;
28
- pluginsByName['./plugins/renderer/renderer.module'].accessToken =
27
+ pluginsByName['./plugins/renderer/renderer.module.js'].useCache = options.useCache;
28
+ pluginsByName['./plugins/renderer/renderer.module.js'].username =
29
+ options.dotStencilFile.username;
30
+ pluginsByName['./plugins/renderer/renderer.module.js'].token = options.dotStencilFile.token;
31
+ pluginsByName['./plugins/renderer/renderer.module.js'].accessToken =
29
32
  options.dotStencilFile.accessToken;
30
- pluginsByName['./plugins/renderer/renderer.module'].customLayouts =
33
+ pluginsByName['./plugins/renderer/renderer.module.js'].customLayouts =
31
34
  options.dotStencilFile.customLayouts;
32
- pluginsByName['./plugins/renderer/renderer.module'].themePath = options.themePath;
33
- pluginsByName['./plugins/renderer/renderer.module'].storeUrl = storeUrl;
34
- pluginsByName['./plugins/renderer/renderer.module'].storeSettingsLocale =
35
+ pluginsByName['./plugins/renderer/renderer.module.js'].themePath = options.themePath;
36
+ pluginsByName['./plugins/renderer/renderer.module.js'].storeUrl = storeUrl;
37
+ pluginsByName['./plugins/renderer/renderer.module.js'].storeSettingsLocale =
35
38
  options.storeSettingsLocale;
36
- pluginsByName['./plugins/theme-assets/theme-assets.module'].themePath = options.themePath;
37
-
39
+ pluginsByName['./plugins/theme-assets/theme-assets.module.js'].themePath = options.themePath;
38
40
  resManifest.register.plugins = _.reduce(
39
41
  pluginsByName,
40
42
  (pluginsArr, opts, plugin) => [...pluginsArr, { plugin, options: opts }],
41
43
  [],
42
44
  );
43
-
44
45
  return resManifest;
45
46
  }
46
-
47
47
  async function create(options) {
48
48
  const serverManifest = buildManifest(manifest.get('/'), options);
49
-
50
- const server = await Glue.compose(serverManifest, { relativeTo: __dirname });
49
+ const server = await Glue.compose(serverManifest, { relativeTo: getDirname });
51
50
  await server.start();
52
51
 
53
52
  console.log(logo);
54
53
 
55
54
  return server;
56
55
  }
57
-
58
- module.exports = { create };
56
+ export default {
57
+ create,
58
+ };
@@ -40,7 +40,6 @@ const PageTypes = {
40
40
  SUBSCRIBED: 'SUBSCRIBED',
41
41
  UNSUBSCRIBE: 'UNSUBSCRIBE',
42
42
  };
43
-
44
43
  const templateFileToPageTypeMap = {
45
44
  'pages/page': PageTypes.PAGE,
46
45
  'pages/product': PageTypes.PRODUCT,
@@ -83,7 +82,6 @@ const templateFileToPageTypeMap = {
83
82
  'pages/subscribed': PageTypes.SUBSCRIBED,
84
83
  'pages/unsubscribe': PageTypes.UNSUBSCRIBE,
85
84
  };
86
-
87
85
  /**
88
86
  * Convert a templateFile to pageType
89
87
  *
@@ -92,10 +90,9 @@ const templateFileToPageTypeMap = {
92
90
  */
93
91
  function getPageType(templateFile) {
94
92
  const pageType = templateFileToPageTypeMap[templateFile];
95
-
96
93
  return pageType;
97
94
  }
98
-
99
- module.exports = {
95
+ export { getPageType };
96
+ export default {
100
97
  getPageType,
101
98
  };
@@ -1,5 +1,6 @@
1
- require('colors');
1
+ import 'colors';
2
2
 
3
+ // eslint-disable-next-line import/no-mutable-exports
3
4
  let logo = '\n';
4
5
  logo += ' `+h\n'.blue;
5
6
  logo += ' `+ddd\n'.blue;
@@ -24,5 +25,4 @@ logo += '_________________________\n'.white;
24
25
  logo += '\n';
25
26
  logo += 'BigCommerce Stencil \n'.yellow;
26
27
  logo += '_________________________\n'.white;
27
-
28
- module.exports = logo;
28
+ export default logo;