feat(v3/cli): add wails3 migrate to assist v2 project migration#5755
Draft
taliesin-ai wants to merge 2 commits into
Draft
feat(v3/cli): add wails3 migrate to assist v2 project migration#5755taliesin-ai wants to merge 2 commits into
wails3 migrate to assist v2 project migration#5755taliesin-ai wants to merge 2 commits into
Conversation
…tion
Adds a migration assistant that takes a Wails v2 project and generates
the v3 equivalents without touching any v2 files:
- Maps wails.json onto the v3 project layout: renders the root
Taskfile.yml (reusing the init template via templates.RootTaskfile,
with the package manager detected from frontend:install) and
generates the build/ assets, copying only files the project does not
already have so existing icons/Info.plist/installer files are
preserved. Product info from wails.json is written into
build/config.yml.
- Parses main.go with go/ast, extracts the wails.Run(&options.App{...})
literal and generates main_v3.go.example: application.New +
app.Window.NewWithOptions, with every Bind entry converted to
application.NewService(...), constructor statements and the
//go:embed directive carried over, and lifecycle hooks surfaced as
TODO(migrate) comments. Output is gofmt-formatted and parse-checked
before writing.
- Writes MIGRATION_REPORT.md: what was migrated, what needs manual
work (with file:line references, including every v2 runtime.* call
found), a v2-to-v3 runtime API mapping table, frontend changes and
next steps.
Non-literal or exotic options (menus, platform options, custom asset
handlers) degrade to report entries rather than broken codegen.
Adds /migration/comparison with a side-by-side reference of v2 and v3 concepts (bootstrap, Bind vs Services, runtime API mapping, events, dialogs, menus, configuration/project layout, build system) and a section on the new `wails3 migrate` command. Cross-linked with the existing step-by-step migration guide and added to the sidebar.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
wails3 migratecommand that assists migrating a Wails v2 project to v3, plus a new docs page with a side-by-side v2 vs v3 comparison. Requested as part of making the v2 to v3 path easier: convert declarative to programmatic, bindings to services, config to config.The tool is an assistant, not a transpiler: it automates the mechanical parts and produces a precise report for everything that needs a human.
What it does
Refuses politely unless the directory has a
wails.jsonand ago.modrequiringgithub.com/wailsapp/wails/v2. Non-destructive by design: it never modifies or deletes existing files.Automated
Taskfile.yml(same templatewails3 inituses, package manager detected fromfrontend:install) and generates thebuild/assets, copying only files the project does not already have (existing v2 icons,Info.plist, installer files are preserved and listed in the report). Product info fromwails.json(info.*) is written intobuild/config.yml.main.gowithgo/ast, extracts thewails.Run(&options.App{...})literal and generatesmain_v3.go.example(never touchesmain.go):application.New(application.Options{...})+app.Window.NewWithOptions(...)with Title/Width/Height/Min-Max/Frameless/BackgroundColour/StartState/SingleInstance mapped, the//go:embeddirective and constructor statements (app := NewApp()) carried over, and asset serving converted toapplication.AssetFileServerFS. Output is gofmt-formatted and parse-checked before it is written.Bindentry becomesapplication.NewService(...)in the generated options.Report-only (MIGRATION_REPORT.md)
wails.jsonkeys, each with guidance on where the setting lives in v3.OnStartup/OnDomReady/OnShutdown/OnBeforeClose(also surfaced asTODO(migrate)comments in the generated bootstrap), menus, platform-specific options, non-literal option values.runtime.*call found in the project, with file:line references, plus a verified v2-to-v3 runtime API mapping table (EventsEmit->app.Event.Emit,WindowSetTitle->window.SetTitle, dialogs, clipboard, browser, logging, ...).ctx,ServiceStartup/ServiceShutdown, constructor injection) and frontend changes (wailsjs->frontend/bindings,@wailsio/runtime).Docs
docs/src/content/docs/migration/comparison.mdx(side-by-side concept/API/config tables +wails3 migrateusage), added to the sidebar and cross-linked with the existing step-by-step guide.Testing
v3/internal/commands/testdata/migrate/basic): detection/refusal, config mapping, preservation of existing files across repeat runs, generated-code validity (parses, gofmt-clean, all options asserted), report contents.go test ./internal/commands/ ./internal/templates/ ./internal/flags/passes.main_v3.go.example(with the fixture services adapted to v3 as a user would) compiles to a working binary in a module requiringwails/v3via a replace directive.To try it: build the CLI (
go build ./cmd/wails3inv3/), then runwails3 migrate -d <v2 project>and openMIGRATION_REPORT.md.Notes for review
writeProjectConfigYMLin init.go was refactored (behaviour-preserving) to share the comment-preserving config.yml rewrite with the migrator.templates.RootTaskfileis a new small exported helper so the migrator reuses the exact init Taskfile template.