From b11cb5f95bc17aad9af42174c5f14d021461589b Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:34:11 -0700 Subject: [PATCH 01/16] Move and refactor scaffold logic --- internal/super/scaffolds.go | 159 ++++++++++++++++++++++++++++++++++++ internal/super/setup.go | 139 ++----------------------------- 2 files changed, 168 insertions(+), 130 deletions(-) create mode 100644 internal/super/scaffolds.go diff --git a/internal/super/scaffolds.go b/internal/super/scaffolds.go new file mode 100644 index 000000000..08bd2944f --- /dev/null +++ b/internal/super/scaffolds.go @@ -0,0 +1,159 @@ +/* + * Flow CLI + * + * Copyright 2019 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package super + +import ( + "encoding/json" + "fmt" + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing" + "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/output" + "io" + "net/http" + "os" + "path/filepath" + "time" +) + +const scaffoldListURL = "https://raw.githubusercontent.com/onflow/flow-cli/master/scaffolds.json" + +type scaffold struct { + Repo string `json:"repo"` + Branch string `json:"branch"` + Name string `json:"name"` + Description string `json:"description"` + Commit string `json:"commit"` + Folder string `json:"folder"` + Type string `json:"type"` +} + +func selectScaffold(logger output.Logger) (*scaffold, error) { + scaffolds, err := getScaffolds() + if err != nil { + return nil, err + } + + // default to first scaffold - basic scaffold + pickedScaffold := scaffolds[0] + + if setupFlags.ScaffoldID != 0 { + if setupFlags.ScaffoldID > len(scaffolds) { + return nil, fmt.Errorf("scaffold with id %d does not exist", setupFlags.ScaffoldID) + } + pickedScaffold = scaffolds[setupFlags.ScaffoldID-1] + } + + if setupFlags.Scaffold { + scaffoldItems := make([]util.ScaffoldItem, 0) + for i, s := range scaffolds { + scaffoldItems = append( + scaffoldItems, + util.ScaffoldItem{ + Index: i, + Title: fmt.Sprintf("%s - %s", output.Bold(s.Name), s.Description), + Category: s.Type, + }, + ) + } + + selected := util.ScaffoldPrompt(logger, scaffoldItems) + pickedScaffold = scaffolds[selected] + } + + return &pickedScaffold, nil +} + +func getScaffolds() ([]scaffold, error) { + httpClient := http.Client{ + Timeout: time.Second * 5, + } + + req, err := http.NewRequest(http.MethodGet, scaffoldListURL, nil) + if err != nil { + return nil, fmt.Errorf("failed creating request for scaffold list: %w", err) + } + + res, err := httpClient.Do(req) + if err != nil { + return nil, fmt.Errorf("failed requesting scaffold list: %w", err) + } + if res.Body != nil { + defer res.Body.Close() + } + + body, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("failed reading scaffold list response: %w", err) + } + + var all []scaffold + err = json.Unmarshal(body, &all) + if err != nil { + return nil, fmt.Errorf("failed parsing scaffold list response: %w", err) + } + + valid := make([]scaffold, 0) + for _, s := range all { + if s.Repo != "" && s.Description != "" && s.Name != "" && s.Commit != "" { + valid = append(valid, s) + } + } + + return valid, nil +} + +func cloneScaffold(targetDir string, conf scaffold) error { + repo, err := git.PlainClone(targetDir, false, &git.CloneOptions{ + URL: conf.Repo, + }) + if err != nil { + return fmt.Errorf("could not download the scaffold: %w", err) + } + + worktree, _ := repo.Worktree() + err = worktree.Checkout(&git.CheckoutOptions{ + Hash: plumbing.NewHash(conf.Commit), + Force: true, + }) + if err != nil { + return fmt.Errorf("could not find the scaffold version") + } + + // if we defined a folder remove everything else + if conf.Folder != "" { + err = os.Rename( + filepath.Join(targetDir, conf.Folder), + filepath.Join(targetDir, "../scaffold-temp"), + ) + if err != nil { + return err + } + + if err = os.RemoveAll(targetDir); err != nil { + return err + } + + if err = os.Rename(filepath.Join(targetDir, "../scaffold-temp"), targetDir); err != nil { + return err + } + } + + return os.RemoveAll(filepath.Join(targetDir, ".git")) +} diff --git a/internal/super/setup.go b/internal/super/setup.go index b44daa6dc..2fa1b991e 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -20,23 +20,16 @@ package super import ( "bytes" - "encoding/json" "fmt" + "github.com/spf13/cobra" "io" - "net/http" "os" "path/filepath" - "time" - - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing" - "github.com/spf13/cobra" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" ) type flagsSetup struct { @@ -58,18 +51,6 @@ var SetupCommand = &command.Command{ Run: create, } -const scaffoldListURL = "https://raw.githubusercontent.com/onflow/flow-cli/master/scaffolds.json" - -type scaffold struct { - Repo string `json:"repo"` - Branch string `json:"branch"` - Name string `json:"name"` - Description string `json:"description"` - Commit string `json:"commit"` - Folder string `json:"folder"` - Type string `json:"type"` -} - func create( args []string, _ command.GlobalFlags, @@ -82,43 +63,19 @@ func create( return nil, err } - scaffolds, err := getScaffolds() + selectedScaffold, err := selectScaffold(logger) if err != nil { - return nil, err - } - - // default to first scaffold - basic scaffold - pickedScaffold := scaffolds[0] - - if setupFlags.ScaffoldID != 0 { - if setupFlags.ScaffoldID > len(scaffolds) { - return nil, fmt.Errorf("scaffold with id %d does not exist", setupFlags.ScaffoldID) - } - pickedScaffold = scaffolds[setupFlags.ScaffoldID-1] - } - - if setupFlags.Scaffold { - scaffoldItems := make([]util.ScaffoldItem, 0) - for i, s := range scaffolds { - scaffoldItems = append( - scaffoldItems, - util.ScaffoldItem{ - Index: i, - Title: fmt.Sprintf("%s - %s", output.Bold(s.Name), s.Description), - Category: s.Type, - }, - ) - } - - selected := util.ScaffoldPrompt(logger, scaffoldItems) - pickedScaffold = scaffolds[selected] + return nil, fmt.Errorf("error selecting scaffold %w", err) } logger.StartProgress(fmt.Sprintf("Creating your project %s", targetDir)) defer logger.StopProgress() - err = cloneScaffold(targetDir, pickedScaffold) - if err != nil { - return nil, fmt.Errorf("failed creating scaffold %w", err) + + if selectedScaffold != nil { + err = cloneScaffold(targetDir, *selectedScaffold) + if err != nil { + return nil, fmt.Errorf("failed creating scaffold %w", err) + } } return &setupResult{targetDir: targetDir}, nil @@ -151,84 +108,6 @@ func getTargetDirectory(directory string) (string, error) { return target, nil } -func getScaffolds() ([]scaffold, error) { - httpClient := http.Client{ - Timeout: time.Second * 5, - } - - req, err := http.NewRequest(http.MethodGet, scaffoldListURL, nil) - if err != nil { - return nil, fmt.Errorf("failed creating request for scaffold list: %w", err) - } - - res, err := httpClient.Do(req) - if err != nil { - return nil, fmt.Errorf("failed requesting scaffold list: %w", err) - } - if res.Body != nil { - defer res.Body.Close() - } - - body, err := io.ReadAll(res.Body) - if err != nil { - return nil, fmt.Errorf("failed reading scaffold list response: %w", err) - } - - var all []scaffold - err = json.Unmarshal(body, &all) - if err != nil { - return nil, fmt.Errorf("failed parsing scaffold list response: %w", err) - } - - valid := make([]scaffold, 0) - for _, s := range all { - if s.Repo != "" && s.Description != "" && s.Name != "" && s.Commit != "" { - valid = append(valid, s) - } - } - - return valid, nil -} - -func cloneScaffold(targetDir string, conf scaffold) error { - repo, err := git.PlainClone(targetDir, false, &git.CloneOptions{ - URL: conf.Repo, - }) - if err != nil { - return fmt.Errorf("could not download the scaffold: %w", err) - } - - worktree, _ := repo.Worktree() - err = worktree.Checkout(&git.CheckoutOptions{ - Hash: plumbing.NewHash(conf.Commit), - Force: true, - }) - if err != nil { - return fmt.Errorf("could not find the scaffold version") - } - - // if we defined a folder remove everything else - if conf.Folder != "" { - err = os.Rename( - filepath.Join(targetDir, conf.Folder), - filepath.Join(targetDir, "../scaffold-temp"), - ) - if err != nil { - return err - } - - if err = os.RemoveAll(targetDir); err != nil { - return err - } - - if err = os.Rename(filepath.Join(targetDir, "../scaffold-temp"), targetDir); err != nil { - return err - } - } - - return os.RemoveAll(filepath.Join(targetDir, ".git")) -} - type setupResult struct { targetDir string } From 813d1a6c7a3095656341586cbb0928c31e0e24de Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:06:26 -0700 Subject: [PATCH 02/16] Refactor init config function to be separate from command --- internal/config/init.go | 66 ++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/internal/config/init.go b/internal/config/init.go index 68dda9f0c..16642f39a 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -52,23 +52,27 @@ var initCommand = &command.Command{ Run: Initialise, } -func Initialise( - _ []string, - _ command.GlobalFlags, - logger output.Logger, - readerWriter flowkit.ReaderWriter, - _ flowkit.Services, -) (command.Result, error) { +// InitConfigParameters holds all necessary parameters for initializing the configuration. +type InitConfigParameters struct { + ServicePrivateKey string + ServiceKeySigAlgo string + ServiceKeyHashAlgo string + Reset bool + Global bool +} + +// InitializeConfiguration creates the Flow configuration json file based on the provided parameters. +func InitializeConfiguration(params InitConfigParameters, logger output.Logger, readerWriter flowkit.ReaderWriter) (*flowkit.State, error) { logger.Info("⚠️Notice: for starting a new project prefer using 'flow setup'.") - sigAlgo := crypto.StringToSignatureAlgorithm(InitFlag.ServiceKeySigAlgo) + sigAlgo := crypto.StringToSignatureAlgorithm(params.ServiceKeySigAlgo) if sigAlgo == crypto.UnknownSignatureAlgorithm { - return nil, fmt.Errorf("invalid signature algorithm: %s", InitFlag.ServiceKeySigAlgo) + return nil, fmt.Errorf("invalid signature algorithm: %s", params.ServiceKeySigAlgo) } - hashAlgo := crypto.StringToHashAlgorithm(InitFlag.ServiceKeyHashAlgo) + hashAlgo := crypto.StringToHashAlgorithm(params.ServiceKeyHashAlgo) if hashAlgo == crypto.UnknownHashAlgorithm { - return nil, fmt.Errorf("invalid hash algorithm: %s", InitFlag.ServiceKeyHashAlgo) + return nil, fmt.Errorf("invalid hash algorithm: %s", params.ServiceKeyHashAlgo) } state, err := flowkit.Init(readerWriter, sigAlgo, hashAlgo) @@ -76,8 +80,8 @@ func Initialise( return nil, err } - if InitFlag.ServicePrivateKey != "" { - privateKey, err := crypto.DecodePrivateKeyHex(sigAlgo, InitFlag.ServicePrivateKey) + if params.ServicePrivateKey != "" { + privateKey, err := crypto.DecodePrivateKeyHex(sigAlgo, params.ServicePrivateKey) if err != nil { return nil, fmt.Errorf("invalid private key: %w", err) } @@ -86,11 +90,11 @@ func Initialise( } path := config.DefaultPath - if InitFlag.Global { + if params.Global { path = config.GlobalPath() } - if config.Exists(path) && !InitFlag.Reset { + if config.Exists(path) && !params.Reset { return nil, fmt.Errorf( "configuration already exists at: %s, if you want to reset configuration use the reset flag", path, @@ -102,18 +106,40 @@ func Initialise( return nil, err } - return &initResult{State: state}, nil + return state, nil +} + +func Initialise( + _ []string, + _ command.GlobalFlags, + logger output.Logger, + readerWriter flowkit.ReaderWriter, + _ flowkit.Services, +) (command.Result, error) { + params := InitConfigParameters{ + ServicePrivateKey: InitFlag.ServicePrivateKey, + ServiceKeySigAlgo: InitFlag.ServiceKeySigAlgo, + ServiceKeyHashAlgo: InitFlag.ServiceKeyHashAlgo, + Reset: InitFlag.Reset, + Global: InitFlag.Global, + } + state, err := InitializeConfiguration(params, logger, readerWriter) + if err != nil { + return nil, err + } + + return &InitResult{State: state}, nil } -type initResult struct { +type InitResult struct { *flowkit.State } -func (r *initResult) JSON() any { +func (r *InitResult) JSON() any { return r } -func (r *initResult) String() string { +func (r *InitResult) String() string { var b bytes.Buffer writer := util.CreateTabWriter(&b) account, _ := r.State.EmulatorServiceAccount() @@ -130,6 +156,6 @@ func (r *initResult) String() string { return b.String() } -func (r *initResult) Oneliner() string { +func (r *InitResult) Oneliner() string { return "" } From 77ee31e6334311d5eddd64ace09eeb30f7c01e4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:03:12 +0000 Subject: [PATCH 03/16] Bump google.golang.org/grpc from 1.62.1 to 1.63.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.62.1 to 1.63.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.62.1...v1.63.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 35 ++++++++++++++------------ go.sum | 77 ++++++++++++++++++++++++++++++---------------------------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/go.mod b/go.mod index 7d65ce5f3..365a11a8c 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/onflow/flixkit-go v1.1.2 github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f github.com/onflow/flow-emulator v0.61.1 + github.com/onflow/flow-go v0.33.2-0.20240306234901-64ab8d27ea30 github.com/onflow/flow-go-sdk v0.46.0 github.com/onflow/flowkit v1.17.1 github.com/onflowser/flowser/v3 v3.1.3 @@ -31,14 +32,14 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 golang.org/x/exp v0.0.0-20240119083558-1b970713d09a - google.golang.org/grpc v1.62.1 + google.golang.org/grpc v1.63.0 ) require ( - cloud.google.com/go/compute v1.23.3 // indirect + cloud.google.com/go/compute v1.24.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.5 // indirect - cloud.google.com/go/kms v1.15.5 // indirect + cloud.google.com/go/iam v1.1.6 // indirect + cloud.google.com/go/kms v1.15.7 // indirect dario.cat/mergo v1.0.0 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect @@ -83,6 +84,7 @@ require ( github.com/emirpasic/gods v1.18.1 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect github.com/ethereum/go-ethereum v1.13.5 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect @@ -102,7 +104,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/go-dap v0.11.0 // indirect github.com/google/go-github v17.0.0+incompatible // indirect @@ -180,7 +182,6 @@ require ( github.com/onflow/flow-cli/flowkit v1.11.0 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect - github.com/onflow/flow-go v0.33.2-0.20240306234901-64ab8d27ea30 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect github.com/onflow/flow/protobuf/go/flow v0.3.7 // indirect github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect @@ -230,6 +231,8 @@ require ( github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/zeebo/blake3 v0.2.3 // indirect go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect go.opentelemetry.io/otel v1.22.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect @@ -240,23 +243,23 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.18.0 // indirect + golang.org/x/crypto v0.19.0 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.3.0 // indirect + golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.17.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gonum.org/v1/gonum v0.14.0 // indirect - google.golang.org/api v0.151.0 // indirect + google.golang.org/api v0.162.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/protobuf v1.32.0 // indirect + google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 9e76eb63d..bc7fd3b42 100644 --- a/go.sum +++ b/go.sum @@ -34,17 +34,17 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= -cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= +cloud.google.com/go/compute v1.24.0 h1:phWcR2eWzRJaL/kOiJwfFsPs4BaKq1j6vnpZrc1YlVg= +cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI= -cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= +cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc= +cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= cloud.google.com/go/kms v1.0.0/go.mod h1:nhUehi+w7zht2XrUfvTRNpxrfayBHqP4lu2NSywui/0= -cloud.google.com/go/kms v1.15.5 h1:pj1sRfut2eRbD9pFRjNnPNg/CzJPuQAzUujMIM1vVeM= -cloud.google.com/go/kms v1.15.5/go.mod h1:cU2H5jnp6G2TDpUGZyqTCoy1n16fbubHZjmVXSMtwDI= +cloud.google.com/go/kms v1.15.7 h1:7caV9K3yIxvlQPAcaFffhlT7d1qpxjB1wHBtjWa13SM= +cloud.google.com/go/kms v1.15.7/go.mod h1:ub54lbsa6tDkUwnu4W7Yt1aAIFLnspgh0kPGToDukeI= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -194,6 +194,7 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= @@ -206,7 +207,6 @@ github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvD github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= @@ -296,6 +296,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= @@ -307,6 +308,8 @@ github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= @@ -457,8 +460,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -670,7 +673,6 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -726,7 +728,6 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= @@ -833,7 +834,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= @@ -1195,7 +1195,6 @@ github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0 github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM= github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= @@ -1238,6 +1237,10 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 h1:UNQQKPfTDe1J81ViolILjTKPr9WetKW6uei2hFgJmFs= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0/go.mod h1:r9vWsPS/3AQItv3OSlEJ/E4mbrhUbbw18meOjArPtKQ= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 h1:sv9kVfal0MK0wBMCOGr+HeJm9v803BkJxGrk2au7j08= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0/go.mod h1:SK2UL73Zy1quvRPonmOmRDiWk1KBV3LyIeeIxcEApWw= go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= @@ -1300,8 +1303,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1405,8 +1408,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1422,8 +1425,8 @@ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1541,15 +1544,15 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1570,8 +1573,8 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1686,8 +1689,8 @@ google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.58.0/go.mod h1:cAbP2FsxoGVNwtgNAmmn3y5G1TWAiVYRmg4yku3lv+E= -google.golang.org/api v0.151.0 h1:FhfXLO/NFdJIzQtCqjpysWwqKk8AzGWBUhMIx67cVDU= -google.golang.org/api v0.151.0/go.mod h1:ccy+MJ6nrYFgE3WgRx/AMXOxOmU8Q4hSa+jjibzhxcg= +google.golang.org/api v0.162.0 h1:Vhs54HkaEpkMBdgGdOT2P6F0csGG/vxDS0hWHJzmmps= +google.golang.org/api v0.162.0/go.mod h1:6SulDkfoBIg4NFmCuZ39XeeAgSHCPecfSUuDyYlAHs0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1763,13 +1766,13 @@ google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211007155348-82e027067bd4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 h1:KAeGQVN3M9nD0/bQXnr/ClcEMJ968gUXJQ9pwfSynuQ= -google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= -google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 h1:Lj5rbfG876hIAYFjqiJnPHfhXbv+nzTWfm04Fg/XSVU= -google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= -google.golang.org/genproto/googleapis/bytestream v0.0.0-20231030173426-d783a09b4405 h1:o4S3HvTUEXgRsNSUQsALDVog0O9F/U1JJlHmmUN8Uas= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= +google.golang.org/genproto/googleapis/bytestream v0.0.0-20240125205218-1f4bbc51befe h1:weYsP+dNijSQVoLAb5bpUos3ciBpNU/NEVlHFKrk8pg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1802,8 +1805,8 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= +google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1818,8 +1821,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From fe4b4e223a6af738dbd3669e6779a805b4eb4e09 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:45:21 -0700 Subject: [PATCH 04/16] Create init in setup --- internal/config/init.go | 22 ++++++++++++++++++---- internal/super/setup.go | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/internal/config/init.go b/internal/config/init.go index 16642f39a..651803e87 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -21,9 +21,9 @@ package config import ( "bytes" "fmt" - "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" + "os" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" @@ -59,6 +59,7 @@ type InitConfigParameters struct { ServiceKeyHashAlgo string Reset bool Global bool + TargetDirectory string } // InitializeConfiguration creates the Flow configuration json file based on the provided parameters. @@ -89,9 +90,22 @@ func InitializeConfiguration(params InitConfigParameters, logger output.Logger, state.SetEmulatorKey(privateKey) } - path := config.DefaultPath - if params.Global { - path = config.GlobalPath() + var path string + if params.TargetDirectory != "" { + path = fmt.Sprintf("%s/flow.json", params.TargetDirectory) + + // Create the directory if it doesn't exist + err := state.ReaderWriter().MkdirAll(params.TargetDirectory, os.ModePerm) + if err != nil { + return nil, fmt.Errorf("failed to create target directory: %w", err) + } + } else { + // Otherwise, choose between the default and global paths + if params.Global { + path = config.GlobalPath() + } else { + path = config.DefaultPath + } } if config.Exists(path) && !params.Reset { diff --git a/internal/super/setup.go b/internal/super/setup.go index 2fa1b991e..240f56aec 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -21,6 +21,7 @@ package super import ( "bytes" "fmt" + "github.com/onflow/flow-cli/internal/config" "github.com/spf13/cobra" "io" "os" @@ -33,6 +34,7 @@ import ( ) type flagsSetup struct { + ConfigOnly bool `default:"false" flag:"config-only" info:"Only create a flow.json default config"` Scaffold bool `default:"" flag:"scaffold" info:"Interactively select a provided scaffold for project creation"` ScaffoldID int `default:"" flag:"scaffold-id" info:"Use provided scaffold ID for project creation"` } @@ -55,7 +57,7 @@ func create( args []string, _ command.GlobalFlags, logger output.Logger, - _ flowkit.ReaderWriter, + readerWriter flowkit.ReaderWriter, _ flowkit.Services, ) (command.Result, error) { targetDir, err := getTargetDirectory(args[0]) @@ -63,18 +65,35 @@ func create( return nil, err } - selectedScaffold, err := selectScaffold(logger) - if err != nil { - return nil, fmt.Errorf("error selecting scaffold %w", err) - } + if setupFlags.Scaffold || setupFlags.ScaffoldID != 0 { + selectedScaffold, err := selectScaffold(logger) + if err != nil { + return nil, fmt.Errorf("error selecting scaffold %w", err) + } - logger.StartProgress(fmt.Sprintf("Creating your project %s", targetDir)) - defer logger.StopProgress() + logger.StartProgress(fmt.Sprintf("Creating your project %s", targetDir)) + defer logger.StopProgress() - if selectedScaffold != nil { - err = cloneScaffold(targetDir, *selectedScaffold) + if selectedScaffold != nil { + err = cloneScaffold(targetDir, *selectedScaffold) + if err != nil { + return nil, fmt.Errorf("failed creating scaffold %w", err) + } + } + } else { + + // TODO: Ask for project name if not given + + params := config.InitConfigParameters{ + ServiceKeySigAlgo: "ECDSA_P256", + ServiceKeyHashAlgo: "SHA3_256", + Reset: false, + Global: false, + TargetDirectory: targetDir, + } + _, err := config.InitializeConfiguration(params, logger, readerWriter) if err != nil { - return nil, fmt.Errorf("failed creating scaffold %w", err) + return nil, fmt.Errorf("failed to initialize configuration: %w", err) } } From d094f92583a8d120aa73cf2ec99d478e076cab91 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:21:55 -0700 Subject: [PATCH 05/16] Create test --- internal/super/setup_test.go | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/super/setup_test.go diff --git a/internal/super/setup_test.go b/internal/super/setup_test.go new file mode 100644 index 000000000..7666159a3 --- /dev/null +++ b/internal/super/setup_test.go @@ -0,0 +1,50 @@ +/* + * Flow CLI + * + * Copyright 2019 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package super + +import ( + "fmt" + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/output" + "github.com/stretchr/testify/assert" + "os" + "path/filepath" + "testing" +) + +func TestCreate(t *testing.T) { + logger := output.NewStdoutLogger(output.NoneLog) + _, state, _ := util.TestMocks(t) + + projectName := "foobar" + + // Test project creation + _, err := create([]string{projectName}, command.GlobalFlags{}, logger, state.ReaderWriter(), nil) + assert.NoError(t, err, "Failed to create project") + + // Check project was created in target directory which is in pwd + pwd, err := os.Getwd() + assert.NoError(t, err, "Failed to get working directory") + + target := filepath.Join(pwd, fmt.Sprintf("%s/flow.json", projectName)) + + _, err = state.ReaderWriter().ReadFile(target) + assert.NoError(t, err, "Failed to read generated file") +} From 10c549a649e35e3a4382caba8995877277fc0b1e Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:22:48 -0700 Subject: [PATCH 06/16] Add name prompt --- internal/super/setup.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/internal/super/setup.go b/internal/super/setup.go index 240f56aec..5d52d625d 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -22,6 +22,7 @@ import ( "bytes" "fmt" "github.com/onflow/flow-cli/internal/config" + "github.com/onflow/flow-cli/internal/util" "github.com/spf13/cobra" "io" "os" @@ -46,7 +47,7 @@ var SetupCommand = &command.Command{ Use: "setup ", Short: "Start a new Flow project", Example: "flow setup my-project", - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), GroupID: "super", }, Flags: &setupFlags, @@ -60,12 +61,15 @@ func create( readerWriter flowkit.ReaderWriter, _ flowkit.Services, ) (command.Result, error) { - targetDir, err := getTargetDirectory(args[0]) - if err != nil { - return nil, err - } + var targetDir string + var err error if setupFlags.Scaffold || setupFlags.ScaffoldID != 0 { + targetDir, err = getTargetDirectory(args[0]) + if err != nil { + return nil, err + } + selectedScaffold, err := selectScaffold(logger) if err != nil { return nil, fmt.Errorf("error selecting scaffold %w", err) @@ -81,8 +85,19 @@ func create( } } } else { - - // TODO: Ask for project name if not given + // Ask for project name if not given + if len(args) < 1 { + name := util.NamePrompt() + targetDir, err = getTargetDirectory(name) + if err != nil { + return nil, err + } + } else { + targetDir, err = getTargetDirectory(args[0]) + if err != nil { + return nil, err + } + } params := config.InitConfigParameters{ ServiceKeySigAlgo: "ECDSA_P256", From c9380a4315ff1ee9a2f8a6fdd8d4822043bae6ce Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:19:49 -0700 Subject: [PATCH 07/16] Refactor to take directory as arg --- internal/super/generate.go | 12 +++++++----- internal/super/generate_test.go | 23 ++++++++++------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index ae077220e..87962f347 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -102,7 +102,7 @@ func generateContract( flow flowkit.Services, state *flowkit.State, ) (result command.Result, err error) { - return generateNew(args, "contract", logger, state) + return generateNew(args, "contract", generateFlags.Directory, logger, state) } func generateTransaction( @@ -112,7 +112,7 @@ func generateTransaction( flow flowkit.Services, state *flowkit.State, ) (result command.Result, err error) { - return generateNew(args, "transaction", logger, state) + return generateNew(args, "transaction", generateFlags.Directory, logger, state) } func generateScript( @@ -122,7 +122,7 @@ func generateScript( flow flowkit.Services, state *flowkit.State, ) (result command.Result, err error) { - return generateNew(args, "script", logger, state) + return generateNew(args, "script", generateFlags.Directory, logger, state) } func addCDCExtension(name string) string { @@ -161,6 +161,7 @@ func processTemplate(templatePath string, data map[string]interface{}) (string, func generateNew( args []string, templateType string, + directory string, logger output.Logger, state *flowkit.State, ) (result command.Result, err error) { @@ -175,8 +176,9 @@ func generateNew( var testFileToWrite string var basePath string - if generateFlags.Directory != "" { - basePath = generateFlags.Directory + if directory != "" { + basePath = directory + fmt.Println("Directory: ", directory) } else { switch templateType { case "contract": diff --git a/internal/super/generate_test.go b/internal/super/generate_test.go index 8a7a37b12..6a6bc470c 100644 --- a/internal/super/generate_test.go +++ b/internal/super/generate_test.go @@ -33,7 +33,7 @@ func TestGenerateNewContract(t *testing.T) { _, state, _ := util.TestMocks(t) // Test contract generation - _, err := generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", "", logger, state) assert.NoError(t, err, "Failed to generate contract") fileContent, err := state.ReaderWriter().ReadFile("cadence/contracts/TestContract.cdc") @@ -68,7 +68,7 @@ access(all) fun testContract() { assert.Equal(t, expectedTestContent, string(testContent)) // Test file already exists scenario - _, err = generateNew([]string{"TestContract"}, "contract", logger, state) + _, err = generateNew([]string{"TestContract"}, "contract", "", logger, state) assert.Error(t, err) assert.Equal(t, "file already exists: cadence/contracts/TestContract.cdc", err.Error()) } @@ -84,7 +84,7 @@ func TestGenerateNewContractSkipTests(t *testing.T) { }) // Test contract generation - _, err := generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", "", logger, state) assert.NoError(t, err, "Failed to generate contract") fileContent, err := state.ReaderWriter().ReadFile("cadence/contracts/TestContract.cdc") @@ -101,7 +101,7 @@ func TestGenerateNewContractWithCDCExtension(t *testing.T) { _, state, _ := util.TestMocks(t) // Test contract generation - _, err := generateNew([]string{"Tester.cdc"}, "contract", logger, state) + _, err := generateNew([]string{"Tester.cdc"}, "contract", "", logger, state) assert.NoError(t, err, "Failed to generate contract") fileContent, err := state.ReaderWriter().ReadFile("cadence/contracts/Tester.cdc") @@ -118,7 +118,7 @@ func TestGenerateNewContractFileAlreadyExists(t *testing.T) { _, state, _ := util.TestMocks(t) // Test contract generation - _, err := generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", "", logger, state) assert.NoError(t, err, "Failed to generate contract") //// Check if the file exists in the correct directory @@ -127,7 +127,7 @@ func TestGenerateNewContractFileAlreadyExists(t *testing.T) { assert.NotNil(t, content) // Test file already exists scenario - _, err = generateNew([]string{"TestContract"}, "contract", logger, state) + _, err = generateNew([]string{"TestContract"}, "contract", "", logger, state) assert.Error(t, err) assert.Equal(t, "file already exists: cadence/contracts/TestContract.cdc", err.Error()) } @@ -136,7 +136,7 @@ func TestGenerateNewContractWithFileExtension(t *testing.T) { logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - _, err := generateNew([]string{"TestContract.cdc"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract.cdc"}, "contract", "", logger, state) assert.NoError(t, err, "Failed to generate contract") // Check file exists @@ -149,7 +149,7 @@ func TestGenerateNewScript(t *testing.T) { logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - _, err := generateNew([]string{"TestScript"}, "script", logger, state) + _, err := generateNew([]string{"TestScript"}, "script", "", logger, state) assert.NoError(t, err, "Failed to generate contract") content, err := state.ReaderWriter().ReadFile("cadence/scripts/TestScript.cdc") @@ -167,7 +167,7 @@ func TestGenerateNewTransaction(t *testing.T) { logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - _, err := generateNew([]string{"TestTransaction"}, "transaction", logger, state) + _, err := generateNew([]string{"TestTransaction"}, "transaction", "", logger, state) assert.NoError(t, err, "Failed to generate contract") content, err := state.ReaderWriter().ReadFile("cadence/transactions/TestTransaction.cdc") @@ -186,10 +186,7 @@ func TestGenerateNewWithDirFlag(t *testing.T) { logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - // Set a custom directory - generateFlags.Directory = "customDir" - - _, err := generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", "customDir", logger, state) assert.NoError(t, err, "Failed to generate contract") content, err := state.ReaderWriter().ReadFile("customDir/TestContract.cdc") From 4843b15394fbb67b1d0f5289fa4a3ebaf0f9aff5 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 13:48:14 -0700 Subject: [PATCH 08/16] Change to fit new definition --- internal/super/setup.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/super/setup.go b/internal/super/setup.go index 5d52d625d..79ebd90e8 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -51,15 +51,15 @@ var SetupCommand = &command.Command{ GroupID: "super", }, Flags: &setupFlags, - Run: create, + RunS: create, } func create( args []string, _ command.GlobalFlags, logger output.Logger, - readerWriter flowkit.ReaderWriter, _ flowkit.Services, + state *flowkit.State, ) (command.Result, error) { var targetDir string var err error @@ -106,7 +106,7 @@ func create( Global: false, TargetDirectory: targetDir, } - _, err := config.InitializeConfiguration(params, logger, readerWriter) + _, err := config.InitializeConfiguration(params, logger, state.ReaderWriter()) if err != nil { return nil, fmt.Errorf("failed to initialize configuration: %w", err) } From 591ecbb1aee00220c0b33ea3c5f31a278a2b3d92 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:07:23 -0700 Subject: [PATCH 09/16] Fix test --- internal/super/setup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/super/setup_test.go b/internal/super/setup_test.go index 7666159a3..761130dcd 100644 --- a/internal/super/setup_test.go +++ b/internal/super/setup_test.go @@ -36,7 +36,7 @@ func TestCreate(t *testing.T) { projectName := "foobar" // Test project creation - _, err := create([]string{projectName}, command.GlobalFlags{}, logger, state.ReaderWriter(), nil) + _, err := create([]string{projectName}, command.GlobalFlags{}, logger, nil, state) assert.NoError(t, err, "Failed to create project") // Check project was created in target directory which is in pwd From 47e5d19f0b4058c143b62a742334fa92d93095ae Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:09:37 -0700 Subject: [PATCH 10/16] Ignore arg --- internal/super/generate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index 87962f347..dd9948afa 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -99,7 +99,7 @@ func generateContract( args []string, _ command.GlobalFlags, logger output.Logger, - flow flowkit.Services, + _ flowkit.Services, state *flowkit.State, ) (result command.Result, err error) { return generateNew(args, "contract", generateFlags.Directory, logger, state) @@ -109,7 +109,7 @@ func generateTransaction( args []string, _ command.GlobalFlags, logger output.Logger, - flow flowkit.Services, + _ flowkit.Services, state *flowkit.State, ) (result command.Result, err error) { return generateNew(args, "transaction", generateFlags.Directory, logger, state) @@ -119,7 +119,7 @@ func generateScript( args []string, _ command.GlobalFlags, logger output.Logger, - flow flowkit.Services, + _ flowkit.Services, state *flowkit.State, ) (result command.Result, err error) { return generateNew(args, "script", generateFlags.Directory, logger, state) From 6c0ff3970f96a614d106352f3343098f74f3fd81 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:15:07 -0700 Subject: [PATCH 11/16] Fix test path --- internal/super/generate.go | 3 ++- internal/super/generate_test.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index dd9948afa..ac5e54877 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -175,9 +175,11 @@ func generateNew( var fileToWrite string var testFileToWrite string var basePath string + var testsBasePath = "cadence/tests" if directory != "" { basePath = directory + testsBasePath = filepath.Join(directory, "tests") fmt.Println("Directory: ", directory) } else { switch templateType { @@ -239,7 +241,6 @@ func generateNew( logger.Info(fmt.Sprintf("Generated new %s: %s at %s", templateType, name, filenameWithBasePath)) if generateFlags.SkipTests != true && templateType == "contract" { - testsBasePath := "cadence/tests" testFilenameWithBasePath := filepath.Join(testsBasePath, addCDCExtension(fmt.Sprintf("%s_test", name))) if _, err := state.ReaderWriter().ReadFile(testFilenameWithBasePath); err == nil { diff --git a/internal/super/generate_test.go b/internal/super/generate_test.go index 6a6bc470c..8ed4ba731 100644 --- a/internal/super/generate_test.go +++ b/internal/super/generate_test.go @@ -193,6 +193,10 @@ func TestGenerateNewWithDirFlag(t *testing.T) { assert.NoError(t, err, "Failed to read generated file") assert.NotNil(t, content) + testContent, err := state.ReaderWriter().ReadFile("customDir/tests/TestContract_test.cdc") + assert.NoError(t, err, "Failed to read generated file") + assert.NotNil(t, testContent) + expectedContent := `access(all) contract TestContract { init() {} From 5bf6499c753b1bf2adaf206b43b55465f2817ab4 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:38:46 -0700 Subject: [PATCH 12/16] Fix generate custom directory logic --- internal/super/generate.go | 35 +++++++++++++++------------------ internal/super/generate_test.go | 2 +- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index ac5e54877..82fd5ff13 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -174,28 +174,21 @@ func generateNew( var fileToWrite string var testFileToWrite string + var rootDir = "cadence" var basePath string - var testsBasePath = "cadence/tests" + var testsBasePath = "tests" if directory != "" { - basePath = directory - testsBasePath = filepath.Join(directory, "tests") - fmt.Println("Directory: ", directory) - } else { - switch templateType { - case "contract": - basePath = "cadence/contracts" - case "script": - basePath = "cadence/scripts" - case "transaction": - basePath = "cadence/transactions" - default: - return nil, fmt.Errorf("invalid template type: %s", templateType) - } + fmt.Println("directory: ", directory) + rootDir = directory + fmt.Println("rootDir in scope: ", rootDir) } + fmt.Println("rootDir: ", rootDir) + switch templateType { case "contract": + basePath = "contracts" nameData := map[string]interface{}{"Name": name} fileToWrite, err = processTemplate("templates/contract_init.cdc.tmpl", nameData) if err != nil { @@ -207,11 +200,13 @@ func generateNew( return nil, fmt.Errorf("error generating contract test template: %w", err) } case "script": + basePath = "scripts" fileToWrite, err = processTemplate("templates/script_init.cdc.tmpl", nil) if err != nil { return nil, fmt.Errorf("error generating script template: %w", err) } case "transaction": + basePath = "transactions" fileToWrite, err = processTemplate("templates/transaction_init.cdc.tmpl", nil) if err != nil { return nil, fmt.Errorf("error generating transaction template: %w", err) @@ -220,7 +215,8 @@ func generateNew( return nil, fmt.Errorf("invalid template type: %s", templateType) } - filenameWithBasePath := filepath.Join(basePath, filename) + directoryWithBasePath := filepath.Join(rootDir, basePath) + filenameWithBasePath := filepath.Join(rootDir, basePath, filename) // Check file existence if _, err := state.ReaderWriter().ReadFile(filenameWithBasePath); err == nil { @@ -228,7 +224,7 @@ func generateNew( } // Ensure the directory exists - if err := state.ReaderWriter().MkdirAll(basePath, 0755); err != nil { + if err := state.ReaderWriter().MkdirAll(directoryWithBasePath, 0755); err != nil { return nil, fmt.Errorf("error creating directories: %w", err) } @@ -241,13 +237,14 @@ func generateNew( logger.Info(fmt.Sprintf("Generated new %s: %s at %s", templateType, name, filenameWithBasePath)) if generateFlags.SkipTests != true && templateType == "contract" { - testFilenameWithBasePath := filepath.Join(testsBasePath, addCDCExtension(fmt.Sprintf("%s_test", name))) + testDirectoryWithBasePath := filepath.Join(rootDir, testsBasePath) + testFilenameWithBasePath := filepath.Join(rootDir, testsBasePath, addCDCExtension(fmt.Sprintf("%s_test", name))) if _, err := state.ReaderWriter().ReadFile(testFilenameWithBasePath); err == nil { return nil, fmt.Errorf("file already exists: %s", testFilenameWithBasePath) } - if err := state.ReaderWriter().MkdirAll(testsBasePath, 0755); err != nil { + if err := state.ReaderWriter().MkdirAll(testDirectoryWithBasePath, 0755); err != nil { return nil, fmt.Errorf("error creating test directory: %w", err) } diff --git a/internal/super/generate_test.go b/internal/super/generate_test.go index 8ed4ba731..c21ef688d 100644 --- a/internal/super/generate_test.go +++ b/internal/super/generate_test.go @@ -189,7 +189,7 @@ func TestGenerateNewWithDirFlag(t *testing.T) { _, err := generateNew([]string{"TestContract"}, "contract", "customDir", logger, state) assert.NoError(t, err, "Failed to generate contract") - content, err := state.ReaderWriter().ReadFile("customDir/TestContract.cdc") + content, err := state.ReaderWriter().ReadFile("customDir/contracts/TestContract.cdc") assert.NoError(t, err, "Failed to read generated file") assert.NotNil(t, content) From 4f46a92f3ac2e82ea9816785c253df121408ea26 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:47:01 -0700 Subject: [PATCH 13/16] Remove prints --- internal/super/generate.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index 82fd5ff13..2dee91770 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -179,13 +179,9 @@ func generateNew( var testsBasePath = "tests" if directory != "" { - fmt.Println("directory: ", directory) rootDir = directory - fmt.Println("rootDir in scope: ", rootDir) } - fmt.Println("rootDir: ", rootDir) - switch templateType { case "contract": basePath = "contracts" From e50fea576d019e2cfb34d618374cf9374f148f83 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:49:15 -0700 Subject: [PATCH 14/16] Generate files for structure --- internal/super/setup.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/super/setup.go b/internal/super/setup.go index 79ebd90e8..d9388442c 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -110,6 +110,30 @@ func create( if err != nil { return nil, fmt.Errorf("failed to initialize configuration: %w", err) } + + // Generate standard cadence files + // cadence/contracts/DefaultContract.cdc + // cadence/scripts/DefaultScript.cdc + // cadence/transactions/DefaultTransaction.cdc + // cadence/tests/DefaultContract_test.cdc + + directoryPath := filepath.Join(targetDir, "cadence") + + _, err = generateNew([]string{"DefaultContract"}, "contract", directoryPath, logger, state) + if err != nil { + return nil, err + } + + _, err = generateNew([]string{"DefaultScript"}, "script", directoryPath, logger, state) + if err != nil { + return nil, err + } + + _, err = generateNew([]string{"DefaultTransaction"}, "transaction", directoryPath, logger, state) + if err != nil { + return nil, err + } + } return &setupResult{targetDir: targetDir}, nil From 360c4d502931ce525eb271ccd2efa83bc4111bf3 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:55:21 -0700 Subject: [PATCH 15/16] Fix imports --- internal/config/init.go | 3 ++- internal/super/scaffolds.go | 10 ++++++---- internal/super/setup.go | 8 +++++--- internal/super/setup_test.go | 10 ++++++---- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/internal/config/init.go b/internal/config/init.go index 651803e87..c7ea5fe47 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -21,9 +21,10 @@ package config import ( "bytes" "fmt" + "os" + "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "os" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" diff --git a/internal/super/scaffolds.go b/internal/super/scaffolds.go index 08bd2944f..5c30b9995 100644 --- a/internal/super/scaffolds.go +++ b/internal/super/scaffolds.go @@ -21,15 +21,17 @@ package super import ( "encoding/json" "fmt" - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing" - "github.com/onflow/flow-cli/internal/util" - "github.com/onflow/flowkit/output" "io" "net/http" "os" "path/filepath" "time" + + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing" + "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/util" ) const scaffoldListURL = "https://raw.githubusercontent.com/onflow/flow-cli/master/scaffolds.json" diff --git a/internal/super/setup.go b/internal/super/setup.go index d9388442c..f5016c26f 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -21,13 +21,15 @@ package super import ( "bytes" "fmt" - "github.com/onflow/flow-cli/internal/config" - "github.com/onflow/flow-cli/internal/util" - "github.com/spf13/cobra" "io" "os" "path/filepath" + "github.com/spf13/cobra" + + "github.com/onflow/flow-cli/internal/config" + "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" diff --git a/internal/super/setup_test.go b/internal/super/setup_test.go index 761130dcd..18da37df3 100644 --- a/internal/super/setup_test.go +++ b/internal/super/setup_test.go @@ -20,13 +20,15 @@ package super import ( "fmt" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" - "github.com/onflow/flowkit/output" - "github.com/stretchr/testify/assert" "os" "path/filepath" "testing" + + "github.com/onflow/flowkit/output" + "github.com/stretchr/testify/assert" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func TestCreate(t *testing.T) { From b674c0b191863a874daa4118aef616782a2b3b88 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:31:32 -0700 Subject: [PATCH 16/16] Run CI on the feature branches --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1882c5056..14d62a674 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,13 @@ name: CI # events but only for the master branch on: push: - branches: [master] + branches: + - master + - 'feature/**' pull_request: - branches: [master] + branches: + - master + - 'feature/**' jobs: test: