@bigcommerce/stencil-cli 7.4.2 → 7.5.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.
@@ -129,10 +129,9 @@ class StencilConfigManager {
129
129
  }
130
130
 
131
131
  if (!config.apiHost) {
132
- this._logger.log(
133
- `No api host found in config file, falling back to ${API_HOST}. You may need to run 'stencil init' again.`,
134
- );
135
132
  config.apiHost = API_HOST;
133
+ } else {
134
+ this._logger.log(`API host set in config file: ${config.apiHost}`);
136
135
  }
137
136
 
138
137
  return config;
package/lib/spinner.js ADDED
@@ -0,0 +1,10 @@
1
+ const spinner = async (action, options) => {
2
+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
3
+ const { oraPromise } = await import('ora');
4
+ return oraPromise(action, {
5
+ spinner: 'triangle',
6
+ ...options,
7
+ });
8
+ };
9
+
10
+ module.exports = spinner;
@@ -1,10 +1,12 @@
1
1
  require('colors');
2
2
 
3
3
  const inquirerModule = require('inquirer');
4
+ const nypmModule = require('nypm');
4
5
 
6
+ const spinnerModule = require('./spinner');
5
7
  const serverConfigModule = require('../server/config');
6
8
  const StencilConfigManager = require('./StencilConfigManager');
7
- const { DEFAULT_CUSTOM_LAYOUTS_CONFIG, API_HOST } = require('../constants');
9
+ const { DEFAULT_CUSTOM_LAYOUTS_CONFIG, API_HOST, THEME_PATH } = require('../constants');
8
10
 
9
11
  class StencilInit {
10
12
  /**
@@ -12,17 +14,23 @@ class StencilInit {
12
14
  * @param stencilConfigManager
13
15
  * @param serverConfig
14
16
  * @param logger
17
+ * @param nypm
18
+ * @param spinner
15
19
  */
16
20
  constructor({
17
21
  inquirer = inquirerModule,
18
22
  stencilConfigManager = new StencilConfigManager(),
19
23
  serverConfig = serverConfigModule,
20
24
  logger = console,
25
+ nypm = nypmModule,
26
+ spinner = spinnerModule,
21
27
  } = {}) {
22
28
  this._inquirer = inquirer;
23
29
  this._stencilConfigManager = stencilConfigManager;
24
30
  this._serverConfig = serverConfig;
25
31
  this._logger = logger;
32
+ this._nypm = nypm;
33
+ this._spinner = spinner;
26
34
  }
27
35
 
28
36
  /**
@@ -39,6 +47,7 @@ class StencilInit {
39
47
  const answers = await this.askQuestions(questions);
40
48
  const updatedStencilConfig = this.applyAnswers(oldStencilConfig, answers, cliOptions);
41
49
  await this._stencilConfigManager.save(updatedStencilConfig);
50
+ await this.installDependencies(THEME_PATH, answers.packageManager);
42
51
 
43
52
  this._logger.log(
44
53
  'You are now ready to go! To start developing, run $ ' + 'stencil start'.cyan,
@@ -123,6 +132,16 @@ class StencilInit {
123
132
  });
124
133
  }
125
134
 
135
+ if (!cliOptions.packageManager) {
136
+ prompts.push({
137
+ type: 'list',
138
+ name: 'packageManager',
139
+ message: 'What is your favourite Package Manager?',
140
+ choices: ['npm', 'yarn', 'pnpm'],
141
+ default: this.getPackageManager(),
142
+ });
143
+ }
144
+
126
145
  return prompts;
127
146
  }
128
147
 
@@ -157,6 +176,41 @@ class StencilInit {
157
176
  ...answers,
158
177
  };
159
178
  }
179
+
180
+ getPackageManager() {
181
+ const userAgent = process.env.npm_config_user_agent || '';
182
+
183
+ if (userAgent.startsWith('yarn')) {
184
+ return 'yarn';
185
+ }
186
+
187
+ if (userAgent.startsWith('pnpm')) {
188
+ return 'pnpm';
189
+ }
190
+
191
+ return 'npm';
192
+ }
193
+
194
+ /**
195
+ *
196
+ * @param {string} projectDir
197
+ * @param {object} packageManager
198
+ * @returns
199
+ */
200
+ installDependencies(projectDir, packageManager) {
201
+ return this._spinner(
202
+ this._nypm.installDependencies({
203
+ cwd: projectDir,
204
+ silent: true,
205
+ packageManager,
206
+ }),
207
+ {
208
+ text: `Installing dependencies. This could take a minute...`,
209
+ successText: `Dependencies installed successfully`,
210
+ failText: (err) => `Failed to install dependencies: ${err.message}`.red,
211
+ },
212
+ );
213
+ }
160
214
  }
161
215
 
162
216
  module.exports = StencilInit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcommerce/stencil-cli",
3
- "version": "7.4.2",
3
+ "version": "7.5.0",
4
4
  "description": "CLI tool to run BigCommerce Stores locally for theme development.",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -59,7 +59,7 @@
59
59
  "ajv": "^6.12.5",
60
60
  "archiver": "^5.0.2",
61
61
  "async": "^3.2.3",
62
- "axios": "^0.27.2",
62
+ "axios": "^0.28.0",
63
63
  "browser-sync": "^2.27.9",
64
64
  "cheerio": "^1.0.0-rc.12",
65
65
  "colors": "1.4.0",
@@ -76,7 +76,9 @@
76
76
  "lodash": "^4.17.20",
77
77
  "memory-cache": "^0.2.0",
78
78
  "npm-which": "^3.0.1",
79
+ "nypm": "^0.3.8",
79
80
  "object-to-spawn-args": "^2.0.0",
81
+ "ora": "^8.0.1",
80
82
  "parse-json": "^5.2.0",
81
83
  "postcss": "^8.4.21",
82
84
  "postcss-safe-parser": "^6.0.0",