Add colorful outputs & remove md text (#13)

* fix: parsePackageInfo to handle pkg names with special character

* Enhance pmg outputs by adding colors and removing markdown notions

* Update pkg/wrapper/npm_base.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

* Update npm_base.go

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

* test: add tests for removeMarkdown

* chore: remove duplicate code

* refactor: convert TerminalColors to global var and split markdown utils

---------

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Sahil Bansal
2025-05-05 23:32:34 +05:30
committed by GitHub
co-authored by Copilot
parent 88f39b56ff
commit df754ccc82
6 changed files with 128 additions and 7 deletions
+5 -3
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"time"
"github.com/fatih/color"
"github.com/safedep/dry/log"
"github.com/safedep/pmg/internal/ui"
"github.com/safedep/pmg/pkg/analyser"
@@ -28,8 +29,8 @@ func NewPackageManagerWrapper(registryType registry.RegistryType) *PackageManage
func (pmw *PackageManagerWrapper) Wrap() error {
ui.StartProgressWriter()
progressTracker := ui.TrackProgress(fmt.Sprintf("Scanning %s ", pmw.PackageName), 5)
var DefaultProgressTotal = 5
progressTracker := ui.TrackProgress(fmt.Sprintf("Scanning %s ", pmw.PackageName), DefaultProgressTotal)
if pmw.PackageName == "" {
return fmt.Errorf("package name cannot be empty")
}
@@ -133,7 +134,8 @@ func (pmw *PackageManagerWrapper) analyzeDependencies(ctx context.Context, deps
log.Infof("Installation canceled due to security concerns")
return fmt.Errorf("installation canceled")
}
log.Warnf("Continuing installation despite security warnings...")
yellow := color.New(color.FgYellow, color.Bold).SprintfFunc()
log.Warnf(yellow("Continuing installation despite security warnings..."))
}
return nil