Pnpm suppport (#6)

* fix: resolves issues #3 and #4

* feat: add pnpm support & introduce pkg manager wrap for npm
This commit is contained in:
Sahil Bansal
2025-04-30 14:26:38 +05:30
committed by GitHub
parent ec010c7d6b
commit 1aa4b06f41
9 changed files with 320 additions and 165 deletions
+37 -1
View File
@@ -1,6 +1,10 @@
package utils
import "os"
import (
"fmt"
"os"
"strings"
)
func ApiKey() string {
return os.Getenv("SAFEDEP_API_KEY")
@@ -13,3 +17,35 @@ func TenantDomain() string {
func NpmAuthToken() string {
return os.Getenv("NPM_AUTH_TOKEN")
}
func ValidateEnvVars() error {
apiKey := ApiKey()
tenantId := TenantDomain()
var missingVars []string
if apiKey == "" {
missingVars = append(missingVars, "SAFEDEP_API_KEY")
}
if tenantId == "" {
missingVars = append(missingVars, "SAFEDEP_TENANT_ID")
}
if len(missingVars) > 0 {
return fmt.Errorf(`
SafeDep configuration incomplete
Missing environment variables:
%s
To enable package scanning:
1. Export these variables in your terminal:
export %s=your_api_key
export %s=your_tenant_id
2. Or add them to your shell profile file
For more information, visit: https://docs.safedep.io/cloud/quickstart
`, strings.Join(missingVars, "\n "), missingVars[0], missingVars[len(missingVars)-1])
}
return nil
}