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/semantic-release-replace

v5.1.4

Published

The plugin of semantic-release that replaces text in files of the repo in prepare, by @wtf/release-replace: each match of a RegExp, in each file of paths, globs and negations, by a text of the context of the release, as ${nextRelease.version}, or a functi

Readme

@wtf/semantic-release-replace

Text replaced in files of the repo as a release is made, as the version of the badge of a README, so the release commit commits them. The semantic-release plugin, in prepare, replaces each match of each of its replacements in each file git tracks of its files, and writes each file whose text changes; in verifyConditions, it checks its options, and imports each template and function of a module it names, before the run releases. Of a package of templates, as @wtf/replace-shields below, which this repo does not have:

{
  "templates": [
    { "module": "@wtf/replace-shields" },
    { "version": { "from": "(VERSION = \")[^\"]*(\")", "to": "$1${nextRelease.version}$2" } }
  ],
  "plugins": [
    [
      "@wtf/semantic-release-replace",
      {
        "files": ["packages/**/README.md", "!packages/shared/**", "src/version.ts"],
        "replacements": [
          "badge",
          "version",
          {
            "from": "UNRELEASED",
            "to": { "module": "./release/replace.mjs", "export": "unreleased" }
          }
        ]
      }
    ]
  ]
}

| Option | What it is | | -------------- | ------------------------------------------------------------------------------------------------------------- | | files | Paths, globs and negations, in order, from the root of the repo, of the files git tracks: required | | replacements | Each { from, flags, to, escape }, or of a template, { template, … } or its name alone, in order: required | | templates | Templates by name: a set, or sets merged in order; at the root of the config too, under the entry's |

files holds, of a path, the file, or each file under the folder; of a glob, 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 replacement replaces each match of from, the source of a RegExp, of its flags but g, which it always has, by to:

  • a text, of $1, $2 … and $<name>, each group of the match, and ${nextRelease.version}, each value of the context semantic-release gives prepare by its dotted path, as nextRelease, lastRelease, branch, commits and options, but env, whose secrets have no place in a file of the repo; the syntax of the message of @semantic-release/git. A path the context has not fails with EVALUE. escape writes each value: none, the default; shields, each - and _ doubled, as the text of a badge of shields.io; or url, as a component of a URL;
  • the function of a module, { module, export }, which the plugin imports, so a config of JSON names one; or a function, of a config of JavaScript. It is given the match, its text, groups, named groups and index; the file; and the context; and gives the text the match is replaced by.

Only a file whose text changes is written, each said; none is said too, and is no failure. List it before @semantic-release/git, whose assets hold the files it replaces.

Templates

A template is a replacement of a name, which a replacement names alone, as "badge", or with options over the template's own, as { "template": "badge", "escape": "none" }. templates is a set, or an array of sets merged in order, each over those before it by name; those of the root of the config, which semantic-release gives every plugin, are under those of the entry. A set is:

  • a map of each template by its name: a replacement, or the export of a module that is one, as { "badge": { "module": "@wtf/replace-shields", "export": "versionBadge" } }, which comes in under the name of the map, badge;
  • or the export of a module that is a set, as { "module": "@wtf/replace-shields" }, each of whose templates comes in under its own name, and may again be the export of a module.

A template a module exports may be a function, which each replacement of it calls with the options beside its name, as { "escape": "none" }, and replaces by the replacement it gives; a name alone gives it none.

So a package shares templates, which a repo names, adds to and overrides. A package of templates exports a replacement, as the version of the badge of shields.io, and a set of them; the to of each may again be a function, or the function of a module:

// @wtf/replace-shields: index.js
export const versionBadge = {
  from: '(img\\.shields\\.io/badge/version-)[^)\\s"\'?#]*?(-[0-9A-Za-z]+(?:\\.svg)?(?=[)\\s"\'?#]|$))',
  to: '$1${nextRelease.version}$2',
  escape: 'shields'
}

export default { badge: versionBadge }

verifyConditions imports each module, of a to too, and checks each export, for prepare: EREPLACEMODULE of a module it cannot load, or of no such export, naming both; ETEMPLATE of an export of no replacement, or of no set. A name of no template fails with ETEMPLATE, naming those there are: the plugin never takes a name for a module.

A module is named by its path from the root of the repo (./, ../ or absolute), or by the name of a package: the repo's, a devDependency; else one installed beside the plugin, of a global install of semantic-release. The semantic-release component of to-be-continuous installs each name of plugins globally, and each line of semrel-required-plugins.txt with them: list a package of templates there.

# semrel-required-plugins.txt
@wtf/replace-shields

| Export | What it is | | -------------------------------------- | ---------------------------------------------------------------------------------------------- | | @wtf/semantic-release-replace | The plugin: verifyConditions and prepare; templatesOf, functionOf; its types | | @wtf/semantic-release-replace/schema | The validators of its options, its templates, and its part of a config; jsonSchema, its file |

As a library

The plugin is a thin adapter over @wtf/release-replace, of no release tool: replaceFiles of its ./replace, the files of ./files, the values of a context of ./values, and the templates of ./templates, which take the replacements and the functions the plugin imported.

Schema

@wtf/semantic-release-replace/schema.json is the JSON Schema of its part of a config of semantic-release, templates of the root and the entries of plugins of the plugin, for an editor; ./schema has the same as a validator, a Standard Schema, for code. Compose the schemas of the packages a repo installs in a release.schema.json, by allOf: see Validating a config.

License

MIT