MCPcopy Create free account
hub / github.com/github/gh-aw / GenerateInstallSteps

Method GenerateInstallSteps

pkg/workflow/lsp_manager.go:99–205  ·  view source on GitHub ↗

GenerateInstallSteps generates GitHub Actions steps that install the LSP server binary dependencies for all configured LSP servers. For npm-based servers the generated install command respects the workflow's runtime-manager settings: - workflowData.RunInstallScripts (runtimes.node.run-install-scrip

(workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

97//
98// Pass nil for workflowData to get secure defaults (--ignore-scripts, cooldown on).
99func (m *LSPManager) GenerateInstallSteps(workflowData *WorkflowData) []GitHubActionStep {
100 if !m.HasServers() {
101 return nil
102 }
103
104 // Determine npm install flags from runtime-manager settings.
105 // Defaults match the runtime manager's secure defaults:
106 // - --ignore-scripts ON (supply-chain protection)
107 // - cooldown ON (NPM_CONFIG_MIN_RELEASE_AGE)
108 runInstallScripts := false
109 cooldownEnabled := true
110 if workflowData != nil {
111 runInstallScripts = workflowData.RunInstallScripts
112 cooldownEnabled = resolveRuntimeCooldown(workflowData, "node")
113 }
114
115 langs := make([]string, 0, len(m.servers))
116 for language := range m.servers {
117 langs = append(langs, language)
118 }
119 sort.Strings(langs)
120
121 var steps []GitHubActionStep
122 for _, language := range langs {
123 spec, ok := lspInstallSpecs[language]
124 if !ok {
125 continue
126 }
127
128 // Resolve effective version: frontmatter overrides the spec default.
129 // Strip any leading 'v' prefix so both "0.17.0" and "v0.17.0" are handled
130 // consistently, avoiding malformed version strings like "@vv0.17.0".
131 config := m.servers[language]
132 effectiveVersion := strings.TrimPrefix(config.Version, "v")
133
134 var step GitHubActionStep
135 if len(spec.NpmPackages) > 0 {
136 // npm-based LSP server: build install command from runtime-manager settings.
137 args := []string{"npm", "install", "-g"}
138 if !runInstallScripts {
139 args = append(args, "--ignore-scripts")
140 }
141 // Pin each npm package to its version. The primary (last) package is the
142 // LSP server binary itself; its version can be overridden via the frontmatter
143 // 'version' field. All other packages use their hardcoded default version.
144 primaryPkg := spec.NpmPackages[len(spec.NpmPackages)-1]
145 for _, pkg := range spec.NpmPackages {
146 ver := spec.NpmPackageVersions[pkg]
147 if pkg == primaryPkg && effectiveVersion != "" {
148 ver = effectiveVersion
149 }
150 if ver != "" {
151 args = append(args, pkg+"@"+ver)
152 } else {
153 args = append(args, pkg)
154 }
155 }
156 installCmd := strings.Join(args, " ")

Calls 2

HasServersMethod · 0.95
resolveRuntimeCooldownFunction · 0.85