@bigcommerce/stencil-cli 8.3.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 (70) 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 +3 -6
  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 +15 -75
  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 +11 -8
  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
@@ -1,12 +1,10 @@
1
- require('colors');
2
-
3
- const inquirerModule = require('inquirer');
4
- const nypmModule = require('nypm');
5
-
6
- const spinnerModule = require('./spinner');
7
- const serverConfigModule = require('../server/config');
8
- const StencilConfigManager = require('./StencilConfigManager');
9
- const { DEFAULT_CUSTOM_LAYOUTS_CONFIG, API_HOST, THEME_PATH } = require('../constants');
1
+ import 'colors';
2
+ import inquirerModule from 'inquirer';
3
+ import * as nypmModule from 'nypm';
4
+ import spinnerModule from './spinner.js';
5
+ import * as serverConfigModule from '../server/config.js';
6
+ import StencilConfigManager from './StencilConfigManager.js';
7
+ import { DEFAULT_CUSTOM_LAYOUTS_CONFIG, API_HOST, THEME_PATH } from '../constants.js';
10
8
 
11
9
  class StencilInit {
12
10
  /**
@@ -48,7 +46,6 @@ class StencilInit {
48
46
  const updatedStencilConfig = this.applyAnswers(oldStencilConfig, answers, cliOptions);
49
47
  await this._stencilConfigManager.save(updatedStencilConfig);
50
48
  await this.installDependencies(THEME_PATH, answers.packageManager, cliOptions);
51
-
52
49
  this._logger.log(
53
50
  'You are now ready to go! To start developing, run $ ' + 'stencil start'.cyan,
54
51
  );
@@ -59,7 +56,6 @@ class StencilInit {
59
56
  */
60
57
  async readStencilConfig() {
61
58
  let parsedConfig;
62
-
63
59
  try {
64
60
  parsedConfig = await this._stencilConfigManager.read(true, true);
65
61
  } catch (err) {
@@ -69,7 +65,6 @@ class StencilInit {
69
65
  '\nThe file will be rewritten with your answers',
70
66
  );
71
67
  }
72
-
73
68
  return parsedConfig || {};
74
69
  }
75
70
 
@@ -93,7 +88,6 @@ class StencilInit {
93
88
  */
94
89
  getQuestions(defaultAnswers, cliOptions) {
95
90
  const prompts = [];
96
-
97
91
  if (!cliOptions.normalStoreUrl) {
98
92
  prompts.push({
99
93
  type: 'input',
@@ -103,7 +97,6 @@ class StencilInit {
103
97
  default: defaultAnswers.normalStoreUrl,
104
98
  });
105
99
  }
106
-
107
100
  if (!cliOptions.accessToken) {
108
101
  prompts.push({
109
102
  type: 'input',
@@ -113,7 +106,6 @@ class StencilInit {
113
106
  filter: (val) => val.trim(),
114
107
  });
115
108
  }
116
-
117
109
  if (!cliOptions.port) {
118
110
  prompts.push({
119
111
  type: 'input',
@@ -131,7 +123,6 @@ class StencilInit {
131
123
  },
132
124
  });
133
125
  }
134
-
135
126
  if (!cliOptions.packageManager) {
136
127
  prompts.push({
137
128
  type: 'list',
@@ -141,7 +132,6 @@ class StencilInit {
141
132
  default: this.getPackageManager(),
142
133
  });
143
134
  }
144
-
145
135
  return prompts;
146
136
  }
147
137
 
@@ -155,9 +145,7 @@ class StencilInit {
155
145
 
156
146
  updateApiHost(stencilConfig, cliOptions) {
157
147
  const host = cliOptions.apiHost || API_HOST;
158
-
159
148
  console.log('Set API host to: ' + host);
160
-
161
149
  return { ...stencilConfig, apiHost: host };
162
150
  }
163
151
 
@@ -179,15 +167,12 @@ class StencilInit {
179
167
 
180
168
  getPackageManager() {
181
169
  const userAgent = process.env.npm_config_user_agent || '';
182
-
183
170
  if (userAgent.startsWith('yarn')) {
184
171
  return 'yarn';
185
172
  }
186
-
187
173
  if (userAgent.startsWith('pnpm')) {
188
174
  return 'pnpm';
189
175
  }
190
-
191
176
  return 'npm';
192
177
  }
193
178
 
@@ -216,5 +201,4 @@ class StencilInit {
216
201
  );
217
202
  }
218
203
  }
219
-
220
- module.exports = StencilInit;
204
+ export default StencilInit;
@@ -1,6 +1,6 @@
1
- const async = require('async');
2
- const stencilPushUtils = require('./stencil-push.utils');
3
- const stencilPullUtils = require('./stencil-pull.utils');
1
+ import async from 'async';
2
+ import stencilPushUtils from './stencil-push.utils.js';
3
+ import stencilPullUtils from './stencil-pull.utils.js';
4
4
 
5
5
  function stencilPull(options = {}, callback) {
6
6
  async.waterfall(
@@ -18,5 +18,4 @@ function stencilPull(options = {}, callback) {
18
18
  callback,
19
19
  );
20
20
  }
21
-
22
- module.exports = stencilPull;
21
+ export default stencilPull;
@@ -1,31 +1,25 @@
1
- const fs = require('fs');
2
- const _ = require('lodash');
3
- const themeApiClient = require('./theme-api-client');
4
- const { parseJsonFile } = require('./utils/fsUtils');
1
+ import * as fs from 'fs';
2
+ import * as _ from 'lodash-es';
3
+ import themeApiClient from './theme-api-client.js';
4
+ import { parseJsonFile } from './utils/fsUtils.js';
5
5
 
6
6
  const utils = {};
7
-
8
7
  utils.getChannelActiveTheme = async (options) => {
9
8
  const {
10
9
  config: { accessToken },
11
10
  storeHash,
12
11
  channelId,
13
12
  } = options;
14
-
15
13
  const apiHost = options.apiHost || options.config.apiHost;
16
-
17
14
  const activeTheme = await themeApiClient.getChannelActiveTheme({
18
15
  accessToken,
19
16
  apiHost,
20
17
  storeHash,
21
18
  channelId,
22
19
  });
23
-
24
20
  console.log('ok'.green + ` -- Fetched theme details for channel ${channelId}`);
25
-
26
21
  return { ...options, activeTheme };
27
22
  };
28
-
29
23
  utils.getCurrentVariation = async (options) => {
30
24
  const {
31
25
  config: { accessToken },
@@ -43,11 +37,9 @@ utils.getCurrentVariation = async (options) => {
43
37
  themeId,
44
38
  });
45
39
  const variation = variations.find((v) => v.uuid === remoteThemeConfiguration.variation_uuid);
46
-
47
40
  console.log('ok'.green + ` -- Fetched ${saved ? 'saved' : 'active'} variation name`);
48
41
  return { ...options, variation };
49
42
  };
50
-
51
43
  utils.getThemeConfiguration = async (options) => {
52
44
  const {
53
45
  config: { accessToken },
@@ -55,15 +47,11 @@ utils.getThemeConfiguration = async (options) => {
55
47
  activeTheme,
56
48
  saved,
57
49
  } = options;
58
-
59
50
  const apiHost = options.apiHost || options.config.apiHost;
60
-
61
51
  const themeId = activeTheme.active_theme_uuid;
62
-
63
52
  const configurationId = saved
64
53
  ? activeTheme.saved_theme_configuration_uuid
65
54
  : activeTheme.active_theme_configuration_uuid;
66
-
67
55
  const remoteThemeConfiguration = await themeApiClient.getThemeConfiguration({
68
56
  accessToken,
69
57
  apiHost,
@@ -71,19 +59,14 @@ utils.getThemeConfiguration = async (options) => {
71
59
  themeId,
72
60
  configurationId,
73
61
  });
74
-
75
62
  console.log('ok'.green + ` -- Fetched ${saved ? 'saved' : 'active'} configuration`);
76
-
77
63
  return { ...options, remoteThemeConfiguration };
78
64
  };
79
-
80
65
  utils.mergeThemeConfiguration = async (options) => {
81
66
  const { remoteThemeConfiguration } = options;
82
-
83
67
  const localConfig = await parseJsonFile('config.json');
84
68
  const variation = localConfig.variations.find((v) => v.name === options.variation.name);
85
69
  let diffDetected = false;
86
-
87
70
  // For any keys the remote configuration has in common with the local configuration,
88
71
  // overwrite the local configuration if the remote configuration differs
89
72
  for (const [key, remoteVal] of Object.entries(remoteThemeConfiguration.settings)) {
@@ -91,7 +74,6 @@ utils.mergeThemeConfiguration = async (options) => {
91
74
  continue;
92
75
  }
93
76
  const defaultVal = localConfig.settings[key];
94
-
95
77
  // Check for different types, and throw an error if they are found
96
78
  if (typeof defaultVal !== typeof remoteVal) {
97
79
  throw new Error(
@@ -99,7 +81,6 @@ utils.mergeThemeConfiguration = async (options) => {
99
81
  `Remote configuration is of type ${typeof remoteVal} while local configuration is of type ${typeof defaultVal}.`,
100
82
  );
101
83
  }
102
-
103
84
  // If a different value is found, overwrite the local config
104
85
  if (!_.isEqual(defaultVal, remoteVal)) {
105
86
  if (!variation.settings) {
@@ -109,7 +90,6 @@ utils.mergeThemeConfiguration = async (options) => {
109
90
  diffDetected = true;
110
91
  }
111
92
  }
112
-
113
93
  // Does a file need to be written?
114
94
  if (diffDetected || options.saveConfigName !== 'config.json') {
115
95
  if (diffDetected) {
@@ -119,7 +99,6 @@ utils.mergeThemeConfiguration = async (options) => {
119
99
  'ok'.green + ' -- Remote and local configurations are in sync for all common keys',
120
100
  );
121
101
  }
122
-
123
102
  await fs.promises.writeFile(options.saveConfigName, JSON.stringify(localConfig, null, 2));
124
103
  console.log('ok'.green + ` -- Configuration written to ${options.saveConfigName}`);
125
104
  } else {
@@ -128,8 +107,6 @@ utils.mergeThemeConfiguration = async (options) => {
128
107
  ` -- Remote and local configurations are in sync for all common keys, no action taken`,
129
108
  );
130
109
  }
131
-
132
110
  return options;
133
111
  };
134
-
135
- module.exports = utils;
112
+ export default utils;
@@ -1,5 +1,5 @@
1
- const async = require('async');
2
- const utils = require('./stencil-push.utils');
1
+ import async from 'async';
2
+ import utils from './stencil-push.utils.js';
3
3
 
4
4
  function stencilPush(options = {}, callback) {
5
5
  async.waterfall(
@@ -28,5 +28,4 @@ function stencilPush(options = {}, callback) {
28
28
  callback,
29
29
  );
30
30
  }
31
-
32
- module.exports = stencilPush;
31
+ export default stencilPush;