Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go generate a mermaid flowchart for org modules #11467

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ goreleaser-dev-build: ## Run goreleaser snapshot build
goreleaser-dev-release: ## run goreleaser snapshot release
./tools/bin/goreleaser_wrapper release --snapshot --rm-dist --config ${GORELEASER_CONFIG}

.PHONY: modgraph
modgraph:
./tools/bin/modgraph > go.md

help:
@echo ""
@echo " .__ .__ .__ .__ __"
Expand Down
65 changes: 65 additions & 0 deletions go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# smartcontractkit Go modules
```mermaid
flowchart LR
subgraph chains
chainlink-cosmos
chainlink-evm
chainlink-solana
chainlink-starknet/relayer
end

subgraph products
chainlink-automation
chainlink-ccip
chainlink-data-streams
chainlink-feeds
chainlink-functions
chainlink-vrf
end

classDef outline stroke-dasharray:6,fill:none;
class chains,products outline

chainlink/v2 --> caigo
click caigo href "https://github.com/smartcontractkit/caigo"
chainlink/v2 --> chainlink-automation
click chainlink-automation href "https://github.com/smartcontractkit/chainlink-automation"
chainlink/v2 --> chainlink-common
click chainlink-common href "https://github.com/smartcontractkit/chainlink-common"
chainlink/v2 --> chainlink-cosmos
click chainlink-cosmos href "https://github.com/smartcontractkit/chainlink-cosmos"
chainlink/v2 --> chainlink-data-streams
click chainlink-data-streams href "https://github.com/smartcontractkit/chainlink-data-streams"
chainlink/v2 --> chainlink-feeds
click chainlink-feeds href "https://github.com/smartcontractkit/chainlink-feeds"
chainlink/v2 --> chainlink-solana
click chainlink-solana href "https://github.com/smartcontractkit/chainlink-solana"
chainlink/v2 --> chainlink-starknet/relayer
click chainlink-starknet/relayer href "https://github.com/smartcontractkit/chainlink-starknet"
chainlink/v2 --> chainlink-vrf
click chainlink-vrf href "https://github.com/smartcontractkit/chainlink-vrf"
chainlink/v2 --> libocr
click libocr href "https://github.com/smartcontractkit/libocr"
chainlink/v2 --> tdh2/go/ocr2/decryptionplugin
click tdh2/go/ocr2/decryptionplugin href "https://github.com/smartcontractkit/tdh2"
chainlink/v2 --> tdh2/go/tdh2
click tdh2/go/tdh2 href "https://github.com/smartcontractkit/tdh2"
chainlink/v2 --> wsrpc
click wsrpc href "https://github.com/smartcontractkit/wsrpc"
chainlink-automation --> libocr
chainlink-common --> libocr
chainlink-cosmos --> chainlink-common
chainlink-cosmos --> libocr
chainlink-data-streams --> chainlink-common
chainlink-data-streams --> libocr
chainlink-feeds --> chainlink-common
chainlink-feeds --> libocr
chainlink-solana --> chainlink-common
chainlink-solana --> libocr
chainlink-starknet/relayer --> caigo
chainlink-starknet/relayer --> chainlink-common
chainlink-starknet/relayer --> libocr
chainlink-vrf --> libocr
tdh2/go/ocr2/decryptionplugin --> libocr
tdh2/go/ocr2/decryptionplugin --> tdh2/go/tdh2
```
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core"
)

//go:generate make modgraph
func main() {
os.Exit(core.Main())
}
46 changes: 46 additions & 0 deletions tools/bin/modgraph
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a sort in here too, which produced a slightly better image, but which was not portable for some reason. My local standard ubuntu install treats / and - as interchangable, and so lists chainlink-vrf after chainlin/v2. CI standard ubuntu doesn't make this mistake. I just removed it so this wasn't blocked, but it would be nice to restore that behavior.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

# Generates go.md

set -e

echo "# smartcontractkit Go modules
\`\`\`mermaid
flowchart LR
subgraph chains
chainlink-cosmos
chainlink-evm
chainlink-solana
chainlink-starknet/relayer
end

subgraph products
chainlink-automation
chainlink-ccip
chainlink-data-streams
chainlink-feeds
chainlink-functions
chainlink-vrf
end

classDef outline stroke-dasharray:6,fill:none;
class chains,products outline
"
go mod graph | \
# org only
grep smartcontractkit.*smartcontractkit | \
# drop prefix
sed s/"github\.com\/smartcontractkit\/"/""/g | \
# insert edges
sed s/" "/" --> "/ | \
# drop versions
sed s/"@[^ ]*"/""/g | \
# insert links
sed s/"\([^ ]*\)$"/"\1\nclick \1 href \"https:\/\/github.com\/smartcontractkit\/\1\""/ | \
# truncate links to repo
sed s/"\"https:\/\/github.com\/smartcontractkit\/\([^\"\/]*\)\/.*\""/"\"https:\/\/github.com\/smartcontractkit\/\1\""/ | \
# dedupe lines
awk '!x[$0]++' | \
# indent
sed 's/^/ /'
echo "\`\`\`"
Loading