index.toml-cli 0.1.0__tar.gz → 0.2.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.2.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.2.0,<0.3
13
+ Requires-Dist: index-toml-adapter-pnpm>=0.2.0,<0.3
14
+ Requires-Dist: index-toml-adapter-python>=0.2.0,<0.3
15
+ Requires-Dist: index-toml-core>=0.2.0,<0.3
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.2.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.2.0,<0.3",
17
+ "index.toml-adapter-pnpm>=0.2.0,<0.3",
18
+ "index.toml-adapter-python>=0.2.0,<0.3",
19
+ "index.toml-core>=0.2.0,<0.3",
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.2.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.2.0,<0.3",
17
+ "index.toml-adapter-pnpm>=0.2.0,<0.3",
18
+ "index.toml-adapter-python>=0.2.0,<0.3",
19
+ "index.toml-core>=0.2.0,<0.3",
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
 
@@ -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,6 +38,9 @@ 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))
@@ -58,6 +68,8 @@ def main(argv: list[str] | None = None) -> int:
58
68
  result = {"valid": True}
59
69
  case "show":
60
70
  result = index.read()
71
+ case "upgrade":
72
+ result = index.upgrade(options.to, write=options.write)
61
73
  case "check":
62
74
  report = check_workspace(index, options.workspace_root, ADAPTERS[options.adapter]())
63
75
  if options.format == "json":
@@ -86,5 +98,5 @@ def main(argv: list[str] | None = None) -> int:
86
98
  except (OSError, ValueError, KeyError, TypeError, Timeout, TOMLKitError) as error:
87
99
  parser.exit(1, f"index-toml: {error}\n")
88
100
  if result is not None:
89
- print(json.dumps(result, indent=2, ensure_ascii=False))
101
+ print(json.dumps(result, indent=2, ensure_ascii=False, default=_json_toml_scalar))
90
102
  return 0