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

pub-time

v0.1.0

Published

A much better `npm publish`

Downloads

11

Readme

pub-time

banner

npm install size coverage npm type definitions license

A much better npm publish, that:

  • performs automatic semantic release versioning, like semantic-release
  • has zero dependencies - uses your built-in git, npm
  • integrates with your npm scripts like build, test and lint
  • checks your package.json for invalid types
  • includes an API (including TypeScript support)
  • supports a --dry-run option to give it a test drive

Release

If "checks" fail or "runs script" has nonzero error code, pub-time exits and the publish is cancelled.

  1. checks you are on local main branch

  2. checks you are level with remote origin/main

  3. checks various key fields in package.json

  4. checks for a README.md

  5. checks that npm audit shows no vulnerabilities

  6. runs script npm run lint if it exists (with default setting)

  7. calculates the next version by looking at both:

    • the latest version (if any) published to npm
    • commits since the previous git tag v#.#.#
  8. final warning, pausing for user input and showing some common final todos that can't be automatically checked

  9. updates the version in package.json

  10. checks that the user's npm and node versions match the user's engines in package.json

  11. deletes and reinstalls npm dependencies

  12. runs script npm run build (with default setting)

  13. runs script npm run test (with default setting)

  14. runs script npm run check-build if it exists (with default setting)

  15. (!) dry run stops doing anything here, but instead logs out the commands it would run

  16. releases

    • commits any changes
    • creates a new v#.#.# git tag
    • pushes up commits and tag
    • npm publish 🎉

Background

I created this library because I was unhappy with the alternatives (especially the install size):

| package | install size | | ------------------ | ------------------------------------------------------------------- | | np | install size | | release-it | install size | | semantic-release | install size |

pub-time leans into the conventions you may already use in your projects and will use your pre-existing project specific scripts in your package.json.

Install

This package is available from the npm registry.

npm install pub-time

Usage

npx pub-time
# Options:
#   --dry-run |
#   1ad4719d1 | custom commit hash override (manually specify previous release commit)

API

Supports JavaScript + TypeScript:

import { publish } from "pub-time";

export const publish = (config: Partial<Config>) => Promise<boolean>;

export type Config = {
  /* custom log function instead of console.log */
  log: (message: string) => void;
  /* if true, package will not be published, git will not be updated */
  dryRun: boolean;
  /* if left undefined, will treat last 'v#.#.#' git tag as the last commit of the prev release
     if a string, will be treated as the hash of the last commit of the prev release
     to force include all commits, use the value 'all' */
  prevHash?: string;
  /* custom functions used in publish process */
  build: string | ((nextSemver: string) => Promise<void>);
  checkBuild: string | ((nextSemver: string) => Promise<void>);
  test: string | (() => Promise<void>);
  lint: string | (() => Promise<void>);
};

export const DEFAULT_CONFIG: Config = {
  // eslint-disable-next-line no-console
  log: console.log,
  prevHash: undefined,
  dryRun: false,
  lint: "lint",
  build: "build",
  checkBuild: "check-build",
  test: "test",
};

Can also be imported via require("pub-time").

Contributing

GitHub issues / PRs welcome.

Dev environment requires:

  • node >= 16.14.0
  • npm >= 6.8.0
  • git >= 2.11

Licence

Apache-2.0