(
self,
project_root: Path,
manifest: IntegrationManifest,
parsed_options: dict[str, Any] | None = None,
**opts: Any,
)
| 1001 | return "\n".join(toml_lines) + "\n" |
| 1002 | |
| 1003 | def setup( |
| 1004 | self, |
| 1005 | project_root: Path, |
| 1006 | manifest: IntegrationManifest, |
| 1007 | parsed_options: dict[str, Any] | None = None, |
| 1008 | **opts: Any, |
| 1009 | ) -> list[Path]: |
| 1010 | templates = self.list_command_templates() |
| 1011 | if not templates: |
| 1012 | return [] |
| 1013 | |
| 1014 | project_root_resolved = project_root.resolve() |
| 1015 | if manifest.project_root != project_root_resolved: |
| 1016 | raise ValueError( |
| 1017 | f"manifest.project_root ({manifest.project_root}) does not match " |
| 1018 | f"project_root ({project_root_resolved})" |
| 1019 | ) |
| 1020 | |
| 1021 | dest = self.commands_dest(project_root).resolve() |
| 1022 | try: |
| 1023 | dest.relative_to(project_root_resolved) |
| 1024 | except ValueError as exc: |
| 1025 | raise ValueError( |
| 1026 | f"Integration destination {dest} escapes " |
| 1027 | f"project root {project_root_resolved}" |
| 1028 | ) from exc |
| 1029 | dest.mkdir(parents=True, exist_ok=True) |
| 1030 | |
| 1031 | script_type = opts.get("script_type", "sh") |
| 1032 | arg_placeholder = ( |
| 1033 | self.registrar_config.get("args", "{{args}}") |
| 1034 | if self.registrar_config |
| 1035 | else "{{args}}" |
| 1036 | ) |
| 1037 | created: list[Path] = [] |
| 1038 | |
| 1039 | for src_file in templates: |
| 1040 | raw = src_file.read_text(encoding="utf-8") |
| 1041 | description = self._extract_description(raw) |
| 1042 | processed = self.process_template( |
| 1043 | raw, self.key, script_type, arg_placeholder, |
| 1044 | project_root=project_root, |
| 1045 | ) |
| 1046 | _, body = self._split_frontmatter(processed) |
| 1047 | toml_content = self._render_toml(description, body) |
| 1048 | dst_name = self.command_filename(src_file.stem) |
| 1049 | dst_file = self.write_file_and_record( |
| 1050 | toml_content, dest / dst_name, project_root, manifest |
| 1051 | ) |
| 1052 | created.append(dst_file) |
| 1053 | |
| 1054 | |
| 1055 | return created |
| 1056 | |
| 1057 | |
| 1058 | # --------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected