hatch-nodejs-version is an active Hatch plugin, currently at version 0.4.0, that facilitates Python project versioning by integrating with Node.js `package.json` files. It provides two main functionalities: a version source plugin that reads and writes the package version from the `version` field of `package.json`, and a metadata hook plugin that reads PEP 621 metadata from the same file. The project sees regular updates, addressing enhancements and bug fixes.
pip install hatch-nodejs-versionNo compatibility data collected yet for this library.
To use `hatch-nodejs-version`, you must first declare it in your `pyproject.toml` under `[build-system].requires`. Then, configure the version source by setting `[tool.hatch.version].source` to `nodejs`. You can optionally specify the `path` to your `package.json` if it's not in the project root. Additionally, the metadata hook can be configured under `[tool.hatch.metadata.hooks.nodejs]` to sync fields like name or description from `package.json` to your Python project's metadata.
Ensure your `package.json` version string adheres to major.minor.patch[-pre-release][.dev-release] format, avoiding build metadata. For example, use `1.2.3-rc.0` instead of `1.2.3+build.1`.
Add `"hatch-nodejs-version"` to the `requires` array under `[build-system]` in your `pyproject.toml`.
Upgrade to version `0.3.2` or newer to ensure `package.json` files maintain correct formatting upon modification.
Verify that `pip install hatch-nodejs-version` has been run and that `"hatch-nodejs-version"` is included in `build-system.requires` in your `pyproject.toml`.
Ensure `package.json` exists in your project, or set the correct `path` (e.g., `path = "./frontend/package.json"`) in your `pyproject.toml` configuration.
Modify the `version` field in `package.json` to adhere to the major.minor.patch.pre-release.dev-release format, removing any build metadata. For example, change `1.0.0+build.1` to `1.0.0` or `1.0.0-beta.1`.