From 6cc11d4b60a5f75f571edaafa35ff3441bd93af4 Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 15:01:48 +0200 Subject: [PATCH 1/7] Replacing all Basecoin references to capitalizedProjectName --- cmd/cosmos-sdk-cli/cmd/init.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 5a0f3ddb38..555a035acf 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -44,7 +44,8 @@ var initCmd = &cobra.Command{ "basecoind", shortProjectName+"d", "BasecoinApp", capitalizedProjectName+"App", remoteBasecoinPath, remoteProjectPath, - "basecoin", shortProjectName) + "basecoin", shortProjectName, + "Basecoin", capitalizedProjectName) setupBasecoinWorkspace(shortProjectName, remoteProjectPath) return nil }, From bfd928ca53d677878ae4703f8aa8f78fef2c01f6 Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 15:40:15 +0200 Subject: [PATCH 2/7] Checking if the path already exists or not before creating the project --- cmd/cosmos-sdk-cli/cmd/init.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 555a035acf..5576ac2f31 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -146,8 +146,12 @@ benchmark: func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { projectPath := resolveProjectPath(remoteProjectPath) fmt.Println("Configuring your project in " + projectPath) - copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) - createGopkg(projectPath) - createMakefile(projectPath) - fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", projectPath) + if _, err := os.Stat(projectPath); os.IsNotExist(err) { + copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) + createGopkg(projectPath) + createMakefile(projectPath) + fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", projectPath) + } else { + fmt.Printf("\n%s already exists, please choose a different project path\n", projectPath) + } } From f2c11d9108131b09b324110a4c46fe1e039856ff Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 15:47:34 +0200 Subject: [PATCH 3/7] Adding comment to make the code clear --- cmd/cosmos-sdk-cli/cmd/init.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 5576ac2f31..fdd57ae999 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -146,6 +146,7 @@ benchmark: func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { projectPath := resolveProjectPath(remoteProjectPath) fmt.Println("Configuring your project in " + projectPath) + // Check if the projectPath already exists or not if _, err := os.Stat(projectPath); os.IsNotExist(err) { copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) createGopkg(projectPath) From adceed9e126671b6de35b457b4740c57721e471c Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 16:05:03 +0200 Subject: [PATCH 4/7] Adding the changes to PENDING.md --- PENDING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PENDING.md b/PENDING.md index 6f82b55e62..d5302c0057 100644 --- a/PENDING.md +++ b/PENDING.md @@ -35,6 +35,9 @@ IMPROVEMENTS * [x/stake] Add revoked to human-readable validator * [x/gov] Votes on a proposal can now be queried * [x/bank] Unit tests are now table-driven +* [cosmos-sdk-cli] + * Replacing all instances of "Basecoin" to ProjectName in Basecoin code + * Checking if directory exists before creating a new project BUG FIXES * \#1666 Add intra-tx counter to the genesis validators From 196a45bb308664b52130006cc5dc66b5074115f8 Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 18:12:22 +0200 Subject: [PATCH 5/7] Fixing the issues suggested in code review --- PENDING.md | 7 ++----- cmd/cosmos-sdk-cli/cmd/init.go | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/PENDING.md b/PENDING.md index d5302c0057..4da4d27a17 100644 --- a/PENDING.md +++ b/PENDING.md @@ -25,8 +25,8 @@ FEATURES * Modules can test random combinations of their own operations * Applications can integrate operations and invariants from modules together for an integrated simulation * [baseapp] Initialize validator set on ResponseInitChain -* Added support for cosmos-sdk-cli tool under cosmos-sdk/cmd - * This allows SDK users to init a new project repository with a single command. +* [cosmos-sdk-cli] Added support for cosmos-sdk-cli tool under cosmos-sdk/cmd + * This allows SDK users to initialize a new project repository. IMPROVEMENTS * [baseapp] Allow any alphanumeric character in route @@ -35,9 +35,6 @@ IMPROVEMENTS * [x/stake] Add revoked to human-readable validator * [x/gov] Votes on a proposal can now be queried * [x/bank] Unit tests are now table-driven -* [cosmos-sdk-cli] - * Replacing all instances of "Basecoin" to ProjectName in Basecoin code - * Checking if directory exists before creating a new project BUG FIXES * \#1666 Add intra-tx counter to the genesis validators diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index fdd57ae999..e31820e818 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -151,8 +151,8 @@ func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) createGopkg(projectPath) createMakefile(projectPath) - fmt.Printf("\nInitialized a new project at %s.\nHappy hacking!\n", projectPath) + fmt.Printf("Initialized a new project at %s.\nHappy hacking!\n", projectPath) } else { - fmt.Printf("\n%s already exists, please choose a different project path\n", projectPath) + fmt.Errorf("%s already exists, please choose a different project path\n", projectPath) } } From cec01f1328f33a429f791f2a44cf27f44e2458c9 Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 19:04:33 +0200 Subject: [PATCH 6/7] Changing the way error messages are displayed --- cmd/cosmos-sdk-cli/cmd/init.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index e31820e818..3b42c53757 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -46,7 +46,10 @@ var initCmd = &cobra.Command{ remoteBasecoinPath, remoteProjectPath, "basecoin", shortProjectName, "Basecoin", capitalizedProjectName) - setupBasecoinWorkspace(shortProjectName, remoteProjectPath) + err := setupBasecoinWorkspace(shortProjectName, remoteProjectPath) + if err != nil { + return err + } return nil }, } @@ -143,16 +146,16 @@ benchmark: } -func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { +func setupBasecoinWorkspace(projectName string, remoteProjectPath string) error { projectPath := resolveProjectPath(remoteProjectPath) fmt.Println("Configuring your project in " + projectPath) // Check if the projectPath already exists or not - if _, err := os.Stat(projectPath); os.IsNotExist(err) { - copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) - createGopkg(projectPath) - createMakefile(projectPath) - fmt.Printf("Initialized a new project at %s.\nHappy hacking!\n", projectPath) - } else { - fmt.Errorf("%s already exists, please choose a different project path\n", projectPath) + if _, err := os.Stat(projectPath); !os.IsNotExist(err) { + return fmt.Errorf("Unable to initialize the project. %s already exists", projectPath) } + copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) + createGopkg(projectPath) + createMakefile(projectPath) + fmt.Printf("Initialized a new project at %s.\nHappy hacking!\n", projectPath) + return nil } From d5a3fa959ff969e12fa6ada7605490962f44d15c Mon Sep 17 00:00:00 2001 From: Rigel Date: Mon, 23 Jul 2018 14:19:52 -0400 Subject: [PATCH 7/7] Update init.go --- cmd/cosmos-sdk-cli/cmd/init.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index 3b42c53757..d5d6422add 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -46,11 +46,7 @@ var initCmd = &cobra.Command{ remoteBasecoinPath, remoteProjectPath, "basecoin", shortProjectName, "Basecoin", capitalizedProjectName) - err := setupBasecoinWorkspace(shortProjectName, remoteProjectPath) - if err != nil { - return err - } - return nil + return setupBasecoinWorkspace(shortProjectName, remoteProjectPath) }, }