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

travis-deploy-example111

v1.2.3

Published

example of using Travis' deploy feature to publish to npm.

Downloads

2

Readme

Travis Deploy Example

Example of using Travis CI to automatically publish your packages to npm, using:

  • Travis CI's npm deploy functionality.
  • the makeshift package, for generating an .npmrc file with your credentials in it.
  • and the standard-version package, for automating semver bumps and CHANGELOG generation.

Setting NPM_TOKEN environment variable

To be able to install private packages and to publish on your behalf, Travis CI needs your npm deploy token. After logging into npm, this token can be found in your ~/.npmrc file.

Once you fetch your token, set this as an environment variable in Travis CI called NPM_TOKEN:

setting NPM_TOKEN

Installing Private npm Packages

.npmrc is npm's configuration file, amongst other things: it contains your auth information, and tells the npm CLI what registry to install from. The following lines in our .travis.yml generate an .npmrc mapping the @bcoe scope to the registry.npmjs.org registry:

before_install:
  - npm i -g makeshift && makeshift -s @bcoe -r registry.npmjs.org

This allows us to install the private @bcoe/super-secret-dependency dependency.

Configuration Travis CI for Deployment

The .travis.yml included in this repository automatically publishes to npm, if tests pass for any git tags that you push to GitHub. Here are the pertinent lines in the .travis.yml to support this:

deploy:
  provider: npm
  email: [email protected]
  api_key: $NPM_TOKEN
  on:
    tags: true

That's all there is to it! note that it references the same NPM_TOKEN environment variable that is used to install @bcoe/super-secret-dependency.

Commit Format

Deciding on what version to bump your package is a hassle; did I add a feature since I last released, was it just patches? This demo uses standard-version to solve this problem.

When making commits, simply follow these commit standards:

patches:

git commit -a -m "fix: fixed a bug in our parser"

features:

git commit -a -m "feat: we now have a parser \o/"

breaking changes:

git commit -a -m "feat: introduces a new parsing library
BREAKING CHANGE: new library does not support foo-construct"

other changes:

You decide, e.g., docs, chore, etc.

Publishing Your Package From Travis CI

When you're ready to have Travis CI publish a new version of your package to npm:

  • npm run release, this will look at your commit history, and use standard-version to: bump the version #, create a tag, and update your CHANGELOG.
  • git push --follow-tags origin master, this will push the tag up to GitHub and kick off a build on Travis CI which will publish your module once it succeeds.

That's all there is to it, it's literally magic.

Using npm Enterprise

To configure Travis CI's deploys to use your private npm Enterprise server only two configuration changes need to be made:

  1. add a publishConfig.registry to your package.json that references your private registry:
{
  "publishConfig": {
    "registry": "https://npmo-demo-registry.npmjs.com"
  }
}
  1. update the makeshift line in your .travis.yml to point to the new registry:
before_install:
  - npm i -g makeshift && makeshift -s @bcoe -r https://npmo-demo-registry.npmjs.com