Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ packages = ["src/specify_cli"]
"templates/commands" = "specify_cli/core_pack/commands"
"scripts/bash" = "specify_cli/core_pack/scripts/bash"
"scripts/powershell" = "specify_cli/core_pack/scripts/powershell"
"scripts/python" = "specify_cli/core_pack/scripts/python"
# Bundled extensions (installable via `specify extension add <name>`)
"extensions/git" = "specify_cli/core_pack/extensions/git"
"extensions/agent-context" = "specify_cli/core_pack/extensions/agent-context"
Expand Down
40 changes: 40 additions & 0 deletions tests/contract/test_wheel_core_pack_scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Contract tests for the script variants bundled into the wheel's core_pack.

``specify init --script <type>`` installs from ``specify_cli/core_pack/scripts/``
when the CLI runs from a wheel. Any script variant that lives in the repository
must therefore be force-included at build time, otherwise the generated
commands reference scripts the released package never ships (#3665).
"""

from __future__ import annotations

import tomllib
from pathlib import Path

REPO_ROOT = Path(__file__).parents[2]


def _force_include() -> dict[str, str]:
with (REPO_ROOT / "pyproject.toml").open("rb") as pyproject_file:
pyproject = tomllib.load(pyproject_file)
return pyproject["tool"]["hatch"]["build"]["targets"]["wheel"]["force-include"]


def test_every_script_variant_is_bundled_into_core_pack():
force_include = _force_include()
variants = sorted(
path.name for path in (REPO_ROOT / "scripts").iterdir() if path.is_dir()
)

assert variants, "expected at least one script variant under scripts/"
for variant in variants:
assert force_include.get(f"scripts/{variant}") == (
f"specify_cli/core_pack/scripts/{variant}"
), f"scripts/{variant} is missing from the wheel force-include list"


def test_python_script_variant_is_bundled():
# Explicit regression guard for #3665: `--script py` shipped skills that
# invoked python3 .specify/scripts/python/*.py while the wheel bundled
# only the bash and PowerShell variants.
assert _force_include()["scripts/python"] == "specify_cli/core_pack/scripts/python"