@bigcommerce/stencil-cli 3.5.2 → 3.6.3

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 CHANGED
@@ -1,3 +1,21 @@
1
+ ### 3.6.3 (2021-10-22)
2
+
3
+ - Bump paper to rc51
4
+ - fix: strf-8846 Send stencil-cli header to storefront api ([789](https://github.com/bigcommerce/stencil-cli/pull/789))
5
+
6
+ ### 3.6.2 (2021-10-06)
7
+
8
+ - feat: Add overwrite option to download command ([785](https://github.com/bigcommerce/stencil-cli/pull/785))
9
+
10
+ ### 3.6.1 (2021-10-04)
11
+
12
+ - fix: strf-9375 Fix custom release tag selection ([f41d6dd44fb](https://github.com/bigcommerce/stencil-cli/commit/f41d6dd44fb))
13
+
14
+ ### 3.6.0 (2021-09-28)
15
+
16
+ - feat: strf-9332 added timeout parameter for stencil bundle command ([9c762fa0aa1](https://github.com/bigcommerce/stencil-cli/commit/9c762fa0aa1))
17
+ - feat: strf-9040 Support dart-sass as primary engine for css rendering ([514ea778eda](https://github.com/bigcommerce/stencil-cli/commit/514ea778eda))
18
+
1
19
  ### 3.5.2 (2021-09-17)
2
20
 
3
21
  - fix: strf-9356 Support npm 7 for stencil cli ([d67747d5384](https://github.com/bigcommerce/stencil-cli/commit/d67747d5384))
@@ -8,6 +8,7 @@ const ThemeConfig = require('../lib/theme-config');
8
8
  const Bundle = require('../lib/stencil-bundle');
9
9
  const { printCliResultErrorAndExit } = require('../lib/cliCommon');
10
10
  const { checkNodeVersion } = require('../lib/cliCommon');
11
+ const BuildConfigManager = require('../lib/BuildConfigManager');
11
12
 
12
13
  program
13
14
  .version(PACKAGE_INFO.version)
@@ -23,6 +24,11 @@ program
23
24
  '-m, --marketplace',
24
25
  'Runs extra bundle validations for partners who can create marketplace themes',
25
26
  )
27
+ .option(
28
+ '-t, --timeout [timeout]',
29
+ 'Set a timeout for the bundle operation. Default is 20 secs',
30
+ '60',
31
+ )
26
32
  .parse(process.argv);
27
33
 
28
34
  const cliOptions = program.opts();
@@ -49,7 +55,15 @@ async function run() {
49
55
  }
50
56
 
51
57
  const rawConfig = await themeConfig.getRawConfig();
52
- const bundle = new Bundle(THEME_PATH, themeConfig, rawConfig, cliOptions);
58
+ const timeout = cliOptions.timeout * 1000; // seconds
59
+ const buildConfigManager = new BuildConfigManager({ timeout });
60
+ const bundle = new Bundle(
61
+ THEME_PATH,
62
+ themeConfig,
63
+ rawConfig,
64
+ cliOptions,
65
+ buildConfigManager,
66
+ );
53
67
 
54
68
  const bundlePath = await bundle.initBundle();
55
69
 
@@ -15,6 +15,7 @@ program
15
15
  .option('-f, --file [filename]', 'specify the filename to download only')
16
16
  .option('-e, --exclude [exclude]', 'specify a directory to exclude from download')
17
17
  .option('-c, --channel_id [channelId]', 'specify the channel ID of the storefront', parseInt)
18
+ .option('-o, --overwrite', 'overwrite local with remote files')
18
19
  .parse(process.argv);
19
20
 
20
21
  checkNodeVersion();
@@ -25,6 +26,7 @@ const options = {
25
26
  exclude: ['parsed', 'manifest.json', ...extraExclude],
26
27
  apiHost: cliOptions.host,
27
28
  channelId: cliOptions.channel_id,
29
+ overwrite: cliOptions.overwrite,
28
30
  applyTheme: true, // fix to be compatible with stencil-push.utils
29
31
  file: cliOptions.file,
30
32
  };
@@ -32,16 +34,23 @@ const options = {
32
34
  async function run(opts) {
33
35
  const overwriteType = opts.file ? opts.file : 'files';
34
36
 
35
- const answers = await inquirer.prompt([
37
+ const promptAnswers = await inquirer.prompt([
36
38
  {
37
39
  message: `${'Warning'.yellow} -- overwrite local with remote ${overwriteType}?`,
38
40
  name: 'overwrite',
39
- type: 'checkbox',
40
- choices: ['Yes', 'No'],
41
+ type: 'confirm',
42
+ when() {
43
+ return !opts.overwrite;
44
+ },
41
45
  },
42
46
  ]);
43
47
 
44
- if (!answers.overwrite.includes('Yes')) {
48
+ const answers = {
49
+ ...opts,
50
+ ...promptAnswers,
51
+ };
52
+
53
+ if (!answers.overwrite) {
45
54
  console.log(`Request cancelled by user ${'No'.red}`);
46
55
  return;
47
56
  }
@@ -5,6 +5,7 @@ const { PACKAGE_INFO } = require('../constants');
5
5
  const program = require('../lib/commander');
6
6
  const StencilStart = require('../lib/stencil-start');
7
7
  const { printCliResultErrorAndExit } = require('../lib/cliCommon');
8
+ const BuildConfigManager = require('../lib/BuildConfigManager');
8
9
 
9
10
  program
10
11
  .version(PACKAGE_INFO.version)
@@ -20,6 +21,7 @@ program
20
21
  '-n, --no-cache',
21
22
  'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.',
22
23
  )
24
+ .option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60')
23
25
  .parse(process.argv);
24
26
 
25
27
  const cliOptions = program.opts();
@@ -33,4 +35,6 @@ const options = {
33
35
  cache: cliOptions.cache,
34
36
  };
35
37
 
36
- new StencilStart().run(options).catch(printCliResultErrorAndExit);
38
+ const timeout = cliOptions.timeout * 1000; // seconds
39
+ const buildConfigManager = new BuildConfigManager({ timeout });
40
+ new StencilStart({ buildConfigManager }).run(options).catch(printCliResultErrorAndExit);
@@ -6,7 +6,7 @@ const fsModule = require('fs');
6
6
  const { THEME_PATH } = require('../constants');
7
7
 
8
8
  class BuildConfigManager {
9
- constructor({ workDir = THEME_PATH, fs = fsModule } = {}) {
9
+ constructor({ workDir = THEME_PATH, fs = fsModule, timeout = 20000 } = {}) {
10
10
  this.configFileName = 'stencil.conf.js';
11
11
 
12
12
  this._workDir = workDir;
@@ -15,6 +15,7 @@ class BuildConfigManager {
15
15
  this._onReadyCallbacks = [];
16
16
  this._worker = null;
17
17
  this._workerIsReady = false;
18
+ this.timeout = timeout;
18
19
 
19
20
  const config = this._getConfig(this._buildConfigPath);
20
21
 
@@ -81,13 +82,17 @@ class BuildConfigManager {
81
82
  return;
82
83
  }
83
84
 
84
- const timeout = setTimeout(() => {
85
+ const timeoutId = setTimeout(() => {
85
86
  this.stopWorker();
87
+ console.log(
88
+ 'The process was timed out. Try to increase it by providing --timeout [number] option'
89
+ .yellow,
90
+ );
86
91
  callback('worker timed out');
87
- }, 20000);
92
+ }, this.timeout);
88
93
 
89
94
  this._onWorkerReady(() => {
90
- clearTimeout(timeout);
95
+ clearTimeout(timeoutId);
91
96
  // send a message to the worker to start bundling js
92
97
  this._worker.send('production');
93
98
  this._worker.on('message', (message) => {
@@ -63,6 +63,7 @@ async function askQuestions(currentVersion, githubToken, remotes) {
63
63
  name: 'version',
64
64
  type: 'input',
65
65
  message: 'What specific version would you like',
66
+ askAnswered: true,
66
67
  when: (answers) => answers.version === 'custom',
67
68
  validate: (value) => {
68
69
  const valid = semver.valid(value) && true;
@@ -43,7 +43,7 @@ class Bundle {
43
43
  themeConfig,
44
44
  rawConfig,
45
45
  options = {},
46
- buildConfigManger = new BuildConfigManager(),
46
+ buildConfigManager = new BuildConfigManager(),
47
47
  ) {
48
48
  const tasks = {};
49
49
  this.options = options;
@@ -68,10 +68,10 @@ class Bundle {
68
68
  tasks.schema = this.assembleSchema.bind(this);
69
69
  tasks.schemaTranslations = this.assembleSchemaTranslations.bind(this);
70
70
 
71
- if (typeof buildConfigManger.production === 'function') {
71
+ if (typeof buildConfigManager.production === 'function') {
72
72
  tasks.theme = (callback) => {
73
73
  console.log('Theme task Started...');
74
- buildConfigManger.initWorker().production((err) => {
74
+ buildConfigManager.initWorker().production((err) => {
75
75
  if (err) {
76
76
  return callback(err);
77
77
  }
@@ -5,7 +5,7 @@ const path = require('path');
5
5
 
6
6
  const Cycles = require('./Cycles');
7
7
  const templateAssemblerModule = require('./template-assembler');
8
- const { THEME_PATH } = require('../constants');
8
+ const { PACKAGE_INFO, THEME_PATH } = require('../constants');
9
9
  const Server = require('../server');
10
10
  const StencilConfigManager = require('./StencilConfigManager');
11
11
  const ThemeConfig = require('./theme-config');
@@ -23,7 +23,7 @@ class StencilStart {
23
23
  cliCommon = cliCommonModule,
24
24
  stencilConfigManager = new StencilConfigManager(),
25
25
  themeConfigManager = ThemeConfig.getInstance(THEME_PATH),
26
- buildConfigManger = new BuildConfigManager(),
26
+ buildConfigManager = new BuildConfigManager(),
27
27
  templateAssembler = templateAssemblerModule,
28
28
  CyclesDetector = Cycles,
29
29
  stencilPushUtils = stencilPushUtilsModule,
@@ -35,7 +35,7 @@ class StencilStart {
35
35
  this._cliCommon = cliCommon;
36
36
  this._stencilConfigManager = stencilConfigManager;
37
37
  this._themeConfigManager = themeConfigManager;
38
- this._buildConfigManger = buildConfigManger;
38
+ this._buildConfigManager = buildConfigManager;
39
39
  this._templateAssembler = templateAssembler;
40
40
  this._CyclesDetector = CyclesDetector;
41
41
  this._stencilPushUtils = stencilPushUtils;
@@ -131,6 +131,7 @@ class StencilStart {
131
131
  variationIndex: this._themeConfigManager.variationIndex || 0,
132
132
  useCache: cliOptions.cache,
133
133
  themePath: this._themeConfigManager.themePath,
134
+ stencilCliVersion: PACKAGE_INFO.version,
134
135
  });
135
136
  }
136
137
 
@@ -138,7 +139,7 @@ class StencilStart {
138
139
  const DEFAULT_WATCH_FILES = ['/assets', '/templates', '/lang', '/.config'];
139
140
  const DEFAULT_WATCH_IGNORED = ['/assets/scss', '/assets/css'];
140
141
  const { themePath, configPath } = this._themeConfigManager;
141
- const { watchOptions } = this._buildConfigManger;
142
+ const { watchOptions } = this._buildConfigManager;
142
143
 
143
144
  // Watch sccs directory and automatically reload all css files if a file changes
144
145
  const stylesPath = path.join(themePath, 'assets/scss');
@@ -211,8 +212,8 @@ class StencilStart {
211
212
  }
212
213
  });
213
214
 
214
- if (this._buildConfigManger.development) {
215
- this._buildConfigManger.initWorker().development(this._browserSync);
215
+ if (this._buildConfigManager.development) {
216
+ this._buildConfigManager.initWorker().development(this._browserSync);
216
217
  }
217
218
  }
218
219