Skip to content

Commit

Permalink
feat(cmd/init): change default module name to project name
Browse files Browse the repository at this point in the history
  • Loading branch information
Twacqwq committed Mar 17, 2024
1 parent 551271a commit 93579cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
17 changes: 17 additions & 0 deletions v2/cmd/wails/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ func initProject(f *flags.Init) error {
return err
}

// Change the module name to project name
err = updateModuleNameToProjectName(options, quiet)
if err != nil {
return err
}

if !f.CIMode {
// Run `go mod tidy` to ensure `go.sum` is up to date
cmd := exec.Command("go", "mod", "tidy")
Expand Down Expand Up @@ -276,3 +282,14 @@ func updateReplaceLine(targetPath string) {
fatal(err.Error())
}
}

func updateModuleNameToProjectName(options *templates.Options, quiet bool) error {
cmd := exec.Command("go", "mod", "edit", "-module", options.ProjectName)
cmd.Dir = options.TargetDir
cmd.Stderr = os.Stderr
if !quiet {
cmd.Stdout = os.Stdout
}

return cmd.Run()
}
1 change: 0 additions & 1 deletion website/docs/reference/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ The Wails CLI has a number of commands that are used for managing your projects.
| -t "template name" | The project template to use. This can be the name of a default template or a URL to a remote template hosted on github. | vanilla |
| -ide | Generate IDE project files | |
| -f | Force build application | false |
| -m | Change go.mod module name to project Name | false |

Example:
`wails init -n test -d mytestproject -g -ide vscode -q`
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added docs to help fix NixOs/Wayland font-size css issue. Added by @atterpac in [PR](https://github.com/wailsapp/wails/pull/3268)
- Added -m (skip `go mod tidy`) flag to dev command by @te5se in [PR](https://github.com/wailsapp/wails/pull/3275)
- Added mac option `DisableZoom` to remove zoom button. Added by @wizzymore in [PR](https://github.com/wailsapp/wails/pull/3289)
- Changed Create a project with changing the default name to the project’s name. Changed by [@Twacqwq](https://github.com/Twacqwq) in [PR](https://github.com/wailsapp/wails/pull/3303)

## v2.8.0 - 2024-02-08

Expand All @@ -27,7 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added documentation for a common GStreamer error on Linux systems. Changed by [@mkwsnyder](https://github.com/mkwsnyder) in [PR](https://github.com/wailsapp/wails/pull/3134)
- Added documentation on explicity example of importing JS runtime. Changed by [@danawoodman](https://github.com/danawoodman) in [PR](https://github.com/wailsapp/wails/pull/3178)
- Add dock icon right-click exit handling by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3157)
- Added init command flag `initModule` to use for changing default module name to project name. Changed by [@Twacqwq](https://github.com/Twacqwq) in [PR](https://github.com/wailsapp/wails/pull/3303)

### Fixed
- Fixed vue-ts template build error. Fixed by @atterpac in
Expand Down

0 comments on commit 93579cf

Please sign in to comment.