Hatch Node.js Version Plugin

0.4.0 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Quickstart

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.

# pyproject.toml
[build-system]
requires = ["hatchling", "hatch-nodejs-version"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "nodejs"
path = "./frontend/package.json" # Optional: if package.json is not in the project root

[tool.hatch.metadata.hooks.nodejs] # Optional: to sync other metadata
fields = ["name", "description"] # Optional: fields to sync

# package.json (example)
{
  "name": "my-package",
  "version": "1.2.3",
  "description": "A simple Node.js package."
}

view raw JSON →