mirror of
https://gitee.com/johng/gf
synced 2026-07-03 11:51:04 +08:00
This pull request introduces a significant enhancement to the `gf init` command by adding support for initializing GoFrame projects from remote templates, including interactive and advanced options for template selection. The changes include new interactive flows, support for remote repositories (including git subdirectories), and modularization of the template initialization logic into a new `geninit` package. The most important changes are: ### New Features & Interactive Initialization * Added support for initializing projects from remote templates via the `--repo/-r` flag, interactive mode (`--interactive/-i`), and version selection (`--select/-s`). Users can now select built-in or remote templates, specify custom repositories, and interactively choose project configuration. (`cmd/gf/internal/cmd/cmd_init.go`) [[1]](diffhunk://#diff-1213f1d7ea9ec0979d1b7aafaf9c84d53846c95f541e0252ab976cca90c677bdR50-R55) [[2]](diffhunk://#diff-1213f1d7ea9ec0979d1b7aafaf9c84d53846c95f541e0252ab976cca90c677bdL68-R161) [[3]](diffhunk://#diff-1213f1d7ea9ec0979d1b7aafaf9c84d53846c95f541e0252ab976cca90c677bdR267-R398) * Introduced interactive prompts for template and project configuration, including project name, module path, and dependency upgrade options. (`cmd/gf/internal/cmd/cmd_init.go`) ### Code Organization & Modularization * Extracted remote template initialization logic into a new package, `geninit`, with a clear API for processing templates, handling Go/gomod/git environments, and managing project generation. (`cmd/gf/internal/cmd/geninit/geninit.go`) * Added helper modules for Go and Git environment checks (`geninit_env.go`), template downloading (`geninit_downloader.go`), and AST-based Go import path replacement (`geninit_ast.go`). [[1]](diffhunk://#diff-6238f52cc62f1e0dd569c7b1eacec609337e6e9eb9faf8604dcfc82149d907d1R1-R90) [[2]](diffhunk://#diff-bbc29bf9a77f7097721185062041ff8ef622176bfb2c3886a94e68485773b5e6R1-R99) [[3]](diffhunk://#diff-269925976ae0929279513615dbafc06f8560859ff0830ce82702735a5a7d6c61R1-R127) ### Usability Improvements * Updated help and usage documentation to reflect new flags and initialization modes, making it easier for users to discover and use the new features. (`cmd/gf/internal/cmd/cmd_init.go`) These changes greatly improve the flexibility and user experience of project initialization in GoFrame, enabling both simple and advanced workflows. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>