(
self,
project_root: Path,
manifest: IntegrationManifest,
parsed_options: dict[str, Any] | None = None,
**opts: Any,
)
| 1193 | |
| 1194 | |
| 1195 | def setup( |
| 1196 | self, |
| 1197 | project_root: Path, |
| 1198 | manifest: IntegrationManifest, |
| 1199 | parsed_options: dict[str, Any] | None = None, |
| 1200 | **opts: Any, |
| 1201 | ) -> list[Path]: |
| 1202 | templates = self.list_command_templates() |
| 1203 | if not templates: |
| 1204 | return [] |
| 1205 | |
| 1206 | project_root_resolved = project_root.resolve() |
| 1207 | if manifest.project_root != project_root_resolved: |
| 1208 | raise ValueError( |
| 1209 | f"manifest.project_root ({manifest.project_root}) does not match " |
| 1210 | f"project_root ({project_root_resolved})" |
| 1211 | ) |
| 1212 | |
| 1213 | dest = self.commands_dest(project_root).resolve() |
| 1214 | try: |
| 1215 | dest.relative_to(project_root_resolved) |
| 1216 | except ValueError as exc: |
| 1217 | raise ValueError( |
| 1218 | f"Integration destination {dest} escapes " |
| 1219 | f"project root {project_root_resolved}" |
| 1220 | ) from exc |
| 1221 | dest.mkdir(parents=True, exist_ok=True) |
| 1222 | |
| 1223 | script_type = opts.get("script_type", "sh") |
| 1224 | arg_placeholder = ( |
| 1225 | self.registrar_config.get("args", "{{args}}") |
| 1226 | if self.registrar_config |
| 1227 | else "{{args}}" |
| 1228 | ) |
| 1229 | created: list[Path] = [] |
| 1230 | |
| 1231 | for src_file in templates: |
| 1232 | raw = src_file.read_text(encoding="utf-8") |
| 1233 | fm = self._extract_frontmatter(raw) |
| 1234 | description = fm.get("description", "") |
| 1235 | if not isinstance(description, str): |
| 1236 | description = str(description) if description is not None else "" |
| 1237 | title = fm.get("title", "") or fm.get("name", "") |
| 1238 | if not isinstance(title, str): |
| 1239 | title = str(title) if title is not None else "" |
| 1240 | if not title: |
| 1241 | title = self._human_title(src_file.stem) |
| 1242 | |
| 1243 | processed = self.process_template( |
| 1244 | raw, self.key, script_type, arg_placeholder, |
| 1245 | project_root=project_root, |
| 1246 | ) |
| 1247 | _, body = self._split_frontmatter(processed) |
| 1248 | yaml_content = self._render_yaml( |
| 1249 | title, description, body, f"templates/commands/{src_file.name}" |
| 1250 | ) |
| 1251 | dst_name = self.command_filename(src_file.stem) |
| 1252 | dst_file = self.write_file_and_record( |
nothing calls this directly
no test coverage detected