Skip to content

Commit 4dca543

Browse files
authored
fix: default baseUrl/version if omitted (#267)
<!-- 🚨 ATTENTION! 🚨 This PR template is REQUIRED. PRs not following this format will be closed without review. Requirements: - PR title must follow commit conventions: https://www.conventionalcommits.org/en/v1.0.0/ - Label your PR with the correct type (e.g., 🐛 Bug, ✨ Enhancement, 🧪 Test, etc.) - Provide clear and specific details in each section --> **Motivation:** <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. --> As a devkit user, I want to be able to select a new template version without selecting a new template baseUrl **Modifications:** <!-- Describe the modifications you've done from a high level. What are the key technical decisions and why were they made? --> - Defaults `baseUrl`/`version` if either are missing **Result:** <!-- *After your change, what will change. --> - `devkit avs create --template-version="v0.0.24" ./` works as expected
1 parent 23a70ff commit 4dca543

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pkg/commands/create.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,30 @@ func getTemplateURLs(cCtx *cli.Context) (string, string, string, error) {
215215
version := cCtx.String("template-version")
216216
lang := cCtx.String("lang")
217217

218-
// If no overrides provided, get from config
219-
if baseURL == "" && version == "" {
218+
// If overrides are omitted, get from config
219+
if baseURL == "" || version == "" {
220220
cfg, err := template.LoadConfig()
221221
if err != nil {
222222
return "", "", "", fmt.Errorf("failed to load templates cfg: %w", err)
223223
}
224224

225225
selectedTemplate := cCtx.String("template")
226-
baseURL, version, err = template.GetTemplateURLs(cfg, selectedTemplate, lang)
226+
defaultBaseURL, defaultVersion, err := template.GetTemplateURLs(cfg, selectedTemplate, lang)
227227
if err != nil {
228228
return "", "", "", fmt.Errorf("failed to get template URLs: %w", err)
229229
}
230230

231-
if baseURL == "" {
231+
if defaultBaseURL == "" {
232232
return "", "", "", fmt.Errorf("no template found for template %s and language %s", selectedTemplate, lang)
233233
}
234+
235+
// If no baseUrl/version is provided use template defaults
236+
if baseURL == "" {
237+
baseURL = defaultBaseURL
238+
}
239+
if version == "" {
240+
version = defaultVersion
241+
}
234242
}
235243

236244
return baseURL, version, lang, nil

0 commit comments

Comments
 (0)