Exemple #1
0
func (p *Pack) bestSupportedNodeVersion() string {
	np := p.PackageJSON
	var nodeVersion *version.V
	nodeVersion = version.Range(np.Engines.Node).BestMatchFrom(p.AvailableNodeVersions())
	if nodeVersion == nil {
		cli.Fatalf("unable to satisfy NodeJS version '%s' (from package.json); available versions are: %s",
			np.Engines.Node, strings.Join(p.AvailableNodeVersions().Strings(), ", "))
	}
	return nodeVersion.String()
}
Exemple #2
0
func (p *Pack) baseDockerfile(target string) *docker.Dockerfile {
	np := p.PackageJSON
	nodeVersion := p.bestSupportedNodeVersion()
	from := p.dockerFrom(nodeVersion, target) + ":latest"
	npmVer := defaultNPMVersion
	if np.Engines.NPM != "" {
		npmVer = version.Range(np.Engines.NPM).BestMatchFrom(npmVersions)
		if npmVer == nil {
			cli.Logf("NPM version %s not supported, try using a range instead.", np.Engines.NPM)
			cli.Fatalf("Available NPM version ranges are: '^3' and '^2'")
		}
	}
	df := &docker.Dockerfile{
		From:        from,
		Add:         []docker.Add{docker.Add{Files: []string{"."}, Dest: wd}},
		Workdir:     wd,
		LabelPrefix: "com.opentable",
	}
	df.AddLabel("build.pack.nodejs.version", nodeVersion)
	return df
}
Exemple #3
0
func (p *Pack) Problems() core.ErrorCollection {
	if p.PackageJSON == nil {
		panic("PackageJSON not set, detect must have failed.")
	}
	np := p.PackageJSON
	errs := core.ErrorCollection{}
	c := config.Load()
	if np.Engines.Node == "" {
		errs.AddWarningf("missing node engine version in package.json, defaulting to node %s; see https://docs.npmjs.com/files/package.json#engines",
			c.Packs.NodeJS.DefaultNodeVersion)
	} else {
		r := version.Range(np.Engines.Node)
		if v := r.BestMatchFrom(p.AvailableNodeVersions()); v == nil {
			f := "node version range (%s) not supported (pick from %s)"
			errs.AddErrorf(f, r.Original, strings.Join((p.AvailableNodeVersions().Strings()), ", "))
		}
	}
	if np.Version == "" {
		errs.AddWarningf("no app version specified in package.json:version")
	}
	return errs
}
Exemple #4
0
func RequireGit() {
	git.RequireVersion(version.Range(">=1.9.1"))
	git.RequireRepo()
}
Exemple #5
0
func RequireDocker() {
	docker.RequireVersion(version.Range(">=1.8.2"))
	docker.RequireDaemon()
}