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-watcher

v0.3.1

Published

An opinionated watcher tool for Lerna.

Downloads

8

Readme

An unofficial watcher for Lerna, similar to lerna-watch.

It was made with personal use in mind, but feel free to use/fork it, PRs are also welcome.

The tool uses internal Lerna APIs and although unlikely, it might break anytime.

Installation

Execute the following in your Lerna root:

yarn add --dev lerna-watcher (-W if you're using workspaces)

or

npm i --save-dev lerna-watcher

Usage

Run

yarn lerna-watcher --help or npm run lerna-watcher --help

for the available commands and options.

An example command:

watch package-foo package-bar --stream --ignore "package-baz-*"

This will watch for changes in packages matching package-foo and package-bar along with their local dependencies excluding any dependency matching with package-baz-*.

If any of the packages change, their respective commands (package.json scripts) will be run with Lerna, then this process is repeated for all dependents in topological order until there are no more dependents.

Forever running commands (such as web servers) are always killed with SIGTERM to allow graceful shutdowns and then restarted on changes. There are no timeouts anywhere.

Caveats

  • Dependency cycles are not supported.
  • Best effort ordering, commands might run multiple times, but they must always run at least once in the correct order.
  • Personal focus, I add non-trivial fixes or features if I need them, the rest are up to external contributions.

Configuration

Apart from the command line options, additional configuration can be done in lerna.json under the watcher property.

Here are the defaults with some explanation in the comments:

// lerna.json
{
  // ...
  // All of the properties are optional.
  "watcher": {
    // Stop the watching process if any of the commands fail.
    "exitOnError": false,
    // Configuration for packages.
    "packages": {
      // The default configuration for every package,
      // unless specified otherwise.
      //
      // These example values are used by default if omitted from the config.
      "default": {
        // Paths to watch relative to the package root.
        "include": ["**"],
        // Files to exclude from watching relative to the package root.
        // These override "include".
        "exclude": [
          "**/node_modules/**",
          "**/.git/**",
          "**/dist/**",
          "**/build/**",
          ".*/**"
        ],
        // The commands (npm/yarn scripts) to run on change.
        // These are executed in order.
        //
        // This list must never be empty for the main watch targets.
        "commands": ["dev"],
        // Alternatively, these commands are run when the package is
        // a dependency, "commands" and "dependencyCommands" are completely
        // independent.
        //
        // This list is allowed to be empty, and is empty by default.
        "dependencyCommands": [],
        // Additional commands to run after a specified command.
        //
        // These are always run in a fire and forget manner compared
        // to the rest, meaning they will never be cancelled and can fail,
        // but they are always executed sequentially.
        //
        // Useful for lints and tests.
        "runAfter": {
          // This doesn't exist in the default config, it's just an example command.
          "build": ["lint", "test", "something-else"]
        },
        // Continue with running the next command in case the previous one fails.
        "continueOnError": false,
        // Always ignore this package as a dependency.
        "ignore": false
      },
      // Configuration for package names by wildcard patterns.
      //
      // All packages must match exactly one pattern.
      "patterns": {
        // All the properties are the same as in "default".
        //
        // For missing properties, the default ones are used.
        "foo-*": {
          // Build and start every foo when directly watched.
          "commands": ["test", "build", "start"],
          // Build and test, but don't start it if it's a dependency.
          "dependencyCommands": ["test", "build"]
        }
      }
    },
    // Caching is done to track file changes,
    // if this is set to true, the cache will be
    // cleared on exit.
    "clearCache": false
  }
}