quality-graph-cli 0.1.1__tar.gz → 0.1.4__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.
@@ -15,6 +15,7 @@ build/
15
15
  .mutmut-cache/
16
16
  mutants/
17
17
  reports/
18
+ site/
18
19
  .tools/
19
20
  node_modules/
20
21
  .DS_Store
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quality-graph-cli
3
- Version: 0.1.1
3
+ Version: 0.1.4
4
4
  Summary: Provider-driven Quality Graph command-line application
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.12
7
- Requires-Dist: quality-graph-core==0.1.1
7
+ Requires-Dist: quality-graph-core==0.1.4
8
8
  Description-Content-Type: text/markdown
9
9
 
10
10
  # qg
@@ -13,4 +13,4 @@ Provider-driven command-line application for Quality Graph projects.
13
13
 
14
14
  The CLI discovers providers through the `qg.providers` entry-point group. Install it together
15
15
  with the GitHub provider using
16
- `uv tool install quality-graph-cli==0.1.1 --with quality-graph-github==0.1.1`.
16
+ `uv tool install quality-graph-cli==0.1.2 --with quality-graph-github==0.1.2`.
@@ -4,4 +4,4 @@ Provider-driven command-line application for Quality Graph projects.
4
4
 
5
5
  The CLI discovers providers through the `qg.providers` entry-point group. Install it together
6
6
  with the GitHub provider using
7
- `uv tool install quality-graph-cli==0.1.1 --with quality-graph-github==0.1.1`.
7
+ `uv tool install quality-graph-cli==0.1.2 --with quality-graph-github==0.1.2`.
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quality-graph-cli"
7
- version = "0.1.1"
7
+ version = "0.1.4"
8
8
  description = "Provider-driven Quality Graph command-line application"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
11
11
  license = "MIT"
12
- dependencies = ["quality-graph-core==0.1.1"]
12
+ dependencies = ["quality-graph-core==0.1.4"]
13
13
 
14
14
  [project.scripts]
15
15
  qg = "qg_cli.cli:main"
@@ -30,6 +30,10 @@ def parser() -> argparse.ArgumentParser:
30
30
  generate.add_argument("--root", default=".")
31
31
  validate_project = commands.add_parser("validate", help="Validate declaration freshness")
32
32
  validate_project.add_argument("--root", default=".")
33
+ generated_files = commands.add_parser(
34
+ "generated-files", help="List compiler-owned artifact paths"
35
+ )
36
+ generated_files.add_argument("--root", default=".")
33
37
  graph_schema = commands.add_parser("schema", help="Render the graph JSON Schema")
34
38
  graph_schema.add_argument("--output", default="-")
35
39
  result_command = commands.add_parser("result", help="Work with native result JSON")
@@ -60,7 +64,7 @@ def main(arguments: Sequence[str] | None = None) -> int:
60
64
  command_parser = parser()
61
65
  args = command_parser.parse_args(arguments)
62
66
  try:
63
- if args.command in {"init", "generate", "validate", "schema"}:
67
+ if args.command in {"init", "generate", "generated-files", "validate", "schema"}:
64
68
  return _project_command(args)
65
69
  if args.command == "result":
66
70
  return _result_command(command_parser, args)
@@ -82,6 +86,10 @@ def _project_command(args: argparse.Namespace) -> int:
82
86
  if args.command == "generate":
83
87
  Project.open(Path(args.root)).generate()
84
88
  return 0
89
+ if args.command == "generated-files":
90
+ project = Project.open(Path(args.root))
91
+ sys.stdout.write("".join(f"{path}\n" for path in project.generated_files()))
92
+ return 0
85
93
  if args.command == "schema":
86
94
  _write_text(args.output, graph_schema_json())
87
95
  return 0
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from dataclasses import dataclass
6
- from pathlib import Path
6
+ from pathlib import Path, PurePosixPath
7
7
  from typing import TYPE_CHECKING, Literal, Self
8
8
 
9
9
  from qg_cli.providers import load_provider
@@ -13,6 +13,9 @@ if TYPE_CHECKING:
13
13
  from quality_graph_core.provider import GeneratedProject, Provider
14
14
 
15
15
  CONFIGURATION_PATH = Path("quality-graph.yml")
16
+ PRETTIER_IGNORE_PATH = Path(".prettierignore")
17
+ PRETTIER_BLOCK_START = "# Quality Graph generated files (managed by qg)"
18
+ PRETTIER_BLOCK_END = "# End Quality Graph generated files"
16
19
 
17
20
 
18
21
  @dataclass(frozen=True)
@@ -52,12 +55,20 @@ class Project:
52
55
  def generate(self) -> GeneratedProject:
53
56
  """Write every deterministic generated file."""
54
57
  generated = self.render()
58
+ prettier_ignore = self._prettier_ignore(generated)
55
59
  for item in generated.files:
56
60
  path = self.root / item.path
57
61
  path.parent.mkdir(parents=True, exist_ok=True)
58
62
  path.write_text(item.content)
63
+ ignore_path = self.root / PRETTIER_IGNORE_PATH
64
+ if not ignore_path.is_file() or ignore_path.read_text() != prettier_ignore:
65
+ ignore_path.write_text(prettier_ignore)
59
66
  return generated
60
67
 
68
+ def generated_files(self) -> tuple[PurePosixPath, ...]:
69
+ """Return stable repository-relative compiler-owned paths."""
70
+ return tuple(item.path for item in self.render().files)
71
+
61
72
  def validate(self) -> ValidationReport:
62
73
  """Compare generated output without mutating files."""
63
74
  problems: list[str] = []
@@ -69,6 +80,37 @@ class Project:
69
80
  problems.append(f"stale generated file: {item.path}")
70
81
  return ValidationReport(tuple(problems))
71
82
 
83
+ def _prettier_ignore(self, generated: GeneratedProject) -> str:
84
+ path = self.root / PRETTIER_IGNORE_PATH
85
+ current = path.read_text() if path.is_file() else ""
86
+ lines = current.splitlines(keepends=True)
87
+ starts = [
88
+ index for index, line in enumerate(lines) if line.rstrip("\r\n") == PRETTIER_BLOCK_START
89
+ ]
90
+ ends = [
91
+ index for index, line in enumerate(lines) if line.rstrip("\r\n") == PRETTIER_BLOCK_END
92
+ ]
93
+ if len(starts) != len(ends) or len(starts) > 1 or (starts and ends[0] < starts[0]):
94
+ message = f"Malformed Quality Graph block in {path}"
95
+ raise ValueError(message)
96
+ block = (
97
+ "\n".join(
98
+ (
99
+ PRETTIER_BLOCK_START,
100
+ *(str(item.path) for item in generated.files),
101
+ PRETTIER_BLOCK_END,
102
+ )
103
+ )
104
+ + "\n"
105
+ )
106
+ if starts:
107
+ return "".join((*lines[: starts[0]], block, *lines[ends[0] + 1 :]))
108
+ if not current:
109
+ return block
110
+ if current.endswith(("\n", "\r")):
111
+ return current + "\n" + block
112
+ return current + "\n\n" + block
113
+
72
114
  @classmethod
73
115
  def initialize(
74
116
  cls,