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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@swxv/cli

v0.1.9

Published

Generic regex-based config switcher CLI for any envs

Readme

swx

A generic regex-based config switcher CLI. Define environments in a single JSON file and swap values across any files in your project with one command.

Installation

pnpm add -D @swx/cli
# or
npm install -D @swx/cli

Quick Start

Run the interactive setup in your project root:

swx init

This walks you through creating a swx.config.json. Once created, switch environments with:

swx switch <env>

Or you can define a command directly in your package.json scripts:

{
  "scripts": {
    "switch:dev": "swx switch dev",
    "switch:staging": "swx switch staging"
  }
}

Commands

swx init

Interactively generates a swx.config.json in the current directory. If one already exists you will be prompted to confirm before overwriting.

swx switch <env>

Applies the replacements defined for the given environment across all configured files.

swx switch dev
swx switch staging

Options:

| Flag | Description | | ------- | ----------------------------------------------- | | --dry | Preview what would change without writing files |

swx switch staging --dry

Dry run output shows a line-by-line diff per file:

src/config.ts:
- const ENV = "dev"
+ const ENV = "staging"

swx list

Opens an interactive prompt to select an environment and switch to it.

swx list

If enableDryRunInList is enabled in your config, you will also be asked whether to perform a dry run before applying changes.

Configuration

swx.config.json lives at the root of your project. swx walks up the directory tree to find it, so you can run commands from any subdirectory.

{
  "environments": {
    "dev": {
      "description": "Development environment",
      "replacements": [
        {
          "files": ["src/config.ts"],
          "regex": "/(staging|production)/",
          "value": "development"
        }
      ]
    },
    "staging": {
      "description": "Staging environment",
      "replacements": [
        {
          "files": ["src/config.ts"],
          "regex": "/(development|production)/",
          "value": "staging"
        }
      ]
    }
  },
  "enableDryRunInList": false
}

Schema

Top level

| Field | Type | Required | Description | | -------------------- | --------- | -------- | ---------------------------------------------------- | | environments | object | Yes | Map of environment name to environment config | | enableDryRunInList | boolean | No | Prompt for dry run mode when using swx list |

Environment

| Field | Type | Required | Description | | -------------- | -------- | -------- | ---------------------------------------- | | description | string | No | Human-readable label for the environment | | replacements | array | Yes | List of replacement rules (minimum 1) |

Replacement

| Field | Type | Required | Description | | ------- | ---------- | -------- | ------------------------------------------------------------------ | | files | string[] | Yes | Paths to files the replacement applies to (minimum 1) | | regex | string | Yes | Regex in /pattern/flags format, e.g. "/(dev\|staging)/" | | value | string | Yes | The string to substitute for every match |

Regex format

Regexes must be written in slash-delimited format:

/(pattern)/

Examples:

/(dev|staging)/
/^API_URL=.*/m
/(development|production)/

Requirements

  • Node.js >= 20