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

lerna-script

v1.4.0

Published

lerna extension for custom scripts

Downloads

15,520

Readme

lerna-script

For usage scenarios documentation please see root of repo;

CLI

lerna-script exports a cli script:

lerna-script [options] <task>

where options:

  • loglevel - set's loglevel, defaults to info;

task:

  • one of exports defined in lerna.js file.

API

loadPackages({[log], [packageConfigs]}): Promise[LernaPackages[]]

Returns list of packages/modules in repo - forward to lerna;

Parameters:

  • log, optional - npmlog logger;

loadRootPackage({[log]}): Promise[LernaPackage[]]

Returns Package of root module.

Parameters:

  • log, optional - npmlog logger;

iter.forEach(lernaPackages, {[log], [build]})(task): Promise

Executed provided command for all lernaPackages in a serial fashion. taskFn can be either sync task or return a Promise.

Parameters:

  • lernaPackages - list of lerna packages to iterate on;
  • log - logger to be used for progress and pass-on to nested tasks;
  • build - should a module be built as in changes.build;
  • task - function to execute with signature (lernaPackage, log) => Promise.

Returns promise with task results.

iter.parallel(lernaPackages, {[log], [build], [concurrency]})(task): Promise

Executed provided command for all lernaPackages in a parallel fashion(Promise.all). taskFn can be either sync task or return a Promise.

Parameters:

  • lernaPackages - list of lerna packages to iterate on;
  • log - logger to be used for progress and pass-on to nested tasks;
  • build - should a module be built as in changes.build;
  • task - function to execute with signature (lernaPackage, log) => Promise.
  • concurrency - number, defaults to Infinity. See bluebird#map API

Returns promise with task results.

iter.batched(lernaPackages, {[log], [build]})(task): Promise

Executed provided command for all lernaPackages in a batched fashion respecting dependency graph. taskFn can be either sync task or return a Promise.

Parameters:

  • lernaPackages - list of lerna packages to iterate on;
  • log - logger to be used for progress and pass-on to nested tasks;
  • build - should a module be built as in changes.build;
  • task - function to execute with signature (lernaPackage, log) => Promise.

Returns promise without results (undefined).

exec.command(lernaPackage, {silent = true})(command): Promise(stdout)

Executes given command for a package and returns collected stdout.

Note that command is a single command, meaning rm -f zzz and not ex. rm -f zzz && mkdir zzz. It's just for convenience you can provide command and args as a single string.

Argument list #1:

  • command - command to execute;

Argument list #2:

  • lernaPackage - package returned either by rootPackage() or packages();
  • silent - should command output be streamed to stdout/stderr or suppressed. Defaults to true;

Returns:

  • stdout - collected output;

exec.script(lernaPackage, {silent = true})(script): Promise(stdout)

Executes given npm script for a package and returns collected stdout.

Argument list #1:

  • script - npm script to execute;

Argument list #2:

  • lernaPackage - package returned either by rootPackage() or packages();
  • silent - should script output be streamed to stdout/stderr or suppressed. Defaults to true;

Returns:

  • stdout - collected output;

changes.build(lernaPackage, {[log]})([label]): undefined

Marks package as built.

Parameters:

  • lernaPackage - package to build;
  • log, optional - npmlog logger;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label.

changes.unbuild(lernaPackage, {[log]})([label]): undefined

Marks package as unbuilt.

Parameters:

  • lernaPackage - package to unbuild;
  • log, optional - npmlog logger;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label

changes.isBuilt(lernaPackage)([label]): boolean

Returns true if package is build and false otherwise.

Parameters:

  • lernaPackage - package to unbuild;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label

filters.removeBuilt(lernaPackages: [], {[log]})([label]: String): []

Filters-out packages that have been marked as built changes.build and were not changed since. Note that it filters-out also dependent packages, so if:

  • a, did not change, depends on b;
  • b, changed;
  • c, not changed, no inter-project dependencies.

Then it will return only c as b has changed and a depends on b, so it needs to be rebuilt/retested/re...

Parameters:

  • lernaPackages - packages to filter;
  • log, optional - npmlog logger;
  • label, optional - given you have several exports scripts, you can separate them in different build/unbuild groups by label

Note: this filter mutates built/unbuild state, meaning that it unbuilds dependents to get reproducible runs.

filters.gitSince(lernaPackages: [], {[log]})(refspec: String, {ignoreChanges: string[]}?): []

Filters-out packages that have did not change since refspec - ex. master, brach, tag.

Parameters:

  • lernaPackages - packages to filter;
  • log, optional - npmlog logger;
  • refspec - git refspec = master, branchname, tag...
  • opts.ignoreChanges - optional array of glob expressions. files matching those globs will be ignored in the diff calculation.

filters.removeByGlob(lernaPackages: [], {[log]})(glob: String): []

Filters-out packages by provided glob pattern.

Parameters:

  • lernaPackages - packages to filter;
  • log, optional - npmlog logger;
  • glob - glob pattern.

filters.includeFilteredDeps(lernaPackages: [], {[log]})(filteredPackages: []): []

Returns a list of packages tgat includes dependencies of filteredPackages that are in lernaPackages.

Parameters:

  • lernaPackages - all packages;
  • log, optional - npmlog logger;
  • filteredPackages - subset of lernaPackages.

fs.readFile(lernaPackage)(relativePath, converter: buffer => ?): Promise[?]

Reads a file as string by default or accepts a custom converter.

Parameters:

  • lernaPackage - a lerna package for cwd of reading;
  • relativePath - file path relative to lernaPackage root.
  • converter - a function to convert content, ex. JSON.parse

fs.writeFile(lernaPackage)(relativePath, content, converter: type => string): Promise[String]

Writes string/buffer to file, accepts custom formatter.

Automatically detects and formats object.

Parameters:

  • lernaPackage - a lerna package for cwd of reading;
  • relativePath - file path relative to lernaPackage root.
  • content - content of file.
  • converter - function to convert provided type to string/buffer.