Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@argos-ci/core

Package Overview
Dependencies
Maintainers
0
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@argos-ci/core - npm Package Compare versions

Comparing version 2.12.0 to 3.0.0

55

dist/index.js

@@ -688,12 +688,57 @@ // src/upload.ts

import { promisify } from "node:util";
import { basename } from "node:path";
import sharp from "sharp";
import tmp from "tmp";
var tmpFile = promisify(tmp.file);
var MAX_PIXELS = 8e7;
var DEFAULT_MAX_WIDTH = 2048;
var optimizeScreenshot = async (filepath) => {
try {
const resultFilePath = await tmpFile();
await sharp(filepath).resize(2048, 64e3, {
fit: "inside",
withoutEnlargement: true
}).png({ force: true }).toFile(resultFilePath);
const [resultFilePath, metadata] = await Promise.all([
tmpFile(),
sharp(filepath).metadata()
]);
const { width, height } = metadata;
const maxDimensions = (() => {
if (!width || !height) {
return {
width: DEFAULT_MAX_WIDTH,
height: Math.floor(MAX_PIXELS / DEFAULT_MAX_WIDTH)
};
}
const nbPixels = width * height;
if (nbPixels <= MAX_PIXELS) {
return null;
}
if (width < height) {
return {
width: DEFAULT_MAX_WIDTH,
height: Math.floor(MAX_PIXELS / DEFAULT_MAX_WIDTH)
};
}
const scaleFactor = Math.sqrt(MAX_PIXELS / nbPixels);
return {
width: Math.floor(width * scaleFactor),
height: Math.floor(height * scaleFactor)
};
})();
let operation = sharp(filepath);
if (maxDimensions) {
operation = operation.resize(maxDimensions.width, maxDimensions.height, {
fit: "inside",
withoutEnlargement: true
});
}
await operation.png({ force: true }).toFile(resultFilePath);
if (width && height && maxDimensions) {
const { width: maxWidth, height: maxHeight } = maxDimensions;
const widthRatio = maxWidth / width;
const heightRatio = maxHeight / height;
const scaleFactor = Math.min(widthRatio, heightRatio);
const newWidth = Math.floor(width * scaleFactor);
const newHeight = Math.floor(height * scaleFactor);
console.warn(
`Image ${basename(filepath)} resized from ${width}x${height} to ${newWidth}x${newHeight}.`
);
}
return resultFilePath;

@@ -700,0 +745,0 @@ } catch (error) {

18

package.json
{
"name": "@argos-ci/core",
"description": "Node.js SDK for visual testing with Argos.",
"version": "2.12.0",
"version": "3.0.0",
"type": "module",

@@ -43,8 +43,8 @@ "main": "./dist/index.cjs",

"dependencies": {
"@argos-ci/api-client": "0.7.1",
"@argos-ci/util": "2.2.1",
"axios": "^1.7.7",
"@argos-ci/api-client": "0.7.2",
"@argos-ci/util": "2.2.2",
"axios": "^1.7.9",
"convict": "^6.2.4",
"debug": "^4.3.7",
"fast-glob": "^3.3.2",
"debug": "^4.4.0",
"fast-glob": "^3.3.3",
"sharp": "^0.33.5",

@@ -54,7 +54,7 @@ "tmp": "^0.2.3"

"devDependencies": {
"@octokit/webhooks": "^13.4.1",
"@octokit/webhooks": "^13.4.2",
"@types/convict": "^6.1.6",
"@types/debug": "^4.1.12",
"@types/tmp": "^0.2.6",
"msw": "^2.5.1"
"msw": "^2.7.0"
},

@@ -65,3 +65,3 @@ "scripts": {

},
"gitHead": "88672d5cd06a792974844d1cb798641cec6e0562"
"gitHead": "0c91306ae0cb8bec5ef93db79565635e405086f7"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc