import json


def create_package_json(directory, version):
    """Create `package.json` in `directory` with a specified version of `version`."""
    package_json = directory / "package.json"
    package_json.write_text(json.dumps({"version": version}), encoding="utf-8")
    return package_json