Skip to content

Commit

Permalink
Fix report
Browse files Browse the repository at this point in the history
  • Loading branch information
chasefleming committed Nov 22, 2024
1 parent fe452b8 commit a713b8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
7 changes: 1 addition & 6 deletions internal/dependencymanager/dependencyinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func NewDependencyInstaller(logger output.Logger, state *flowkit.State, saveStat
SkipDeployments: flags.skipDeployments,
SkipAlias: flags.skipAlias,
dependencies: make(map[string]config.Dependency),
logs: categorizedLogs{},
}, nil
}

Expand Down Expand Up @@ -176,8 +177,6 @@ func (di *DependencyInstaller) Install() error {
return fmt.Errorf("error saving state: %w", err)
}

di.logs.LogAll(di.Logger)

return nil
}

Expand Down Expand Up @@ -240,8 +239,6 @@ func (di *DependencyInstaller) Add(dep config.Dependency) error {
return err
}

di.logs.LogAll(di.Logger)

return nil
}

Expand All @@ -257,8 +254,6 @@ func (di *DependencyInstaller) AddMany(dependencies []config.Dependency) error {
return err
}

di.logs.LogAll(di.Logger)

return nil
}

Expand Down
61 changes: 35 additions & 26 deletions internal/dependencymanager/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ var installCommand = &command.Command{
Short: "Install contract and dependencies.",
Example: `flow dependencies install
flow dependencies install testnet://0afe396ebc8eee65.FlowToken
flow dependencies install FlowToken`,
flow dependencies install FlowToken
flow dependencies install FlowToken NonFungibleToken`,
Args: cobra.ArbitraryArgs,
},
Flags: &installFlags,
Expand All @@ -56,49 +57,57 @@ func install(
flow flowkit.Services,
state *flowkit.State,
) (result command.Result, err error) {
if len(args) > 0 {
logger.Info(fmt.Sprintf("%s Installing dependency %s...", util.PrintEmoji("🔄"), args[0]))

dep := args[0]
installer, err := NewDependencyInstaller(logger, state, true, "", installFlags)
if err != nil {
logger.Error(fmt.Sprintf("Error initializing dependency installer: %v", err))
return nil, err
}

installer, err := NewDependencyInstaller(logger, state, true, "", installFlags)
if err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
return nil, err
}
if len(args) > 0 {
for _, dep := range args {
logger.Info(fmt.Sprintf("%s Processing dependency %s...", util.PrintEmoji("🔄"), dep))

// Check if the dependency is a core contract
coreContractName := findCoreContractCaseInsensitive(dep)
if coreContractName != "" {
if err := installer.AddByCoreContractName(coreContractName); err != nil {
logger.Error(fmt.Sprintf("Error adding core contract %s: %v", coreContractName, err))
return nil, err
}
continue
}

// Check if the dependency is a core contract
coreContractName := findCoreContractCaseInsensitive(dep)
if coreContractName != "" {
if err := installer.AddByCoreContractName(coreContractName); err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
if err := installer.AddBySourceString(dep); err != nil {
if strings.Contains(err.Error(), "invalid dependency source format") {
logger.Error(fmt.Sprintf("Error: '%s' is neither a core contract nor a valid dependency source format.\nPlease provide a valid dependency source in the format 'network://address.ContractName', e.g., 'testnet://0x1234567890abcdef.MyContract', or use a valid core contract name such as 'FlowToken'.", dep))
} else {
logger.Error(fmt.Sprintf("Error adding dependency %s: %v", dep, err))
}
return nil, err
}
return nil, nil
}

// Otherwise, add the dependency by source string
if err := installer.AddBySourceString(dep); err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
logger.Info(util.MessageWithEmojiPrefix("🔄", "Installing added dependencies..."))

if err := installer.Install(); err != nil {
logger.Error(fmt.Sprintf("Error installing dependencies: %v", err))
return nil, err
}

installer.logs.LogAll(logger)

return nil, nil
}

logger.Info(util.MessageWithEmojiPrefix("🔄", "Installing dependencies from flow.json..."))

installer, err := NewDependencyInstaller(logger, state, true, "", installFlags)
if err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
return nil, err
}

if err := installer.Install(); err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
logger.Error(fmt.Sprintf("Error installing dependencies: %v", err))
return nil, err
}

installer.logs.LogAll(logger)

return nil, nil
}

Expand Down

0 comments on commit a713b8f

Please sign in to comment.