index.toml-cli 0.2.0__tar.gz → 0.3.1__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.2.0
3
+ Version: 0.3.1
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
@@ -8,11 +8,11 @@ Classifier: Programming Language :: Python :: 3.12
8
8
  Classifier: Programming Language :: Python :: 3.13
9
9
  Classifier: Programming Language :: Python :: 3.14
10
10
  Classifier: Programming Language :: Python :: 3.15
11
- Requires-Dist: filelock>=3.16,<4
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
11
+ Requires-Dist: portalocker>=4.3,<5
12
+ Requires-Dist: index-toml-adapter-cargo>=0.3.1,<0.4
13
+ Requires-Dist: index-toml-adapter-pnpm>=0.3.1,<0.4
14
+ Requires-Dist: index-toml-adapter-python>=0.3.1,<0.4
15
+ Requires-Dist: index-toml-core>=0.3.1,<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.2.0"
3
+ version = "0.3.1"
4
4
  description = "Command-line interface for ecosystem-neutral package indexes"
5
5
  requires-python = ">=3.10,<3.16"
6
6
  classifiers = [
@@ -12,11 +12,11 @@ classifiers = [
12
12
  "Programming Language :: Python :: 3.15",
13
13
  ]
14
14
  dependencies = [
15
- "filelock>=3.16,<4",
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",
15
+ "portalocker>=4.3,<5",
16
+ "index.toml-adapter-cargo>=0.3.1,<0.4",
17
+ "index.toml-adapter-pnpm>=0.3.1,<0.4",
18
+ "index.toml-adapter-python>=0.3.1,<0.4",
19
+ "index.toml-core>=0.3.1,<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.2.0"
3
+ version = "0.3.1"
4
4
  description = "Command-line interface for ecosystem-neutral package indexes"
5
5
  requires-python = ">=3.10,<3.16"
6
6
  classifiers = [
@@ -12,11 +12,11 @@ classifiers = [
12
12
  "Programming Language :: Python :: 3.15",
13
13
  ]
14
14
  dependencies = [
15
- "filelock>=3.16,<4",
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",
15
+ "portalocker>=4.3,<5",
16
+ "index.toml-adapter-cargo>=0.3.1,<0.4",
17
+ "index.toml-adapter-pnpm>=0.3.1,<0.4",
18
+ "index.toml-adapter-python>=0.3.1,<0.4",
19
+ "index.toml-core>=0.3.1,<0.4",
20
20
  "tomlkit>=0.13,<1",
21
21
  ]
22
22
 
@@ -6,11 +6,11 @@ from datetime import date, datetime, time
6
6
  from dataclasses import asdict
7
7
  from pathlib import Path
8
8
 
9
- from filelock import Timeout
9
+ from portalocker.exceptions import LockException
10
10
  from tomlkit.exceptions import TOMLKitError
11
11
 
12
12
  from index_toml_core import IndexFile
13
- from index_toml_core.workspace import check_workspace
13
+ from index_toml_core.workspace import check_workspace, sync_workspace
14
14
 
15
15
  from .adapters import ADAPTERS
16
16
 
@@ -45,6 +45,12 @@ def main(argv: list[str] | None = None) -> int:
45
45
  check.add_argument("--workspace-root", required=True, type=Path)
46
46
  check.add_argument("--adapter", required=True, choices=sorted(ADAPTERS))
47
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")
48
54
  for kind in ("layer", "package"):
49
55
  actions = commands.add_parser(kind).add_subparsers(dest="action", required=True)
50
56
  listing = actions.add_parser("list")
@@ -70,6 +76,25 @@ def main(argv: list[str] | None = None) -> int:
70
76
  result = index.read()
71
77
  case "upgrade":
72
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
73
98
  case "check":
74
99
  report = check_workspace(index, options.workspace_root, ADAPTERS[options.adapter]())
75
100
  if options.format == "json":
@@ -95,7 +120,7 @@ def main(argv: list[str] | None = None) -> int:
95
120
  else:
96
121
  method = getattr(index, f"{options.action}_{kind}")
97
122
  result = method(options.id, **getattr(options, "fields", {}))
98
- except (OSError, ValueError, KeyError, TypeError, Timeout, TOMLKitError) as error:
123
+ except (OSError, ValueError, KeyError, TypeError, LockException, TOMLKitError) as error:
99
124
  parser.exit(1, f"index-toml: {error}\n")
100
125
  if result is not None:
101
126
  print(json.dumps(result, indent=2, ensure_ascii=False, default=_json_toml_scalar))