diff --git a/v3/internal/commands/build-assets.go b/v3/internal/commands/build-assets.go index 03fdf748e..8954f152e 100644 --- a/v3/internal/commands/build-assets.go +++ b/v3/internal/commands/build-assets.go @@ -25,6 +25,7 @@ type BuildAssetsOptions struct { 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"` + Silent bool `description:"Suppress output to console"` } func GenerateBuildAssets(options *BuildAssetsOptions) error { @@ -56,7 +57,9 @@ func GenerateBuildAssets(options *BuildAssetsOptions) error { return err } - println("Generating build assets in " + options.Dir) + if !options.Silent { + println("Generating build assets in " + options.Dir) + } return gosod.New(tfs).Extract(options.Dir, options) } diff --git a/v3/internal/commands/init.go b/v3/internal/commands/init.go index 5742caa49..71ca311ac 100644 --- a/v3/internal/commands/init.go +++ b/v3/internal/commands/init.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/wailsapp/wails/v3/internal/flags" "github.com/wailsapp/wails/v3/internal/templates" + "path/filepath" "github.com/pterm/pterm" ) @@ -21,11 +22,22 @@ func Init(options *flags.Init) error { return fmt.Errorf("please use the -n flag to specify a project name") } - if templates.ValidTemplateName(options.TemplateName) { - return templates.Install(options) + if !templates.ValidTemplateName(options.TemplateName) { + return fmt.Errorf("invalid template name: %s. Use -l flag to list valid templates", options.TemplateName) } - return templates.Install(options) + err := templates.Install(options) + if err != nil { + return err + } + + // Generate build assets + buildAssetsOptions := &BuildAssetsOptions{ + Name: options.ProjectName, + Dir: filepath.Join(options.ProjectDir, "build"), + Silent: true, + } + return GenerateBuildAssets(buildAssetsOptions) } func printTemplates() error { diff --git a/v3/internal/templates/vanilla/Taskfile.tmpl.yml b/v3/internal/templates/vanilla/Taskfile.tmpl.yml index 182a72c4c..dd6041b7c 100644 --- a/v3/internal/templates/vanilla/Taskfile.tmpl.yml +++ b/v3/internal/templates/vanilla/Taskfile.tmpl.yml @@ -17,7 +17,7 @@ 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}}" + - 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 @@ -79,17 +79,16 @@ tasks: generate-icons: summary: Generates Windows `.ico` and Mac `.icns` files from an image - dir: build cmds: # Generates both .ico and .icns files - - wails generate icons -input appicon.png + - wails3 generate icons -input {{ "{{.BUILD_DIR}}" }}/appicon.png build-app-prod-darwin: summary: Creates a production build of the application cmds: - task: pre-build - task: build-frontend - - GOOS=darwin GOARCH={{ "{{.ARCH}}" }} go build -tags production -ldflags="-w -s" -o build/bin/{{ "{{.APP_NAME}}" }} + - GOOS=darwin GOARCH={{ "{{.ARCH}}" }} go build -tags production -ldflags="-w -s" -o bin/{{ "{{.APP_NAME}}" }} - task: post-build env: CGO_CFLAGS: "-mmacosx-version-min=10.13" @@ -103,9 +102,9 @@ tasks: summary: Builds a `.app` bundle cmds: - mkdir -p {{ "{{.APP_NAME}}" }}.app/Contents/{MacOS,Resources} - - cp build/icons.icns {{ "{{.APP_NAME}}" }}.app/Contents/Resources - - cp build/bin/{{ "{{.APP_NAME}}" }} {{ "{{.APP_NAME}}" }}.app/Contents/MacOS - - cp build/Info.plist {{ "{{.APP_NAME}}" }}.app/Contents + - cp {{ "{{.BUILD_DIR}}" }}/icons.icns {{ "{{.APP_NAME}}" }}.app/Contents/Resources + - cp bin/{{ "{{.APP_NAME}}" }} {{ "{{.APP_NAME}}" }}.app/Contents/MacOS + - cp {{ "{{.BUILD_DIR}}" }}/Info.plist {{ "{{.APP_NAME}}" }}.app/Contents package-darwin-arm64: summary: Packages a production build of the application into a `.app` bundle @@ -122,7 +121,7 @@ tasks: dir: build platform: windows cmds: - - wails generate syso -arch {{ "{{.ARCH}}" }} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso + - wails3 generate syso -arch {{ "{{.ARCH}}" }} -icon {{ "{{.BUILD_DIR}}" }}/icon.ico -manifest {{ "{{.BUILD_DIR}}" }}/wails.exe.manifest -info {{ "{{.BUILD_DIR}}" }}/info.json -out ../wails.syso vars: ARCH: $GOARCH @@ -135,5 +134,5 @@ tasks: - task: generate:syso vars: ARCH: amd64 - - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/{{ "{{.APP_NAME}}" }}.exe + - go build -tags production -ldflags="-w -s -H windowsgui" -o "{{ "{{.BUILD_DIR}}" }}"/bin/{{ "{{.APP_NAME}}" }}.exe - powershell Remove-item wails.syso diff --git a/v3/internal/templates/vanilla/build/Info.dev.plist.tmpl b/v3/internal/templates/vanilla/build/Info.dev.plist.tmpl deleted file mode 100644 index 7efa134f4..000000000 --- a/v3/internal/templates/vanilla/build/Info.dev.plist.tmpl +++ /dev/null @@ -1,32 +0,0 @@ - - - - CFBundlePackageType - APPL - CFBundleName - My Product Name - CFBundleExecutable - {{.ProjectName}} - CFBundleIdentifier - com.wails.{{.ProjectName}} - CFBundleVersion - v1.0.0 - CFBundleGetInfoString - This is a comment - CFBundleShortVersionString - v1.0.0 - CFBundleIconFile - icons - LSMinimumSystemVersion - 10.13.0 - NSHighResolutionCapable - true - NSHumanReadableCopyright - (c) 2023 My Company Name - NSAppTransportSecurity - - NSAllowsLocalNetworking - - - - \ No newline at end of file diff --git a/v3/internal/templates/vanilla/build/Info.plist.tmpl b/v3/internal/templates/vanilla/build/Info.plist.tmpl deleted file mode 100644 index 6bfa8c316..000000000 --- a/v3/internal/templates/vanilla/build/Info.plist.tmpl +++ /dev/null @@ -1,27 +0,0 @@ - - - - CFBundlePackageType - APPL - CFBundleName - My Product Name - CFBundleExecutable - {{.ProjectName}} - CFBundleIdentifier - com.wails.{{.ProjectName}} - CFBundleVersion - v1.0.0 - CFBundleGetInfoString - This is a comment - CFBundleShortVersionString - v1.0.0 - CFBundleIconFile - icons - LSMinimumSystemVersion - 10.13.0 - NSHighResolutionCapable - true - NSHumanReadableCopyright - (c) 2023 My Company Name - - \ No newline at end of file diff --git a/v3/internal/templates/vanilla/build/appicon.png b/v3/internal/templates/vanilla/build/appicon.png deleted file mode 100644 index 63617fe4f..000000000 Binary files a/v3/internal/templates/vanilla/build/appicon.png and /dev/null differ diff --git a/v3/internal/templates/vanilla/build/icons.icns b/v3/internal/templates/vanilla/build/icons.icns deleted file mode 100644 index 1b5bd4c86..000000000 Binary files a/v3/internal/templates/vanilla/build/icons.icns and /dev/null differ