Skip to content

Commit

Permalink
Add message to clarify no updates when none to Dependency Manager (#1536
Browse files Browse the repository at this point in the history
)

* Add message to clarify no updates when none to Dependency Manager

* Make emojis conditional based on runtime os

* Update internal/util/emoji.go

Co-authored-by: Jordan Ribbink <[email protected]>

* Fix go error

* Add license to file

---------

Co-authored-by: Chase Fleming <[email protected]>
Co-authored-by: Jordan Ribbink <[email protected]>
  • Loading branch information
3 people authored Apr 24, 2024
1 parent a42acab commit b2b91c7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
3 changes: 2 additions & 1 deletion internal/dependencymanager/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package dependencymanager

import (
"fmt"

Check failure on line 22 in internal/dependencymanager/add.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/onflow/flow-cli (goimports)
"github.com/onflow/flow-cli/internal/util"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -62,7 +63,7 @@ func add(
flow flowkit.Services,
state *flowkit.State,
) (result command.Result, err error) {
logger.Info(fmt.Sprintf("🔄 Installing dependencies for %s...", args[0]))
logger.Info(fmt.Sprintf("%s Installing dependencies for %s...", util.PrintEmoji("🔄"), args[0]))

dep := args[0]

Expand Down
12 changes: 8 additions & 4 deletions internal/dependencymanager/dependencyinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,28 @@ type categorizedLogs struct {
}

func (cl *categorizedLogs) LogAll(logger output.Logger) {
logger.Info("📝 Dependency Manager Actions Summary")
logger.Info(util.MessageWithEmojiPrefix("📝", "Dependency Manager Actions Summary"))
logger.Info("") // Add a line break after the section

if len(cl.fileSystemActions) > 0 {
logger.Info("🗃️ File System Actions:")
for _, msg := range cl.fileSystemActions {
logger.Info(fmt.Sprintf("✅ %s", msg))
logger.Info(util.MessageWithEmojiPrefix("✅", msg))
}
logger.Info("") // Add a line break after the section
}

if len(cl.stateUpdates) > 0 {
logger.Info("💾 State Updates:")
for _, msg := range cl.stateUpdates {
logger.Info(fmt.Sprintf("✅ %s", msg))
logger.Info(util.MessageWithEmojiPrefix("✅", msg))
}
logger.Info("") // Add a line break after the section
}

if len(cl.fileSystemActions) == 0 && len(cl.stateUpdates) == 0 {
logger.Info(util.MessageWithEmojiPrefix("👍", "Zero changes were made. Everything looks good."))
}
}

type dependencyManagerFlagsCollection struct {
Expand Down Expand Up @@ -305,7 +309,7 @@ func (di *DependencyInstaller) handleFoundContract(networkName, contractAddr, as

// If a dependency by this name already exists and its remote source network or address does not match, then give option to stop or continue
if dependency != nil && (dependency.Source.NetworkName != networkName || dependency.Source.Address.String() != contractAddr) {
di.Logger.Info(fmt.Sprintf("🚫 A dependency named %s already exists with a different remote source. Please fix the conflict and retry.", assignedName))
di.Logger.Info(fmt.Sprintf("%s A dependency named %s already exists with a different remote source. Please fix the conflict and retry.", util.PrintEmoji("🚫"), assignedName))
os.Exit(0)
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion internal/dependencymanager/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package dependencymanager

import (
"fmt"

Check failure on line 22 in internal/dependencymanager/install.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/onflow/flow-cli (goimports)
"github.com/onflow/flow-cli/internal/util"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -48,7 +49,7 @@ func install(
flow flowkit.Services,
state *flowkit.State,
) (result command.Result, err error) {
logger.Info("🔄 Installing dependencies from flow.json...")
logger.Info(util.MessageWithEmojiPrefix("🔄", "Installing dependencies from flow.json..."))

installer, err := NewDependencyInstaller(logger, state, installFlags)
if err != nil {
Expand Down
36 changes: 36 additions & 0 deletions internal/util/emoji.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 util

import (
"fmt"
"runtime"
)

func PrintEmoji(emoji string) string {
if runtime.GOOS == "windows" {
return ""
}

return emoji
}

func MessageWithEmojiPrefix(emoji string, message string) string {
return fmt.Sprintf("%s%s", PrintEmoji(emoji+" "), message)
}

0 comments on commit b2b91c7

Please sign in to comment.