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

@paulsevere/safe-publish

v0.1.0-beta.0

Published

Safe NPM package publication

Downloads

4

Readme

Safe publish script

This scripts wraps npm publish to execute it in a safe way, without failing if the package already exists.

Use cases

Avoid publication failing when a NPM package and version already exists.

It is useful to work along with Lerna to be able to manage the versions of each package independently.

Requirements and dependencies

NodeJS/NPM are required to work with the repository.

Installation and running

npm install safe-publish
const cwd = process.cwd();
const { name, version } = require(join(cwd, 'package.json'));

publish({
  cwd,
  name,
  version
})
.catch((error) => {});

Options

These values are required to be able to publish the package:

  • cwd (string): working directory of the package to be published.
  • name (string): name of the package to be published.
  • version (string): version of the package to be published.

These values are optional and allow to configure the publication:

  • registry (string): override the registry.
    • If the registry is not defined, NPM will use the default one.
    • The registry can be set in the package.json:
    "publishConfig": {
      "registry": "http://registry.url"
    }
  • force (boolean): force the publication despite the fact that the package could exist.
    • It implies that the process could fail.
  • dry-run (boolean): for testing purposes, it does not try to publish the package.
  • silent (boolean): disable the log output.

Command Line Interface

The script can be run via CLI:

safe-publish
safe-publish --registry=http://registry.url --silent

Options and aliases:

  --version       Show version number                                  [boolean]
  --help          Show help                                            [boolean]
  -r, --registry  Override default registry                             [string]
  -f, --force     Force publication                   [boolean] [default: false]
  -d, --dry-run   Test publication process            [boolean] [default: false]
  -s, --silent    Disable log output                  [boolean] [default: false]

Example along with Lerna

Having a mono repository in which its package versions have to be managed in an independently way. We can use Lerna to run the safe-publish script:

  • Root package.json with the running script:
    {
      "name": "mono-repository",
      "version": "0.0.0",
      "scripts": {
        "lerna:publish": "lerna exec -- safe-publish"
      },
      "devDependencies": {
        "lerna": "^2",
        "safe-publish": "^1"
      }
    }
  • Package package.json:
    {
      "name": "package",
      "version": "1.0.0",
      "files": [
        "dist",
        "README.md",
        "CHANGELOG.md"
      ]
    }
  • Running NPM script:
    npm run lerna:publish -- --silent

FAQ

Maintainers

Check the contributor list and you will be welcome if you want to contribute.

Contributing

Check out the CONTRIBUTING.md file to know how to contribute to this project.

License and Software Information

© adidas AG

adidas AG publishes this software and accompanied documentation (if any) subject to the terms of the MIT license with the aim of making the NPM package publications of a mono repository easier. You will find a copy of the MIT license in the root folder of this package. All rights not explicitly granted to you under the MIT license remain the sole and exclusive property of adidas AG.

NOTICE: The software has been designed solely for the purpose of analyzing the code quality by checking the coding guidelines. The software is NOT designed, tested or verified for productive use whatsoever, nor or for any use related to high risk environments, such as health care, highly or fully autonomous driving, power plants, or other critical infrastructures or services.

If you want to contact adidas regarding the software, you can mail us at [email protected].

For further information open the adidas terms and conditions page.

License

MIT