MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / checkDependencies

Function checkDependencies

cmd/pulumi.go:826–889  ·  view source on GitHub ↗

checkDependencies returns whether installation is needed and a human-readable description.

(runtime, dir, venv string)

Source from the content-addressed store, hash-verified

824
825// checkDependencies returns whether installation is needed and a human-readable description.
826func checkDependencies(runtime, dir, venv string) (needed bool, desc string) {
827 switch runtime {
828 case "go":
829 if _, err := os.Stat(filepath.Join(dir, "go.sum")); os.IsNotExist(err) {
830 return false, ""
831 }
832 c := exec.Command("go", "mod", "verify")
833 c.Dir = dir
834 if err := c.Run(); err != nil {
835 return true, "Go modules (go mod download)"
836 }
837 return false, ""
838
839 case "nodejs", "node":
840 if _, err := os.Stat(filepath.Join(dir, "node_modules", "@pulumi", "pulumi", "cmd", "run", "index.js")); os.IsNotExist(err) {
841 return true, "Node.js packages (npm install)"
842 }
843 return false, ""
844
845 case "python":
846 venvPath := filepath.Join(dir, pythonVenvDir(venv))
847 venvPython := filepath.Join(venvPath, "bin", "python3")
848 if _, err := os.Stat(venvPython); os.IsNotExist(err) {
849 tool := "pip"
850 if hasUV() {
851 tool = "uv"
852 }
853 src := "requirements.txt"
854 if fileExists(filepath.Join(dir, "pyproject.toml")) {
855 src = "pyproject.toml"
856 }
857 extra := ""
858 if venv == "" {
859 extra = " — a 'venv' folder will be created and removed after"
860 }
861 return true, fmt.Sprintf("Python packages from %s (%s)%s", src, tool, extra)
862 }
863 return false, ""
864
865 case "dotnet":
866 if _, err := os.Stat(filepath.Join(dir, "obj")); os.IsNotExist(err) {
867 return true, ".NET packages (dotnet restore)"
868 }
869 return false, ""
870
871 case "java":
872 if fileExists(filepath.Join(dir, "pom.xml")) {
873 // Check if Maven has already downloaded dependencies (local .m2 or target/classes).
874 if _, err := os.Stat(filepath.Join(dir, "target", "classes")); os.IsNotExist(err) {
875 return true, "Java dependencies (mvn compile)"
876 }
877 } else if fileExists(filepath.Join(dir, "build.gradle")) || fileExists(filepath.Join(dir, "build.gradle.kts")) {
878 if _, err := os.Stat(filepath.Join(dir, "build", "classes")); os.IsNotExist(err) {
879 return true, "Java dependencies (gradle classes)"
880 }
881 }
882 return false, ""
883

Callers 1

runPulumiEstimateFunction · 0.85

Calls 3

pythonVenvDirFunction · 0.85
hasUVFunction · 0.85
fileExistsFunction · 0.85

Tested by

no test coverage detected