Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build assets update #3901

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

ansxuman
Copy link

@ansxuman ansxuman commented Nov 22, 2024

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

                                                                                                                                                                 
# System
┌────────────────────────────┐
| Name          | MacOS      |
| Version       | 15.1       |
| ID            | 24B83      |
| Branding      | MacOS 15.1 |
| Platform      | darwin     |
| Architecture  | arm64      |
| Apple Silicon | true       |
| CPU           | Apple M1   |
| CPU           | Unknown    |
| GPU           | Unknown    |
| Memory        | Unknown    |
└────────────────────────────┘

# Build Environment
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-alpha.7                                                                                                            |
| Go Version     | go1.23.2                                                                                                                  |
| Revision       | 5f1b1efc66d6286b1dcf54a51b33bdcdfa0b3c3b                                                                                  |
| Modified       | true                                                                                                                      |
| -buildmode     | exe                                                                                                                       |
| -compiler      | gc                                                                                                                        |
| CGO_CFLAGS     |                                                                                                                           |
| CGO_CPPFLAGS   |                                                                                                                           |
| CGO_CXXFLAGS   |                                                                                                                           |
| CGO_ENABLED    | 1                                                                                                                         |
| CGO_LDFLAGS    |                                                                                                                           |
| DefaultGODEBUG | asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1 |
| GOARCH         | arm64                                                                                                                     |
| GOARM64        | v8.0                                                                                                                      |
| GOOS           | darwin                                                                                                                    |
| vcs            | git                                                                                                                       |
| vcs.modified   | true                                                                                                                      |
| vcs.revision   | 5f1b1efc66d6286b1dcf54a51b33bdcdfa0b3c3b                                                                                  |
| vcs.time       | 2024-11-17T10:37:59Z                                                                                                      |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────────────────────┐
| *NSIS           | Not Installed. Install with `brew install makensis`. |
| Xcode cli tools | 2409                                                 |
| npm             | 10.8.1                                               |
└─────────────────────── * - Optional Dependency ────────────────────────┘

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Introduced commands for building assets and generating runtime.
    • Added options for window positioning and autofill features.
    • New templates for SvelteKit and enhanced documentation for events.
  • Bug Fixes

    • Resolved issues with build assets update and macOS AlwaysOnTop feature.
    • Fixed platform-specific issues, including compilation errors on Linux.
  • Documentation

    • Updated changelog to reflect new features, changes, and bug fixes.

Copy link
Contributor

coderabbitai bot commented Nov 22, 2024

Walkthrough

The pull request introduces significant updates to the project's changelog, detailing new features, enhancements, and bug fixes. Key additions include new commands for managing build assets and runtime generation, updated window options, and a new configuration type for Wails projects. The changes also encompass various bug fixes across platforms and improvements in asset embedding and configuration handling. Overall, the updates reflect a comprehensive enhancement of the project's functionality and structure.

Changes

File Path Change Summary
mkdocs-website/docs/en/changelog.md Updated changelog to include new features, changes, and bug fixes; added documentation for events and new SvelteKit templates.
v3/internal/commands/build-assets.go Introduced WailsConfig type for configuration handling; updated UpdateBuildAssets to utilize WailsConfig.

Possibly related PRs

Suggested reviewers

  • leaanthony: Suggested for review due to expertise in the relevant project areas.

Poem

🐇 In the meadow where changes bloom,
New commands and fixes chase away gloom.
With WailsConfig now in play,
Our project shines brighter each day!
Templates and options, all in a line,
Hop along, dear friends, the future is fine! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ansxuman ansxuman changed the base branch from master to v3-alpha November 22, 2024 06:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
v3/internal/commands/build-assets.go (2)

125-136: Consider adding field validation for WailsConfig

The new WailsConfig type is well-structured, but consider adding validation for required fields to ensure configuration completeness.

Consider implementing a Validate() method:

func (c *WailsConfig) Validate() error {
    if c.Info.ProductName == "" {
        return fmt.Errorf("productName is required")
    }
    if c.Info.ProductIdentifier == "" {
        return fmt.Errorf("productIdentifier is required")
    }
    // Add other required field validations
    return nil
}

Line range hint 125-170: Consider documenting the configuration precedence

While the new configuration system is a good improvement, it would be beneficial to document the precedence rules between command-line options and config file values. Consider adding this information to:

  1. User documentation
  2. Code comments
  3. Help text in CLI

Would you like me to help draft the documentation for this?

mkdocs-website/docs/en/changelog.md (1)

44-44: Enhance the changelog entry with more details.

The current entry "Fixed build assets update" is quite brief. Consider expanding it to provide more context about what was fixed and its impact. This helps users understand the significance of the change.

Example format:

-Fixed build assets update by @ansxuman in [#3900](https://github.com/wailsapp/wails/pull/3900)
+Fixed build assets update: [brief description of the specific issue and its impact] by @ansxuman in [#3900](https://github.com/wailsapp/wails/pull/3900)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eccfd34 and 4d45825.

📒 Files selected for processing (2)
  • mkdocs-website/docs/en/changelog.md (1 hunks)
  • v3/internal/commands/build-assets.go (2 hunks)
🔇 Additional comments (2)
v3/internal/commands/build-assets.go (1)

169-169: Verify options assignment order

The assignment of options to config occurs after setting individual fields, which could lead to unexpected behavior if there are default values in the options struct.

Let's verify the usage of these options throughout the codebase:

✅ Verification successful

Let me gather more context about the specific code flow in the build-assets.go file.


Options assignment order is correct and safe

The code flow shows that all individual fields from the wailsConfig are assigned to the options struct before the final assignment to config.UpdateBuildAssetsOptions. This ensures that any values read from the config file properly override the defaults, and the final assignment captures all the updated values. There's no risk of unexpected behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to UpdateBuildAssetsOptions fields
rg -t go "UpdateBuildAssetsOptions\." --no-heading

# Search for direct field access
rg -t go "ProductName|ProductIdentifier|ProductCompany" --no-heading

Length of output: 2663


Script:

#!/bin/bash
# Get the full context around the options assignment
rg -t go -B 20 -A 10 "config.UpdateBuildAssetsOptions = \*options" v3/internal/commands/build-assets.go

Length of output: 1044

mkdocs-website/docs/en/changelog.md (1)

Line range hint 1-24: LGTM! The changelog structure follows best practices.

The changelog is well-organized, following the Keep a Changelog format with proper categorization of changes, consistent PR linking, and author attribution.

🧰 Tools
🪛 LanguageTool

[duplication] ~43-~43: Possible typo: you repeated a word
Context: ...ny](https://github.com/leaanthony) ### Fixed - Fixed build assets update by @ansxuman in [#3...

(ENGLISH_WORD_REPEAT_RULE)

Comment on lines +149 to +166
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add validation and error handling for config loading

Several critical issues need to be addressed in the config loading logic:

  1. Missing error handling for required fields
  2. No validation of loaded values
  3. Potential for silent overwriting of command-line options

Consider applying these improvements:

 var wailsConfig WailsConfig
 bytes, err := os.ReadFile(options.Config)
 if err != nil {
     return err
 }
 err = yaml.Unmarshal(bytes, &wailsConfig)
 if err != nil {
     return err
 }
+// Validate required fields
+if err := wailsConfig.Validate(); err != nil {
+    return fmt.Errorf("invalid config file: %w", err)
+}

+// Log if command-line options are being overridden
+if !options.Silent && options.ProductName != "" && 
+   options.ProductName != wailsConfig.Info.ProductName {
+    fmt.Printf("Warning: Overriding ProductName from '%s' to '%s'\n",
+        options.ProductName, wailsConfig.Info.ProductName)
+}

Committable suggestion skipped: line range outside the PR's diff.

@leaanthony leaanthony merged commit c54fbdb into wailsapp:v3-alpha Nov 22, 2024
10 of 13 checks passed
@leaanthony
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants