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

util.pkgwrap

v0.0.115

Published

A script wrapper for package.json scripts.

Downloads

642

Readme

util.pkgwrap

A script wrapper for package.json scripts.

build code style: prettier NPM

This creates a command line program named pkgwrap in node_modules/.bin. It is used to wrap common/reusable command line operations for launching scripts in NPM or Yarn script. The wrapper simplifies the setting of command line parameters for the programs below to create a set of opinionated options. e.g. dynamically setting the temporary directory for nyc output or parallel building of JSX files or setting the default list of file extensions used by prettier.

This implementation is opinionated and wraps the following packages:

Installation

To install as an application dependency with cli:

$ npm install --save util.pkgwrap

This module must be a regular dependency in a project and NOT a development one. A package that uses the pkgwrap script must have it installed in the node_modules/.bin when installed by other packages. If it is not, then the pkgwrap calls for postinstall will fail to find it when your package is installed as a 3rd party dependency.

Usage

This is a command line package used with the scripts section of package.json. An example would be:

"scripts": {
    "build": "pkgwrap --build --jsx",
    "clean": "pkgwrap --clean",
    "coverage": "pkgwrap --coverage",
    "docs": "pkgwrap --docs --site",
    "lint": "pkgwrap --lint",
    "postinstall": "pkgwrap --postinstall",
    "prettier": "pkgwrap --prettier",
    "report": "pkgwrap --reporting",
    "test": "pkgwrap --testing --ava"
}

Commands

  • --build: calls the typescript build process
  • --clean: removes intermediate build/distribution files from the module. This includes dist, build, coverage.
  • --coverage: runs coveralls to upload report details after a successful build.
  • --docs: generates markdown and website documents for a module
  • --globals: takes global dependencies from package.json ("globalDependencies") and installs them. These follow the same conventions as dependencies/devDependencies.
  • --lint: calls the tslint code checking program
  • --postinstall: this is executed after npm install. It is used to create directories or fix their permissions (for programs like nyc or coverage).
  • --prettier: calls the prettier style formatter program to ensure all source files conform to an opinionated format.
  • --reporting: runs nyc to create information that can be used in reporting testing coverage
  • --testing: calls the testing program. It uses mocha by default. It can be overriden to use ava with an additonal --ava flag or --jest.

Options

  • --ava: Used with the --testing command to use the ava test runner.
  • --debug: Turns on verbose output where available.
  • --jest: Used witht he --testing command to use the jest test runner.
  • --jsx: Used with the --build command to search for .jsx files and use babel to transpile them.
  • --minWorkers (5): Used with --build to set the smallest number of workers in the execution pool for building JSX files with babel (builds JSX files in parallel)
  • --maxWorkers (10): Used with --build to set the largest number of workers in the execution pool for building JSX files with babel (builds JSX files in parallel)
  • --site: Used with the --docs command to generate a corresponding jsdoc website (jsdoc)
  • --webpack: Used with the --build command to invoke webpack if it is avaialble (or will generate an error if it is not)

Dependencies

The following development dependencies must be included within the package.json file of the project that uses this cli: