index.toml-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: index.toml-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Command-line interface for ecosystem-neutral package indexes
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
11
|
+
Requires-Dist: filelock>=3.16,<4
|
|
12
|
+
Requires-Dist: index-toml-adapter-cargo>=0.1.0,<0.2
|
|
13
|
+
Requires-Dist: index-toml-adapter-pnpm>=0.1.0,<0.2
|
|
14
|
+
Requires-Dist: index-toml-adapter-python>=0.1.0,<0.2
|
|
15
|
+
Requires-Dist: index-toml-core>=0.1.0,<0.2
|
|
16
|
+
Requires-Dist: tomlkit>=0.13,<1
|
|
17
|
+
Requires-Python: >=3.10, <3.16
|
|
18
|
+
Project-URL: Repository, https://github.com/groupsum/index.toml
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "index.toml-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Command-line interface for ecosystem-neutral package indexes"
|
|
5
|
+
requires-python = ">=3.10,<3.16"
|
|
6
|
+
classifiers = [
|
|
7
|
+
"Programming Language :: Python :: 3.10",
|
|
8
|
+
"Programming Language :: Python :: 3.11",
|
|
9
|
+
"Programming Language :: Python :: 3.12",
|
|
10
|
+
"Programming Language :: Python :: 3.13",
|
|
11
|
+
"Programming Language :: Python :: 3.14",
|
|
12
|
+
"Programming Language :: Python :: 3.15",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"filelock>=3.16,<4",
|
|
16
|
+
"index.toml-adapter-cargo>=0.1.0,<0.2",
|
|
17
|
+
"index.toml-adapter-pnpm>=0.1.0,<0.2",
|
|
18
|
+
"index.toml-adapter-python>=0.1.0,<0.2",
|
|
19
|
+
"index.toml-core>=0.1.0,<0.2",
|
|
20
|
+
"tomlkit>=0.13,<1",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
index-toml-cli = "index_toml_cli.cli:main"
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Repository = "https://github.com/groupsum/index.toml"
|
|
28
|
+
|
|
29
|
+
[[tool.uv.cache-keys]]
|
|
30
|
+
file = "pyproject.toml"
|
|
31
|
+
|
|
32
|
+
[[tool.uv.cache-keys]]
|
|
33
|
+
file = "src/**/*"
|
|
34
|
+
|
|
35
|
+
[tool.uv.sources."index.toml-adapter-cargo"]
|
|
36
|
+
workspace = true
|
|
37
|
+
|
|
38
|
+
[tool.uv.sources."index.toml-adapter-pnpm"]
|
|
39
|
+
workspace = true
|
|
40
|
+
|
|
41
|
+
[tool.uv.sources."index.toml-adapter-python"]
|
|
42
|
+
workspace = true
|
|
43
|
+
|
|
44
|
+
[tool.uv.sources."index.toml-core"]
|
|
45
|
+
workspace = true
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["uv_build>=0.9,<1"]
|
|
49
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "index.toml-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Command-line interface for ecosystem-neutral package indexes"
|
|
5
|
+
requires-python = ">=3.10,<3.16"
|
|
6
|
+
classifiers = [
|
|
7
|
+
"Programming Language :: Python :: 3.10",
|
|
8
|
+
"Programming Language :: Python :: 3.11",
|
|
9
|
+
"Programming Language :: Python :: 3.12",
|
|
10
|
+
"Programming Language :: Python :: 3.13",
|
|
11
|
+
"Programming Language :: Python :: 3.14",
|
|
12
|
+
"Programming Language :: Python :: 3.15",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"filelock>=3.16,<4",
|
|
16
|
+
"index.toml-adapter-cargo>=0.1.0,<0.2",
|
|
17
|
+
"index.toml-adapter-pnpm>=0.1.0,<0.2",
|
|
18
|
+
"index.toml-adapter-python>=0.1.0,<0.2",
|
|
19
|
+
"index.toml-core>=0.1.0,<0.2",
|
|
20
|
+
"tomlkit>=0.13,<1",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
index-toml-cli = "index_toml_cli.cli:main"
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Repository = "https://github.com/groupsum/index.toml"
|
|
28
|
+
|
|
29
|
+
[tool.uv]
|
|
30
|
+
cache-keys = [{ file = "pyproject.toml" }, { file = "src/**/*" }]
|
|
31
|
+
|
|
32
|
+
[tool.uv.sources]
|
|
33
|
+
"index.toml-adapter-cargo" = { workspace = true }
|
|
34
|
+
"index.toml-adapter-pnpm" = { workspace = true }
|
|
35
|
+
"index.toml-adapter-python" = { workspace = true }
|
|
36
|
+
"index.toml-core" = { workspace = true }
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["uv_build>=0.9,<1"]
|
|
40
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Built-in workspace adapter selection shared by both CLI entry points."""
|
|
2
|
+
|
|
3
|
+
from index_toml_adapter_cargo import CargoWorkspaceAdapter
|
|
4
|
+
from index_toml_adapter_pnpm import PnpmWorkspaceAdapter
|
|
5
|
+
from index_toml_adapter_python import PythonWorkspaceAdapter
|
|
6
|
+
|
|
7
|
+
ADAPTERS = {
|
|
8
|
+
adapter.name: adapter
|
|
9
|
+
for adapter in (PythonWorkspaceAdapter, CargoWorkspaceAdapter, PnpmWorkspaceAdapter)
|
|
10
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""Command line interface for index validation and CRUD."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from dataclasses import asdict
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from filelock import Timeout
|
|
9
|
+
from tomlkit.exceptions import TOMLKitError
|
|
10
|
+
|
|
11
|
+
from index_toml_core import IndexFile
|
|
12
|
+
from index_toml_core.workspace import check_workspace
|
|
13
|
+
|
|
14
|
+
from .adapters import ADAPTERS
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _object(value: str) -> dict:
|
|
18
|
+
try:
|
|
19
|
+
result = json.loads(value)
|
|
20
|
+
except ValueError as error:
|
|
21
|
+
raise argparse.ArgumentTypeError(str(error)) from error
|
|
22
|
+
if not isinstance(result, dict):
|
|
23
|
+
raise argparse.ArgumentTypeError("Expected a JSON object")
|
|
24
|
+
return result
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main(argv: list[str] | None = None) -> int:
|
|
28
|
+
parser = argparse.ArgumentParser(prog="index-toml")
|
|
29
|
+
parser.add_argument("--file", default="pkgs/index.toml")
|
|
30
|
+
commands = parser.add_subparsers(dest="command", required=True)
|
|
31
|
+
commands.add_parser("init")
|
|
32
|
+
commands.add_parser("validate")
|
|
33
|
+
commands.add_parser("show")
|
|
34
|
+
check = commands.add_parser("check", help="compare the index with workspace manifests")
|
|
35
|
+
check.add_argument("--workspace-root", required=True, type=Path)
|
|
36
|
+
check.add_argument("--adapter", required=True, choices=sorted(ADAPTERS))
|
|
37
|
+
check.add_argument("--format", choices=("text", "json"), default="text")
|
|
38
|
+
for kind in ("layer", "package"):
|
|
39
|
+
actions = commands.add_parser(kind).add_subparsers(dest="action", required=True)
|
|
40
|
+
listing = actions.add_parser("list")
|
|
41
|
+
if kind == "package":
|
|
42
|
+
listing.add_argument("--layer")
|
|
43
|
+
for action in ("get", "add", "update", "delete"):
|
|
44
|
+
command = actions.add_parser(action)
|
|
45
|
+
command.add_argument("id")
|
|
46
|
+
if action in ("add", "update"):
|
|
47
|
+
command.add_argument("fields", type=_object, metavar="JSON")
|
|
48
|
+
|
|
49
|
+
options = parser.parse_args(argv)
|
|
50
|
+
index = IndexFile(options.file)
|
|
51
|
+
result = None
|
|
52
|
+
try:
|
|
53
|
+
match options.command:
|
|
54
|
+
case "init":
|
|
55
|
+
index.initialize()
|
|
56
|
+
case "validate":
|
|
57
|
+
index.read()
|
|
58
|
+
result = {"valid": True}
|
|
59
|
+
case "show":
|
|
60
|
+
result = index.read()
|
|
61
|
+
case "check":
|
|
62
|
+
report = check_workspace(index, options.workspace_root, ADAPTERS[options.adapter]())
|
|
63
|
+
if options.format == "json":
|
|
64
|
+
print(json.dumps({
|
|
65
|
+
"adapter": report.adapter, "ecosystem": report.ecosystem,
|
|
66
|
+
"ok": report.ok,
|
|
67
|
+
"differences": [asdict(item) for item in report.differences],
|
|
68
|
+
"diagnostics": [asdict(item) for item in report.diagnostics],
|
|
69
|
+
}, indent=2, ensure_ascii=False))
|
|
70
|
+
elif report.ok:
|
|
71
|
+
print(f"{report.adapter}: workspace matches the index")
|
|
72
|
+
else:
|
|
73
|
+
for item in report.diagnostics:
|
|
74
|
+
print(f"{item.code} {item.manifest}: {item.message}")
|
|
75
|
+
for item in report.differences:
|
|
76
|
+
location = item.manifest or item.actual or item.expected or ""
|
|
77
|
+
print(f"{item.code} {item.package_id or item.identity} ({location}) "
|
|
78
|
+
f"expected={item.expected!r} actual={item.actual!r}")
|
|
79
|
+
return 0 if report.ok else 1
|
|
80
|
+
case kind:
|
|
81
|
+
if options.action == "list":
|
|
82
|
+
result = index.list_layers() if kind == "layer" else index.list_packages(options.layer)
|
|
83
|
+
else:
|
|
84
|
+
method = getattr(index, f"{options.action}_{kind}")
|
|
85
|
+
result = method(options.id, **getattr(options, "fields", {}))
|
|
86
|
+
except (OSError, ValueError, KeyError, TypeError, Timeout, TOMLKitError) as error:
|
|
87
|
+
parser.exit(1, f"index-toml: {error}\n")
|
|
88
|
+
if result is not None:
|
|
89
|
+
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
90
|
+
return 0
|