diff --git a/mkdocs-website/mkdocs.yml b/mkdocs-website/mkdocs.yml
index ca49ecc6..afc281f2 100644
--- a/mkdocs-website/mkdocs.yml
+++ b/mkdocs-website/mkdocs.yml
@@ -14,8 +14,11 @@ theme:
- navigation.sections
- navigation.expand
- navigation.instant
+ - navigation.instant.prefetch
- navigation.top
- navigation.footer
+ - navigation.path
+ - navigation.prune
- toc.integrate
- toc.follow
@@ -86,6 +89,7 @@ nav:
- Status: development/status.md
- v3 Changes: development/changes.md
- Change Log: changelog.md
+ - Sponsor❤️: https://github.com/sponsors/leaanthony
markdown_extensions:
diff --git a/v3/cmd/wails3/main.go b/v3/cmd/wails3/main.go
index 59002499..27b4dbb1 100644
--- a/v3/cmd/wails3/main.go
+++ b/v3/cmd/wails3/main.go
@@ -37,7 +37,7 @@ func main() {
})
task.LongDescription("\nUsage: wails task [taskname] [flags]\n\nTasks are defined in the `Taskfile.yaml` file. See https://taskfile.dev for more information.")
generate := app.NewSubCommand("generate", "Generation tools")
- generate.NewSubCommandFunction("defaults", "Generate default build assets", commands.Defaults)
+ generate.NewSubCommandFunction("build-assets", "Generate build assets", commands.GenerateBuildAssets)
generate.NewSubCommandFunction("icons", "Generate icons", commands.GenerateIcons)
generate.NewSubCommandFunction("syso", "Generate Windows .syso file", commands.GenerateSyso)
generate.NewSubCommandFunction("bindings", "Generate bindings + models", commands.GenerateBindings)
diff --git a/v3/internal/commands/build-assets.go b/v3/internal/commands/build-assets.go
new file mode 100644
index 00000000..03fdf748
--- /dev/null
+++ b/v3/internal/commands/build-assets.go
@@ -0,0 +1,66 @@
+package commands
+
+import (
+ "embed"
+ _ "embed"
+ "fmt"
+ "github.com/leaanthony/gosod"
+ "io/fs"
+ "os"
+ "path/filepath"
+ "strings"
+ "time"
+)
+
+//go:embed build_assets
+var buildAssets embed.FS
+
+type BuildAssetsOptions struct {
+ Dir string `description:"The directory to generate the files into" default:"build"`
+ Name string `description:"The name of the project"`
+ ProductName string `description:"The name of the product" default:"My Product"`
+ ProductDescription string `description:"The description of the product" default:"My Product Description"`
+ ProductVersion string `description:"The version of the product" default:"0.1.0"`
+ ProductCompany string `description:"The company of the product" default:"My Company"`
+ ProductCopyright string `description:"The copyright notice"`
+ ProductComments string `description:"Comments to add to the generated files" default:"This is a comment"`
+ ProductIdentifier string `description:"The product identifier, e.g com.mycompany.myproduct"`
+}
+
+func GenerateBuildAssets(options *BuildAssetsOptions) error {
+
+ var err error
+ options.Dir, err = filepath.Abs(options.Dir)
+ if err != nil {
+ return err
+ }
+
+ // If directory doesn't exist, create it
+ if _, err := os.Stat(options.Dir); os.IsNotExist(err) {
+ err = os.MkdirAll(options.Dir, 0755)
+ if err != nil {
+ return err
+ }
+ }
+
+ if options.ProductComments == "" {
+ options.ProductComments = fmt.Sprintf("(c) %d %s", time.Now().Year(), options.ProductCompany)
+ }
+
+ if options.ProductIdentifier == "" {
+ options.ProductIdentifier = "com.wails." + normaliseName(options.Name)
+ }
+
+ tfs, err := fs.Sub(buildAssets, "build_assets")
+ if err != nil {
+ return err
+ }
+
+ println("Generating build assets in " + options.Dir)
+ return gosod.New(tfs).Extract(options.Dir, options)
+
+}
+
+func normaliseName(name string) string {
+ return strings.ToLower(strings.ReplaceAll(name, " ", "-"))
+}
diff --git a/v3/internal/commands/defaults/Info.dev.plist b/v3/internal/commands/build_assets/Info.dev.plist.tmpl
similarity index 75%
rename from v3/internal/commands/defaults/Info.dev.plist
rename to v3/internal/commands/build_assets/Info.dev.plist.tmpl
index 28c8c482..eead3308 100644
--- a/v3/internal/commands/defaults/Info.dev.plist
+++ b/v3/internal/commands/build_assets/Info.dev.plist.tmpl
@@ -4,17 +4,17 @@
CFBundlePackageType
APPL
CFBundleName
- {{.Info.ProductName}}
+ {{.ProductName}}
CFBundleExecutable
{{.Name}}
CFBundleIdentifier
- com.wails.{{.Name}}
+ {{.ProductIdentifier}}
CFBundleVersion
- {{.Info.ProductVersion}}
+ {{.ProductVersion}}
CFBundleGetInfoString
- {{.Info.Comments}}
+ {{.ProductComments}}
CFBundleShortVersionString
- {{.Info.ProductVersion}}
+ {{.ProductVersion}}
CFBundleIconFile
icons
LSMinimumSystemVersion
@@ -22,7 +22,7 @@
NSHighResolutionCapable
true
NSHumanReadableCopyright
- {{.Info.Copyright}}
+ {{.ProductCopyright}}
NSAppTransportSecurity
NSAllowsLocalNetworking
diff --git a/v3/internal/commands/defaults/Info.plist b/v3/internal/commands/build_assets/Info.plist.tmpl
similarity index 77%
rename from v3/internal/commands/defaults/Info.plist
rename to v3/internal/commands/build_assets/Info.plist.tmpl
index 24490f5c..61a60d9d 100644
--- a/v3/internal/commands/defaults/Info.plist
+++ b/v3/internal/commands/build_assets/Info.plist.tmpl
@@ -8,13 +8,13 @@
CFBundleExecutable
{{.Name}}
CFBundleIdentifier
- com.wails.{{.Name}}
+ {{.ProductIdentifier}}
CFBundleVersion
- {{.Info.ProductVersion}}
+ {{.ProductVersion}}
CFBundleGetInfoString
- {{.Info.Comments}}
+ {{.ProductComments}}
CFBundleShortVersionString
- {{.Info.ProductVersion}}
+ {{.ProductVersion}}
CFBundleIconFile
icons
LSMinimumSystemVersion
@@ -22,6 +22,6 @@
NSHighResolutionCapable
true
NSHumanReadableCopyright
- {{.Info.Copyright}}
+ {{.ProductCopyright}}
\ No newline at end of file
diff --git a/v3/internal/commands/defaults/appicon.png b/v3/internal/commands/build_assets/appicon.png
similarity index 100%
rename from v3/internal/commands/defaults/appicon.png
rename to v3/internal/commands/build_assets/appicon.png
diff --git a/v3/internal/commands/defaults/icon.ico b/v3/internal/commands/build_assets/icon.ico
similarity index 100%
rename from v3/internal/commands/defaults/icon.ico
rename to v3/internal/commands/build_assets/icon.ico
diff --git a/v3/internal/commands/defaults/icons.icns b/v3/internal/commands/build_assets/icons.icns
similarity index 100%
rename from v3/internal/commands/defaults/icons.icns
rename to v3/internal/commands/build_assets/icons.icns
diff --git a/v3/internal/commands/build_assets/info.json.tmpl b/v3/internal/commands/build_assets/info.json.tmpl
new file mode 100644
index 00000000..c3423b2d
--- /dev/null
+++ b/v3/internal/commands/build_assets/info.json.tmpl
@@ -0,0 +1,15 @@
+{
+ "fixed": {
+ "file_version": "{{.ProductVersion}}"
+ },
+ "info": {
+ "0000": {
+ "ProductVersion": "{{.ProductVersion}}",
+ "CompanyName": "{{.ProductCompany}}",
+ "FileDescription": "{{.ProductDescription}}",
+ "LegalCopyright": "{{.ProductCopyright}}",
+ "ProductName": "{{.ProductName}}",
+ "Comments": "{{.ProductComments}}"
+ }
+ }
+}
\ No newline at end of file
diff --git a/v3/internal/commands/defaults/wails.exe.manifest b/v3/internal/commands/build_assets/wails.exe.manifest.tmpl
similarity index 88%
rename from v3/internal/commands/defaults/wails.exe.manifest
rename to v3/internal/commands/build_assets/wails.exe.manifest.tmpl
index fb1ce5bd..97cf66e7 100644
--- a/v3/internal/commands/defaults/wails.exe.manifest
+++ b/v3/internal/commands/build_assets/wails.exe.manifest.tmpl
@@ -1,6 +1,6 @@
-
+
diff --git a/v3/internal/commands/defaults.go b/v3/internal/commands/defaults.go
deleted file mode 100644
index 6e8e44d6..00000000
--- a/v3/internal/commands/defaults.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package commands
-
-import (
- _ "embed"
- "os"
-)
-
-//go:embed defaults/info.json
-var Info []byte
-
-//go:embed defaults/wails.exe.manifest
-var Manifest []byte
-
-//go:embed defaults/appicon.png
-var AppIcon []byte
-
-//go:embed defaults/icon.ico
-var IconIco []byte
-
-//go:embed defaults/Info.plist
-var InfoPlist []byte
-
-//go:embed defaults/Info.dev.plist
-var InfoDevPlist []byte
-
-//go:embed defaults/icons.icns
-var IconsIcns []byte
-
-var AllAssets = map[string][]byte{
- "info.json": Info,
- "wails.exe.manifest": Manifest,
- "appicon.png": AppIcon,
- "icon.ico": IconIco,
- "Info.plist": InfoPlist,
- "Info.dev.plist": InfoDevPlist,
- "icons.icns": IconsIcns,
-}
-
-type DefaultsOptions struct {
- Dir string `description:"The directory to generate the files into"`
-}
-
-func Defaults(options *DefaultsOptions) error {
- dir := options.Dir
- if dir == "" {
- dir = "."
- }
- for filename, data := range AllAssets {
- // If file exists, skip it
- if _, err := os.Stat(dir + "/" + filename); err == nil {
- println("Skipping " + filename)
- continue
- }
- err := os.WriteFile(dir+"/"+filename, data, 0644)
- if err != nil {
- return err
- }
- println("Generated " + filename)
- }
- return nil
-}
diff --git a/v3/internal/commands/defaults/info.json b/v3/internal/commands/defaults/info.json
deleted file mode 100644
index 1005eb5c..00000000
--- a/v3/internal/commands/defaults/info.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "fixed": {
- "file_version": "v1.0.0"
- },
- "info": {
- "0000": {
- "ProductVersion": "v1.0.0",
- "CompanyName": "My Company Name",
- "FileDescription": "A thing that does a thing",
- "LegalCopyright": "(c) 2023 My Company Name",
- "ProductName": "My Product Name",
- "Comments": "This is a comment"
- }
- }
-}
\ No newline at end of file
diff --git a/v3/internal/commands/icons.go b/v3/internal/commands/icons.go
index f4fcf7a7..ef6ce197 100644
--- a/v3/internal/commands/icons.go
+++ b/v3/internal/commands/icons.go
@@ -68,7 +68,11 @@ func GenerateIcons(options *IconsOptions) error {
}
func generateExampleIcon() error {
- return os.WriteFile("appicon.png", []byte(AppIcon), 0644)
+ appIcon, err := buildAssets.ReadFile("build_assets/appicon.png")
+ if err != nil {
+ return err
+ }
+ return os.WriteFile("appicon.png", appIcon, 0644)
}
func parseSizes(sizes string) ([]int, error) {
diff --git a/v3/internal/commands/syso.go b/v3/internal/commands/syso.go
index 70821789..63a9b618 100644
--- a/v3/internal/commands/syso.go
+++ b/v3/internal/commands/syso.go
@@ -10,7 +10,6 @@ import (
)
type SysoOptions struct {
- Example bool `description:"Generate example manifest & info files"`
Manifest string `description:"The manifest file"`
Info string `description:"The info.json file"`
Icon string `description:"The icon file"`
@@ -26,11 +25,6 @@ func (i *SysoOptions) Default() *SysoOptions {
func GenerateSyso(options *SysoOptions) error {
- // Generate example files?
- if options.Example {
- return generateExampleSyso()
- }
-
if options.Manifest == "" {
return fmt.Errorf("manifest is required")
}
@@ -107,17 +101,3 @@ func GenerateSyso(options *SysoOptions) error {
}
return nil
}
-
-func generateExampleSyso() error {
- // Generate example info.json
- err := os.WriteFile("info.json", Info, 0644)
- if err != nil {
- return err
- }
- // Generate example manifest
- err = os.WriteFile("wails.exe.manifest", Manifest, 0644)
- if err != nil {
- return err
- }
- return nil
-}
diff --git a/v3/internal/templates/_base/default/Taskfile.tmpl.yml b/v3/internal/templates/_base/default/Taskfile.tmpl.yml
index 7926f0d5..924d3159 100644
--- a/v3/internal/templates/_base/default/Taskfile.tmpl.yml
+++ b/v3/internal/templates/_base/default/Taskfile.tmpl.yml
@@ -2,9 +2,23 @@ version: '3'
vars:
APP_NAME: "{{.ProjectName}}{{exeExt}}"
+ APP_VERSION: "0.1.0"
+ PRODUCT_NAME: "My Product"
+ PRODUCT_DESCRIPTION: "My Product Description"
+ PRODUCT_VERSION: "0.1.0"
+ PRODUCT_COMPANY: "My Company"
+ PRODUCT_COPYRIGHT: "(c) 2023 My Company"
+ PRODUCT_COMMENTS: "My Comments"
+ PRODUCT_IDENTIFIER: "com.mycompany.myproduct"
+ BUILD_DIR: "build"
tasks:
+ generate:build-assets:
+ summary: Generates the build assets
+ cmds:
+ - wails3 generate build-assets -dir {{.BUILD_DIR}} -name "{{.APP_NAME}}" -productname "{{.PRODUCT_NAME}}" -productdescription "{{.PRODUCT_DESCRIPTION}}" -productversion "{{.PRODUCT_VERSION}}" -productcompany "{{.PRODUCT_COMPANY}}" -productcopyright "{{.PRODUCT_COPYRIGHT}}" -productcomments "{{.PRODUCT_COMMENTS}}" -productidentifier "{{.PRODUCT_IDENTIFIER}}"
+
pre-build:
summary: Pre-build hooks
diff --git a/v3/internal/templates/vanilla/Taskfile.tmpl.yml b/v3/internal/templates/vanilla/Taskfile.tmpl.yml
index f9646a73..182a72c4 100644
--- a/v3/internal/templates/vanilla/Taskfile.tmpl.yml
+++ b/v3/internal/templates/vanilla/Taskfile.tmpl.yml
@@ -2,9 +2,23 @@ version: '3'
vars:
APP_NAME: "{{.ProjectName}}"
+ APP_VERSION: "0.1.0"
+ PRODUCT_NAME: "My Product"
+ PRODUCT_DESCRIPTION: "My Product Description"
+ PRODUCT_VERSION: "0.1.0"
+ PRODUCT_COMPANY: "My Company"
+ PRODUCT_COPYRIGHT: "(c) 2023 My Company"
+ PRODUCT_COMMENTS: "My Comments"
+ PRODUCT_IDENTIFIER: "com.mycompany.myproduct"
+ BUILD_DIR: "build"
tasks:
+ generate:build-assets:
+ summary: Generates the build assets
+ cmds:
+ - wails3 generate build-assets -dir {{.BUILD_DIR}} -name "{{.APP_NAME}}" -productname "{{.PRODUCT_NAME}}" -productdescription "{{.PRODUCT_DESCRIPTION}}" -productversion "{{.PRODUCT_VERSION}}" -productcompany "{{.PRODUCT_COMPANY}}" -productcopyright "{{.PRODUCT_COPYRIGHT}}" -productcomments "{{.PRODUCT_COMMENTS}}" -productidentifier "{{.PRODUCT_IDENTIFIER}}"
+
pre-build:
summary: Pre-build hooks