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

@invisible/publish

v2.0.4

Published

Asserts a version bump and publishes your package to npm automatically

Downloads

26

Readme

@invisible/publish

CircleCI

Asserts a version bump and publishes your package to npm automatically.

Install

yarn add -D @invisible/publish
# or
npm install -D @invisible/publish

Usage

Programmatically

'use strict'

const {
  assertVersionBump,
  publish,
} = require('@invisible/publish')

const newRelease = async () => {
  {
    // fileName defaults to 'package.json' if no argument given.
    // This method return a promise of an object with pass and msg as keys.
    const { pass, msg } = await assertVersionBump({ fileName: 'package.json' })
    // You can process the results as you wish. As an example, you can consume it like below:
    if (msg) console.log(`assert-version-bump: ${msg}`)
    if (! pass) process.exit(1)
  }

  {
    const { NPM_TOKEN, NPMRC_DIR } = process.env

    // NPMRC_DIR defaults to 'process.env.HOME' if no argument given.
    // This method return an object with pass and msg as keys.
    const { pass, msg } = publish({ NPM_TOKEN, NPMRC_DIR })
    // You can process the results as you wish. As an example, you can consume it like below:
    if (msg) console.log(`publish: ${msg}`)
    if (pass) process.exit(0)
    process.exit(1)
  }
}
newRelease()

Hook Scripts

assert-version-bump

Add assert-version-bump to your package posttest script in package.json:

// It would look something like:
  "scripts": {
    "posttest": "assert-version-bump"
  }

You can also run it at any time from your CLI.

$ assert-version-bump # will output the change if found
$ assert-version-bump --quiet # will silently succeed, but output error if not found
  • OPTIONAL: you can pass the filename as argument to assert version bump. Defaults to package.json
"scripts": {
    "posttest": "assert-version-bump manifest.json"
  }

publish

  • Add publish to the commands on deployment section of your package circle.yml:
# It would look something like:
deployment:
  release:
    branch: master
    commands:
      - publish

NPM_TOKEN environmental variable is required for publishing. See Miscellaneous Information to know options on how to add it.

You can also run it at any time from your CLI. Just make sure you are on master branch and have a ~/.npmrc file with a valid token.

$ publish
$ publish --quiet # will silently succeed, but output error.

Miscellaneous Information

  • Add NPM_TOKEN environmental variable to your package on circleCI.

    To do this you will have to:

    • Go to https://circleci.com/gh/invisible-tech/<your-package-name>/edit#env-vars (replace <your-package-name>, e.g. merge-parsers)
    • Click on Import Variable(s).
    • Select NPM_TOKEN.
      • If you don't have permission to do that, ask your superior to do it!
  • You can add NPM_TOKEN to your .env file and install dotenv as dependency/devDependency.

Troubleshooting

If you are having problems, it probably is because you don't have your package .bin folder set on PATH.

machine:
  environment:
    # For yarn
    PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"

Known Issues

assert-version-bump does not work on the first PR because it asserts through diff of HEAD and last merge commit.

TODO

Make assert-version-bump work since first PR.

LICENSE

MIT