@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.
- package/README.md +1 -1
- package/bin/stencil-bundle.js +7 -18
- package/bin/stencil-debug.js +5 -9
- package/bin/stencil-download.js +7 -19
- package/bin/stencil-init.js +4 -8
- package/bin/stencil-pull.js +5 -11
- package/bin/stencil-push.js +5 -8
- package/bin/stencil-release.js +5 -10
- package/bin/stencil-scss-autofix.js +6 -11
- package/bin/stencil-start.js +6 -9
- package/bin/stencil.js +2 -3
- package/constants.js +9 -9
- package/lib/BuildConfigManager.js +25 -23
- package/lib/Cycles.js +3 -12
- package/lib/ScssValidator.js +5 -9
- package/lib/StencilCLISettings.js +1 -3
- package/lib/StencilConfigManager.js +6 -22
- package/lib/StencilDebug.js +7 -10
- package/lib/archiveManager.js +7 -23
- package/lib/bundle-validator.js +28 -64
- package/lib/cliCommon.js +11 -21
- package/lib/commander.js +2 -3
- package/lib/content-api-client.js +5 -13
- package/lib/css/compile.js +3 -6
- package/lib/graphql/query.js +5 -8
- package/lib/lang/validator.js +5 -11
- package/lib/lang-assembler.js +4 -10
- package/lib/lang-helper.js +3 -6
- package/lib/nodeSass/AutoFixer.js +10 -19
- package/lib/nodeSass/BaseFixer.js +5 -7
- package/lib/nodeSass/BaseRulesFixer.js +3 -8
- package/lib/nodeSass/CommaRemovalFixer.js +3 -8
- package/lib/nodeSass/ConditionalImportFixer.js +3 -9
- package/lib/nodeSass/UndefinedVariableFixer.js +3 -6
- package/lib/parse-json.js +10 -9
- package/lib/regions.js +3 -23
- package/lib/release/questions.js +3 -13
- package/lib/release/release.js +16 -55
- package/lib/spinner.js +1 -2
- package/lib/stencil-bundle.js +15 -75
- package/lib/stencil-download.js +5 -6
- package/lib/stencil-download.utils.js +5 -18
- package/lib/stencil-init.js +8 -24
- package/lib/stencil-pull.js +4 -5
- package/lib/stencil-pull.utils.js +5 -28
- package/lib/stencil-push.js +3 -4
- package/lib/stencil-push.utils.js +12 -102
- package/lib/stencil-start.js +19 -48
- package/lib/store-settings-api-client.js +4 -7
- package/lib/template-assembler.js +6 -45
- package/lib/theme-api-client.js +7 -30
- package/lib/theme-config.js +16 -59
- package/lib/utils/NetworkUtils.js +6 -16
- package/lib/utils/asyncUtils.js +2 -3
- package/lib/utils/frontmatter.js +4 -5
- package/lib/utils/fsUtils.js +6 -10
- package/lib/validator/schema-translations.js +5 -7
- package/package.json +11 -8
- package/server/config.js +3 -7
- package/server/index.js +29 -29
- package/server/lib/page-type-util.js +2 -5
- package/server/lib/show-logo.js +3 -3
- package/server/lib/utils.js +6 -11
- package/server/manifest.js +7 -11
- package/server/plugins/renderer/renderer.module.js +38 -100
- package/server/plugins/renderer/responses/index.js +7 -4
- package/server/plugins/renderer/responses/pencil-response.js +4 -32
- package/server/plugins/renderer/responses/raw-response.js +6 -14
- package/server/plugins/renderer/responses/redirect-response.js +1 -4
- package/server/plugins/router/router.module.js +9 -14
- package/server/plugins/theme-assets/theme-assets.module.js +15 -27
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const StencilConfigManager = require('./StencilConfigManager');
|
|
1
|
+
import * as _ from 'lodash-es';
|
|
2
|
+
import async from 'async';
|
|
3
|
+
import Inquirer from 'inquirer';
|
|
4
|
+
import ProgressBar from 'progress';
|
|
5
|
+
import uuid from 'uuid4';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import { THEME_PATH } from '../constants.js';
|
|
8
|
+
import Bundle from './stencil-bundle.js';
|
|
9
|
+
import themeApiClient from './theme-api-client.js';
|
|
10
|
+
import ThemeConfig from './theme-config.js';
|
|
11
|
+
import StencilConfigManager from './StencilConfigManager.js';
|
|
13
12
|
|
|
14
13
|
const themeConfigManager = ThemeConfig.getInstance(THEME_PATH);
|
|
15
14
|
const stencilConfigManager = new StencilConfigManager();
|
|
16
15
|
const utils = {};
|
|
17
|
-
|
|
18
16
|
const bar = new ProgressBar('Processing [:bar] :percent; ETA: :etas', {
|
|
19
17
|
complete: '=',
|
|
20
18
|
incomplete: ' ',
|
|
21
19
|
total: 100,
|
|
22
20
|
});
|
|
23
|
-
|
|
24
21
|
function validateOptions(options = {}, fields = []) {
|
|
25
22
|
for (const field of fields) {
|
|
26
23
|
if (!_.has(options, field)) {
|
|
@@ -28,7 +25,6 @@ function validateOptions(options = {}, fields = []) {
|
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
utils.readStencilConfigFile = async (options) => {
|
|
33
29
|
try {
|
|
34
30
|
const config = await stencilConfigManager.read();
|
|
@@ -38,41 +34,31 @@ utils.readStencilConfigFile = async (options) => {
|
|
|
38
34
|
throw err;
|
|
39
35
|
}
|
|
40
36
|
};
|
|
41
|
-
|
|
42
37
|
utils.getStoreHash = async (options) => {
|
|
43
38
|
validateOptions(options, ['config.normalStoreUrl']);
|
|
44
|
-
|
|
45
39
|
const storeHash = await themeApiClient.getStoreHash({
|
|
46
40
|
storeUrl: options.config.normalStoreUrl,
|
|
47
41
|
});
|
|
48
|
-
|
|
49
42
|
return { ...options, storeHash };
|
|
50
43
|
};
|
|
51
|
-
|
|
52
44
|
utils.getThemes = async (options) => {
|
|
53
45
|
const {
|
|
54
46
|
config: { accessToken },
|
|
55
47
|
storeHash,
|
|
56
48
|
} = options;
|
|
57
|
-
|
|
58
49
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
59
|
-
|
|
60
50
|
const themes = await themeApiClient.getThemes({ accessToken, apiHost, storeHash });
|
|
61
|
-
|
|
62
51
|
return { ...options, themes };
|
|
63
52
|
};
|
|
64
|
-
|
|
65
53
|
utils.generateBundle = async (options) => {
|
|
66
54
|
if (options.bundleZipPath) {
|
|
67
55
|
return options;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
const output = options.saveBundleName
|
|
71
58
|
? { dest: THEME_PATH, name: options.saveBundleName }
|
|
72
59
|
: { dest: os.tmpdir(), name: uuid() };
|
|
73
60
|
const rawConfig = await themeConfigManager.getRawConfig();
|
|
74
61
|
const bundle = new Bundle(THEME_PATH, themeConfigManager, rawConfig, output);
|
|
75
|
-
|
|
76
62
|
try {
|
|
77
63
|
const bundleZipPath = await bundle.initBundle();
|
|
78
64
|
return { ...options, bundleZipPath };
|
|
@@ -81,7 +67,6 @@ utils.generateBundle = async (options) => {
|
|
|
81
67
|
throw err;
|
|
82
68
|
}
|
|
83
69
|
};
|
|
84
|
-
|
|
85
70
|
utils.uploadBundle = async (options) => {
|
|
86
71
|
const {
|
|
87
72
|
config: { accessToken },
|
|
@@ -89,9 +74,7 @@ utils.uploadBundle = async (options) => {
|
|
|
89
74
|
storeHash,
|
|
90
75
|
uploadBundleAgain,
|
|
91
76
|
} = options;
|
|
92
|
-
|
|
93
77
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
94
|
-
|
|
95
78
|
try {
|
|
96
79
|
const result = await themeApiClient.postTheme({
|
|
97
80
|
accessToken,
|
|
@@ -110,7 +93,6 @@ utils.uploadBundle = async (options) => {
|
|
|
110
93
|
throw err;
|
|
111
94
|
}
|
|
112
95
|
};
|
|
113
|
-
|
|
114
96
|
utils.notifyUserOfThemeLimitReachedIfNecessary = async (options) => {
|
|
115
97
|
if (options.themeLimitReached && !options.deleteOldest) {
|
|
116
98
|
console.log(
|
|
@@ -119,15 +101,12 @@ utils.notifyUserOfThemeLimitReachedIfNecessary = async (options) => {
|
|
|
119
101
|
"In order to proceed, you'll need to delete at least one theme.",
|
|
120
102
|
);
|
|
121
103
|
}
|
|
122
|
-
|
|
123
104
|
return options;
|
|
124
105
|
};
|
|
125
|
-
|
|
126
106
|
utils.promptUserToDeleteThemesIfNecessary = async (options) => {
|
|
127
107
|
if (!options.themeLimitReached) {
|
|
128
108
|
return options;
|
|
129
109
|
}
|
|
130
|
-
|
|
131
110
|
if (options.deleteOldest) {
|
|
132
111
|
const oldestTheme = options.themes
|
|
133
112
|
.filter((theme) => theme.is_private && !theme.is_active)
|
|
@@ -136,10 +115,8 @@ utils.promptUserToDeleteThemesIfNecessary = async (options) => {
|
|
|
136
115
|
updated_at: new Date(theme.updated_at).valueOf(),
|
|
137
116
|
}))
|
|
138
117
|
.reduce((prev, current) => (prev.updated_at < current.updated_at ? prev : current));
|
|
139
|
-
|
|
140
118
|
return { ...options, themeIdsToDelete: [oldestTheme.uuid] };
|
|
141
119
|
}
|
|
142
|
-
|
|
143
120
|
const questions = [
|
|
144
121
|
{
|
|
145
122
|
choices: options.themes.map((theme) => ({
|
|
@@ -159,10 +136,8 @@ utils.promptUserToDeleteThemesIfNecessary = async (options) => {
|
|
|
159
136
|
},
|
|
160
137
|
];
|
|
161
138
|
const answers = await Inquirer.prompt(questions);
|
|
162
|
-
|
|
163
139
|
return { ...options, ...answers };
|
|
164
140
|
};
|
|
165
|
-
|
|
166
141
|
utils.deleteThemesIfNecessary = async (options) => {
|
|
167
142
|
const {
|
|
168
143
|
config: { accessToken },
|
|
@@ -170,13 +145,10 @@ utils.deleteThemesIfNecessary = async (options) => {
|
|
|
170
145
|
themeLimitReached,
|
|
171
146
|
themeIdsToDelete,
|
|
172
147
|
} = options;
|
|
173
|
-
|
|
174
148
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
175
|
-
|
|
176
149
|
if (!themeLimitReached) {
|
|
177
150
|
return options;
|
|
178
151
|
}
|
|
179
|
-
|
|
180
152
|
try {
|
|
181
153
|
const promises = themeIdsToDelete.map((themeId) =>
|
|
182
154
|
themeApiClient.deleteThemeById({ accessToken, apiHost, storeHash, themeId }),
|
|
@@ -186,10 +158,8 @@ utils.deleteThemesIfNecessary = async (options) => {
|
|
|
186
158
|
err.name = 'ThemeDeletionError';
|
|
187
159
|
throw err;
|
|
188
160
|
}
|
|
189
|
-
|
|
190
161
|
return options;
|
|
191
162
|
};
|
|
192
|
-
|
|
193
163
|
utils.checkIfDeletionIsComplete = () => {
|
|
194
164
|
return async.retryable(
|
|
195
165
|
{
|
|
@@ -206,7 +176,6 @@ utils.checkIfDeletionIsComplete = () => {
|
|
|
206
176
|
utils.checkIfThemeIsDeleted(),
|
|
207
177
|
);
|
|
208
178
|
};
|
|
209
|
-
|
|
210
179
|
utils.checkIfThemeIsDeleted = () => async (options) => {
|
|
211
180
|
const {
|
|
212
181
|
themeLimitReached,
|
|
@@ -214,47 +183,34 @@ utils.checkIfThemeIsDeleted = () => async (options) => {
|
|
|
214
183
|
storeHash,
|
|
215
184
|
themeIdsToDelete,
|
|
216
185
|
} = options;
|
|
217
|
-
|
|
218
186
|
if (!themeLimitReached) {
|
|
219
187
|
return options;
|
|
220
188
|
}
|
|
221
|
-
|
|
222
189
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
223
|
-
|
|
224
190
|
const result = await themeApiClient.getThemes({ accessToken, apiHost, storeHash });
|
|
225
|
-
|
|
226
191
|
const themeStillExists = result.some((theme) => themeIdsToDelete.includes(theme.uuid));
|
|
227
|
-
|
|
228
192
|
if (themeStillExists) {
|
|
229
193
|
throw new Error('ThemeStillExists');
|
|
230
194
|
}
|
|
231
|
-
|
|
232
195
|
return options;
|
|
233
196
|
};
|
|
234
|
-
|
|
235
197
|
utils.uploadBundleAgainIfNecessary = async (options) => {
|
|
236
198
|
if (!options.themeLimitReached) {
|
|
237
199
|
return options;
|
|
238
200
|
}
|
|
239
|
-
|
|
240
201
|
return utils.uploadBundle({ ...options, uploadThemeAgain: true });
|
|
241
202
|
};
|
|
242
|
-
|
|
243
203
|
utils.notifyUserOfThemeUploadCompletion = async (options) => {
|
|
244
204
|
console.log(`${'ok'.green} -- Theme Upload Finished`);
|
|
245
|
-
|
|
246
205
|
return options;
|
|
247
206
|
};
|
|
248
|
-
|
|
249
207
|
utils.markJobProgressPercentage = (percentComplete) => {
|
|
250
208
|
bar.update(percentComplete / 100);
|
|
251
209
|
};
|
|
252
|
-
|
|
253
210
|
utils.markJobComplete = () => {
|
|
254
211
|
utils.markJobProgressPercentage(100);
|
|
255
212
|
console.log(`${'ok'.green} -- Theme Processing Finished`);
|
|
256
213
|
};
|
|
257
|
-
|
|
258
214
|
utils.pollForJobCompletion = (resultFilter) => {
|
|
259
215
|
return async.retryable(
|
|
260
216
|
{
|
|
@@ -264,7 +220,6 @@ utils.pollForJobCompletion = (resultFilter) => {
|
|
|
264
220
|
utils.markJobProgressPercentage(err.message);
|
|
265
221
|
return true;
|
|
266
222
|
}
|
|
267
|
-
|
|
268
223
|
return false;
|
|
269
224
|
},
|
|
270
225
|
times: Number.POSITIVE_INFINITY,
|
|
@@ -272,7 +227,6 @@ utils.pollForJobCompletion = (resultFilter) => {
|
|
|
272
227
|
utils.checkIfJobIsComplete(resultFilter),
|
|
273
228
|
);
|
|
274
229
|
};
|
|
275
|
-
|
|
276
230
|
utils.checkIfJobIsComplete = (resultFilter) => async (options) => {
|
|
277
231
|
const {
|
|
278
232
|
config: { accessToken },
|
|
@@ -280,9 +234,7 @@ utils.checkIfJobIsComplete = (resultFilter) => async (options) => {
|
|
|
280
234
|
bundleZipPath,
|
|
281
235
|
jobId,
|
|
282
236
|
} = options;
|
|
283
|
-
|
|
284
237
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
285
|
-
|
|
286
238
|
const result = await themeApiClient.getJob({
|
|
287
239
|
accessToken,
|
|
288
240
|
apiHost,
|
|
@@ -291,17 +243,13 @@ utils.checkIfJobIsComplete = (resultFilter) => async (options) => {
|
|
|
291
243
|
jobId,
|
|
292
244
|
resultFilter,
|
|
293
245
|
});
|
|
294
|
-
|
|
295
246
|
utils.markJobComplete();
|
|
296
|
-
|
|
297
247
|
return { ...options, ...result };
|
|
298
248
|
};
|
|
299
|
-
|
|
300
249
|
utils.promptUserWhetherToApplyTheme = async (options) => {
|
|
301
250
|
if (options.activate) {
|
|
302
251
|
return { ...options, applyTheme: true };
|
|
303
252
|
}
|
|
304
|
-
|
|
305
253
|
const questions = [
|
|
306
254
|
{
|
|
307
255
|
type: 'confirm',
|
|
@@ -311,10 +259,8 @@ utils.promptUserWhetherToApplyTheme = async (options) => {
|
|
|
311
259
|
},
|
|
312
260
|
];
|
|
313
261
|
const answers = await Inquirer.prompt(questions);
|
|
314
|
-
|
|
315
262
|
return { ...options, ...answers };
|
|
316
263
|
};
|
|
317
|
-
|
|
318
264
|
utils.getChannels = async (options) => {
|
|
319
265
|
const {
|
|
320
266
|
config: { accessToken },
|
|
@@ -323,22 +269,17 @@ utils.getChannels = async (options) => {
|
|
|
323
269
|
storeHash,
|
|
324
270
|
applyTheme,
|
|
325
271
|
} = options;
|
|
326
|
-
|
|
327
272
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
328
|
-
|
|
329
273
|
if (!applyTheme || channelIds || channelId) {
|
|
330
274
|
return options;
|
|
331
275
|
}
|
|
332
|
-
|
|
333
276
|
const channels = await themeApiClient.getStoreChannels({
|
|
334
277
|
accessToken,
|
|
335
278
|
apiHost,
|
|
336
279
|
storeHash,
|
|
337
280
|
});
|
|
338
|
-
|
|
339
281
|
return { ...options, channels };
|
|
340
282
|
};
|
|
341
|
-
|
|
342
283
|
utils.getVariations = async (options) => {
|
|
343
284
|
const {
|
|
344
285
|
config: { accessToken },
|
|
@@ -347,20 +288,16 @@ utils.getVariations = async (options) => {
|
|
|
347
288
|
applyTheme,
|
|
348
289
|
activate,
|
|
349
290
|
} = options;
|
|
350
|
-
|
|
351
291
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
352
|
-
|
|
353
292
|
if (!applyTheme) {
|
|
354
293
|
return options;
|
|
355
294
|
}
|
|
356
|
-
|
|
357
295
|
const variations = await themeApiClient.getVariationsByThemeId({
|
|
358
296
|
accessToken,
|
|
359
297
|
apiHost,
|
|
360
298
|
themeId,
|
|
361
299
|
storeHash,
|
|
362
300
|
});
|
|
363
|
-
|
|
364
301
|
// Activate the default variation
|
|
365
302
|
if (activate === true) {
|
|
366
303
|
return { ...options, variationId: variations[0].uuid };
|
|
@@ -368,42 +305,33 @@ utils.getVariations = async (options) => {
|
|
|
368
305
|
// Activate the specified variation
|
|
369
306
|
if (activate !== undefined) {
|
|
370
307
|
const foundVariation = variations.find((item) => item.name === activate);
|
|
371
|
-
|
|
372
308
|
if (!foundVariation || !foundVariation.uuid) {
|
|
373
309
|
const availableOptionsStr = variations.map((item) => `${item.name}`).join(', ');
|
|
374
310
|
throw new Error(
|
|
375
311
|
`Invalid theme variation provided! Available options: ${availableOptionsStr}.`,
|
|
376
312
|
);
|
|
377
313
|
}
|
|
378
|
-
|
|
379
314
|
return { ...options, variationId: foundVariation.uuid };
|
|
380
315
|
}
|
|
381
|
-
|
|
382
316
|
// Didn't specify a variation explicitly, will ask the user later
|
|
383
317
|
return { ...options, variations };
|
|
384
318
|
};
|
|
385
|
-
|
|
386
319
|
utils.promptUserForChannels = async (options) => {
|
|
387
320
|
const { applyTheme, channelIds, channels, allChannels } = options;
|
|
388
|
-
|
|
389
321
|
if (!applyTheme || channelIds) {
|
|
390
322
|
return options;
|
|
391
323
|
}
|
|
392
|
-
|
|
393
324
|
if (allChannels) {
|
|
394
325
|
const allIds = channels.map((chanel) => chanel.channel_id);
|
|
395
326
|
return { ...options, channelIds: allIds };
|
|
396
327
|
}
|
|
397
|
-
|
|
398
328
|
const selectedChannelIds = await utils.promptUserToSelectChannels(channels);
|
|
399
329
|
return { ...options, channelIds: selectedChannelIds };
|
|
400
330
|
};
|
|
401
|
-
|
|
402
331
|
utils.promptUserToSelectChannels = async (channels) => {
|
|
403
332
|
if (channels.length < 2) {
|
|
404
333
|
return [channels[0].channel_id];
|
|
405
334
|
}
|
|
406
|
-
|
|
407
335
|
const questions = [
|
|
408
336
|
{
|
|
409
337
|
type: 'checkbox',
|
|
@@ -415,27 +343,21 @@ utils.promptUserToSelectChannels = async (channels) => {
|
|
|
415
343
|
})),
|
|
416
344
|
},
|
|
417
345
|
];
|
|
418
|
-
|
|
419
346
|
const answer = await Inquirer.prompt(questions);
|
|
420
347
|
return answer.channelIds;
|
|
421
348
|
};
|
|
422
|
-
|
|
423
349
|
utils.promptUserForChannel = async (options) => {
|
|
424
350
|
const { applyTheme, channelId, channels } = options;
|
|
425
|
-
|
|
426
351
|
if (!applyTheme || channelId) {
|
|
427
352
|
return options;
|
|
428
353
|
}
|
|
429
|
-
|
|
430
354
|
const selectedChannelId = await utils.promptUserToSelectChannel(channels);
|
|
431
355
|
return { ...options, channelId: selectedChannelId };
|
|
432
356
|
};
|
|
433
|
-
|
|
434
357
|
utils.promptUserToSelectChannel = async (channels) => {
|
|
435
358
|
if (channels.length < 2) {
|
|
436
359
|
return channels[0].channel_id;
|
|
437
360
|
}
|
|
438
|
-
|
|
439
361
|
const questions = [
|
|
440
362
|
{
|
|
441
363
|
type: 'list',
|
|
@@ -447,16 +369,13 @@ utils.promptUserToSelectChannel = async (channels) => {
|
|
|
447
369
|
})),
|
|
448
370
|
},
|
|
449
371
|
];
|
|
450
|
-
|
|
451
372
|
const answer = await Inquirer.prompt(questions);
|
|
452
373
|
return answer.channelId;
|
|
453
374
|
};
|
|
454
|
-
|
|
455
375
|
utils.promptUserForVariation = async (options) => {
|
|
456
376
|
if (!options.applyTheme || options.variationId) {
|
|
457
377
|
return options;
|
|
458
378
|
}
|
|
459
|
-
|
|
460
379
|
const questions = [
|
|
461
380
|
{
|
|
462
381
|
type: 'list',
|
|
@@ -469,10 +388,8 @@ utils.promptUserForVariation = async (options) => {
|
|
|
469
388
|
},
|
|
470
389
|
];
|
|
471
390
|
const answers = await Inquirer.prompt(questions);
|
|
472
|
-
|
|
473
391
|
return { ...options, ...answers };
|
|
474
392
|
};
|
|
475
|
-
|
|
476
393
|
utils.requestToApplyVariationWithRetrys = () => {
|
|
477
394
|
return async.retryable(
|
|
478
395
|
{
|
|
@@ -482,7 +399,6 @@ utils.requestToApplyVariationWithRetrys = () => {
|
|
|
482
399
|
console.log(`${'warning'.yellow} -- Theme Activation Timed Out; Retrying...`);
|
|
483
400
|
return true;
|
|
484
401
|
}
|
|
485
|
-
|
|
486
402
|
return false;
|
|
487
403
|
},
|
|
488
404
|
times: 3,
|
|
@@ -490,7 +406,6 @@ utils.requestToApplyVariationWithRetrys = () => {
|
|
|
490
406
|
utils.requestToApplyVariation,
|
|
491
407
|
);
|
|
492
408
|
};
|
|
493
|
-
|
|
494
409
|
utils.requestToApplyVariation = async (options) => {
|
|
495
410
|
const {
|
|
496
411
|
config: { accessToken },
|
|
@@ -498,9 +413,7 @@ utils.requestToApplyVariation = async (options) => {
|
|
|
498
413
|
variationId,
|
|
499
414
|
channelIds,
|
|
500
415
|
} = options;
|
|
501
|
-
|
|
502
416
|
const apiHost = options.apiHost || options.config.apiHost;
|
|
503
|
-
|
|
504
417
|
if (options.applyTheme) {
|
|
505
418
|
await themeApiClient.activateThemeByVariationId({
|
|
506
419
|
variationId,
|
|
@@ -510,12 +423,9 @@ utils.requestToApplyVariation = async (options) => {
|
|
|
510
423
|
accessToken,
|
|
511
424
|
});
|
|
512
425
|
}
|
|
513
|
-
|
|
514
426
|
return options;
|
|
515
427
|
};
|
|
516
|
-
|
|
517
428
|
utils.notifyUserOfCompletion = (options, callback) => {
|
|
518
429
|
callback(null, `Stencil Push Finished. Variation ID: ${options.variationId}`);
|
|
519
430
|
};
|
|
520
|
-
|
|
521
|
-
module.exports = utils;
|
|
431
|
+
export default utils;
|
package/lib/stencil-start.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const LangValidator = require('./lang/validator');
|
|
1
|
+
import 'colors';
|
|
2
|
+
import BrowserSync from 'browser-sync';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import Cycles from './Cycles.js';
|
|
6
|
+
import templateAssemblerModule from './template-assembler.js';
|
|
7
|
+
import { PACKAGE_INFO, THEME_PATH } from '../constants.js';
|
|
8
|
+
import Server from '../server/index.js';
|
|
9
|
+
import StencilConfigManager from './StencilConfigManager.js';
|
|
10
|
+
import ThemeConfig from './theme-config.js';
|
|
11
|
+
import BuildConfigManager from './BuildConfigManager.js';
|
|
12
|
+
import fsUtilsModule from './utils/fsUtils.js';
|
|
13
|
+
import stencilPushUtilsModule from './stencil-push.utils.js';
|
|
14
|
+
import cliCommonModule from './cliCommon.js';
|
|
15
|
+
import themeApiClientModule from './theme-api-client.js';
|
|
16
|
+
import storeSettingsApiClientModule from './store-settings-api-client.js';
|
|
17
|
+
import LangHelper from './lang-helper.js';
|
|
18
|
+
import LangValidator from './lang/validator.js';
|
|
20
19
|
|
|
21
20
|
class StencilStart {
|
|
22
21
|
constructor({
|
|
@@ -53,16 +52,13 @@ class StencilStart {
|
|
|
53
52
|
|
|
54
53
|
async run(cliOptions) {
|
|
55
54
|
this.runBasicChecks(cliOptions);
|
|
56
|
-
|
|
57
55
|
if (cliOptions.variation) {
|
|
58
56
|
await this._themeConfigManager.setVariationByName(cliOptions.variation);
|
|
59
57
|
}
|
|
60
58
|
const initialStencilConfig = await this._stencilConfigManager.read();
|
|
61
59
|
// Use initial (before updates) port for BrowserSync
|
|
62
60
|
const browserSyncPort = initialStencilConfig.port;
|
|
63
|
-
|
|
64
61
|
const channelUrl = await this.getChannelUrl(initialStencilConfig, cliOptions);
|
|
65
|
-
|
|
66
62
|
const storeInfoFromAPI = await this._themeApiClient.checkCliVersion({
|
|
67
63
|
storeUrl: channelUrl,
|
|
68
64
|
});
|
|
@@ -70,16 +66,12 @@ class StencilStart {
|
|
|
70
66
|
initialStencilConfig,
|
|
71
67
|
storeInfoFromAPI,
|
|
72
68
|
);
|
|
73
|
-
|
|
74
69
|
this._storeSettingsLocale = await this.getStoreSettingsLocale(
|
|
75
70
|
cliOptions,
|
|
76
71
|
updatedStencilConfig,
|
|
77
72
|
);
|
|
78
|
-
|
|
79
73
|
await this.startLocalServer(cliOptions, updatedStencilConfig);
|
|
80
|
-
|
|
81
74
|
this._logger.log(this.getStartUpInfo(updatedStencilConfig));
|
|
82
|
-
|
|
83
75
|
await this.startBrowserSync(cliOptions, updatedStencilConfig, browserSyncPort);
|
|
84
76
|
}
|
|
85
77
|
|
|
@@ -104,11 +96,9 @@ class StencilStart {
|
|
|
104
96
|
accessToken,
|
|
105
97
|
apiHost,
|
|
106
98
|
});
|
|
107
|
-
|
|
108
99
|
const channelId = cliOptions.channelId
|
|
109
100
|
? cliOptions.channelId
|
|
110
101
|
: await this._stencilPushUtils.promptUserToSelectChannel(channels);
|
|
111
|
-
|
|
112
102
|
const foundChannel = channels.find(
|
|
113
103
|
(channel) => channel.channel_id === parseInt(channelId, 10),
|
|
114
104
|
);
|
|
@@ -120,7 +110,6 @@ class StencilStart {
|
|
|
120
110
|
*/
|
|
121
111
|
runBasicChecks(cliOptions) {
|
|
122
112
|
this._cliCommon.checkNodeVersion();
|
|
123
|
-
|
|
124
113
|
if (!this._fsUtils.existsSync(this._themeConfigManager.configPath)) {
|
|
125
114
|
throw new Error(
|
|
126
115
|
'You must have a '.red +
|
|
@@ -128,7 +117,6 @@ class StencilStart {
|
|
|
128
117
|
'file in your top level theme directory.',
|
|
129
118
|
);
|
|
130
119
|
}
|
|
131
|
-
|
|
132
120
|
// If the value is true it means that no variation was passed in.
|
|
133
121
|
if (cliOptions.variation === true) {
|
|
134
122
|
throw new Error('You have to specify a value for -v or --variation'.red);
|
|
@@ -165,7 +153,6 @@ class StencilStart {
|
|
|
165
153
|
const DEFAULT_WATCH_IGNORED = ['/assets/scss', '/assets/css'];
|
|
166
154
|
const { themePath, configPath } = this._themeConfigManager;
|
|
167
155
|
const { watchOptions } = this._buildConfigManager;
|
|
168
|
-
|
|
169
156
|
// Watch sccs directory and automatically reload all css files if a file changes
|
|
170
157
|
const stylesPath = path.join(themePath, 'assets/scss');
|
|
171
158
|
this._browserSync.watch(stylesPath, (event) => {
|
|
@@ -173,14 +160,12 @@ class StencilStart {
|
|
|
173
160
|
this._browserSync.reload('*.css');
|
|
174
161
|
}
|
|
175
162
|
});
|
|
176
|
-
|
|
177
163
|
this._browserSync.watch(configPath, (event) => {
|
|
178
164
|
if (event === 'change') {
|
|
179
165
|
this._themeConfigManager.resetVariationSettings();
|
|
180
166
|
this._browserSync.reload();
|
|
181
167
|
}
|
|
182
168
|
});
|
|
183
|
-
|
|
184
169
|
const storefrontConfigPath = path.join(themePath, '.config/storefront.json');
|
|
185
170
|
this._browserSync.watch(storefrontConfigPath, (event, file) => {
|
|
186
171
|
if (event === 'change') {
|
|
@@ -193,7 +178,6 @@ class StencilStart {
|
|
|
193
178
|
this._browserSync.reload();
|
|
194
179
|
}
|
|
195
180
|
});
|
|
196
|
-
|
|
197
181
|
const templatesPath = path.join(themePath, 'templates');
|
|
198
182
|
this._browserSync.watch(templatesPath, { ignoreInitial: true }, async () => {
|
|
199
183
|
try {
|
|
@@ -203,7 +187,6 @@ class StencilStart {
|
|
|
203
187
|
this._logger.error(e);
|
|
204
188
|
}
|
|
205
189
|
});
|
|
206
|
-
|
|
207
190
|
const langsPath = path.join(themePath, 'lang');
|
|
208
191
|
this._browserSync.watch(langsPath, async (event) => {
|
|
209
192
|
try {
|
|
@@ -217,7 +200,6 @@ class StencilStart {
|
|
|
217
200
|
this._logger.error(e);
|
|
218
201
|
}
|
|
219
202
|
});
|
|
220
|
-
|
|
221
203
|
// tunnel value should be true/false or a string with name
|
|
222
204
|
// https://browsersync.io/docs/options#option-tunnel
|
|
223
205
|
// convert undefined/true -> false/true
|
|
@@ -225,7 +207,6 @@ class StencilStart {
|
|
|
225
207
|
typeof cliOptions.tunnel === 'string' ? cliOptions.tunnel : Boolean(cliOptions.tunnel);
|
|
226
208
|
const watchFiles = (watchOptions && watchOptions.files) || DEFAULT_WATCH_FILES;
|
|
227
209
|
const watchIgnored = (watchOptions && watchOptions.ignored) || DEFAULT_WATCH_IGNORED;
|
|
228
|
-
|
|
229
210
|
this._browserSync.init({
|
|
230
211
|
open: !!cliOptions.open,
|
|
231
212
|
port: browserSyncPort,
|
|
@@ -237,24 +218,20 @@ class StencilStart {
|
|
|
237
218
|
proxy: `localhost:${stencilConfig.port}`,
|
|
238
219
|
tunnel,
|
|
239
220
|
});
|
|
240
|
-
|
|
241
221
|
// Handle manual reloading of browsers by typing 'rs';
|
|
242
222
|
// Borrowed from https://github.com/remy/nodemon
|
|
243
223
|
process.stdin.resume();
|
|
244
224
|
process.stdin.setEncoding('utf8');
|
|
245
225
|
process.stdin.on('data', (data) => {
|
|
246
226
|
const normalizedData = `${data}`.trim().toLowerCase();
|
|
247
|
-
|
|
248
227
|
// if the keys entered match the restartable value, then restart!
|
|
249
228
|
if (normalizedData === 'rs') {
|
|
250
229
|
this._browserSync.reload();
|
|
251
230
|
}
|
|
252
231
|
});
|
|
253
|
-
|
|
254
232
|
if (this._buildConfigManager.development) {
|
|
255
233
|
this._buildConfigManager.initWorker().development(this._browserSync);
|
|
256
234
|
}
|
|
257
|
-
|
|
258
235
|
await this.checkLangFiles(langsPath, this._storeSettingsLocale.default_shopper_language);
|
|
259
236
|
}
|
|
260
237
|
|
|
@@ -269,7 +246,6 @@ class StencilStart {
|
|
|
269
246
|
const templateNames = filesPaths.map((file) =>
|
|
270
247
|
file.replace(templatesPath + path.sep, '').replace('.html', ''),
|
|
271
248
|
);
|
|
272
|
-
|
|
273
249
|
return Promise.all(
|
|
274
250
|
templateNames.map(async (templateName) =>
|
|
275
251
|
promisify(this._templateAssembler.assemble)(templatesPath, templateName),
|
|
@@ -282,7 +258,6 @@ class StencilStart {
|
|
|
282
258
|
const isDefaultLanguagePresent = filesPaths.some((file) =>
|
|
283
259
|
file.includes(defaultShopperLanguage),
|
|
284
260
|
);
|
|
285
|
-
|
|
286
261
|
if (!isDefaultLanguagePresent) {
|
|
287
262
|
this._logger.log(
|
|
288
263
|
`${
|
|
@@ -312,21 +287,17 @@ class StencilStart {
|
|
|
312
287
|
secretsFileName,
|
|
313
288
|
} = this._stencilConfigManager;
|
|
314
289
|
let information = '\n';
|
|
315
|
-
|
|
316
290
|
information += '-----------------Startup Information-------------\n'.gray;
|
|
317
291
|
information += '\n';
|
|
318
292
|
information += `${configFileName} location: ${configPath.cyan}\n`;
|
|
319
293
|
information += `${secretsFileName} location: ${secretsPath.cyan}\n`;
|
|
320
294
|
information += `config.json location: ${this._themeConfigManager.configPath.cyan}\n`;
|
|
321
295
|
information += `Store URL: ${stencilConfig.normalStoreUrl.cyan}\n`;
|
|
322
|
-
|
|
323
296
|
information += `SSL Store URL: ${stencilConfig.storeUrl.cyan}\n`;
|
|
324
297
|
information += `Node Version: ${process.version.cyan}\n`;
|
|
325
298
|
information += '\n';
|
|
326
299
|
information += '-------------------------------------------------\n'.gray;
|
|
327
|
-
|
|
328
300
|
return information;
|
|
329
301
|
}
|
|
330
302
|
}
|
|
331
|
-
|
|
332
|
-
module.exports = StencilStart;
|
|
303
|
+
export default StencilStart;
|