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

publishy

v0.0.2

Published

Publish modules like a boss

Downloads

129

Readme

publishy

Build Status Dependency Status devDependency Status NPM version node License npm download

Publish modules like a boss

What does publishy do?

  • Run tests
  • Run prepublish script
  • Check that project should on correct version
  • Check that project should on correct branch
  • Check that all changes have been committed
  • Check that all files and directories have been tracked
  • Check that dependencies are on the correct versions
  • Check that changelog of current version exists
  • Check that tag can be used
  • Publish to git
  • Publish to npm
  • Configurable by .publishrc

publishy-demo

Installing

$ npm install -g publishy

Usage

Use as a global module

$ cd your_project
# create default .publishrc file
$ publishy rc

# publish version 1.0.0
$ publishy 1.0.0

# manual
$ publishy -h
Usage: publishy [options] <version>

Options:

  -h, --help       output usage information
  -V, --version    output the version number
  -c, --cwd [cwd]  Project path, default current working directory

Use as a normal module

const publishy = require('publishy');
const CWD = process.cwd();

// create .publishrc file
publishy.createRcFile(cwd, {
  // custom configurations
});

// publish version 1.0. in /Users/xxx/myproject with custom configurations
publishy.publish('1.0.0', '/Users/xxx/myproject', {
  // my configurations
});

Default Configurations

Checking Level

  • 0: Do not run this checker
  • 1: Only warn if not pass
  • 2: Stop publishing if not pass
{
  "checkCommitted": 2, //
  "checkTracked": 2,
  "checkBranch": 2,
  "checkTaggable": 2,
  "checkDepVersion": 2,
  "checkChangelog": 2,
  "checkVersion": 2,
  "runPrepublish": true, // run prepublish script or not
  "runTest": true, // run test or not
  "confirm": true, // confirm before publish or not
  "tagFormat": "<%= version %>", // custom format of tag name
  "branchFormat": "dev/<%= version %>", // custom format of branch name
  "npm": "npm", // npm or tnpm or cnpm
  "remote": "origin", // which remote should new tag be push to
  "type": [ // publish type
    "git", // should create tag and push to git
    "npm" // should run `npm publish`
  ]
}

Custom

Custom Commands

Commands will be runned before checkers. Commands can be registered like this:

const publishy = require('publishy');
const execSync = require('child_process').execSync;
publishy.commands['runRemoveTmp'] = {
  startMsg: 'Removing tmp',
  run: cwd => new Promise(resolve => {
    execSync('rm -rf tmp', {
      cwd: cwd,
      stdio: 'inherit'
    });
    resolve();
  })
};

Then in your .publishrc file:

{
  "runRemoveTmp": true,
  "commands": [
    "runTest",
    "runPrepublish",
    "runRemoveTmp"
  ]
}

Custom Checkers

Checker can also be added just like the commands:

const publishy = require('publishy');
publishy.checkers['checkTmpRemoved'] = {
  /**
   * Name of this checker, it can be configured by .publishrc
   **/
  name: 'checkTmpRemoved',
  /**
   * Message when checking starts
   **/
  startMsg: (version, cwd, config) => `Checking that tmp has been removed`,
  /**
   * Check function, should run a Promise, and resolve an object with success and detail
   * - success: {Boolean} passed or not
   * - detail: {String} if not passed, why. This will passed to failMsg as the first parameter
   **/
  check: (version, cwd, config) => new Promise((resolve, reject) => {
    return {
      success: ifExists(path.join(cwd, 'tmp')),
      detail: 'some reason'
    };
  }),
  /**
   * Message when checking failed
   **/
  failMsg: (detail, version, cwd, config) => `Tmp should be removed, but not because of ${detail}`,
  /**
   * Message when checking successed
   **/
  successMsg: (version, cwd, config) => `Tmp has been removed`
};

Then in your .publishrc file, you can add it to your checking queue and specific a checking level for it:

{
  "checkTmpRemoved": 2,
  "checkers": [
    "checkTmpRemoved",
    "checkVersion",
    "checkBranch",
    "checkCommitted",
    "checkTracked",
    "checkDepVersion",
    "checkChangelog",
    "checkTaggable"
  ]
}

Custom Publisher

You can also reqister new publisher like this:

const publishy = require('publishy');
const logger = publishy.logger;
const execSync = require('child_process').execSync;
publishy.publishers['custom'] = (version, cwd, tag, config) => {
  return new Promise(resolve => {
    logger.info(`Custom Publishing:`);
    // custom publishing code
    logger.success(`Publish to ${config.npm} successed`);
    resolve();
  });
};

License

The MIT License (MIT)

Copyright (c) 2015 LingyuCoder

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.