npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

whales-story-shots

v3.1.0

Published

# CLI API - `shoot.js` - perform automatic story shooting - `compare.js` - perform automatic image comparison

Downloads

239

Readme

🐳📖📸Whales-story-shots

CLI API

  • shoot.js - perform automatic story shooting
  • compare.js - perform automatic image comparison

Support

  • v1 - Storybook 4
  • v2 - Storybook 5

API

Storybook API

  • to activate whale-shots
import 'whales-story-shots/storybook/register';
  • to activate dev mode hightlighting
import whalesStyles from 'whales-story-shots/storybook/styles';
<style dangerouslySetInnerHTML={{ __html: whalesStyles }} />
  • to active shot for specific story
import whales from 'whales-story-shots/storybook/decorator';
addDecorator(whales({
    hinted: { jsLingui: [Trans] }, // will "hint" jsLingui Trans components and store it's coordinates
    failOnCatch: true|false // fail or not on any exception during the render (error image will be stored in any case)
}));

Whales API

  • compare/stories - for comparison
  • shot/shooter - for image generation

ENV

  • IMAGESDIR(/build-output) - directory to store result images
  • SOURCEDIR(/images) - directory to get result images(for comparison)
  • METADIR(/meta-output) - directory to store result meta files
  • STORYBOOK(http://host.docker.internal:6006) - storybook location
  • STORYBOOK_PORT(6006) - port
  • WAIT_UNTIL(load) - load, idle
  • ISOLATED(false) - should stories be shooted in isolation(slow) or not
  • THREAD_COUNT(8) - workers count
  • PATHRULE - "path rule" file location

Volumes

  • /whales-story-shots/compare/pathRule - to override file name generator

#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

echo "data will be saved to"
echo "${DIR}/../../build-output/shots"

# force image update
./node_modules/whales-story-shots/install.sh

# run image generation
docker run --shm-size 1G --rm \
-v "${DIR}/../../build-output/shots":/build-output \
-v "${DIR}/../../build-output/shots/meta":/meta-output \
-e MODE="iframe" \
whales-story-shots:latest node /whales-story-shots/shoot.js

# run image comparison
docker run --shm-size 1G --rm \
-v "${DIR}/../../templates":/images \
-v"${DIR}/pathRule":/whales-story-shots/compare/pathRule \
-v "${DIR}/../../build-output/shots":/build-output \
-v "${DIR}/../../build-output/shots/meta":/meta-output \
whales-story-shots:latest node /whales-story-shots/compare.js

Docker less run

It just could be faster, especially if you are already inside Docker.

Generation
const shooter = require('whales-story-shots/shot/shooter');

const storybook = `file://${join(__dirname, '..', '..', 'storybook-static')}`;
const imagesDir = join(__dirname, 'shots');

shooter({
    storybook,
    imagesDir,
    metaDir: join(imagesDir, 'meta'),
    waitUntil: 'load',
    isolated: false,
}).then(() => {
    process.exit();
});
Comparison
export METADIR="${DIR}/../../build-output/shots/meta"
export IMAGESDIR="${DIR}/../../build-output/shots"
export SOURCEDIR="${DIR}/../../templates"
export PATHRULE="${DIR}/pathRule"

node ../../node_modules/whales-story-shots/compare.js