Skip to content

Commit 7efc6e6

Browse files
authored
Merge pull request #39 from Vonage/fix/add-default-templates
fix: add entrypoint to default templates and reorder the templates
2 parents 1812bae + 5edee8f commit 7efc6e6

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

pkg/config/manifest.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ func NewManifestWithDefaults() *Manifest {
6969
return &Manifest{
7070
Instance: Instance{
7171
ApplicationID: "<please create an application on VONAGE APIs dashboard>",
72+
Entrypoint: []string{"<please include the entrypoint for your script>"},
7273
},
7374
Debug: Debug{
7475
ApplicationID: "<please create an application on VONAGE APIs dashboard>",
76+
Entrypoint: []string{"<please include the entrypoint for your script>"},
7577
},
7678
}
7779
}

pkg/format/format.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func GetTemplateOptions(templateNames []api.Product) TemplateOptions {
2828
Labels: make([]string, 0),
2929
IDLookup: make(map[string]string),
3030
}
31-
options.Labels = append(options.Labels, SkipValue)
3231
for _, r := range templateNames {
3332
options.Labels = append(options.Labels, r.Name)
3433
options.IDLookup[r.Name] = r.ID

pkg/format/format_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func TestGetTemplateOptions(t *testing.T) {
290290
}
291291

292292
expectedOptions := TemplateOptions{
293-
Labels: []string{"SKIP", "template1", "template2", "template3"},
293+
Labels: []string{"template1", "template2", "template3"},
294294
IDLookup: map[string]string{
295295
"template1": "1",
296296
"template2": "2",

vcr/init/init.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ func askTemplate(ctx context.Context, opts *Options) error {
290290
if err != nil {
291291
return fmt.Errorf("failed to ask user to select a product template for runtime %s: %w", opts.manifest.Instance.Runtime, err)
292292
}
293-
if templateLabel == format.SkipValue {
294-
return nil
295-
}
296293

297294
selectedProductID := templateOptions.IDLookup[templateLabel]
298295

@@ -335,13 +332,20 @@ func askTemplate(ctx context.Context, opts *Options) error {
335332
}
336333

337334
func getProductTemplatesByLang(productList []api.Product, programmingLang string) []api.Product {
338-
list := make([]api.Product, 0)
339-
for _, l := range productList {
340-
if programmingLang == strings.ToLower(l.ProgrammingLanguage) {
341-
list = append(list, l)
335+
starterProjects := make([]api.Product, 0)
336+
otherProjects := make([]api.Product, 0)
337+
338+
for _, product := range productList {
339+
if programmingLang == strings.ToLower(product.ProgrammingLanguage) {
340+
if strings.HasPrefix(strings.ToLower(product.Name), "starter project") {
341+
starterProjects = append(starterProjects, product)
342+
} else {
343+
otherProjects = append(otherProjects, product)
344+
}
342345
}
343346
}
344-
return list
347+
348+
return append(starterProjects, otherProjects...)
345349
}
346350

347351
// uncompressToDir uncompresses the given tar.gz file bytes to the given directory.

0 commit comments

Comments
 (0)