5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 02:49:29 +08:00

feat(cmd/init): change default module name to project name (#3303)

* feat(cmd/init): change default module name to project name

* chore: write go.mod using chmod 644

* refactor: using go mod edit change module name

* docs: update changelog.mdx and cli.mdx

* Revert "feat(cmd/init): change default module name to project name"

This reverts commit 504d951759.

* feat(cmd/init): change default module name to project name

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Twacqwq 2024-03-24 13:58:46 +08:00 committed by GitHub
parent 769a882e58
commit bc69b39ccd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -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")
@ -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()
}

View File

@ -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 projects name. Changed by [@Twacqwq](https://github.com/Twacqwq) in [PR](https://github.com/wailsapp/wails/pull/3303)
## v2.8.0 - 2024-02-08