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

@wtf/release-replace

v6.1.1

Published

Text replaced in the files of a repo, of no release tool, each function by the folder of the repo and the platform it is given: what a replacement is (.), each match of a RegExp of each file git tracks of paths, globs and negations replaced, and of a text

Readme

@wtf/release-replace

Text replaced in the files of a repo, with no release tool: each match of each replacement, in each file git tracks of paths or globs, as the version of a release written into the badge of a README, so the release commit commits it. A badge that names a version is wrong from the next release, and nothing fails then. The library of @wtf/semantic-release-replace, with no dependency on semantic-release; each function reads and writes the files of the folder of the repo, a handle of the File System standard, and runs git by the platform, as @wtf/release has them, which its caller gives it.

As a library

A replacement replaces each match of from, the source of a RegExp, of its flags but g, which it always has, by to, a text or a function:

  • a text reads $1, $2 … and $<name>, each group of the match, as String.prototype.replace reads them, and ${nextRelease.version}, each value of the context by its dotted path, as the message of @semantic-release/git writes one: a path the context has not fails with EVALUE. escape writes each value as it is, none, the default; as the text of a badge of shields.io, shields, each - and _ doubled; or as a component of a URL, url;
  • a function is given the match, its text, groups, named groups and index, the file, and the context, and gives the text it is replaced by, or a promise of one.

files are the files git tracks of paths and globs, in order, from the root of the repo: a path holds the file, or each file under the folder; a glob, of picomatch, each file it matches, * and ? within a name, ** across folders, […] a class, [^…] one not of it, and {a,b} each of a list; and an entry of ! first leaves out what it matches of what the entries before it hold.

A template is a replacement of a name, of templates: a replacement names it alone, as 'badge', or with options over the template's own, as { template: 'badge', escape: 'none' }; a name of none fails with ETEMPLATE, naming those there are. mergeTemplates merges sets of them in order, by name, as a repo's own over those a package shares.

import type { RepoContext } from '@wtf/release'
import { replaceFiles } from '@wtf/release-replace/replace'
import { mergeTemplates } from '@wtf/release-replace/templates'

/** The version of a badge of shields.io, of any colour, as a package of templates shares it. */
const shared = {
  badge: {
    from: '(img\\.shields\\.io/badge/version-)[^)\\s"\'?#]*?(-[0-9A-Za-z]+(?:\\.svg)?(?=[)\\s"\'?#]|$))',
    to: '$1${nextRelease.version}$2',
    escape: 'shields' as const
  }
}

export function replaceVersion({ root, platform }: RepoContext, version: string) {
  return replaceFiles({
    files: ['packages/**/README.md', '!packages/shared/**', 'src/version.ts'],
    templates: mergeTemplates([
      shared,
      { version: { from: '(VERSION = ")[^"]*(")', to: '$1${nextRelease.version}$2' } }
    ]),
    replacements: [
      'badge',
      'version',
      { from: 'UNRELEASED', to: (_match, file) => `${version} of ${file}` }
    ],
    context: { nextRelease: { version } },
    root,
    platform
  })
}

Only a file whose text changes is written; replaceFiles gives each it wrote.

| Export | What it is | | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | @wtf/release-replace | The types of a replacement: Replacement, ReplacementSpec, Templates, ReplaceFunction | | @wtf/release-replace/replace | replaceFiles, each file of paths or globs replaced; replaceText, a text; regExpOf | | @wtf/release-replace/files | filesMatcher, the files of paths, globs and negations | | @wtf/release-replace/values | textOf, the values of a context in the text of a replacement; escapeValue, valueAt | | @wtf/release-replace/templates | resolveReplacements, the replacement of each template named; mergeTemplates, sets merged; noTemplate, the error of a name of none | | @wtf/release-replace/errors | ReplaceError, the class of its errors, and their codes, REPLACE_ERRORS |

See Configuring trains.

License

MIT