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

@designsystemsinternational/email

v0.0.5

Published

Make working with email more enjoyable (if possible)

Downloads

5

Readme

@designsystemsinternational/email

A collection of utilities to make working with email a bit more enjoyable.

CLI

When installed into a project (or globally) the email-cli can be used.

# Turns an HTML file into a standalone ZIP file, with all images downloaded and
# added to that ZIP file
#
# --force let's you overwrite the output file if it's already present
# --skip-preparation skips the HTML preparation and just bundles things into a ZIP
email-cli zip input.html output.zip --force --skip-preparation

# Turns an HTML file into a package and pushes everything to s3. Writes the
# updated HTML with all images pointing to s3 to output file for further use.
#
# The AWS credentials are stored in email-cli.config.js, which can be generated
# using the scaffold command below.
#
# --force overwrite the output file if it's already present
# --skip-preparation skips HTML preparation and just bundles
email-cli s3 input.html output.html --force --skip-preparation

# Packages HTML file and pushes to Mailchimp
# Mailchimp API credentials should be stored in email-cli.config.js in the
# root directory of your project.
#
# --id the mailchimp ID you want to publish at
# --skip-preparation skips the HTML preparation and just bundles things into a ZIP
email-cli mailchimp input.html --id 12345678 --skip-preparation

# Sends the content of an HTML file as a preview email
# does not perform any preparation or packaging, so make sure to run
# any packaging before
#
# The credentials for sending email (either through SMTP or SES) are stored
# in email-cli.config.js, which can be generated using the scaffold command.
#
# --method either 'smtp' or 'ses' (defaults to smtp)
email-cli send input.html --to [email protected] --from [email protected] --subject "Test email" --method smtp

# To create a basic configuration file in the current directory you can use the
# provided scaffold command
email-cli scaffold

Utilities

Alternatively you can also import the utilities into your projects. Use different entry points depending on if your in a Node or Browser environment.

// Server/Node
import {
  prapareHtml,
  packageToZip,
  packageToMailchimp,
  packageToS3,
} from '@designsystemsinternational/email';

// Browser
//
// Heads up: The browser version does not have all the packagers and does
// currently not allow for sending test emails from the client, use the server
// package in a server-less function to make your own endpoint to handle this
import {
  prapareHtml,
  packageToZip,
} from '@designsystemsinternational/email/src/browser.js';

Make your own packager

Packagers are build from a modular setup. The package exposes preparePackageFactory to allow you build your own packager. The factory sets up a method that first runs your input through the image extraction step. Processed HTML and Images are next passed to a custom packaging script to e.g. zip it, or publish it. See the following example.

import { preparePackageFactory } from '@designsystemsinternational/email';

const myPackager = preparePackageFactory({
  handlePackage: async ({ html, images }, options) => {
    // HTML is a plain string of the optimized HTML
    console.log(html);

    // Images is an array of image object of this shape
    // {
    //   filename: 'image-name.png',
    //   buffer: // node: Buffer, browser: base64 string
    // }
    console.log(images.length);

    // Options are passed in when calling the packager
    console.log(options);
  },
});

// Next, call your packager
myPackager(htmlString, { optionA: true, optionB: false });