Skip to content

Commit aed505c

Browse files
committed
devenv codegen
1 parent 9f02f86 commit aed505c

File tree

4 files changed

+2000
-0
lines changed

4 files changed

+2000
-0
lines changed

framework/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# dev environment generated by manually testing CLI
2+
cmd/devenv/
3+
# dev environments generated by automated tests
4+
test-env*/

framework/cmd/main.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,57 @@ func main() {
2525
Aliases: []string{"g"},
2626
Usage: "Generates various test templates",
2727
Subcommands: []*cli.Command{
28+
{
29+
Name: "env",
30+
Aliases: []string{"e"},
31+
Usage: "Generate a Chainlink Node developer environment",
32+
Description: `This utility generate a Chainlink Node Cluster (DON) environment.
33+
Default setup includes:
34+
- Anvil (EVM emulator from Foundry) or Geth blockchain nodes
35+
- Chainlink Nodes
36+
- Fake server (for 3rd party dependencies)
37+
- Test boilerplates, CI and documentation
38+
39+
Usage:
40+
41+
Generate a basic environment:
42+
ctf gen env --cli myenv --nodes 4
43+
`,
44+
ArgsUsage: "",
45+
Flags: []cli.Flag{
46+
&cli.StringFlag{
47+
Name: "cli",
48+
Aliases: []string{"c"},
49+
Usage: "Your devenv CLI binary name",
50+
},
51+
&cli.IntFlag{
52+
Name: "nodes",
53+
Aliases: []string{"n"},
54+
Value: 4,
55+
Usage: "Chainlink Nodes",
56+
},
57+
},
58+
Action: func(c *cli.Context) error {
59+
nodes := c.Int("nodes")
60+
cliName := c.String("cli")
61+
if cliName == "" {
62+
return fmt.Errorf("CLI name can't be empty, choose your CLI name")
63+
}
64+
framework.L.Info().
65+
Str("Name", cliName).
66+
Int("CLNodes", nodes).
67+
Msg("Generating developer environment")
68+
69+
cg, err := framework.NewEnvBuilder(cliName, nodes).Build()
70+
if err != nil {
71+
return fmt.Errorf("failed to create codegen: %w", err)
72+
}
73+
if err := cg.Write(); err != nil {
74+
return fmt.Errorf("failed to generate module: %w", err)
75+
}
76+
return nil
77+
},
78+
},
2879
{
2980
Name: "load",
3081
Aliases: []string{"l"},

0 commit comments

Comments
 (0)