From c9a192999fad1c0b71bccea77a29f0d1cc624257 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 7 Nov 2026 08:43:22 -0800 Subject: [PATCH] chore(release): use the @ucsantacruz/wordpress-version-updater package Replace the local wp-plugin-version-updater.js with the published npm package. The plugin.php bump file now uses the package updater, and a prerelease hook runs "wordpress-version-updater check plugin.php" before any bump. Update README.md and CLAUDE.md to name the package. Closes #31 Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 5 ++++- README.md | 4 +++- package-lock.json | 14 ++++++++++++++ package.json | 12 ++++++++---- wp-plugin-version-updater.js | 11 ----------- 5 files changed, 29 insertions(+), 17 deletions(-) delete mode 100644 wp-plugin-version-updater.js diff --git a/CLAUDE.md b/CLAUDE.md index bfe103b..298d7cb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,7 +41,10 @@ npm run release # Bump version via commit-and-tag-version (updates plugin.php npm run zip # Package plugin as .zip for distribution ``` -`npm run release` uses `wp-plugin-version-updater.js` to keep the version string in the `plugin.php` header in sync alongside the standard `package.json` bump. +`npm run release` uses the `@ucsantacruz/wordpress-version-updater` dev dependency as the +`plugin.php` bump-file updater, which keeps the `Version:` header in sync with the +`package.json` bump. A `prerelease` hook runs `wordpress-version-updater check plugin.php` +first, so the release stops before any bump if the header cannot be parsed. ## Architecture diff --git a/README.md b/README.md index 383616d..690c510 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,9 @@ them there, keeping them under version control. `npm run release` uses [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) to bump `package.json`, `package-lock.json`, and the `Version:` header in `plugin.php` -(through `wp-plugin-version-updater.js`), and to update `CHANGELOG.md` from the commit +(through the +[`@ucsantacruz/wordpress-version-updater`](https://www.npmjs.com/package/@ucsantacruz/wordpress-version-updater) +package), and to update `CHANGELOG.md` from the commit history. Push the resulting `v*.*.*` tag and [.github/workflows/release.yml](.github/workflows/release.yml) builds the zip and publishes the GitHub release via the shared `ucsc/actions` workflow. diff --git a/package-lock.json b/package-lock.json index b2d5024..5e696f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.6", "license": "GPL-3.0-or-later", "devDependencies": { + "@ucsantacruz/wordpress-version-updater": "^2.0.0", "@wordpress/scripts": "^30.23.0", "commit-and-tag-version": "^12.0.0" } @@ -5150,6 +5151,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@ucsantacruz/wordpress-version-updater": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@ucsantacruz/wordpress-version-updater/-/wordpress-version-updater-2.0.0.tgz", + "integrity": "sha512-I/z7J7f2aXNiUvAoDl/k2vQwES7AOholNpz+lBjx/w/UR4Z6tkgRQIo6KrP0GvsmmjHbPfStwWbbwH2nyfMe/w==", + "dev": true, + "license": "GPL-2.0-or-later", + "bin": { + "wordpress-version-updater": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", diff --git a/package.json b/package.json index 8059a7e..b44f6a5 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "packages-update": "wp-scripts packages-update" }, "devDependencies": { + "@ucsantacruz/wordpress-version-updater": "^2.0.0", "@wordpress/scripts": "^30.23.0", "commit-and-tag-version": "^12.0.0" }, @@ -37,7 +38,14 @@ "LICENSE" ], "commit-and-tag-version": { + "scripts": { + "prerelease": "wordpress-version-updater check plugin.php" + }, "bumpFiles": [ + { + "filename": "plugin.php", + "updater": "node_modules/@ucsantacruz/wordpress-version-updater/index.js" + }, { "filename": "package-lock.json", "type": "json" @@ -45,10 +53,6 @@ { "filename": "package.json", "type": "json" - }, - { - "filename": "plugin.php", - "updater": "wp-plugin-version-updater.js" } ] } diff --git a/wp-plugin-version-updater.js b/wp-plugin-version-updater.js deleted file mode 100644 index c55411e..0000000 --- a/wp-plugin-version-updater.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports.readVersion = function (contents) { - const capturingRegex = /Version:\s*(?[0-9]+\.[0-9]+\.[0-9]+)/; - const found = contents.match(capturingRegex); - if (!found) return null; - return found.groups.vnum; -}; - -module.exports.writeVersion = function (_contents, version) { - const regex = /Version:\s*[0-9]+\.[0-9]+\.[0-9]+/; - return _contents.replace(regex, "Version: " + version); -};