Skip to content

Commit

Permalink
refactor to flowkit dependency installer
Browse files Browse the repository at this point in the history
  • Loading branch information
bartolomej committed Jun 23, 2024
1 parent b6c8838 commit b8fbb9e
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 773 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,6 @@ require (
nhooyr.io/websocket v1.8.7 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

//replace github.com/onflow/flowkit/v2 => github.com/onflowser/flowkit/v2 v2.0.0-20240623105755-c0604188301b
replace github.com/onflow/flowkit/v2 => ../flowkit
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,7 @@ github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4V
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc=
github.com/onflow/wal v1.0.2/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk=
github.com/onflowser/flowkit/v2 v2.0.0-20240623105755-c0604188301b/go.mod h1:89ipBRMJE9nWRimoqaa02+l6kCQuBiVyzszI6N3a6Sk=
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 h1:eBS8Rm1V9TTGpj9lcpoCi6MIwWgYQZ8crJ7cSrS39Y4=
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48/go.mod h1:Pvw+OkV3eqLGMpHWu38rJYE30N9G3VgQ2MRQQnRr4to=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
4 changes: 2 additions & 2 deletions internal/command/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help")
Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
Global flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
Expand Down
22 changes: 18 additions & 4 deletions internal/dependencymanager/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ package dependencymanager

import (
"fmt"

"github.com/onflow/flow-cli/internal/util"

"github.com/spf13/cobra"

"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/deps"
"github.com/onflow/flowkit/v2/output"

"github.com/onflow/flow-cli/internal/command"
Expand All @@ -52,9 +52,9 @@ var addCommand = &command.Command{
}

func init() {
// Add common flags.
// Add common Flags.
addFlags.Flags.AddToCommand(addCommand.Cmd)
// Add command-specific flags.
// Add command-specific Flags.
addCommand.Cmd.Flags().StringVar(&addFlags.name, "name", "", "Name of the dependency")
}

Expand All @@ -69,7 +69,21 @@ func add(

dep := args[0]

installer, err := NewDependencyInstaller(logger, state, true, "", *addFlags.Flags)
options := []deps.Option{
deps.WithSaveState(),
deps.WithLogger(logger),
}

if addFlags.skipDeployments {
options = append(options, deps.WithSkippedDeployments())
}

if addFlags.skipAlias {
options = append(options, deps.WithSkippedAlias())
}

installer, err := NewCliDependencyInstaller(state, options...)

if err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
return nil, err
Expand Down
Loading

0 comments on commit b8fbb9e

Please sign in to comment.