Files
wehub-resource-sync a0c8464e58
Build Package / build (ubuntu-latest) (push) Failing after 1s
CodeQL / Analyze (python) (push) Failing after 1s
Core Typecheck / core-typecheck (push) Failing after 1s
Linting / lint (push) Failing after 1s
llama-dev tests / test-llama-dev (push) Failing after 1s
Publish Sub-Package to PyPI if Needed / publish_subpackage_if_needed (push) Has been skipped
Sync Docs to Developer Hub / sync-docs (push) Failing after 0s
Build Package / build (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:26:52 +08:00

62 lines
1.8 KiB
Python

import json
import click
from rich.table import Table
from llama_dev.utils import find_all_packages, is_llama_index_package, load_pyproject
@click.command(short_help="Get package details")
@click.argument("package_names", required=False, nargs=-1)
@click.option(
"--all",
is_flag=True,
help="Get info for all the packages in the monorepo",
)
@click.option(
"--json",
"use_json",
is_flag=True,
default=False,
help="Use JSON as the output format",
)
@click.pass_obj
def info(obj: dict, all: bool, use_json: bool, package_names: tuple):
if not all and not package_names:
raise click.UsageError("Either specify a package name or use the --all flag")
packages = set()
if all:
packages = find_all_packages(obj["repo_root"])
else:
for package_name in package_names:
package_path = obj["repo_root"] / package_name
if not is_llama_index_package(package_path):
raise click.UsageError(
f"{package_name} is not a path to a LlamaIndex package"
)
packages.add(package_path)
if use_json:
data = {}
for package in packages:
package_data = load_pyproject(package)
data["name"] = package_data["project"]["name"]
data["version"] = package_data["project"]["version"]
data["path"] = str(package)
obj["console"].print(json.dumps(data))
else:
table = Table(box=None)
table.add_column("Name")
table.add_column("Version")
table.add_column("Path")
for package in packages:
package_data = load_pyproject(package)
table.add_row(
package_data["project"]["name"],
package_data["project"]["version"],
str(package),
)
obj["console"].print(table)