소스 검색

Detect the Node engine version if available

Mohammed Nafees 4 년 전
부모
커밋
1ea98c48a2
4개의 변경된 파일14개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 0
      cli/cmd/pack/pack.go
  2. 1 0
      cmd/test-runtime/runtimes/go.go
  3. 9 3
      cmd/test-runtime/runtimes/nodejs.go
  4. 1 1
      go.mod

+ 3 - 0
cli/cmd/pack/pack.go

@@ -35,6 +35,9 @@ func (a *Agent) Build(opts *docker.BuildOpts) error {
 		AppPath:         opts.BuildContext,
 		TrustBuilder:    true,
 		Env:             opts.Env,
+		// Builder:            "paketobuildpacks/builder:tiny",
+		// DefaultProcessType: "some-custom-command from Procfile",
+		// Buildpacks:         []string{"gcr.io/paketo-buildpacks/procfile"},
 	}
 
 	return client.Build(context, buildOpts)

+ 1 - 0
cmd/test-runtime/runtimes/go.go

@@ -85,6 +85,7 @@ func (runtime *goRuntime) Detect(workingDir string) (BuildpackInfo, map[string]i
 	go runtime.detectDep(results, workingDir)
 	go runtime.detectStandalone(results, workingDir)
 	runtime.wg.Wait()
+	close(results)
 
 	return BuildpackInfo{}, nil
 }

+ 9 - 3
cmd/test-runtime/runtimes/nodejs.go

@@ -207,13 +207,19 @@ func (runtime *nodeRuntime) Detect(workingDir string) (BuildpackInfo, map[string
 			os.Exit(1)
 		}
 		scripts := packageJSONContents["scripts"].(map[string]interface{})
+		packageJSONParser := npminstall.NewPackageJSONParser()
+		engineVersion, err := packageJSONParser.ParseVersion(packageJSONPath)
+		if err != nil {
+			fmt.Printf("Error reading %s: %v\n", packageJSONPath, err)
+			os.Exit(1)
+		}
 
 		if detected[yarn] {
-			return *runtime.packs[yarn], map[string]interface{}{"scripts": scripts}
+			return *runtime.packs[yarn], map[string]interface{}{"scripts": scripts, "engine_version": engineVersion}
 		} else if detected[npm] {
-			return *runtime.packs[npm], map[string]interface{}{"scripts": scripts}
+			return *runtime.packs[npm], map[string]interface{}{"scripts": scripts, "engine_version": engineVersion}
 		} else if detected[standalone] {
-			return *runtime.packs[standalone], map[string]interface{}{"scripts": scripts}
+			return *runtime.packs[standalone], map[string]interface{}{"scripts": scripts, "engine_version": engineVersion}
 		}
 	}
 

+ 1 - 1
go.mod

@@ -50,7 +50,7 @@ require (
 	github.com/paketo-buildpacks/rails-assets v0.3.0
 	github.com/paketo-buildpacks/rake v0.1.0
 	github.com/paketo-buildpacks/yarn-install v0.5.0
-	github.com/pelletier/go-toml v1.9.4 // indirect
+	github.com/pelletier/go-toml v1.9.4
 	github.com/pkg/errors v0.9.1
 	github.com/rogpeppe/go-internal v1.5.2 // indirect
 	github.com/rs/zerolog v1.20.0