-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhatch_build.py
More file actions
30 lines (21 loc) · 1.14 KB
/
hatch_build.py
File metadata and controls
30 lines (21 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Hatch build hook: verify the OpenClaw plugin bundle is present.
`scripts/bump_version.py` rebuilds `keep/data/openclaw-plugin/dist/index.js`
before `uv build` runs, and `pyproject.toml` force-includes that file in
the wheel. This hook is a safety check: if the bundled artifact is missing,
fail the build loudly rather than shipping a broken plugin.
"""
from pathlib import Path
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class OpenClawPluginBuildHook(BuildHookInterface):
"""Verify the pre-built OpenClaw plugin entry point is present."""
PLUGIN_NAME = "openclaw-plugin-build"
def initialize(self, version, build_data):
plugin_dir = Path(self.root) / "keep" / "data" / "openclaw-plugin"
dist_file = plugin_dir / "dist" / "index.js"
if not dist_file.exists():
raise RuntimeError(
f"OpenClaw plugin not built: {dist_file} is missing. "
f"Run `node build.mjs` in {plugin_dir}, or release via "
"`scripts/release.sh` which rebuilds it automatically."
)
self.app.display_info(f"OpenClaw plugin present: {dist_file}")