@argos-ci/cli 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.mjs +9 -42
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -252,33 +252,14 @@ const discoverScreenshots = async (patterns, { root =process.cwd() , ignore } =
252
252
  };
253
253
 
254
254
  const tmpFile = promisify(tmp.file);
255
- const getImageFormat = async (filepath)=>{
256
- const metadata = await sharp(filepath).metadata();
257
- if (!metadata.format) {
258
- throw new Error(`Could not get image format for ${filepath}`);
259
- }
260
- return metadata.format;
261
- };
262
- const optimizeScreenshot = async (filepath, format)=>{
255
+ const optimizeScreenshot = async (filepath)=>{
263
256
  const resultFilePath = await tmpFile();
264
- const optimization = sharp(filepath).resize(2048, 20480, {
257
+ await sharp(filepath).resize(2048, 20480, {
265
258
  fit: "inside",
266
259
  withoutEnlargement: true
267
- });
268
- switch(format){
269
- case "jpeg":
270
- case "jpg":
271
- {
272
- optimization.jpeg();
273
- break;
274
- }
275
- case "png":
276
- {
277
- optimization.png();
278
- break;
279
- }
280
- }
281
- await optimization.toFile(resultFilePath);
260
+ }).png({
261
+ force: true
262
+ }).toFile(resultFilePath);
282
263
  return resultFilePath;
283
264
  };
284
265
 
@@ -291,7 +272,7 @@ const hashFile = async (filepath)=>{
291
272
  hash.on("finish", resolve);
292
273
  fileStream.pipe(hash);
293
274
  });
294
- return hash.read().toString("hex");
275
+ return hash.digest("hex");
295
276
  };
296
277
 
297
278
  const base64Encode = (obj)=>Buffer.from(JSON.stringify(obj), "utf8").toString("base64");
@@ -352,17 +333,6 @@ const createArgosApiClient = (options)=>{
352
333
  };
353
334
  };
354
335
 
355
- const formatToContentType = (format)=>{
356
- switch(format){
357
- case "jpeg":
358
- case "jpg":
359
- return "image/jpeg";
360
- case "png":
361
- return "image/png";
362
- default:
363
- throw new Error(`Unsupported format ${format}`);
364
- }
365
- };
366
336
  const upload$1 = async (input)=>{
367
337
  const file = await readFile(input.path);
368
338
  await axios({
@@ -370,7 +340,7 @@ const upload$1 = async (input)=>{
370
340
  url: input.url,
371
341
  data: file,
372
342
  headers: {
373
- "Content-Type": formatToContentType(input.format)
343
+ "Content-Type": "image/png"
374
344
  }
375
345
  });
376
346
  };
@@ -426,13 +396,11 @@ const getConfigFromOptions = (options)=>{
426
396
  });
427
397
  // Optimize & compute hashes
428
398
  const screenshots = await Promise.all(foundScreenshots.map(async (screenshot)=>{
429
- const format = await getImageFormat(screenshot.path);
430
- const optimizedPath = await optimizeScreenshot(screenshot.path, format);
399
+ const optimizedPath = await optimizeScreenshot(screenshot.path);
431
400
  const hash = await hashFile(optimizedPath);
432
401
  return {
433
402
  ...screenshot,
434
403
  optimizedPath,
435
- format,
436
404
  hash
437
405
  };
438
406
  }));
@@ -456,8 +424,7 @@ const getConfigFromOptions = (options)=>{
456
424
  }
457
425
  await upload$1({
458
426
  url: putUrl,
459
- path: screenshot.optimizedPath,
460
- format: screenshot.format
427
+ path: screenshot.optimizedPath
461
428
  });
462
429
  }));
463
430
  // Update build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/cli",
3
3
  "description": "Visual testing solution to avoid visual regression. Argos CLI is used to interact with and upload screenshots to argos-ci.com via command line.",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
5
5
  "bin": {
6
6
  "argos": "./bin/argos-cli.js"
7
7
  },
@@ -40,7 +40,7 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@argos-ci/core": "^0.6.0",
43
+ "@argos-ci/core": "^0.6.2",
44
44
  "commander": "^9.4.1",
45
45
  "ora": "^6.1.2",
46
46
  "update-notifier": "^6.0.2"
@@ -49,5 +49,5 @@
49
49
  "rollup": "^2.79.1",
50
50
  "rollup-plugin-swc3": "^0.6.0"
51
51
  },
52
- "gitHead": "b4651fc030328c04b15a62fa206a20dff1bbe0ec"
52
+ "gitHead": "bffcdb6010c67b9a77e94b79043a189e1086d1d8"
53
53
  }