Example #1
0
func main() {
	if len(os.Args) < 2 {
		usage()
	}
	sousFlags, args := parseFlags(os.Args[2:])
	command := os.Args[1]
	var cfg *config.Config
	var sous *core.Sous
	if command != "config" {
		updateHourly()
		cfg = config.Load()
		trapSignals()
		defer cli.Cleanup()
		sous = core.NewSous(Version, Revision, OS, Arch, loadCommands(), BuildPacks(cfg), sousFlags, cfg)
	} else {
		sous = core.NewSous(Version, Revision, OS, Arch, loadCommands(), nil, sousFlags, nil)
	}
	c, ok := sous.Commands[command]
	if !ok {
		cli.Fatalf("Command %s not recognised; try `sous help`", command)
	}
	// It is the responsibility of the command to exit with an appropriate
	// error code...
	c.Func(sous, args)
	// If it does not, we assume it failed...
	cli.Fatalf("Command did not complete correctly")
}
Example #2
0
func GetContext(action string) *Context {
	var c = config.Load()
	registry := c.DockerRegistry
	gitInfo := git.GetInfo()
	bs := GetBuildState(action, gitInfo)
	wd, err := os.Getwd()
	if err != nil {
		cli.Fatalf("Unable to get current working directory: %s", err)
	}
	return &Context{
		Git:            gitInfo,
		WorkDir:        wd,
		TargetName:     action,
		DockerRegistry: registry,
		Host:           cmd.Stdout("hostname"),
		FullHost:       cmd.Stdout("hostname", "-f"),
		User:           getUser(),
		BuildState:     bs,
		BuildVersion:   buildVersion(gitInfo),
	}
}
Example #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
}