index.toml-cli 0.1.0__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: index.toml-cli
3
- Version: 0.1.0
3
+ Version: 0.3.0
4
4
  Summary: Command-line interface for ecosystem-neutral package indexes
5
5
  Classifier: Programming Language :: Python :: 3.10
6
6
  Classifier: Programming Language :: Python :: 3.11
@@ -9,10 +9,10 @@ Classifier: Programming Language :: Python :: 3.13
9
9
  Classifier: Programming Language :: Python :: 3.14
10
10
  Classifier: Programming Language :: Python :: 3.15
11
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
12
+ Requires-Dist: index-toml-adapter-cargo>=0.3.0,<0.4
13
+ Requires-Dist: index-toml-adapter-pnpm>=0.3.0,<0.4
14
+ Requires-Dist: index-toml-adapter-python>=0.3.0,<0.4
15
+ Requires-Dist: index-toml-core>=0.3.0,<0.4
16
16
  Requires-Dist: tomlkit>=0.13,<1
17
17
  Requires-Python: >=3.10, <3.16
18
18
  Project-URL: Repository, https://github.com/groupsum/index.toml
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "index.toml-cli"
3
- version = "0.1.0"
3
+ version = "0.3.0"
4
4
  description = "Command-line interface for ecosystem-neutral package indexes"
5
5
  requires-python = ">=3.10,<3.16"
6
6
  classifiers = [
@@ -13,10 +13,10 @@ classifiers = [
13
13
  ]
14
14
  dependencies = [
15
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",
16
+ "index.toml-adapter-cargo>=0.3.0,<0.4",
17
+ "index.toml-adapter-pnpm>=0.3.0,<0.4",
18
+ "index.toml-adapter-python>=0.3.0,<0.4",
19
+ "index.toml-core>=0.3.0,<0.4",
20
20
  "tomlkit>=0.13,<1",
21
21
  ]
22
22
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "index.toml-cli"
3
- version = "0.1.0"
3
+ version = "0.3.0"
4
4
  description = "Command-line interface for ecosystem-neutral package indexes"
5
5
  requires-python = ">=3.10,<3.16"
6
6
  classifiers = [
@@ -13,10 +13,10 @@ classifiers = [
13
13
  ]
14
14
  dependencies = [
15
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",
16
+ "index.toml-adapter-cargo>=0.3.0,<0.4",
17
+ "index.toml-adapter-pnpm>=0.3.0,<0.4",
18
+ "index.toml-adapter-python>=0.3.0,<0.4",
19
+ "index.toml-core>=0.3.0,<0.4",
20
20
  "tomlkit>=0.13,<1",
21
21
  ]
22
22
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import argparse
4
4
  import json
5
+ from datetime import date, datetime, time
5
6
  from dataclasses import asdict
6
7
  from pathlib import Path
7
8
 
@@ -9,7 +10,7 @@ from filelock import Timeout
9
10
  from tomlkit.exceptions import TOMLKitError
10
11
 
11
12
  from index_toml_core import IndexFile
12
- from index_toml_core.workspace import check_workspace
13
+ from index_toml_core.workspace import check_workspace, sync_workspace
13
14
 
14
15
  from .adapters import ADAPTERS
15
16
 
@@ -24,6 +25,12 @@ def _object(value: str) -> dict:
24
25
  return result
25
26
 
26
27
 
28
+ def _json_toml_scalar(value):
29
+ if isinstance(value, (date, datetime, time)):
30
+ return value.isoformat()
31
+ raise TypeError(f"Cannot represent {type(value).__name__} as JSON")
32
+
33
+
27
34
  def main(argv: list[str] | None = None) -> int:
28
35
  parser = argparse.ArgumentParser(prog="index-toml")
29
36
  parser.add_argument("--file", default="pkgs/index.toml")
@@ -31,10 +38,19 @@ def main(argv: list[str] | None = None) -> int:
31
38
  commands.add_parser("init")
32
39
  commands.add_parser("validate")
33
40
  commands.add_parser("show")
41
+ upgrade = commands.add_parser("upgrade", help="preview a forward schema upgrade")
42
+ upgrade.add_argument("--to", required=True)
43
+ upgrade.add_argument("--write", action="store_true", help="apply the validated upgrade")
34
44
  check = commands.add_parser("check", help="compare the index with workspace manifests")
35
45
  check.add_argument("--workspace-root", required=True, type=Path)
36
46
  check.add_argument("--adapter", required=True, choices=sorted(ADAPTERS))
37
47
  check.add_argument("--format", choices=("text", "json"), default="text")
48
+ sync = commands.add_parser("sync", help="preview updates to existing workspace records")
49
+ sync.add_argument("--workspace-root", required=True, type=Path)
50
+ sync.add_argument("--adapter", required=True, choices=sorted(ADAPTERS))
51
+ sync.add_argument("--format", choices=("text", "json"), default="text")
52
+ sync.add_argument("--dependency-category", action="append", metavar="CATEGORY")
53
+ sync.add_argument("--write", action="store_true")
38
54
  for kind in ("layer", "package"):
39
55
  actions = commands.add_parser(kind).add_subparsers(dest="action", required=True)
40
56
  listing = actions.add_parser("list")
@@ -58,6 +74,27 @@ def main(argv: list[str] | None = None) -> int:
58
74
  result = {"valid": True}
59
75
  case "show":
60
76
  result = index.read()
77
+ case "upgrade":
78
+ result = index.upgrade(options.to, write=options.write)
79
+ case "sync":
80
+ report = sync_workspace(
81
+ index, options.workspace_root, ADAPTERS[options.adapter](), write=options.write,
82
+ dependency_categories=(
83
+ frozenset(options.dependency_category) if options.dependency_category else None
84
+ ),
85
+ )
86
+ if options.format == "json":
87
+ print(json.dumps({"ok": report.ok, **asdict(report)}, indent=2))
88
+ else:
89
+ for item in (*report.changes, *report.blockers):
90
+ print(f"{item.code} {item.package_id or item.identity}: {item.expected!r} -> {item.actual!r}")
91
+ for item in report.diagnostics:
92
+ print(f"{item.code} {item.manifest}: {item.message}")
93
+ if report.ok:
94
+ print("Applied workspace updates" if report.written else (
95
+ "Preview of workspace updates" if report.changes else "Workspace matches the index"
96
+ ))
97
+ return 0 if report.ok else 1
61
98
  case "check":
62
99
  report = check_workspace(index, options.workspace_root, ADAPTERS[options.adapter]())
63
100
  if options.format == "json":
@@ -86,5 +123,5 @@ def main(argv: list[str] | None = None) -> int:
86
123
  except (OSError, ValueError, KeyError, TypeError, Timeout, TOMLKitError) as error:
87
124
  parser.exit(1, f"index-toml: {error}\n")
88
125
  if result is not None:
89
- print(json.dumps(result, indent=2, ensure_ascii=False))
126
+ print(json.dumps(result, indent=2, ensure_ascii=False, default=_json_toml_scalar))
90
127
  return 0