@micromag/cli 0.2.295 → 0.2.300
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/bin/export.js +12 -5
- package/lib/index.js +52 -42
- package/package.json +9 -9
package/bin/export.js
CHANGED
|
@@ -109,22 +109,29 @@ const captureStory = async (story, location, settings = {}) => {
|
|
|
109
109
|
width,
|
|
110
110
|
height
|
|
111
111
|
} = defaultViewport;
|
|
112
|
+
const {
|
|
113
|
+
components: screens = null,
|
|
114
|
+
metadata
|
|
115
|
+
} = story || {};
|
|
116
|
+
const {
|
|
117
|
+
language = 'fr'
|
|
118
|
+
} = metadata || {};
|
|
112
119
|
const browser = await puppeteer__default['default'].launch({
|
|
113
120
|
devtools: DEBUG,
|
|
114
121
|
...(executablePath !== null ? {
|
|
115
122
|
executablePath
|
|
116
123
|
} : null),
|
|
117
124
|
defaultViewport,
|
|
118
|
-
args: ['--no-sandbox']
|
|
125
|
+
args: ['--no-sandbox', `--lang=${language}-CA,${language}`]
|
|
119
126
|
}); // try {
|
|
120
127
|
|
|
121
128
|
const pages = await browser.pages();
|
|
122
129
|
const hasPage = pages.length > 0;
|
|
123
130
|
const page = hasPage ? pages[0] : await browser.newPage();
|
|
124
|
-
await page.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
await page.setExtraHTTPHeaders({
|
|
132
|
+
'Accept-Language': language
|
|
133
|
+
});
|
|
134
|
+
await page.goto(`http://127.0.0.1:${serverPort}`); //
|
|
128
135
|
|
|
129
136
|
if (screens !== null) {
|
|
130
137
|
const count = screens.length;
|
package/lib/index.js
CHANGED
|
@@ -148,13 +148,17 @@ var captureStory = /*#__PURE__*/function () {
|
|
|
148
148
|
serverPort,
|
|
149
149
|
width,
|
|
150
150
|
height,
|
|
151
|
+
_ref2,
|
|
152
|
+
_ref2$components,
|
|
153
|
+
screens,
|
|
154
|
+
metadata,
|
|
155
|
+
_ref3,
|
|
156
|
+
_ref3$language,
|
|
157
|
+
language,
|
|
151
158
|
browser,
|
|
152
159
|
pages,
|
|
153
160
|
hasPage,
|
|
154
161
|
page,
|
|
155
|
-
_ref2,
|
|
156
|
-
_ref2$components,
|
|
157
|
-
screens,
|
|
158
162
|
count,
|
|
159
163
|
index,
|
|
160
164
|
screenNumber,
|
|
@@ -177,60 +181,66 @@ var captureStory = /*#__PURE__*/function () {
|
|
|
177
181
|
server = _context2.sent;
|
|
178
182
|
serverPort = server.address().port;
|
|
179
183
|
width = defaultViewport.width, height = defaultViewport.height;
|
|
180
|
-
|
|
184
|
+
_ref2 = story || {}, _ref2$components = _ref2.components, screens = _ref2$components === void 0 ? null : _ref2$components, metadata = _ref2.metadata;
|
|
185
|
+
_ref3 = metadata || {}, _ref3$language = _ref3.language, language = _ref3$language === void 0 ? 'fr' : _ref3$language;
|
|
186
|
+
_context2.next = 11;
|
|
181
187
|
return puppeteer__default['default'].launch(_objectSpread__default['default'](_objectSpread__default['default']({
|
|
182
188
|
devtools: DEBUG
|
|
183
189
|
}, executablePath !== null ? {
|
|
184
190
|
executablePath: executablePath
|
|
185
191
|
} : null), {}, {
|
|
186
192
|
defaultViewport: defaultViewport,
|
|
187
|
-
args: ['--no-sandbox']
|
|
193
|
+
args: ['--no-sandbox', "--lang=".concat(language, "-CA,").concat(language)]
|
|
188
194
|
}));
|
|
189
195
|
|
|
190
|
-
case
|
|
196
|
+
case 11:
|
|
191
197
|
browser = _context2.sent;
|
|
192
|
-
_context2.next =
|
|
198
|
+
_context2.next = 14;
|
|
193
199
|
return browser.pages();
|
|
194
200
|
|
|
195
|
-
case
|
|
201
|
+
case 14:
|
|
196
202
|
pages = _context2.sent;
|
|
197
203
|
hasPage = pages.length > 0;
|
|
198
204
|
|
|
199
205
|
if (!hasPage) {
|
|
200
|
-
_context2.next =
|
|
206
|
+
_context2.next = 20;
|
|
201
207
|
break;
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
_context2.t0 = pages[0];
|
|
205
|
-
_context2.next =
|
|
211
|
+
_context2.next = 23;
|
|
206
212
|
break;
|
|
207
213
|
|
|
208
|
-
case
|
|
209
|
-
_context2.next =
|
|
214
|
+
case 20:
|
|
215
|
+
_context2.next = 22;
|
|
210
216
|
return browser.newPage();
|
|
211
217
|
|
|
212
|
-
case
|
|
218
|
+
case 22:
|
|
213
219
|
_context2.t0 = _context2.sent;
|
|
214
220
|
|
|
215
|
-
case
|
|
221
|
+
case 23:
|
|
216
222
|
page = _context2.t0;
|
|
217
|
-
_context2.next =
|
|
218
|
-
return page
|
|
223
|
+
_context2.next = 26;
|
|
224
|
+
return page.setExtraHTTPHeaders({
|
|
225
|
+
'Accept-Language': language
|
|
226
|
+
});
|
|
219
227
|
|
|
220
|
-
case
|
|
221
|
-
|
|
228
|
+
case 26:
|
|
229
|
+
_context2.next = 28;
|
|
230
|
+
return page["goto"]("http://127.0.0.1:".concat(serverPort));
|
|
222
231
|
|
|
232
|
+
case 28:
|
|
223
233
|
if (!(screens !== null)) {
|
|
224
|
-
_context2.next =
|
|
234
|
+
_context2.next = 54;
|
|
225
235
|
break;
|
|
226
236
|
}
|
|
227
237
|
|
|
228
238
|
count = screens.length;
|
|
229
239
|
index = 0;
|
|
230
240
|
|
|
231
|
-
case
|
|
241
|
+
case 31:
|
|
232
242
|
if (!(index < count)) {
|
|
233
|
-
_context2.next =
|
|
243
|
+
_context2.next = 54;
|
|
234
244
|
break;
|
|
235
245
|
}
|
|
236
246
|
|
|
@@ -243,7 +253,7 @@ var captureStory = /*#__PURE__*/function () {
|
|
|
243
253
|
console.log("Screen ".concat(screenNumber, "/").concat(count, " (").concat(type, ")..."));
|
|
244
254
|
|
|
245
255
|
if (!(type === 'video' || type === 'video-360')) {
|
|
246
|
-
_context2.next =
|
|
256
|
+
_context2.next = 39;
|
|
247
257
|
break;
|
|
248
258
|
}
|
|
249
259
|
|
|
@@ -280,10 +290,10 @@ var captureStory = /*#__PURE__*/function () {
|
|
|
280
290
|
}
|
|
281
291
|
}
|
|
282
292
|
}, _callee);
|
|
283
|
-
})(), "t1",
|
|
293
|
+
})(), "t1", 39);
|
|
284
294
|
|
|
285
|
-
case
|
|
286
|
-
_context2.next =
|
|
295
|
+
case 39:
|
|
296
|
+
_context2.next = 41;
|
|
287
297
|
return page.evaluate(function (storyToRender, storyProps) {
|
|
288
298
|
return renderStory(storyToRender, storyProps);
|
|
289
299
|
}, singleScreenStory, {
|
|
@@ -296,46 +306,46 @@ var captureStory = /*#__PURE__*/function () {
|
|
|
296
306
|
googleApiKey: googleApiKey
|
|
297
307
|
});
|
|
298
308
|
|
|
299
|
-
case
|
|
300
|
-
_context2.prev =
|
|
301
|
-
_context2.next =
|
|
309
|
+
case 41:
|
|
310
|
+
_context2.prev = 41;
|
|
311
|
+
_context2.next = 44;
|
|
302
312
|
return page.waitForSelector('[data-screen-ready="true"]', {
|
|
303
313
|
timeout: READY_WAIT_TIMEOUT
|
|
304
314
|
});
|
|
305
315
|
|
|
306
|
-
case
|
|
307
|
-
_context2.next =
|
|
316
|
+
case 44:
|
|
317
|
+
_context2.next = 49;
|
|
308
318
|
break;
|
|
309
319
|
|
|
310
|
-
case
|
|
311
|
-
_context2.prev =
|
|
312
|
-
_context2.t2 = _context2["catch"](
|
|
320
|
+
case 46:
|
|
321
|
+
_context2.prev = 46;
|
|
322
|
+
_context2.t2 = _context2["catch"](41);
|
|
313
323
|
console.log("Timeout reached: ".concat(id));
|
|
314
324
|
|
|
315
|
-
case
|
|
316
|
-
_context2.next =
|
|
325
|
+
case 49:
|
|
326
|
+
_context2.next = 51;
|
|
317
327
|
return page.screenshot({
|
|
318
328
|
path: getOutputPath(location, "".concat(screenNumber, ".png"))
|
|
319
329
|
});
|
|
320
330
|
|
|
321
|
-
case
|
|
331
|
+
case 51:
|
|
322
332
|
index += 1;
|
|
323
|
-
_context2.next =
|
|
333
|
+
_context2.next = 31;
|
|
324
334
|
break;
|
|
325
335
|
|
|
326
|
-
case
|
|
327
|
-
_context2.next =
|
|
336
|
+
case 54:
|
|
337
|
+
_context2.next = 56;
|
|
328
338
|
return browser.close();
|
|
329
339
|
|
|
330
|
-
case
|
|
340
|
+
case 56:
|
|
331
341
|
server.close();
|
|
332
342
|
|
|
333
|
-
case
|
|
343
|
+
case 57:
|
|
334
344
|
case "end":
|
|
335
345
|
return _context2.stop();
|
|
336
346
|
}
|
|
337
347
|
}
|
|
338
|
-
}, _callee2, null, [[
|
|
348
|
+
}, _callee2, null, [[41, 46]]);
|
|
339
349
|
}));
|
|
340
350
|
|
|
341
351
|
return function captureStory(_x, _x2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.300",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.13.10",
|
|
47
|
-
"@micromag/core": "^0.2.
|
|
48
|
-
"@micromag/elements": "^0.2.
|
|
49
|
-
"@micromag/fields": "^0.2.
|
|
50
|
-
"@micromag/screens": "^0.2.
|
|
51
|
-
"@micromag/transforms": "^0.2.
|
|
52
|
-
"@micromag/viewer": "^0.2.
|
|
53
|
-
"@micromag/viewer-build": "^0.2.
|
|
47
|
+
"@micromag/core": "^0.2.300",
|
|
48
|
+
"@micromag/elements": "^0.2.300",
|
|
49
|
+
"@micromag/fields": "^0.2.300",
|
|
50
|
+
"@micromag/screens": "^0.2.300",
|
|
51
|
+
"@micromag/transforms": "^0.2.300",
|
|
52
|
+
"@micromag/viewer": "^0.2.300",
|
|
53
|
+
"@micromag/viewer-build": "^0.2.300",
|
|
54
54
|
"change-case": "^4.1.2",
|
|
55
55
|
"classnames": "^2.2.6",
|
|
56
56
|
"commander": "^7.2.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "0beff892194f4a52ce6b916d3c819f46354b92ec"
|
|
71
71
|
}
|