@bigcommerce/stencil-cli 4.1.1 → 5.0.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.
- package/CHANGELOG.md +7 -0
- package/README.md +15 -1
- package/lib/stencil-push.js +1 -0
- package/lib/stencil-push.utils.js +45 -1
- package/lib/theme-api-client.js +8 -2
- package/package-lock.json +166 -317
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
### Draft
|
|
2
2
|
|
|
3
|
+
### 5.0.0 (2022-06-07)
|
|
4
|
+
|
|
5
|
+
- fix: STRF-9835 Bump paper ([947](https://github.com/bigcommerce/stencil-cli/pull/947))
|
|
6
|
+
- feat: strf-9791 Drop Node 12 Support ([945](https://github.com/bigcommerce/stencil-cli/pull/945))
|
|
7
|
+
- feat: STRF-9807 Dockerize stencil cli ([938]https://github.com/bigcommerce/stencil-cli/pull/938)
|
|
8
|
+
- merc-8592 Fix stencil CLI Push resulting in intermittent failures ([935]https://github.com/bigcommerce/stencil-cli/pull/935)
|
|
9
|
+
|
|
3
10
|
### 4.1.1 (2022-05-24)
|
|
4
11
|
|
|
5
12
|
- fix: strf-9781 Bump dev packages for linting ([932](https://github.com/bigcommerce/stencil-cli/pull/932))
|
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
|
-
version
|
|
11
|
+
version 14.x is supported.
|
|
12
12
|
We do not yet have support for versions greater than Node 14._
|
|
13
13
|
|
|
14
14
|
Run `npm install -g @bigcommerce/stencil-cli`.
|
|
@@ -95,6 +95,20 @@ If you need any help or experience any bugs, please create a GitHub issue in thi
|
|
|
95
95
|
If you would like to improve this project check out the [Contributing Guide](./CONTRIBUTING.md). Also, you can find
|
|
96
96
|
the implementation details there.
|
|
97
97
|
|
|
98
|
+
## Running in docker
|
|
99
|
+
|
|
100
|
+
There is possibility to run stencil-cli in docker.
|
|
101
|
+
Here are steps to have this functionality.
|
|
102
|
+
First of all, build a docker image, let's name it `bc/stencil-cli`
|
|
103
|
+
Run `docker build . -t bc/stencil-cli` in stencil-cli repo directory.
|
|
104
|
+
|
|
105
|
+
Then, after the image is built, you want to run some commands against your theme.
|
|
106
|
+
|
|
107
|
+
For example
|
|
108
|
+
`docker run -p 3005:3005 -v /bigcommerce/cornerstone:/usr/src/app -it bc/stencil-cli stencil init`, where `3005` is port number definded in `config.stencil.json` and `/bigcommerce/cornerstone` path to where theme is located.
|
|
109
|
+
|
|
110
|
+
`docker run -p 3005:3005 -v /bigcommerce/cornerstone:/usr/src/app -it bc/stencil-cli stencil start` and so on
|
|
111
|
+
|
|
98
112
|
## License
|
|
99
113
|
|
|
100
114
|
Copyright (c) 2015-present, BigCommerce Inc.
|
package/lib/stencil-push.js
CHANGED
|
@@ -13,6 +13,7 @@ function stencilPush(options = {}, callback) {
|
|
|
13
13
|
utils.notifyUserOfThemeLimitReachedIfNecessary,
|
|
14
14
|
utils.promptUserToDeleteThemesIfNecessary,
|
|
15
15
|
utils.deleteThemesIfNecessary,
|
|
16
|
+
utils.checkIfDeletionIsComplete(),
|
|
16
17
|
utils.uploadBundleAgainIfNecessary,
|
|
17
18
|
utils.notifyUserOfThemeUploadCompletion,
|
|
18
19
|
utils.pollForJobCompletion((data) => ({ themeId: data.theme_id })),
|
|
@@ -87,6 +87,7 @@ utils.uploadBundle = async (options) => {
|
|
|
87
87
|
config: { accessToken },
|
|
88
88
|
bundleZipPath,
|
|
89
89
|
storeHash,
|
|
90
|
+
uploadBundleAgain,
|
|
90
91
|
} = options;
|
|
91
92
|
|
|
92
93
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
@@ -97,6 +98,7 @@ utils.uploadBundle = async (options) => {
|
|
|
97
98
|
apiHost,
|
|
98
99
|
bundleZipPath,
|
|
99
100
|
storeHash,
|
|
101
|
+
uploadBundleAgain,
|
|
100
102
|
});
|
|
101
103
|
return {
|
|
102
104
|
...options,
|
|
@@ -188,12 +190,54 @@ utils.deleteThemesIfNecessary = async (options) => {
|
|
|
188
190
|
return options;
|
|
189
191
|
};
|
|
190
192
|
|
|
193
|
+
utils.checkIfDeletionIsComplete = () => {
|
|
194
|
+
return async.retryable(
|
|
195
|
+
{
|
|
196
|
+
interval: 1000,
|
|
197
|
+
errorFilter: (err) => {
|
|
198
|
+
if (err.message === 'ThemeStillExists') {
|
|
199
|
+
console.log(`${'warning'.yellow} -- Theme still exists;Retrying ...`);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
},
|
|
204
|
+
times: 5,
|
|
205
|
+
},
|
|
206
|
+
utils.checkIfThemeIsDeleted(),
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
utils.checkIfThemeIsDeleted = () => async (options) => {
|
|
211
|
+
const {
|
|
212
|
+
themeLimitReached,
|
|
213
|
+
config: { accessToken },
|
|
214
|
+
storeHash,
|
|
215
|
+
themeIdsToDelete,
|
|
216
|
+
} = options;
|
|
217
|
+
|
|
218
|
+
if (!themeLimitReached) {
|
|
219
|
+
return options;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const apiHost = options.apiHost || options.config.apiHost;
|
|
223
|
+
|
|
224
|
+
const result = await themeApiClient.getThemes({ accessToken, apiHost, storeHash });
|
|
225
|
+
|
|
226
|
+
const themeStillExists = result.some((theme) => themeIdsToDelete.includes(theme.uuid));
|
|
227
|
+
|
|
228
|
+
if (themeStillExists) {
|
|
229
|
+
throw new Error('ThemeStillExists');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return options;
|
|
233
|
+
};
|
|
234
|
+
|
|
191
235
|
utils.uploadBundleAgainIfNecessary = async (options) => {
|
|
192
236
|
if (!options.themeLimitReached) {
|
|
193
237
|
return options;
|
|
194
238
|
}
|
|
195
239
|
|
|
196
|
-
return utils.uploadBundle(options);
|
|
240
|
+
return utils.uploadBundle({ ...options, uploadThemeAgain: true });
|
|
197
241
|
};
|
|
198
242
|
|
|
199
243
|
utils.notifyUserOfThemeUploadCompletion = async (options) => {
|
package/lib/theme-api-client.js
CHANGED
|
@@ -278,9 +278,10 @@ async function getVariationsByThemeId({ accessToken, apiHost, storeHash, themeId
|
|
|
278
278
|
* @param {string} options.accessToken
|
|
279
279
|
* @param {string} options.apiHost
|
|
280
280
|
* @param {string} options.storeHash
|
|
281
|
+
* @param {boolean} options.uploadBundleAgain
|
|
281
282
|
* @returns {Promise<object>}
|
|
282
283
|
*/
|
|
283
|
-
async function postTheme({ bundleZipPath, accessToken, apiHost, storeHash }) {
|
|
284
|
+
async function postTheme({ bundleZipPath, accessToken, apiHost, storeHash, uploadBundleAgain }) {
|
|
284
285
|
const formData = new FormData();
|
|
285
286
|
formData.append('file', fs.createReadStream(bundleZipPath), {
|
|
286
287
|
filename: path.basename(bundleZipPath),
|
|
@@ -303,7 +304,12 @@ async function postTheme({ bundleZipPath, accessToken, apiHost, storeHash }) {
|
|
|
303
304
|
// This status code is overloaded, so we need to check the message to determine
|
|
304
305
|
// if we want to trigger the theme deletion flow.
|
|
305
306
|
const uploadLimitPattern = /You have reached your upload limit/;
|
|
306
|
-
if (
|
|
307
|
+
if (
|
|
308
|
+
payload &&
|
|
309
|
+
payload.title &&
|
|
310
|
+
uploadLimitPattern.exec(payload.title) &&
|
|
311
|
+
!uploadBundleAgain
|
|
312
|
+
) {
|
|
307
313
|
return { themeLimitReached: true };
|
|
308
314
|
}
|
|
309
315
|
|