@argos-ci/core 0.6.1 → 0.6.2

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/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import * as sharp from 'sharp';
2
-
3
1
  interface UploadParameters {
4
2
  /** Globs matching image file paths to upload */
5
3
  files?: string[];
@@ -35,8 +33,7 @@ declare const upload: (params: UploadParameters) => Promise<{
35
33
  };
36
34
  screenshots: {
37
35
  optimizedPath: string;
38
- format: keyof sharp.FormatEnum;
39
- hash: any;
36
+ hash: string;
40
37
  name: string;
41
38
  path: string;
42
39
  }[];
package/dist/index.mjs CHANGED
@@ -249,33 +249,14 @@ const discoverScreenshots = async (patterns, { root =process.cwd() , ignore } =
249
249
  };
250
250
 
251
251
  const tmpFile = promisify(tmp.file);
252
- const getImageFormat = async (filepath)=>{
253
- const metadata = await sharp(filepath).metadata();
254
- if (!metadata.format) {
255
- throw new Error(`Could not get image format for ${filepath}`);
256
- }
257
- return metadata.format;
258
- };
259
- const optimizeScreenshot = async (filepath, format)=>{
252
+ const optimizeScreenshot = async (filepath)=>{
260
253
  const resultFilePath = await tmpFile();
261
- const optimization = sharp(filepath).resize(2048, 20480, {
254
+ await sharp(filepath).resize(2048, 20480, {
262
255
  fit: "inside",
263
256
  withoutEnlargement: true
264
- });
265
- switch(format){
266
- case "jpeg":
267
- case "jpg":
268
- {
269
- optimization.jpeg();
270
- break;
271
- }
272
- case "png":
273
- {
274
- optimization.png();
275
- break;
276
- }
277
- }
278
- await optimization.toFile(resultFilePath);
257
+ }).png({
258
+ force: true
259
+ }).toFile(resultFilePath);
279
260
  return resultFilePath;
280
261
  };
281
262
 
@@ -288,7 +269,7 @@ const hashFile = async (filepath)=>{
288
269
  hash.on("finish", resolve);
289
270
  fileStream.pipe(hash);
290
271
  });
291
- return hash.read().toString("hex");
272
+ return hash.digest("hex");
292
273
  };
293
274
 
294
275
  const base64Encode = (obj)=>Buffer.from(JSON.stringify(obj), "utf8").toString("base64");
@@ -349,17 +330,6 @@ const createArgosApiClient = (options)=>{
349
330
  };
350
331
  };
351
332
 
352
- const formatToContentType = (format)=>{
353
- switch(format){
354
- case "jpeg":
355
- case "jpg":
356
- return "image/jpeg";
357
- case "png":
358
- return "image/png";
359
- default:
360
- throw new Error(`Unsupported format ${format}`);
361
- }
362
- };
363
333
  const upload$1 = async (input)=>{
364
334
  const file = await readFile(input.path);
365
335
  await axios({
@@ -367,7 +337,7 @@ const upload$1 = async (input)=>{
367
337
  url: input.url,
368
338
  data: file,
369
339
  headers: {
370
- "Content-Type": formatToContentType(input.format)
340
+ "Content-Type": "image/png"
371
341
  }
372
342
  });
373
343
  };
@@ -423,13 +393,11 @@ const getConfigFromOptions = (options)=>{
423
393
  });
424
394
  // Optimize & compute hashes
425
395
  const screenshots = await Promise.all(foundScreenshots.map(async (screenshot)=>{
426
- const format = await getImageFormat(screenshot.path);
427
- const optimizedPath = await optimizeScreenshot(screenshot.path, format);
396
+ const optimizedPath = await optimizeScreenshot(screenshot.path);
428
397
  const hash = await hashFile(optimizedPath);
429
398
  return {
430
399
  ...screenshot,
431
400
  optimizedPath,
432
- format,
433
401
  hash
434
402
  };
435
403
  }));
@@ -453,8 +421,7 @@ const getConfigFromOptions = (options)=>{
453
421
  }
454
422
  await upload$1({
455
423
  url: putUrl,
456
- path: screenshot.optimizedPath,
457
- format: screenshot.format
424
+ path: screenshot.optimizedPath
458
425
  });
459
426
  }));
460
427
  // Update build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/core",
3
3
  "description": "Visual testing solution to avoid visual regression. The core component of Argos SDK that handles build creation.",
4
- "version": "0.6.1",
4
+ "version": "0.6.2",
5
5
  "scripts": {
6
6
  "prebuild": "rm -rf dist",
7
7
  "build": "rollup -c",
@@ -60,5 +60,5 @@
60
60
  "rollup-plugin-dts": "^4.2.3",
61
61
  "rollup-plugin-swc3": "^0.6.0"
62
62
  },
63
- "gitHead": "653c9799ae22607b6bc8442c94ceb98ae1eaf0d5"
63
+ "gitHead": "bffcdb6010c67b9a77e94b79043a189e1086d1d8"
64
64
  }