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

feat(gno.land/cmd): auto load and sort pkgs from examples #763

Merged
merged 30 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
75d1ed5
feat: add gno.mod to each package
harry-hov Apr 19, 2023
42dafe6
feat: add logic to load and sort gno pkgs
harry-hov Apr 19, 2023
54b8ffa
feat(gno.land/cmd): auto load pkgs from examples
harry-hov Apr 21, 2023
20d4866
fix failing tests
harry-hov Apr 21, 2023
68fe2f9
Use more concise if statement
harry-hov Apr 29, 2023
10330b5
Move pkg loading and sorting logic to gnomod
harry-hov Apr 29, 2023
d296ad5
Merge branch 'master' into hariom/load-pkgs
harry-hov Apr 29, 2023
a3e978a
Fix review comments
harry-hov May 2, 2023
fb56382
Fix gno.mod files
harry-hov May 3, 2023
312236f
Extract visit() as named func
harry-hov May 4, 2023
2d222e0
Merge branch 'master' into hariom/load-pkgs
harry-hov May 4, 2023
527c78d
Skip draft or depends on draft
harry-hov May 4, 2023
df872c0
s/v0.0.0/v0.0.0-latest
harry-hov May 15, 2023
875bf62
Merge branch 'master' into hariom/load-pkgs
harry-hov May 15, 2023
4ca9e02
Merge branch 'master' into hariom/load-pkgs
harry-hov May 16, 2023
875da90
Fix `ListPkgs()`
harry-hov May 22, 2023
9282dba
Test `ListPkgs()`
harry-hov May 22, 2023
2a7391e
Merge branch 'master' into hariom/load-pkgs
harry-hov May 22, 2023
69ead49
oversight: remove print statement
harry-hov May 22, 2023
ee268b8
Export `Pkg` and add field `draft`
harry-hov May 24, 2023
6eb4e7a
Refactor and improvements
harry-hov May 24, 2023
72d7f2d
Merge branch 'master' into hariom/load-pkgs
harry-hov May 24, 2023
2fa5e09
make fmt
harry-hov May 24, 2023
c474363
Merge branch 'master' into hariom/load-pkgs
harry-hov May 25, 2023
ea7a6f6
Merge branch 'master' into hariom/load-pkgs
harry-hov May 26, 2023
84d13a3
Merge branch 'master' into hariom/load-pkgs
harry-hov Jun 14, 2023
2fb5408
ListPkgs(): don't skip nested pkgs
harry-hov Jun 16, 2023
4c39033
Add gno.mod files to `tests/subtests`
harry-hov Jun 16, 2023
a0bbcf9
No need to subtests manually
harry-hov Jun 16, 2023
5619816
Merge branch 'master' into hariom/load-pkgs
harry-hov Jun 16, 2023
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
6 changes: 6 additions & 0 deletions examples/gno.land/p/demo/acl/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/p/demo/acl

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/testutils" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/avl/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/avl
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/bank/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/bank
6 changes: 6 additions & 0 deletions examples/gno.land/p/demo/blog/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/p/demo/blog

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
)
5 changes: 5 additions & 0 deletions examples/gno.land/p/demo/dom/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/p/demo/dom

require (
"gno.land/p/demo/avl" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/flow/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module "gno.land/p/demo/flow"
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/gnode/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module "gno.land/p/demo/gnode"
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/grc/exts/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/grc/exts
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/grc/grc1155/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/p/demo/grc/grc1155

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/grc/grc20/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/p/demo/grc/grc20

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
"gno.land/p/demo/grc/exts" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/grc/grc721/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/p/demo/grc/grc721

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
)
5 changes: 5 additions & 0 deletions examples/gno.land/p/demo/grc/grc777/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/p/demo/grc/grc777

require (
"gno.land/p/demo/grc/exts" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/groups/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/p/demo/groups

require (
"gno.land/r/demo/boards" v0.0.0-latest
"gno.land/p/demo/maths" v0.0.0-latest
"gno.land/p/demo/testutils" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/maths/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/maths
3 changes: 3 additions & 0 deletions examples/gno.land/p/demo/rand/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Draft

module gno.land/p/demo/rand
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/releases/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/releases
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/stack/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/stack
6 changes: 6 additions & 0 deletions examples/gno.land/p/demo/tests/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/p/demo/tests

require (
"gno.land/p/demo/tests/subtests" v0.0.0-latest
"gno.land/r/demo/tests" v0.0.0-latest
)
4 changes: 4 additions & 0 deletions examples/gno.land/p/demo/tests/subtests/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module gno.land/p/demo/tests/subtests

// TODO: this file should not exist.
// This is a temporary workaround. Until https://github.com/gnolang/gno/issues/852
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/testutils/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/testutils
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/ufmt/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/ufmt
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/art/gnoface/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/art/gnoface

require (
"gno.land/p/demo/rand" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
)
5 changes: 5 additions & 0 deletions examples/gno.land/r/demo/art/millipede/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/demo/art/millipede

require (
"gno.land/p/demo/ufmt" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/banktest/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/banktest
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/boards/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/boards

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/deep/very/deep/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/deep/very/deep
7 changes: 7 additions & 0 deletions examples/gno.land/r/demo/foo1155/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/r/demo/foo1155

require (
"gno.land/p/demo/ufmt" v0.0.0-latest
"gno.land/p/demo/grc/grc1155" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions examples/gno.land/r/demo/foo20/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/r/demo/foo20

require (
"gno.land/p/demo/ufmt" v0.0.0-latest
"gno.land/p/demo/grc/grc20" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions examples/gno.land/r/demo/foo721/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/r/demo/foo721

require (
"gno.land/p/demo/ufmt" v0.0.0-latest
"gno.land/p/demo/grc/grc721" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
)
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/groups/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/groups

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/markdown_test/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/markdown_test
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/nft/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/nft

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/grc/grc721" v0.0.0-latest
)
5 changes: 5 additions & 0 deletions examples/gno.land/r/demo/releases_example/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/demo/releases_example

require (
"gno.land/p/demo/releases" v0.0.0-latest
)
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/tests/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/tests

require (
"gno.land/p/demo/testutils" v0.0.0-latest
"gno.land/r/demo/tests/subtests" v0.0.0-latest
)
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/tests/subtests/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module gno.land/r/demo/tests/subtests

// TODO: this file should not exist.
// This is a temporary workaround. Until https://github.com/gnolang/gno/issues/852
5 changes: 5 additions & 0 deletions examples/gno.land/r/demo/tests_foo/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/demo/tests_foo

require (
"gno.land/r/demo/tests" v0.0.0-latest
)
5 changes: 5 additions & 0 deletions examples/gno.land/r/demo/types/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/demo/types

require (
"gno.land/p/demo/avl" v0.0.0-latest
)
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/users/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/users

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/testutils" v0.0.0-latest
)
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/x/outfmt/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/demo/x/outfmt

require (
"gno.land/p/demo/rand" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
)
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/x/upgrade/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Draft

module gno.land/r/demo/x/upgrade
6 changes: 6 additions & 0 deletions examples/gno.land/r/gnoland/blog/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module gno.land/r/gnoland/blog

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/blog" v0.0.0-latest
)
7 changes: 7 additions & 0 deletions examples/gno.land/r/gnoland/faucet/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gno.land/r/gnoland/faucet

require (
"gno.land/p/demo/avl" v0.0.0-latest
"gno.land/p/demo/testutils" v0.0.0-latest
"gno.land/p/demo/ufmt" v0.0.0-latest
harry-hov marked this conversation as resolved.
Show resolved Hide resolved
)
5 changes: 5 additions & 0 deletions examples/gno.land/r/system/names/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module gno.land/r/system/names

require (
"gno.land/p/demo/avl" v0.0.0-latest
)
1 change: 1 addition & 0 deletions examples/gno.land/r/system/rewards/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/system/rewards
1 change: 1 addition & 0 deletions examples/gno.land/r/system/validators/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/system/validators
45 changes: 19 additions & 26 deletions gno.land/cmd/gnoland/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/gnolang/gno/gno.land/pkg/gnoland"
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/pkg/gnomod"
"github.com/gnolang/gno/tm2/pkg/amino"
abci "github.com/gnolang/gno/tm2/pkg/bft/abci/types"
"github.com/gnolang/gno/tm2/pkg/bft/config"
Expand Down Expand Up @@ -228,33 +229,25 @@ func makeGenesisDoc(
// Load initial packages from examples.
test1 := crypto.MustAddressFromString("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5")
txs := []std.Tx{}
for _, path := range []string{
"p/demo/ufmt",
"p/demo/avl",
"p/demo/grc/exts",
"p/demo/grc/grc20",
"p/demo/grc/grc721",
"p/demo/grc/grc1155",
"p/demo/maths",
"p/demo/blog",
"r/demo/users",
"r/demo/foo20",
"r/demo/foo1155",
"r/demo/boards",
"r/demo/banktest",
"r/demo/types",
"r/demo/markdown_test",
"r/gnoland/blog",
"r/gnoland/faucet",
"r/system/validators",
"r/system/names",
"r/system/rewards",
"r/demo/deep/very/deep",
} {

// List initial packages to load from examples.
pkgs, err := gnomod.ListPkgs(filepath.Join("..", "examples"))
if err != nil {
panic(fmt.Errorf("listing gno packages: %w", err))
}

// Sort packages by dependencies.
sortedPkgs, err := pkgs.Sort()
if err != nil {
panic(fmt.Errorf("sorting packages: %w", err))
}

// Filter out draft packages.
nonDraftPkgs := sortedPkgs.GetNonDraftPkgs()

for _, pkg := range nonDraftPkgs {
// open files in directory as MemPackage.
fsPath := filepath.Join("..", "examples", "gno.land", path)
importPath := "gno.land/" + path
memPkg := gno.ReadMemPackage(fsPath, importPath)
memPkg := gno.ReadMemPackage(pkg.Path(), pkg.Name())
var tx std.Tx
tx.Msgs = []std.Msg{
vmm.MsgAddPackage{
Expand Down
Loading