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

sparkpost-publisher

v1.2.1

Published

A package that publishes your emails to SparkPost

Downloads

72

Readme

npm version Build Status Build Status

SparkPost publisher

This library allows you to publish your emails to SparkPost automatically. No longer you need to copy paste your emails to SparkPost and mistakenly update the wrong template. A version controlled single source of truth for your emails.

Made for Foundation for Emails but can be used for other frameworks such as MJML.

The library works by mapping your generated email files to a SparkPost template using a JSON file called sparkpost-map.json. It is also possible to specify the name and path of the file.

Basic example:

{
    "password-reset": {
        "config": {
            "html": {
                "file": "password-reset.html"
            }
        },
        "sparkpost": {
            "content": {
                "from": {
                    "email": "[email protected]",
                    "name": "Example.com"
                },
                "subject": "Password reset"
            },
            "options": {
                "transactional": true
            }
        }
    }
}

The keys of the root object are the IDs of the templates in SparkPost. If the ID does not exist, the template will be created.

The config key contains the configuration used by this library.

Config explained:

{
    "html": {
        "file": "password-reset.html"
    },
    "email_rfc822": {
        "file": "password-reset.rfc"
    },
    "text": {
        "file": "password-reset.txt"
    }
}

This config object means the following:

  • replace content.html with the contents of the file found at dist/password-reset.html.
  • replace content.email_rfc822 with the contents of the file found at dist/password-reset.rfc.
  • replace content.text with the contents of the file found at dist/password-reset.txt.

While you can use both html and text if desired, you cannot mix either of them with email_rfc822.

The config.content object is essentially merged into the sparkpost.content object after the source files are read.

The sparkpost key contains any template configuration you would like to specify. This allows you to version control name, description and other options of your templates. Add any configuration as described in https://developers.sparkpost.com/api/templates.html#header-template-attributes. Do NOT specify the published field or any readonly fields as this will cause errors.

Usage

Publish

Publish all your emails using the spp publish --api-key your-api-key-here command. Optionally, you can specify that you only wish to publish one email using the --template template-id flag. New templates will be created and published.

Endpoint and API version

Endpoint and api version can be configured using --endpoint and --api-version.

Multiple environments, review/staging

If you have multiple environments you can use the suffix flag to deploy your templates with a suffix.

E.g. using --suffix review with template password-reset will create or update a template with the ID of password-reset-review.

Draft

Submit your drafts using the spp draft command with the same options as the publish command.

Verbose

Add the -v flag for more verbosity. Helpful to identify any errors.

Permissions

The SparkPost API key needs the following permissions:

  • Templates: Read/Write