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

wp-update-version

v1.0.1

Published

Command-line tool that updates the version number in various files within a WordPress project (plugin or theme).

Downloads

129

Readme

WP Update Version

wp-update-version is a command-line tool that updates the version number in various files within a WordPress project (theme or plugin). This allows you to synchronize your WP project's version number with the one in your package.json file.

Features

  • Updates the version number in CSS and PHP files' header comment blocks.
  • Optionally updates the version as constant declaration in specified PHP files.
  • Supports single or multiple files updates with one command.
  • Retrieves the version number from a package.json file (or allows you to specify it manually)

Installation

Save wp-update-version as a devDependency in your project:

npm install --save-dev wp-update-version

Usage

Run the script directly in your terminal using npx:

npx wp-update-version --file src/theme.scss --file plugin.php --project-version 2.1.0 --constant PLUGIN_VERSION

Or add it to your project's version script in package.json:

{
  "name": "my-wp-project",
  "version": "2.0.0",
  "scripts": {
    "build": "[compile src/theme.scss into style.css]",
    "version": "wp-update-version -f src/theme.scss && npm run build && git add ."
  }
}

For instance, when running npm version minor, the following will happen with the configuration above:

  1. (npm version) Updates the version number to 2.1.0 in package(-lock).json
  2. (wp-update-version) Updates the version number to 2.1.0 in src/theme.scss
  3. Builds style.css with version number 2.1.0
  4. Commits all updated files

Available options

| Option | Description | Default Value | |-------------------------------------|---------------------------------------------------------------------------------------------|----------------------------------| | -f <file> --file <file> | Specify the file(s) to be updated. Can be repeated to update multiple files. | ./style.css, ./<dirname>.php | | -p <file> --package-json <file> | Specify the location of the package.json file. | ./package.json | | --project-version <version> | (Optional) Specify the new version number to apply. Overrides the value from package.json | - | | --constant <constant> | (Optional) Specify a constant declaration to be updated in the PHP file(s). | - |

Development

Permission issue

When building and running your own version of the command, you might need to run chmod u+r bin/* to allow the program to execute.

Testing

This project uses Vitest for unit and integration testing.

  • Run npm test for a single test suite run.
  • Run npm run test:watch to enable test-based development.

Contributing

If you encounter any issues or have suggestions for improvements, please feel free to open a new issue or submit a pull request.

Credits

This tool was inspired by and derived from the following:

License

This project is licensed under the MIT License.