MCPcopy Index your code
hub / github.com/jetify-com/devbox / buildConfig

Function buildConfig

internal/plugin/plugin.go:178–202  ·  view source on GitHub ↗

buildConfig returns a plugin.Config

(pkg Includable, projectDir, content string)

Source from the content-addressed store, hash-verified

176
177// buildConfig returns a plugin.Config
178func buildConfig(pkg Includable, projectDir, content string) (*Config, error) {
179 cfg := &Config{PluginOnlyData: PluginOnlyData{Source: pkg}}
180 name := pkg.CanonicalName()
181 t, err := template.New(name + "-template").Parse(content)
182 if err != nil {
183 return nil, errors.WithStack(err)
184 }
185 var buf bytes.Buffer
186 if err = t.Execute(&buf, map[string]string{
187 "DevboxProjectDir": projectDir,
188 "DevboxDir": filepath.Join(projectDir, devboxDirName, name),
189 "DevboxDirRoot": filepath.Join(projectDir, devboxDirName),
190 "DevboxProfileDefault": filepath.Join(projectDir, nix.ProfilePath),
191 "Virtenv": filepath.Join(projectDir, VirtenvPath, name),
192 }); err != nil {
193 return nil, errors.WithStack(err)
194 }
195
196 jsonb, err := jsonPurifyPluginContent(buf.Bytes())
197 if err != nil {
198 return nil, err
199 }
200
201 return cfg, errors.WithStack(json.Unmarshal(jsonb, cfg))
202}
203
204func jsonPurifyPluginContent(content []byte) ([]byte, error) {
205 return hujson.Standardize(slices.Clone(content))

Callers 2

getConfigIfAnyFunction · 0.85

Calls 4

jsonPurifyPluginContentFunction · 0.85
BytesMethod · 0.80
CanonicalNameMethod · 0.65
ExecuteMethod · 0.65

Tested by

no test coverage detected