From 7f02f6886f6dd8ee921e22502c2ccd5b36d86d43 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 21 Nov 2020 11:56:01 +1100 Subject: [PATCH] Improved project generation --- .../commands/initialise/initialise.go | 2 -- v2/internal/templates/templates.go | 24 +++++++++++++------ .../{package.json => package.tmpl.json} | 2 +- .../templates/vuetify2-basic/wails.tmpl.json | 6 ++++- 4 files changed, 23 insertions(+), 11 deletions(-) rename v2/internal/templates/templates/vuetify2-basic/frontend/{package.json => package.tmpl.json} (95%) diff --git a/v2/cmd/wails/internal/commands/initialise/initialise.go b/v2/cmd/wails/internal/commands/initialise/initialise.go index cf0d49505..6b51fdfff 100644 --- a/v2/cmd/wails/internal/commands/initialise/initialise.go +++ b/v2/cmd/wails/internal/commands/initialise/initialise.go @@ -177,8 +177,6 @@ func findAuthorDetails(options *templates.Options) error { return err } options.AuthorEmail = strings.TrimSpace(email) - - println("Name", name, "Email", email) } return nil diff --git a/v2/internal/templates/templates.go b/v2/internal/templates/templates.go index c0891ebe0..6250aa007 100644 --- a/v2/internal/templates/templates.go +++ b/v2/internal/templates/templates.go @@ -22,13 +22,14 @@ var templateCache []Template = nil // Data contains the data we wish to embed during template installation type Data struct { - ProjectName string - BinaryName string - WailsVersion string - NPMProjectName string - AuthorName string - AuthorEmail string - WailsDirectory string + ProjectName string + BinaryName string + WailsVersion string + NPMProjectName string + AuthorName string + AuthorEmail string + AuthorNameAndEmail string + WailsDirectory string } // Options for installing a template @@ -232,6 +233,15 @@ func Install(options *Options) error { AuthorName: options.AuthorName, } + // Create a formatted name and email combo. + if options.AuthorName != "" { + templateData.AuthorNameAndEmail = options.AuthorName + " " + } + if options.AuthorEmail != "" { + templateData.AuthorNameAndEmail += "<" + options.AuthorEmail + ">" + } + templateData.AuthorNameAndEmail = strings.TrimSpace(templateData.AuthorNameAndEmail) + // Extract the template err = installer.Extract(options.TargetDir, templateData) if err != nil { diff --git a/v2/internal/templates/templates/vuetify2-basic/frontend/package.json b/v2/internal/templates/templates/vuetify2-basic/frontend/package.tmpl.json similarity index 95% rename from v2/internal/templates/templates/vuetify2-basic/frontend/package.json rename to v2/internal/templates/templates/vuetify2-basic/frontend/package.tmpl.json index 9f0cac08e..9d2242d6c 100644 --- a/v2/internal/templates/templates/vuetify2-basic/frontend/package.json +++ b/v2/internal/templates/templates/vuetify2-basic/frontend/package.tmpl.json @@ -1,6 +1,6 @@ { "name": "vuetify2", - "author": "Travis McLane", + "author": "{{.AuthorNameAndEmail}}", "private": true, "scripts": { "serve": "vue-cli-service serve", diff --git a/v2/internal/templates/templates/vuetify2-basic/wails.tmpl.json b/v2/internal/templates/templates/vuetify2-basic/wails.tmpl.json index 05fd2f26a..656b8b9a3 100644 --- a/v2/internal/templates/templates/vuetify2-basic/wails.tmpl.json +++ b/v2/internal/templates/templates/vuetify2-basic/wails.tmpl.json @@ -5,5 +5,9 @@ "js": "frontend/dist/app.js", "css": "frontend/dist/app.css", "frontend:build": "npm run build", - "frontend:install": "npm install" + "frontend:install": "npm install", + "author": { + "name": "{{.AuthorName}}", + "email": "{{.AuthorEmail}}" + } }