MCPcopy Index your code
hub / github.com/github/spec-kit / setup

Method setup

src/specify_cli/integrations/generic/__init__.py:87–135  ·  view source on GitHub ↗

Install commands to the user-provided commands directory.

(
        self,
        project_root: Path,
        manifest: IntegrationManifest,
        parsed_options: dict[str, Any] | None = None,
        **opts: Any,
    )

Source from the content-addressed store, hash-verified

85 )
86
87 def setup(
88 self,
89 project_root: Path,
90 manifest: IntegrationManifest,
91 parsed_options: dict[str, Any] | None = None,
92 **opts: Any,
93 ) -> list[Path]:
94 """Install commands to the user-provided commands directory."""
95 commands_dir = self._resolve_commands_dir(parsed_options, opts)
96
97 templates = self.list_command_templates()
98 if not templates:
99 return []
100
101 project_root_resolved = project_root.resolve()
102 if manifest.project_root != project_root_resolved:
103 raise ValueError(
104 f"manifest.project_root ({manifest.project_root}) does not match "
105 f"project_root ({project_root_resolved})"
106 )
107
108 dest = (project_root / commands_dir).resolve()
109 try:
110 dest.relative_to(project_root_resolved)
111 except ValueError as exc:
112 raise ValueError(
113 f"Integration destination {dest} escapes "
114 f"project root {project_root_resolved}"
115 ) from exc
116 dest.mkdir(parents=True, exist_ok=True)
117
118 script_type = opts.get("script_type", "sh")
119 arg_placeholder = "$ARGUMENTS"
120 created: list[Path] = []
121
122 for src_file in templates:
123 raw = src_file.read_text(encoding="utf-8")
124 processed = self.process_template(
125 raw, self.key, script_type, arg_placeholder,
126 project_root=project_root,
127 )
128 dst_name = self.command_filename(src_file.stem)
129 dst_file = self.write_file_and_record(
130 processed, dest / dst_name, project_root, manifest
131 )
132 created.append(dst_file)
133
134
135 return created

Callers

nothing calls this directly

Calls 8

_resolve_commands_dirMethod · 0.95
read_textMethod · 0.80
write_file_and_recordMethod · 0.80
resolveMethod · 0.45
getMethod · 0.45
process_templateMethod · 0.45
command_filenameMethod · 0.45

Tested by

no test coverage detected