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

@guardian/paparazzi

Package Overview
Dependencies
Maintainers
18
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/paparazzi - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

51

index.js

@@ -5,6 +5,11 @@ #!/usr/bin/env node

const chalk = require('chalk');
const mkdirp = require('mkdirp');
const { resolve } = require('path');
const { readFileSync, mkdirSync } = require('fs');
const { readFileSync } = require('fs');
const { config } = {
config: '.paparazzirc',
...require('minimist')(process.argv.slice(2)),
};
const takeShot = async (route, { prefix, sizes, path }) => {
const takeShot = async (route, { prefix, sizes, path, screenshot }) => {
console.log(`started ${route}`);

@@ -19,2 +24,3 @@ const browser = await puppeteer.launch();

path: `${path}/${size}-${route.replace(/\//gi, '-')}.png`,
...screenshot,
});

@@ -28,15 +34,36 @@ console.log(chalk.blue(`done ${route} – ${size}`));

const getConfig = () => {
const defaultConfig = {
sizes: {
phone: {
width: 375,
height: 1100,
},
},
out: 'screenshots',
screenshot: {},
};
try {
const handle = readFileSync(resolve(process.cwd(), config), 'utf8');
return {
...defaultConfig,
...JSON.parse(handle),
};
} catch (error) {
console.error(chalk.red(`Error! ${error}`));
return defaultConfig;
}
};
(async () => {
const { prefix, sizes, routes, out } = JSON.parse(
readFileSync(resolve(process.cwd(), '.paparazzirc'), 'utf8')
);
const path = resolve(process.cwd(), out);
mkdirSync(path);
if (!prefix || !sizes || !routes) {
console.error(
chalk.red('Could not find .paparazzirc in the project folder')
);
const { prefix, sizes, routes, out, screenshot } = getConfig();
if (!prefix || !routes || !out) {
console.error(chalk.red(`Could not find ${config} in the current folder`));
process.exit(1);
}
await Promise.all(routes.map(r => takeShot(r, { prefix, sizes, path })));
const path = resolve(process.cwd(), out);
mkdirp.sync(path);
await Promise.all(
routes.map(r => takeShot(r, { prefix, sizes, path, screenshot }))
);
})();
{
"name": "@guardian/paparazzi",
"version": "0.0.3",
"version": "0.1.0",
"description": "Automated manual visual regression testing",

@@ -16,4 +16,6 @@ "main": "index.js",

"chalk": "^2.4.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"puppeteer": "^1.11.0"
}
}

@@ -23,5 +23,2 @@ # Paparazzi

{
// Name of the folder where screenshots will go to
"out": "screenies",
// List of routes you wanna screenshot

@@ -43,3 +40,12 @@ "routes": [

// Screen size pairs
// [optional] Name of the folder where screenshots will go to
"out": "screenies",
// [optional] Extra options for puppeteer's page.screenshot
"screenshot": {
"omitBackground": true,
"fullPage": true
},
// [optional] Screen size pairs
"sizes": {

@@ -46,0 +52,0 @@ "desktop": {

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