quality-graph-cli 0.1.9__tar.gz → 0.1.10__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,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quality-graph-cli
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Provider-driven Quality Graph command-line application
5
5
  Project-URL: Homepage, https://quality-graph.xyz/
6
6
  Project-URL: Documentation, https://quality-graph.xyz/
7
7
  License-Expression: MIT
8
8
  Requires-Python: >=3.12
9
- Requires-Dist: quality-graph-core==0.1.9
9
+ Requires-Dist: quality-graph-core==0.1.10
10
10
  Description-Content-Type: text/markdown
11
11
 
12
12
  # qg
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quality-graph-cli"
7
- version = "0.1.9"
7
+ version = "0.1.10"
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.9"]
12
+ dependencies = ["quality-graph-core==0.1.10"]
13
13
 
14
14
  [project.urls]
15
15
  Homepage = "https://quality-graph.xyz/"
@@ -57,6 +57,7 @@ class Project:
57
57
  def generate(self) -> GeneratedProject:
58
58
  """Write every deterministic generated file."""
59
59
  generated = self.render()
60
+ self._validate_output_paths(generated)
60
61
  prettier_ignore = self._prettier_ignore(generated)
61
62
  retired = self._retired_paths(generated)
62
63
  for path in retired:
@@ -80,14 +81,33 @@ class Project:
80
81
  ignore_path.write_text(prettier_ignore)
81
82
  return generated
82
83
 
84
+ def _validate_output_paths(self, generated: GeneratedProject) -> None:
85
+ root = self.root.resolve()
86
+ for relative in (*[item.path for item in generated.files], PRETTIER_IGNORE_PATH):
87
+ path = self.root / relative
88
+ if root not in path.resolve().parents:
89
+ message = f"Generated file is outside the project root: {path}"
90
+ raise ValueError(message)
91
+ if path.is_symlink():
92
+ message = f"Refusing to overwrite a generated-file symbolic link: {path}"
93
+ raise ValueError(message)
94
+
83
95
  def _retired_paths(self, generated: GeneratedProject) -> tuple[Path, ...]:
84
96
  root = self.root.resolve()
85
- paths = tuple(self.root / path for path in generated.retired_files)
86
- for path in paths:
97
+ required = tuple(self.root / path for path in generated.retired_files)
98
+ optional = tuple(self.root / path for path in generated.retired_if_generated)
99
+ for path in (*required, *optional):
87
100
  if root not in path.resolve().parents:
88
101
  message = f"Retired workflow is outside the project root: {path}"
89
102
  raise ValueError(message)
90
- return paths
103
+ owned = tuple(
104
+ path
105
+ for path in optional
106
+ if not path.is_symlink()
107
+ and path.is_file()
108
+ and path.read_text().startswith("# Generated by Quality Graph. DO NOT EDIT MANUALLY.")
109
+ )
110
+ return (*required, *owned)
91
111
 
92
112
  def generated_files(self) -> tuple[PurePosixPath, ...]:
93
113
  """Return stable repository-relative compiler-owned paths."""
@@ -97,6 +117,7 @@ class Project:
97
117
  """Compare generated output without mutating files."""
98
118
  problems: list[str] = []
99
119
  generated = self.render()
120
+ self._validate_output_paths(generated)
100
121
  problems.extend(
101
122
  f"retired generated file: {path.relative_to(self.root)}"
102
123
  for path in self._retired_paths(generated)