Skip to content

Commit a0de2ed

Browse files
authored
Allow specifying local module paths in the init command (#278)
1 parent 151e3b4 commit a0de2ed

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ We are using a tool called `goreleaser` which you can get from brew if you're on
219219
After you have the tool, you can follow these steps:
220220
```
221221
export GITHUB_TOKEN=<your token with access to write to the zero repo>
222-
git tag -a <version number like v0.0.1> -m "Some message about this release"
222+
git tag -s -a <version number like v0.0.1> -m "Some message about this release"
223223
git push origin <version number>
224224
goreleaser release
225225
```

cmd/init.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import (
1010
"github.com/spf13/cobra"
1111
)
1212

13+
var localModulePath string
14+
1315
func init() {
16+
initCmd.PersistentFlags().StringVarP(&localModulePath, "local-module-path", "m", "github.com/commitdev", "local module path - for using local modules instead of downloading from github")
1417
rootCmd.AddCommand(initCmd)
1518
}
1619

@@ -19,7 +22,7 @@ var initCmd = &cobra.Command{
1922
Short: "Create new project with provided name and initialize configuration based on user input.",
2023
Run: func(cmd *cobra.Command, args []string) {
2124
flog.Debugf("Root directory is %s", projectconfig.RootDir)
22-
projectContext := initPrompts.Init(projectconfig.RootDir)
25+
projectContext := initPrompts.Init(projectconfig.RootDir, localModulePath)
2326
projectConfigErr := projectconfig.CreateProjectConfigFile(projectconfig.RootDir, projectContext.Name, projectContext)
2427

2528
if projectConfigErr != nil {

internal/init/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
)
2020

2121
// Create cloud provider context
22-
func Init(outDir string) *projectconfig.ZeroProjectConfig {
22+
func Init(outDir string, localModulePath string) *projectconfig.ZeroProjectConfig {
2323
projectConfig := defaultProjConfig()
2424

2525
projectConfig.Name = getProjectNamePrompt().GetParam(projectConfig.Parameters)
@@ -34,7 +34,7 @@ func Init(outDir string) *projectconfig.ZeroProjectConfig {
3434
exit.Fatal("Error creating root: %v ", err)
3535
}
3636

37-
moduleSources := chooseStack(registry.GetRegistry())
37+
moduleSources := chooseStack(registry.GetRegistry(localModulePath))
3838
moduleConfigs, mappedSources := loadAllModules(moduleSources)
3939

4040
prompts := getProjectPrompts(projectConfig.Name, moduleConfigs)

internal/registry/registry.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ type Stack struct {
66
ModuleSources []string
77
}
88

9-
func GetRegistry() Registry {
9+
func GetRegistry(path string) Registry {
1010
return Registry{
1111
// TODO: better place to store these options as configuration file or any source
1212
{
1313
"EKS + Go + React + Gatsby",
1414
[]string{
15-
"github.com/commitdev/zero-aws-eks-stack",
16-
"github.com/commitdev/zero-deployable-landing-page",
17-
"github.com/commitdev/zero-deployable-backend",
18-
"github.com/commitdev/zero-deployable-react-frontend",
15+
path+"/zero-aws-eks-stack",
16+
path+"/zero-deployable-landing-page",
17+
path+"/zero-deployable-backend",
18+
path+"/zero-deployable-react-frontend",
1919
},
2020
},
2121
{
2222
"EKS + NodeJS + React + Gatsby",
2323
[]string{
24-
"github.com/commitdev/zero-aws-eks-stack",
25-
"github.com/commitdev/zero-deployable-landing-page",
26-
"github.com/commitdev/zero-deployable-node-backend",
27-
"github.com/commitdev/zero-deployable-react-frontend",
24+
path+"/zero-aws-eks-stack",
25+
path+"/zero-deployable-landing-page",
26+
path+"/zero-deployable-node-backend",
27+
path+"/zero-deployable-react-frontend",
2828
},
2929
},
3030
{

0 commit comments

Comments
 (0)