replaced deps fetching from arborist to custom

This commit is contained in:
Sahilb315
2025-04-24 03:46:38 +05:30
parent 7167db9830
commit b8444d244b
5 changed files with 229 additions and 42 deletions
+24
View File
@@ -7,6 +7,7 @@ import (
"github.com/safedep/dry/crypto"
"github.com/safedep/pmg/pkg/common/utils"
"github.com/safedep/pmg/pkg/models"
)
// ExtractorOptions holds configuration for running an extractor script
@@ -19,6 +20,29 @@ type ExtractorOptions struct {
Env map[string]string // Environment variables to pass to the script
}
func FlattenDependencyTree(node *models.DependencyNode) []string {
result := make([]string, 0)
seen := make(map[string]bool)
var flatten func(*models.DependencyNode)
flatten = func(n *models.DependencyNode) {
key := fmt.Sprintf("%s@%s", n.Name, n.Version)
if seen[key] {
return
}
seen[key] = true
result = append(result, fmt.Sprintf("%s@%s", n.Name, n.Version))
for _, dep := range n.Dependencies {
flatten(dep)
}
}
flatten(node)
return result
}
// RunExtractor extracts an embedded script to a temp file and executes it
func RunPkgExtractor(opts ExtractorOptions) (string, error) {
interpreterPath, err := utils.GetExecutablePath(opts.Interpreter)