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 504d9517591f876e4a3a75fd16e22ed312f991c5.

* 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 16:58:46 +11:00
committed by GitHub
co-authored by Lea Anthony
parent 769a882e58
commit bc69b39ccd
2 changed files with 18 additions and 0 deletions
+17
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()
}
+1
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