Skip to content

Commit

Permalink
Fix build assets update (#3901)
Browse files Browse the repository at this point in the history
* fix: build assets update from config

* Updated changelog
  • Loading branch information
ansxuman authored Nov 22, 2024
1 parent eccfd34 commit c54fbdb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions mkdocs-website/docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Consolidated dev config into `config.yml` by [leaanthony](https://github.com/leaanthony)

### Fixed
- Fixed build assets update by @ansxuman in [#3900](https://github.com/wailsapp/wails/pull/3900)
- Fixed Linux systray `OnClick` and `OnRightClick` implementation by @atterpac in [#3886](https://github.com/wailsapp/wails/pull/3886)
- Fixed `AlwaysOnTop` not working on Mac by [leaanthony](https://github.com/leaanthony) in [#3841](https://github.com/wailsapp/wails/pull/3841)
- [darwin] Fixed `application.NewEditMenu` including a duplicate `PasteAndMatchStyle` role in the edit menu on Darwin by [johnmccabe](https://github.com/johnmccabe) in [#3839](https://github.com/wailsapp/wails/pull/3839)
Expand Down
30 changes: 26 additions & 4 deletions v3/internal/commands/build-assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ type UpdateConfig struct {
FileAssociations []FileAssociation `yaml:"fileAssociations"`
}

type WailsConfig struct {
Info struct {
CompanyName string `yaml:"companyName"`
ProductName string `yaml:"productName"`
ProductIdentifier string `yaml:"productIdentifier"`
Description string `yaml:"description"`
Copyright string `yaml:"copyright"`
Comments string `yaml:"comments"`
Version string `yaml:"version"`
} `yaml:"info"`
FileAssociations []FileAssociation `yaml:"fileAssociations"`
}

func UpdateBuildAssets(options *UpdateBuildAssetsOptions) error {
DisableFooter = true

Expand All @@ -132,18 +145,29 @@ func UpdateBuildAssets(options *UpdateBuildAssetsOptions) error {
}

var config UpdateConfig

if options.Config != "" {
var wailsConfig WailsConfig
bytes, err := os.ReadFile(options.Config)
if err != nil {
return err
}
err = yaml.Unmarshal(bytes, &config)
err = yaml.Unmarshal(bytes, &wailsConfig)
if err != nil {
return err
}

options.ProductCompany = wailsConfig.Info.CompanyName
options.ProductName = wailsConfig.Info.ProductName
options.ProductIdentifier = wailsConfig.Info.ProductIdentifier
options.ProductDescription = wailsConfig.Info.Description
options.ProductCopyright = wailsConfig.Info.Copyright
options.ProductComments = wailsConfig.Info.Comments
options.ProductVersion = wailsConfig.Info.Version
config.FileAssociations = wailsConfig.FileAssociations
}

config.UpdateBuildAssetsOptions = *options

// If directory doesn't exist, create it
if _, err := os.Stat(options.Dir); os.IsNotExist(err) {
err = os.MkdirAll(options.Dir, 0755)
Expand All @@ -157,8 +181,6 @@ func UpdateBuildAssets(options *UpdateBuildAssetsOptions) error {
return err
}

config.UpdateBuildAssetsOptions = *options

err = gosod.New(tfs).Extract(options.Dir, config)
if err != nil {
return err
Expand Down

0 comments on commit c54fbdb

Please sign in to comment.