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

workspaces-filter

v0.4.5

Published

A companion for filtering monorepo workspaces, by package name or package dir. Useful for running scripts on a subset of workspaces. The primary reason is because Bun's "--filter" feature is buggy, but it's also useful for other package manger, it also ru

Downloads

658

Readme

workspaces-filter

A companion for filtering monorepo workspaces, by package name or package dir. Useful for running scripts on a subset of workspaces. The primary reason is because Bun's "--filter" feature is buggy, but it's also useful for other package manger, it also runs shell scripts using the execa package

Install

bun add workspaces-filter
npm install workspaces-filter

or use the CLI directly:

bunx workspaces-filter
npx workspaces-filter
pnpm dlx workspaces-filter

# or install globally
npm install -g workspaces-filter

Usage

workspaces-filter/0.4

Usage:
  $ workspaces-filter <pattern> [...command]

Commands:
  <pattern> [...command]  Select by package name or workspace directory

For more info, run any command with the `--help` flag:
  $ workspaces-filter --help

Options:
  --print <mode>                Print the names/folders of selected packages, without running command
  --cwd <dir>                   Current working directory (default: /home/charlike/code/hela)
  --pm, --package-manager <pm>  The package manager to use. Defaults to packageManager from root package.json, or Bun
  -v, --version                 Display version number
  -h, --help                    Display this message

Examples:
workspaces-filter . build   # run in all packages of all workspaces
workspaces-filter _ build   # because the '*' would not work

workspaces-filter '*preset*' build
workspaces-filter '*preset*' add foo-pkg
workspaces-filter '*preset*' add --dev typescript

workspaces-filter './packages/foo' -- echo 'Hello, World!'
workspaces-filter './packages/*preset*' -- pwd

workspaces-filter '*preset*' --print names
workspaces-filter '*preset*' --print json
workspaces-filter '*preset*' --print dirs

NOTE: To run a shell command in selected/filtered packages, use -- right after the pattern!

Examples

npx workspaces-filter '*preset*' build
pnpm dlx workspaces-filter '*preset*' add foo-pkg
bunx workspaces-filter '*preset*' add --dev typescript

It checks if there is a script in package's scripts field (thus runs it with bun run, npm run or pnpm run), if not runs the package manager command (bun add, npm add), or a shell command if _ or sh is provided right after the pattern, like so

bunx workspaces-filter './packages/foo' -- echo 'Hello, World!' # runs `echo 'Hello, World!'` in the `./packages/foo` workspace
bunx workspaces-filter './packages/*preset*' -- pwd # runs `pwd` in each workspace

You can run pnpm dlx like so

pnpx workspaces-filter '*preset*' dlx esmc