Adding comments for variables and refactoring how replacer is initialized, adding comment about tools/ structure
This commit is contained in:
parent
1d9415eae0
commit
e572513d91
|
@ -14,7 +14,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var remoteBasecoinPath = "github.com/cosmos/cosmos-sdk/examples/basecoin"
|
var remoteBasecoinPath = "github.com/cosmos/cosmos-sdk/examples/basecoin"
|
||||||
|
|
||||||
|
// Replacer to replace all instances of basecoin/basecli/BasecoinApp to project specific names
|
||||||
|
// Gets initialized when initCmd is executing after getting the project name from user
|
||||||
var replacer *strings.Replacer
|
var replacer *strings.Replacer
|
||||||
|
|
||||||
|
// Remote path for the project.
|
||||||
var remoteProjectPath string
|
var remoteProjectPath string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -35,7 +40,11 @@ var initCmd = &cobra.Command{
|
||||||
if remoteProjectPath == "" {
|
if remoteProjectPath == "" {
|
||||||
remoteProjectPath = strings.ToLower(shortProjectName)
|
remoteProjectPath = strings.ToLower(shortProjectName)
|
||||||
}
|
}
|
||||||
replacer = strings.NewReplacer("basecli", shortProjectName+"cli", "basecoind", shortProjectName+"d", "BasecoinApp", capitalizedProjectName+"App", "github.com/cosmos/cosmos-sdk/examples/basecoin/", remoteProjectPath+"/", "basecoin", shortProjectName)
|
replacer = strings.NewReplacer("basecli", shortProjectName+"cli",
|
||||||
|
"basecoind", shortProjectName+"d",
|
||||||
|
"BasecoinApp", capitalizedProjectName+"App",
|
||||||
|
remoteBasecoinPath, remoteProjectPath,
|
||||||
|
"basecoin", shortProjectName)
|
||||||
setupBasecoinWorkspace(shortProjectName, remoteProjectPath)
|
setupBasecoinWorkspace(shortProjectName, remoteProjectPath)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -103,6 +112,7 @@ func createGopkg(projectPath string) {
|
||||||
|
|
||||||
func createMakefile(projectPath string) {
|
func createMakefile(projectPath string) {
|
||||||
// Create makefile
|
// Create makefile
|
||||||
|
// TODO: Should we use tools/ directory as in Cosmos-SDK to get tools for linting etc.
|
||||||
makefileContents := `PACKAGES=$(shell go list ./... | grep -v '/vendor/')
|
makefileContents := `PACKAGES=$(shell go list ./... | grep -v '/vendor/')
|
||||||
|
|
||||||
all: get_tools get_vendor_deps build test
|
all: get_tools get_vendor_deps build test
|
||||||
|
@ -124,7 +134,10 @@ benchmark:
|
||||||
@go test -bench=. $(PACKAGES)
|
@go test -bench=. $(PACKAGES)
|
||||||
|
|
||||||
.PHONY: all build test benchmark`
|
.PHONY: all build test benchmark`
|
||||||
|
|
||||||
|
// Replacing instances of base* to project specific names
|
||||||
makefileContents = replacer.Replace(makefileContents)
|
makefileContents = replacer.Replace(makefileContents)
|
||||||
|
|
||||||
ioutil.WriteFile(projectPath+"/Makefile", []byte(makefileContents), os.ModePerm)
|
ioutil.WriteFile(projectPath+"/Makefile", []byte(makefileContents), os.ModePerm)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue