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

now-travis

v1.2.0

Published

Automatically deploy to ∆ Now from Travis pushes. Setting up now-travis can:

Downloads

50

Readme

now-travis

Automatically deploy to ∆ Now from Travis pushes. Setting up now-travis can:

  • Automatically create staging deployments for pull requests
  • Automatically deploy and alias upon pushes to master

Warning: Using now-travis has the potential to create many deployments, enough to blow through the allotment on the Free plan. It is recommended to only use this on the Pro or Enterprise accounts.

Setup

In order to use now-travis on a repository, you'll need some keys to authorize it to execute actions in Travis. The following set up will walk you through this process.

First, you'll need to create a New personal access token. Give the token a name, and check the repo scope checkbox. This will only be used to set the status on pull requests with a ∆ Now URL. Be sure to keep this key ready to paste into an upcoming command.

Second, head over to Zeit's API tokens page and create a new token. This will be used to create deployments during pull requests and master pushes.

If your repository doesn't have a .travis.yml file, create an empty one now in the root of the repo.

Now we need to encrypt the API keys we generated into the .travis.yml file. This is done using a CLI tool. You can either install the travis-ci tool or the travis-encrypt npm tool for encrypting these values.

If you are using the travis-ci tool, execute the following command in your terminal, substituting <owner>, <repo_name>, <gh_key>, and <now_key> with the appropriate values:

travis encrypt -r <owner>/<repo_name> GH_TOKEN=<gk_key> NOW_TOKEN=<now_key> --add

If you are using the travis-encrypt tool from npm, execute the following command in your terminal, substituting <owner>, <repo_name>, <gh_key>, and <now_key> with the appropriate values:

travis-encrypt --add -r <owner>/<repo_name> GH_TOKEN=<gk_key> NOW_TOKEN=<now_key>

Your API keys are now encrypted in your .travis.yml file. Next, install now-travis in your project:

# Execute if using npm
npm install --save-dev now-travis

# Execute this instead if you are using yarn
yarn add --dev now-travis

Let's edit the .travis.yml file to automate deployments:

  1. Add after_script to execute now-travis after the build is done and successful. If you use an alias for your production deployments, add that to the NOW_ALIAS environment variable:
after_script:
  - NOW_ALIAS=myalias.com node_modules/.bin/now-travis
  1. Add branches to ensure we only create production deployments when pushing to the master branch:
branches:
  only:
    - master

Deployment

When creating pull requests after a Travis build has been successfully completed, now-travis will create a ∆ Now deployment and update the pull request with the staging URL:

Screenshot

Clicking on the "Details" link will open the page to the staging deployment URL.

If you want to get the staging URL in subsequent steps of your Travis build, e.g running a lighthouse-ci test on the stage build, you can instruct now-travis to write the URL in a file by passing a file argument with the name of the file.

  - NOW_ALIAS=myalias.com node_modules/.bin/now-travis --file=now-staging-url

With this, the staging URL will be written to a file named now-staging-url.

When pushing commits to master, now-travis will deploy the build to ∆ Now and alias the deployment using the value specified in the NOW_ALIAS environment variable. This environment variable is only used on pushes, not pull requests.

Notes

While this module has been tested, it may not work perfectly in every Travis deployment situation. Please test it out and report any issues that may arise.

Again, this package has the ability to create many deployments, potentially more than your Zeit plan allots. Please exercise judgement when installing this. By default, following these instructions for now-travis will create a deployment:

  • When a pull request is opened
  • When a pull request is re-opened
  • When a new commit is pushed to a pull request
  • When a commit is pushed to the master branch