-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from TIBCOSoftware/develop
Develop
- Loading branch information
Showing
65 changed files
with
5,986 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: go | ||
go: | ||
- "1.11" | ||
- "1.12.9" | ||
script: | ||
- make depend | ||
- make | ||
- make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"scanSettings": { | ||
"configMode": "AUTO", | ||
"configExternalURL": "", | ||
"projectToken" : "" | ||
}, | ||
"checkRunSettings": { | ||
"vulnerableCheckRunConclusionLevel": "failure" | ||
}, | ||
"issueSettings": { | ||
"minSeverityLevel": "LOW" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright © 2018. TIBCO Software Inc. | ||
* This file is subject to the license terms contained | ||
* in the license file that is distributed with this file. | ||
*/ | ||
|
||
// Package dapp is the one containing all the cli commands for dapp operations | ||
package client | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
ClientCmd.PersistentFlags().StringP("version", "v", "v1.0.0", "client version") | ||
} | ||
|
||
// ClientCmd is the command for client app | ||
var ClientCmd = &cobra.Command{ | ||
Use: "client", | ||
Short: "Commands for Client Apps", | ||
Long: `Commands for Client Apps`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright © 2018. TIBCO Software Inc. | ||
* This file is subject to the license terms contained | ||
* in the license file that is distributed with this file. | ||
*/ | ||
|
||
// Package contract is the one containing all the cli commands for contract operations | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
cordac "github.com/TIBCOSoftware/dovetail-cli/corda/client" | ||
"github.com/TIBCOSoftware/dovetail-cli/model" | ||
"github.com/TIBCOSoftware/dovetail-cli/pkg/contract" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
namespace string | ||
target string | ||
caversion string | ||
modelfile string | ||
) | ||
|
||
func init() { | ||
ClientCmd.AddCommand(generateCmd) | ||
generateCmd.PersistentFlags().StringP("target", "t", ".", "Destination path for generated artifacts, if a filename is given (With extension) the generated artifacts will compressed as a zip file with the file name provided") | ||
generateCmd.Flags().StringP("namespace", "", "", "CorDapp namespace to generate generic client") | ||
generateCmd.Flags().StringVarP(&modelfile, "modelfile", "m", "", "DApp flow model file to generate generic client") | ||
|
||
generateCmd.MarkFlagRequired("target") | ||
generateCmd.MarkFlagRequired("namespace") | ||
generateCmd.MarkFlagRequired("modelfile") | ||
} | ||
|
||
var generateCmd = &cobra.Command{ | ||
Use: "generate", | ||
Short: "Commands for generating dapp artifacts", | ||
Long: `Commands for generating dapp artifacts`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
smversion, err := ClientCmd.PersistentFlags().GetString("version") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
caversion = smversion | ||
|
||
if modelfile != "" { | ||
err = validateModelFile(modelfile) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
namespace, err = cmd.Flags().GetString("namespace") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
target, err = cmd.Flags().GetString("target") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
if target == "" { | ||
target = "./target" | ||
} | ||
|
||
target, err = filepath.Abs(target) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
generator, err := createCordaClientGenerator() | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
if err := generator.Generate(); err != nil { | ||
fmt.Printf("Error generating the contract: '%s'", err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func createCordaClientGenerator() (contract.Generator, error) { | ||
if modelfile != "" && namespace == "" { | ||
return nil, fmt.Errorf("namespace is required") | ||
} | ||
options := cordac.NewOptions(modelfile, caversion, target, namespace) | ||
cordaGen := cordac.NewGenerator(options) | ||
return cordaGen, nil | ||
} | ||
|
||
func validateModelFile(modelfile string) error { | ||
appConfig, err := model.ParseApp(modelfile) | ||
if err != nil { | ||
return errors.Wrapf(err, "Failed to parse model file %s", modelfile) | ||
} | ||
|
||
if len(appConfig.Triggers) == 0 { | ||
return fmt.Errorf("There must be at least one trigger defined in dapp application") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright © 2018. TIBCO Software Inc. | ||
* This file is subject to the license terms contained | ||
* in the license file that is distributed with this file. | ||
*/ | ||
|
||
// Package corda is the one containing all the cli commands for corda operations | ||
package corda | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/TIBCOSoftware/dovetail-cli/commands/corda/client" | ||
"github.com/TIBCOSoftware/dovetail-cli/commands/corda/contract" | ||
"github.com/TIBCOSoftware/dovetail-cli/commands/corda/dapp" | ||
) | ||
|
||
func init() { | ||
CordaCmd.AddCommand(client.ClientCmd) | ||
CordaCmd.AddCommand(contract.ContractCmd) | ||
CordaCmd.AddCommand(dapp.DAppCmd) | ||
} | ||
|
||
// CordaCmd is the command for smart contracts | ||
var CordaCmd = &cobra.Command{ | ||
Use: "corda", | ||
Short: "Commands for Corda apps", | ||
Long: `Commands for Corda apps`, | ||
} |
Oops, something went wrong.