Skip to content

Commit

Permalink
build(DRAFT): Add vegalite_to_vega_version
Browse files Browse the repository at this point in the history
Not fully convinced this is a reliable alterntive to manually maintaining

#3600 (comment)
  • Loading branch information
dangotbanned committed Sep 28, 2024
1 parent 968114e commit 061b066
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/generate_schema_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
"""

SCHEMA_URL_TEMPLATE: Final = "https://vega.github.io/schema/{library}/{version}.json"
VL_PACKAGE_TEMPLATE = (
"https://raw.githubusercontent.com/vega/vega-lite/refs/tags/{version}/package.json"
)
SCHEMA_FILE = "vega-lite-schema.json"
THEMES_FILE = "vega-themes.json"
EXPR_FILE: Path = (
Expand Down Expand Up @@ -471,6 +474,15 @@ def schema_url(version: str = SCHEMA_VERSION) -> str:
return SCHEMA_URL_TEMPLATE.format(library="vega-lite", version=version)


def vegalite_to_vega_version(vl_version: str, /) -> str:
"""Return the minimum supported ``vega`` release for a ``vega-lite`` version."""
with request.urlopen(VL_PACKAGE_TEMPLATE.format(version=vl_version)) as response:
package_json = json.load(response)

version_spec = package_json["peerDependencies"]["vega"]
return f"v{version_spec.lstrip('^~')}"


def download_schemafile(
version: str, schemapath: Path, skip_download: bool = False
) -> Path:
Expand Down

0 comments on commit 061b066

Please sign in to comment.