@bigcommerce/stencil-cli 8.3.0 → 8.4.1

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/README.md +1 -1
  2. package/bin/stencil-bundle.js +7 -18
  3. package/bin/stencil-debug.js +5 -9
  4. package/bin/stencil-download.js +7 -19
  5. package/bin/stencil-init.js +4 -8
  6. package/bin/stencil-pull.js +5 -11
  7. package/bin/stencil-push.js +5 -8
  8. package/bin/stencil-release.js +5 -10
  9. package/bin/stencil-scss-autofix.js +6 -11
  10. package/bin/stencil-start.js +6 -9
  11. package/bin/stencil.js +2 -3
  12. package/constants.js +9 -9
  13. package/lib/BuildConfigManager.js +25 -23
  14. package/lib/Cycles.js +3 -12
  15. package/lib/ScssValidator.js +5 -9
  16. package/lib/StencilCLISettings.js +1 -3
  17. package/lib/StencilConfigManager.js +6 -22
  18. package/lib/StencilDebug.js +7 -10
  19. package/lib/archiveManager.js +7 -23
  20. package/lib/bundle-validator.js +28 -64
  21. package/lib/cliCommon.js +11 -21
  22. package/lib/commander.js +2 -3
  23. package/lib/content-api-client.js +5 -13
  24. package/lib/css/compile.js +3 -6
  25. package/lib/graphql/query.js +5 -8
  26. package/lib/lang/validator.js +5 -11
  27. package/lib/lang-assembler.js +4 -10
  28. package/lib/lang-helper.js +3 -6
  29. package/lib/nodeSass/AutoFixer.js +10 -19
  30. package/lib/nodeSass/BaseFixer.js +5 -7
  31. package/lib/nodeSass/BaseRulesFixer.js +3 -8
  32. package/lib/nodeSass/CommaRemovalFixer.js +3 -8
  33. package/lib/nodeSass/ConditionalImportFixer.js +3 -9
  34. package/lib/nodeSass/UndefinedVariableFixer.js +3 -6
  35. package/lib/parse-json.js +10 -9
  36. package/lib/regions.js +3 -23
  37. package/lib/release/questions.js +3 -13
  38. package/lib/release/release.js +16 -55
  39. package/lib/spinner.js +1 -2
  40. package/lib/stencil-bundle.js +15 -75
  41. package/lib/stencil-download.js +5 -6
  42. package/lib/stencil-download.utils.js +5 -18
  43. package/lib/stencil-init.js +8 -24
  44. package/lib/stencil-pull.js +4 -5
  45. package/lib/stencil-pull.utils.js +5 -28
  46. package/lib/stencil-push.js +3 -4
  47. package/lib/stencil-push.utils.js +12 -102
  48. package/lib/stencil-start.js +19 -48
  49. package/lib/store-settings-api-client.js +4 -7
  50. package/lib/template-assembler.js +6 -45
  51. package/lib/theme-api-client.js +7 -30
  52. package/lib/theme-config.js +16 -59
  53. package/lib/utils/NetworkUtils.js +6 -16
  54. package/lib/utils/asyncUtils.js +2 -3
  55. package/lib/utils/frontmatter.js +4 -5
  56. package/lib/utils/fsUtils.js +6 -10
  57. package/lib/validator/schema-translations.js +5 -7
  58. package/package.json +11 -8
  59. package/server/config.js +3 -7
  60. package/server/index.js +29 -29
  61. package/server/lib/page-type-util.js +2 -5
  62. package/server/lib/show-logo.js +3 -3
  63. package/server/lib/utils.js +6 -11
  64. package/server/manifest.js +7 -11
  65. package/server/plugins/renderer/renderer.module.js +38 -100
  66. package/server/plugins/renderer/responses/index.js +7 -4
  67. package/server/plugins/renderer/responses/pencil-response.js +4 -32
  68. package/server/plugins/renderer/responses/raw-response.js +6 -14
  69. package/server/plugins/renderer/responses/redirect-response.js +1 -4
  70. package/server/plugins/router/router.module.js +9 -14
  71. package/server/plugins/theme-assets/theme-assets.module.js +15 -27
package/README.md CHANGED
@@ -8,7 +8,7 @@ The BigCommerce server emulator for local theme development.
8
8
  ## Install
9
9
 
10
10
  Note: Stencil requires the Node.js runtime environment,
11
- versions 16.x, 18.x are supported.
11
+ versions 20.x are supported.
12
12
 
13
13
  Run `npm install -g @bigcommerce/stencil-cli`.
14
14
 
@@ -1,14 +1,11 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
-
5
- const program = require('../lib/commander');
6
- const { THEME_PATH, PACKAGE_INFO } = require('../constants');
7
- const ThemeConfig = require('../lib/theme-config');
8
- const Bundle = require('../lib/stencil-bundle');
9
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
10
- const { prepareCommand } = require('../lib/cliCommon');
11
- const BuildConfigManager = require('../lib/BuildConfigManager');
2
+ import 'colors';
3
+ import program from '../lib/commander.js';
4
+ import { THEME_PATH, PACKAGE_INFO } from '../constants.js';
5
+ import ThemeConfig from '../lib/theme-config.js';
6
+ import Bundle from '../lib/stencil-bundle.js';
7
+ import { printCliResultErrorAndExit, prepareCommand } from '../lib/cliCommon.js';
8
+ import BuildConfigManager from '../lib/BuildConfigManager.js';
12
9
 
13
10
  program
14
11
  .version(PACKAGE_INFO.version)
@@ -29,20 +26,16 @@ program
29
26
  'Set a timeout for the bundle operation. Default is 20 secs',
30
27
  '60',
31
28
  );
32
-
33
29
  const cliOptions = prepareCommand(program);
34
30
  const themeConfig = ThemeConfig.getInstance(THEME_PATH);
35
-
36
31
  async function run() {
37
32
  try {
38
33
  if (cliOptions.dest === true) {
39
34
  throw new Error('You have to specify a value for -d or --dest'.red);
40
35
  }
41
-
42
36
  if (cliOptions.name === true) {
43
37
  throw new Error('You have to specify a value for -n or --name'.red);
44
38
  }
45
-
46
39
  if (!themeConfig.configExists()) {
47
40
  throw new Error(
48
41
  `${
@@ -50,7 +43,6 @@ async function run() {
50
43
  } file in your top level theme directory.`,
51
44
  );
52
45
  }
53
-
54
46
  const rawConfig = await themeConfig.getRawConfig();
55
47
  const timeout = cliOptions.timeout * 1000; // seconds
56
48
  const buildConfigManager = new BuildConfigManager({ timeout });
@@ -61,13 +53,10 @@ async function run() {
61
53
  cliOptions,
62
54
  buildConfigManager,
63
55
  );
64
-
65
56
  const bundlePath = await bundle.initBundle();
66
-
67
57
  console.log(`Bundled saved to: ${bundlePath.cyan}`);
68
58
  } catch (err) {
69
59
  printCliResultErrorAndExit(err);
70
60
  }
71
61
  }
72
-
73
62
  run();
@@ -1,17 +1,13 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
- const program = require('../lib/commander');
5
-
6
- const StencilDebug = require('../lib/StencilDebug');
7
- const { PACKAGE_INFO } = require('../constants');
8
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import 'colors';
3
+ import program from '../lib/commander.js';
4
+ import StencilDebug from '../lib/StencilDebug.js';
5
+ import { PACKAGE_INFO } from '../constants.js';
6
+ import { printCliResultErrorAndExit } from '../lib/cliCommon.js';
9
7
 
10
8
  program
11
9
  .version(PACKAGE_INFO.version)
12
10
  .option('-o, --output [filename]', 'If provided will write to file')
13
11
  .parse(process.argv);
14
-
15
12
  const cliOptions = program.opts();
16
-
17
13
  new StencilDebug().run(cliOptions).catch(printCliResultErrorAndExit);
@@ -1,13 +1,10 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
- const inquirer = require('inquirer');
5
- const program = require('../lib/commander');
6
-
7
- const { PACKAGE_INFO } = require('../constants');
8
- const stencilDownload = require('../lib/stencil-download');
9
- const { prepareCommand } = require('../lib/cliCommon');
10
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import 'colors';
3
+ import inquirer from 'inquirer';
4
+ import program from '../lib/commander.js';
5
+ import { PACKAGE_INFO } from '../constants.js';
6
+ import stencilDownload from '../lib/stencil-download.js';
7
+ import { prepareCommand, printCliResultErrorAndExit } from '../lib/cliCommon.js';
11
8
 
12
9
  program
13
10
  .version(PACKAGE_INFO.version)
@@ -15,7 +12,6 @@ program
15
12
  .option('-e, --exclude [exclude]', 'specify a directory to exclude from download')
16
13
  .option('-c, --channel_id [channelId]', 'specify the channel ID of the storefront', parseInt)
17
14
  .option('-o, --overwrite', 'overwrite local with remote files');
18
-
19
15
  const cliOptions = prepareCommand(program);
20
16
  const extraExclude = cliOptions.exclude ? [cliOptions.exclude] : [];
21
17
  const options = {
@@ -23,13 +19,11 @@ const options = {
23
19
  apiHost: cliOptions.host,
24
20
  channelId: cliOptions.channel_id,
25
21
  overwrite: cliOptions.overwrite,
26
- applyTheme: true, // fix to be compatible with stencil-push.utils
22
+ applyTheme: true,
27
23
  file: cliOptions.file,
28
24
  };
29
-
30
25
  async function run(opts) {
31
26
  const overwriteType = opts.file ? opts.file : 'files';
32
-
33
27
  const promptAnswers = await inquirer.prompt([
34
28
  {
35
29
  message: `${'Warning'.yellow} -- overwrite local with remote ${overwriteType}?`,
@@ -40,26 +34,20 @@ async function run(opts) {
40
34
  },
41
35
  },
42
36
  ]);
43
-
44
37
  const answers = {
45
38
  ...opts,
46
39
  ...promptAnswers,
47
40
  };
48
-
49
41
  if (!answers.overwrite) {
50
42
  console.log(`Request cancelled by user ${'No'.red}`);
51
43
  return;
52
44
  }
53
-
54
45
  console.log(`${'ok'.green} -- ${overwriteType} will be overwritten by the changes`);
55
-
56
46
  try {
57
47
  await stencilDownload(opts);
58
48
  } catch (err) {
59
49
  printCliResultErrorAndExit(err);
60
50
  }
61
-
62
51
  console.log(`${'ok'.green} -- Theme file(s) updated from remote`);
63
52
  }
64
-
65
53
  run(options);
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
-
3
- const program = require('../lib/commander');
4
-
5
- const StencilInit = require('../lib/stencil-init');
6
- const { PACKAGE_INFO } = require('../constants');
7
- const { prepareCommand, printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import program from '../lib/commander.js';
3
+ import StencilInit from '../lib/stencil-init.js';
4
+ import { PACKAGE_INFO } from '../constants.js';
5
+ import { prepareCommand, printCliResultErrorAndExit } from '../lib/cliCommon.js';
8
6
 
9
7
  program
10
8
  .version(PACKAGE_INFO.version)
@@ -14,9 +12,7 @@ program
14
12
  .option('-h, --apiHost [host]', 'API Host')
15
13
  .option('-pm, --packageManager [pm]', 'Package manager')
16
14
  .option('-skip, --skipInstall', 'Skip packages installation');
17
-
18
15
  const cliOptions = prepareCommand(program);
19
-
20
16
  new StencilInit()
21
17
  .run({
22
18
  normalStoreUrl: cliOptions.url,
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
-
5
- const { PACKAGE_INFO } = require('../constants');
6
- const program = require('../lib/commander');
7
- const stencilPull = require('../lib/stencil-pull');
8
- const { prepareCommand } = require('../lib/cliCommon');
9
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import 'colors';
3
+ import { PACKAGE_INFO } from '../constants.js';
4
+ import program from '../lib/commander.js';
5
+ import stencilPull from '../lib/stencil-pull.js';
6
+ import { prepareCommand, printCliResultErrorAndExit } from '../lib/cliCommon.js';
10
7
 
11
8
  program
12
9
  .version(PACKAGE_INFO.version)
@@ -21,9 +18,7 @@ program
21
18
  'specify the channel ID of the storefront to pull configuration from',
22
19
  parseInt,
23
20
  );
24
-
25
21
  const cliOptions = prepareCommand(program);
26
-
27
22
  const options = {
28
23
  apiHost: cliOptions.host,
29
24
  saveConfigName: cliOptions.filename,
@@ -31,7 +26,6 @@ const options = {
31
26
  saved: cliOptions.saved || false,
32
27
  applyTheme: true, // fix to be compatible with stencil-push.utils
33
28
  };
34
-
35
29
  stencilPull(options, (err) => {
36
30
  if (err) {
37
31
  printCliResultErrorAndExit(err);
@@ -1,11 +1,9 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
- const { PACKAGE_INFO } = require('../constants');
5
- const program = require('../lib/commander');
6
- const stencilPush = require('../lib/stencil-push');
7
- const { prepareCommand } = require('../lib/cliCommon');
8
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import 'colors';
3
+ import { PACKAGE_INFO } from '../constants.js';
4
+ import program from '../lib/commander.js';
5
+ import stencilPush from '../lib/stencil-push.js';
6
+ import { prepareCommand, printCliResultErrorAndExit } from '../lib/cliCommon.js';
9
7
 
10
8
  program
11
9
  .version(PACKAGE_INFO.version)
@@ -18,7 +16,6 @@ program
18
16
  'specify the channel IDs of the storefront to push the theme to',
19
17
  )
20
18
  .option('-allc, --all_channels', 'push a theme to all available channels');
21
-
22
19
  const cliOptions = prepareCommand(program);
23
20
  const options = {
24
21
  apiHost: cliOptions.host,
@@ -1,22 +1,17 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
- const StencilRelease = require('../lib/release/release');
5
- const { PACKAGE_INFO } = require('../constants');
6
- const program = require('../lib/commander');
7
- const { checkNodeVersion } = require('../lib/cliCommon');
8
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import 'colors';
3
+ import StencilRelease from '../lib/release/release.js';
4
+ import { PACKAGE_INFO } from '../constants.js';
5
+ import program from '../lib/commander.js';
6
+ import { checkNodeVersion, printCliResultErrorAndExit } from '../lib/cliCommon.js';
9
7
 
10
8
  program
11
9
  .version(PACKAGE_INFO.version)
12
10
  .option('-b, --branch [name]', 'specify the main branch name')
13
11
  .parse(process.argv);
14
-
15
12
  checkNodeVersion();
16
-
17
13
  const cliOptions = program.opts();
18
14
  const options = {
19
15
  branch: cliOptions.branch || 'master',
20
16
  };
21
-
22
17
  new StencilRelease().run(options).catch(printCliResultErrorAndExit);
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
- const program = require('../lib/commander');
5
-
6
- const ThemeConfig = require('../lib/theme-config');
7
- const NodeSassAutoFixer = require('../lib/nodeSass/AutoFixer');
8
- const { THEME_PATH, PACKAGE_INFO } = require('../constants');
9
- const { printCliResultErrorAndExit } = require('../lib/cliCommon');
2
+ import 'colors';
3
+ import program from '../lib/commander.js';
4
+ import ThemeConfig from '../lib/theme-config.js';
5
+ import NodeSassAutoFixer from '../lib/nodeSass/AutoFixer.js';
6
+ import { THEME_PATH, PACKAGE_INFO } from '../constants.js';
7
+ import { printCliResultErrorAndExit } from '../lib/cliCommon.js';
10
8
 
11
9
  program
12
10
  .version(PACKAGE_INFO.version)
@@ -15,9 +13,6 @@ program
15
13
  'will not write any changes to the file system, instead it will print the changes to the console',
16
14
  )
17
15
  .parse(process.argv);
18
-
19
16
  const cliOptions = program.opts();
20
-
21
17
  const themeConfig = ThemeConfig.getInstance(THEME_PATH);
22
-
23
18
  new NodeSassAutoFixer(THEME_PATH, themeConfig, cliOptions).run().catch(printCliResultErrorAndExit);
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
-
3
- require('colors');
4
- const { PACKAGE_INFO } = require('../constants');
5
- const program = require('../lib/commander');
6
- const StencilStart = require('../lib/stencil-start');
7
- const { printCliResultErrorAndExit, prepareCommand } = require('../lib/cliCommon');
8
- const BuildConfigManager = require('../lib/BuildConfigManager');
2
+ import 'colors';
3
+ import { PACKAGE_INFO } from '../constants.js';
4
+ import program from '../lib/commander.js';
5
+ import StencilStart from '../lib/stencil-start.js';
6
+ import { printCliResultErrorAndExit, prepareCommand } from '../lib/cliCommon.js';
7
+ import BuildConfigManager from '../lib/BuildConfigManager.js';
9
8
 
10
9
  program
11
10
  .version(PACKAGE_INFO.version)
@@ -21,7 +20,6 @@ program
21
20
  'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.',
22
21
  )
23
22
  .option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60');
24
-
25
23
  const cliOptions = prepareCommand(program);
26
24
  const options = {
27
25
  open: cliOptions.open,
@@ -31,7 +29,6 @@ const options = {
31
29
  tunnel: cliOptions.tunnel,
32
30
  cache: cliOptions.cache,
33
31
  };
34
-
35
32
  const timeout = cliOptions.timeout * 1000; // seconds
36
33
  const buildConfigManager = new BuildConfigManager({ timeout });
37
34
  new StencilStart({ buildConfigManager }).run(options).catch(printCliResultErrorAndExit);
package/bin/stencil.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
-
3
- const program = require('../lib/commander');
4
- const { PACKAGE_INFO } = require('../constants');
2
+ import program from '../lib/commander.js';
3
+ import { PACKAGE_INFO } from '../constants.js';
5
4
 
6
5
  program
7
6
  .version(PACKAGE_INFO.version)
package/constants.js CHANGED
@@ -1,23 +1,23 @@
1
- /// ////////////////////////////////////// Stencil CLI ///////////////////////////////////// ///
2
-
3
- const PACKAGE_INFO = require('./package.json');
4
-
1
+ import { readFileSync } from 'fs';
5
2
  /// //////////////////////////////////////// Themes /////////////////////////////////////// ///
6
-
7
3
  const THEME_PATH = process.cwd();
8
-
9
4
  const DEFAULT_CUSTOM_LAYOUTS_CONFIG = {
10
5
  brand: {},
11
6
  category: {},
12
7
  page: {},
13
8
  product: {},
14
9
  };
15
-
16
10
  /// ///////////////////////////////////////// Other //////////////////////////////////////// ///
17
-
18
11
  const API_HOST = 'https://api.bigcommerce.com';
19
12
 
20
- module.exports = {
13
+ const packageConfigUrl = new URL('./package.json', import.meta.url);
14
+ const PACKAGE_INFO = JSON.parse(readFileSync(packageConfigUrl));
15
+
16
+ export { PACKAGE_INFO };
17
+ export { THEME_PATH };
18
+ export { DEFAULT_CUSTOM_LAYOUTS_CONFIG };
19
+ export { API_HOST };
20
+ export default {
21
21
  PACKAGE_INFO,
22
22
  THEME_PATH,
23
23
  DEFAULT_CUSTOM_LAYOUTS_CONFIG,
@@ -1,24 +1,25 @@
1
- const _ = require('lodash');
2
- const { fork } = require('child_process');
3
- const path = require('path');
4
- const fsModule = require('fs');
1
+ import { once } from 'lodash-es';
2
+ import { fork } from 'child_process';
3
+ import path from 'path';
4
+ import fsModule from 'fs';
5
+ import { createRequire } from 'node:module';
6
+ import { THEME_PATH } from '../constants.js';
5
7
 
6
- const { THEME_PATH } = require('../constants');
8
+ const require = createRequire(import.meta.url);
7
9
 
8
10
  class BuildConfigManager {
9
11
  constructor({ workDir = THEME_PATH, fs = fsModule, timeout = 20000 } = {}) {
10
- this.configFileName = 'stencil.conf.js';
11
-
12
+ this.oldConfigFileName = 'stencil.conf.js';
13
+ this.configFileName = 'stencil.conf.cjs';
12
14
  this._workDir = workDir;
13
15
  this._buildConfigPath = path.join(workDir, this.configFileName);
16
+ this._oldBuildConfigPath = path.join(workDir, this.oldConfigFileName);
14
17
  this._fs = fs;
15
18
  this._onReadyCallbacks = [];
16
19
  this._worker = null;
17
20
  this._workerIsReady = false;
18
21
  this.timeout = timeout;
19
-
20
- const config = this._getConfig(this._buildConfigPath);
21
-
22
+ const config = this._getConfig(this._buildConfigPath, this._oldBuildConfigPath);
22
23
  this.development = config.development || this._devWorker;
23
24
  this.production = config.production || this._prodWorker;
24
25
  this.watchOptions = config.watchOptions;
@@ -27,7 +28,6 @@ class BuildConfigManager {
27
28
  initWorker() {
28
29
  if (this._fs.existsSync(this._buildConfigPath)) {
29
30
  this._worker = fork(this._buildConfigPath, [], { cwd: this._workDir });
30
-
31
31
  this._worker.on('message', (message) => {
32
32
  if (message === 'ready') {
33
33
  this._workerIsReady = true;
@@ -35,7 +35,6 @@ class BuildConfigManager {
35
35
  }
36
36
  });
37
37
  }
38
-
39
38
  return this;
40
39
  }
41
40
 
@@ -43,20 +42,28 @@ class BuildConfigManager {
43
42
  this._worker.kill(signal);
44
43
  }
45
44
 
46
- _getConfig(configPath) {
45
+ _getConfig(configPath, oldConfigPath) {
47
46
  if (this._fs.existsSync(configPath)) {
48
- // eslint-disable-next-line
47
+ // eslint-disable-next-line import/no-dynamic-require
48
+ return require(configPath);
49
+ }
50
+ if (this._fs.existsSync(oldConfigPath)) {
51
+ this._moveOldConfig(configPath, oldConfigPath);
52
+ // eslint-disable-next-line import/no-dynamic-require
49
53
  return require(configPath);
50
54
  }
51
-
52
55
  return {};
53
56
  }
54
57
 
58
+ _moveOldConfig(newPath, oldPath) {
59
+ this._fs.copyFileSync(oldPath, newPath);
60
+ this._fs.rmSync(oldPath);
61
+ }
62
+
55
63
  _onWorkerReady(onReady) {
56
64
  if (this._workerIsReady) {
57
65
  process.nextTick(onReady);
58
66
  }
59
-
60
67
  this._onReadyCallbacks.push(onReady);
61
68
  }
62
69
 
@@ -75,13 +82,11 @@ class BuildConfigManager {
75
82
  }
76
83
 
77
84
  _prodWorker(done) {
78
- const callback = _.once(done);
79
-
85
+ const callback = once(done);
80
86
  if (!this._worker) {
81
87
  process.nextTick(() => callback('worker initialization failed'));
82
88
  return;
83
89
  }
84
-
85
90
  const timeoutId = setTimeout(() => {
86
91
  this.stopWorker();
87
92
  console.log(
@@ -90,7 +95,6 @@ class BuildConfigManager {
90
95
  );
91
96
  callback('worker timed out');
92
97
  }, this.timeout);
93
-
94
98
  this._onWorkerReady(() => {
95
99
  clearTimeout(timeoutId);
96
100
  // send a message to the worker to start bundling js
@@ -102,12 +106,10 @@ class BuildConfigManager {
102
106
  }
103
107
  });
104
108
  });
105
-
106
109
  this._worker.on('close', () => {
107
110
  callback('worker terminated');
108
111
  clearTimeout(timeoutId);
109
112
  });
110
113
  }
111
114
  }
112
-
113
- module.exports = BuildConfigManager;
115
+ export default BuildConfigManager;
package/lib/Cycles.js CHANGED
@@ -1,5 +1,5 @@
1
- const Graph = require('tarjan-graph');
2
- const util = require('util');
1
+ import Graph from 'tarjan-graph';
2
+ import util from 'util';
3
3
 
4
4
  class Cycles {
5
5
  /**
@@ -9,7 +9,6 @@ class Cycles {
9
9
  if (!Array.isArray(templatePaths)) {
10
10
  throw new Error('templatePaths must be an Array');
11
11
  }
12
-
13
12
  this.templatePaths = templatePaths;
14
13
  this.partialRegex = /{{>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}}/g;
15
14
  this.dynamicComponentRegex = /{{\s*?dynamicComponent\s*(?:'|")([_|\-|a-zA-Z0-9/]+)(?:'|").*?}}/g;
@@ -22,7 +21,6 @@ class Cycles {
22
21
  detect() {
23
22
  for (const templatesByPath of this.templatePaths) {
24
23
  const graph = new Graph();
25
-
26
24
  for (const [templatePath, templateContent] of Object.entries(templatesByPath)) {
27
25
  const dependencies = [
28
26
  ...this._geDependantPartials(templateContent, templatePath),
@@ -32,10 +30,8 @@ class Cycles {
32
30
  templatePath,
33
31
  ),
34
32
  ];
35
-
36
33
  graph.add(templatePath, dependencies);
37
34
  }
38
-
39
35
  if (graph.hasCycle()) {
40
36
  const foundCycles = util.inspect(graph.getCycles());
41
37
  throw new Error(`Circular dependency in template detected. \r\n${foundCycles}`);
@@ -51,7 +47,6 @@ class Cycles {
51
47
  */
52
48
  _geDependantPartials(templateContent, pathToSkip) {
53
49
  const dependencies = [];
54
-
55
50
  let match = this.partialRegex.exec(templateContent);
56
51
  while (match !== null) {
57
52
  const partialPath = match[1];
@@ -61,7 +56,6 @@ class Cycles {
61
56
  }
62
57
  match = this.partialRegex.exec(templateContent);
63
58
  }
64
-
65
59
  return dependencies;
66
60
  }
67
61
 
@@ -74,7 +68,6 @@ class Cycles {
74
68
  */
75
69
  _getDependantDynamicComponents(templateContent, allTemplatesByPath, pathToSkip) {
76
70
  const dependencies = [];
77
-
78
71
  let match = this.dynamicComponentRegex.exec(templateContent);
79
72
  while (match !== null) {
80
73
  const dynamicComponents = this._getDynamicComponents(
@@ -85,7 +78,6 @@ class Cycles {
85
78
  dependencies.push(...dynamicComponents);
86
79
  match = this.dynamicComponentRegex.exec(templateContent);
87
80
  }
88
-
89
81
  return dependencies;
90
82
  }
91
83
 
@@ -105,5 +97,4 @@ class Cycles {
105
97
  }, []);
106
98
  }
107
99
  }
108
-
109
- module.exports = Cycles;
100
+ export default Cycles;
@@ -1,8 +1,7 @@
1
- require('colors');
2
- const path = require('path');
3
- const StencilStyles = require('@bigcommerce/stencil-styles');
4
-
5
- const cssCompiler = require('./css/compile');
1
+ import 'colors';
2
+ import path from 'path';
3
+ import StencilStyles from '@bigcommerce/stencil-styles';
4
+ import cssCompiler from './css/compile.js';
6
5
 
7
6
  class ScssValidator {
8
7
  /**
@@ -20,7 +19,6 @@ class ScssValidator {
20
19
  const stylesPath = path.join(this.themePath, 'assets/scss');
21
20
  const rawConfig = await this.themeConfig.getConfig();
22
21
  const cssFiles = await this.getCssFiles();
23
-
24
22
  for await (const file of cssFiles) {
25
23
  try {
26
24
  /* eslint-disable-next-line no-await-in-loop */
@@ -43,7 +41,6 @@ class ScssValidator {
43
41
  if (e.formatted) {
44
42
  return `${e.formatted.replace('Error: ', '')}: `;
45
43
  }
46
-
47
44
  return e.message;
48
45
  }
49
46
 
@@ -52,5 +49,4 @@ class ScssValidator {
52
49
  return styles.getCssFiles(this.themePath);
53
50
  }
54
51
  }
55
-
56
- module.exports = ScssValidator;
52
+ export default ScssValidator;
@@ -14,7 +14,5 @@ class StencilCLISettings {
14
14
  return this.versboseNetworkLogging;
15
15
  }
16
16
  }
17
-
18
17
  const settings = new StencilCLISettings();
19
-
20
- module.exports = settings;
18
+ export default settings;