Skip to content

Commit 319c6a2

Browse files
authored
Merge branch 'master' into holyfuchs/parallel-test
2 parents b1cd433 + 371d3eb commit 319c6a2

8 files changed

Lines changed: 807 additions & 66 deletions

File tree

CLAUDE.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build & Run
6+
7+
```bash
8+
# Build the binary (requires CGO for BLS crypto)
9+
CGO_ENABLED=1 CGO_CFLAGS="-O2 -D__BLST_PORTABLE__ -std=gnu11" GO111MODULE=on go build -o ./cmd/flow/flow ./cmd/flow
10+
11+
# Or use Make
12+
make binary
13+
14+
# Run directly without building
15+
go run cmd/flow/main.go [command]
16+
```
17+
18+
## Testing
19+
20+
```bash
21+
# Run all tests
22+
make test
23+
# Equivalent: CGO_ENABLED=1 CGO_CFLAGS="-O2 -D__BLST_PORTABLE__ -std=gnu11" GO111MODULE=on go test -coverprofile=coverage.txt ./...
24+
25+
# Run a single test package
26+
CGO_ENABLED=1 CGO_CFLAGS="-O2 -D__BLST_PORTABLE__ -std=gnu11" go test ./internal/accounts/...
27+
28+
# Run a specific test
29+
CGO_ENABLED=1 CGO_CFLAGS="-O2 -D__BLST_PORTABLE__ -std=gnu11" go test ./internal/accounts/... -run TestFunctionName
30+
31+
# Skip network-dependent tests (e.g. in sandboxed environments)
32+
SKIP_NETWORK_TESTS=1 make test
33+
```
34+
35+
## Linting
36+
37+
```bash
38+
make lint # Run golangci-lint
39+
make fix-lint # Auto-fix lint issues
40+
make check-headers # Verify Apache license headers on all Go files
41+
go generate ./... # Regenerate generated code (required before lint)
42+
```
43+
44+
## Architecture
45+
46+
The CLI is a [Cobra](https://github.com/spf13/cobra)-based application with three main layers:
47+
48+
### Entry Point
49+
`cmd/flow/main.go` — wires all subcommands into the root `flow` command.
50+
51+
### Command Framework (`internal/command/`)
52+
The `command.Command` struct wraps a `cobra.Command` with two execution modes:
53+
- `Run` — for commands that don't need a loaded `flow.json` state
54+
- `RunS` — for commands that require an initialized project state (`*flowkit.State`)
55+
56+
`Command.AddToParent()` handles all shared boilerplate: loading `flow.json`, resolving network/host, creating the gRPC gateway, initializing `flowkit.Services`, version checking, analytics, and error formatting. **All new commands should use this pattern.**
57+
58+
Every command's run function returns a `command.Result` interface with three output methods: `String()` (human-readable), `Oneliner()` (grep-friendly inline), and `JSON()` (structured). The framework handles `--output`, `--filter`, and `--save` flags automatically.
59+
60+
### Command Packages (`internal/`)
61+
Each feature area is its own package with a top-level `Cmd *cobra.Command` that aggregates subcommands. Pattern:
62+
- `accounts.Cmd` (`internal/accounts/`) — registered in `main.go` via `cmd.AddCommand(accounts.Cmd)`
63+
- Subcommands (e.g., `get.go`, `create.go`) define a package-level `var getCommand = &command.Command{...}` and register via `init()` or the parent's `init()`
64+
65+
Key packages:
66+
- `internal/super/` — high-level "super commands": `flow init`, `flow dev`, `flow generate`, `flow flix`
67+
- `internal/super/generator/` — code generation engine for Cadence contracts, scripts, transactions, and tests
68+
- `internal/dependencymanager/``flow deps` commands for managing on-chain contract dependencies
69+
- `internal/config/``flow config` subcommands for managing `flow.json`
70+
- `internal/emulator/` — wraps the Flow emulator
71+
72+
### flowkit Dependency
73+
The CLI delegates all blockchain interactions to the `github.com/onflow/flowkit/v2` module (external). The `flowkit.Services` interface is the primary abstraction for network calls. The local `flowkit/` directory is a historical artifact (migrated to the external module) and contains only a README and schema.
74+
75+
### Global Flags
76+
Defined in `internal/command/global_flags.go`, applied to every command: `--network`, `--host`, `--log`, `--output`, `--filter`, `--save`, `--config-path`, `--yes`, `--skip-version-check`.
77+
78+
### Configuration
79+
`flow.json` is the project config file. `flowkit.Load()` reads it. The `internal/config/` commands modify it. `state.Networks()`, `state.Accounts()`, etc. provide typed access.
80+
81+
## CLI Design Conventions
82+
- Commands follow `noun verb` pattern (`flow accounts get`)
83+
- Prefer flags over positional args; use args only for the primary required value
84+
- `--output json` must always work for machine-readable output
85+
- Errors go to stderr; normal output to stdout
86+
- Progress indicators for long-running operations via `logger.StartProgress()` / `logger.StopProgress()`
87+
- Long-running commands support `--yes` to skip confirmation prompts
88+
89+
## License Headers
90+
All Go source files must have the Apache 2.0 license header. Run `make check-headers` to verify.

go.mod

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@ require (
99
github.com/coreos/go-semver v0.3.1
1010
github.com/dukex/mixpanel v1.0.1
1111
github.com/ethereum/go-ethereum v1.16.8
12-
github.com/getsentry/sentry-go v0.42.0
12+
github.com/getsentry/sentry-go v0.43.0
1313
github.com/gosuri/uilive v0.0.4
1414
github.com/logrusorgru/aurora/v4 v4.0.0
1515
github.com/onflow/cadence v1.9.10
16-
github.com/onflow/cadence-tools/languageserver v1.9.4
17-
github.com/onflow/cadence-tools/lint v1.7.5
18-
github.com/onflow/cadence-tools/test v1.11.1
16+
github.com/onflow/cadence-tools/languageserver v1.9.6
17+
github.com/onflow/cadence-tools/lint v1.7.6
18+
github.com/onflow/cadence-tools/test v1.11.4
1919
github.com/onflow/fcl-dev-wallet v0.9.1
2020
github.com/onflow/flixkit-go/v2 v2.7.4
2121
github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.3
2222
github.com/onflow/flow-core-contracts/lib/go/templates v1.9.3
23-
github.com/onflow/flow-emulator v1.17.0
24-
github.com/onflow/flow-evm-gateway v1.4.8-0.20260311083540-75525b282115
25-
github.com/onflow/flow-go v0.47.0-ledger-service.1.0.20260306194353-7770192048a9
23+
github.com/onflow/flow-emulator v1.18.0
24+
github.com/onflow/flow-evm-gateway v1.4.8-0.20260319182047-38311c7efd1f
25+
github.com/onflow/flow-go v0.47.0-ledger-service.1.0.20260318224013-f6e2e8f41961
2626
github.com/onflow/flow-go-sdk v1.9.16
27-
github.com/onflow/flow/protobuf/go/flow v0.4.19
28-
github.com/onflow/flowkit/v2 v2.11.1
27+
github.com/onflow/flow/protobuf/go/flow v0.4.20
28+
github.com/onflow/flowkit/v2 v2.11.2
2929
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48
3030
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
3131
github.com/pkg/errors v0.9.1
3232
github.com/psiemens/sconfig v0.1.0
3333
github.com/radovskyb/watcher v1.0.7
34-
github.com/rs/zerolog v1.34.0
34+
github.com/rs/zerolog v1.35.0
3535
github.com/sergi/go-diff v1.4.0
3636
github.com/spf13/afero v1.15.0
3737
github.com/spf13/cobra v1.10.2
3838
github.com/spf13/viper v1.21.0
3939
github.com/stretchr/testify v1.11.1
4040
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546
41-
golang.org/x/term v0.40.0
41+
golang.org/x/term v0.41.0
4242
google.golang.org/grpc v1.79.2
4343
)
4444

@@ -287,7 +287,7 @@ require (
287287
golang.org/x/net v0.49.0 // indirect
288288
golang.org/x/oauth2 v0.35.0 // indirect
289289
golang.org/x/sync v0.19.0 // indirect
290-
golang.org/x/sys v0.41.0 // indirect
290+
golang.org/x/sys v0.42.0 // indirect
291291
golang.org/x/text v0.33.0 // indirect
292292
golang.org/x/time v0.14.0 // indirect
293293
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect

0 commit comments

Comments
 (0)