Runs the full pre-deploy validation suite against a project directory.
| 120 | |
| 121 | |
| 122 | class DeployValidator: |
| 123 | """Runs the full pre-deploy validation suite against a project directory.""" |
| 124 | |
| 125 | def __init__(self, project_root: Path | None = None) -> None: |
| 126 | self.project_root: Path = (project_root or Path.cwd()).resolve() |
| 127 | self.results: list[ValidationResult] = [] |
| 128 | self._pyproject: dict[str, Any] | None = None |
| 129 | self._project_name: str | None = None |
| 130 | self._package_name: str | None = None |
| 131 | self._package_dir: Path | None = None |
| 132 | self._is_flow: bool = False |
| 133 | |
| 134 | def _add( |
| 135 | self, |
| 136 | severity: Severity, |
| 137 | code: str, |
| 138 | title: str, |
| 139 | detail: str = "", |
| 140 | hint: str = "", |
| 141 | ) -> None: |
| 142 | self.results.append( |
| 143 | ValidationResult( |
| 144 | severity=severity, |
| 145 | code=code, |
| 146 | title=title, |
| 147 | detail=detail, |
| 148 | hint=hint, |
| 149 | ) |
| 150 | ) |
| 151 | |
| 152 | @property |
| 153 | def errors(self) -> list[ValidationResult]: |
| 154 | return [r for r in self.results if r.severity is Severity.ERROR] |
| 155 | |
| 156 | @property |
| 157 | def warnings(self) -> list[ValidationResult]: |
| 158 | return [r for r in self.results if r.severity is Severity.WARNING] |
| 159 | |
| 160 | @property |
| 161 | def ok(self) -> bool: |
| 162 | return not self.errors |
| 163 | |
| 164 | @property |
| 165 | def _is_json_crew(self) -> bool: |
| 166 | """True for JSON crew projects with configured crew definitions.""" |
| 167 | pyproject_path = self.project_root / "pyproject.toml" |
| 168 | if not pyproject_path.exists(): |
| 169 | return False |
| 170 | try: |
| 171 | data = read_toml(pyproject_path) |
| 172 | except Exception: |
| 173 | return False |
| 174 | crewai_config = get_crewai_project_config(data) |
| 175 | return crewai_config.get("type") == "crew" and "definition" in crewai_config |
| 176 | |
| 177 | def run(self) -> list[ValidationResult]: |
| 178 | """Run all checks. Later checks are skipped when earlier ones make |
| 179 | them impossible (e.g. no pyproject.toml → no lockfile check).""" |
no outgoing calls