Пример #1
0
func RunGeneratorCommand(s *settings.Settings, args []string) {
	_, err := workspace.ReadWorkspace(s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Println("Generate secrets and values completed")
}
Пример #2
0
func UpdatePackagesCommand(s *settings.Settings, args []string) {
	w, err := workspace.ReadWorkspace(s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	if err := w.Packages.UpdateAll(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
Пример #3
0
func BuildHistoryCommand(s *settings.Settings, args []string) {
	w, err := workspace.ReadWorkspace(s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	scaff, err := scaffolding.ReadScaffolding(w, s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	if err := scaff.BuildHistory(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Println("All rebuilded")
}
Пример #4
0
func AddPackagCommand(s *settings.Settings, args []string) {
	w, err := workspace.ReadWorkspace(s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	if len(args) < 1 {
		fmt.Println("You must defined dependencie id like 'github.com/goatcms/go-project' or 'github.com/goatcms/go-project.version' ")
		os.Exit(1)
	}
	for _, depId := range args {
		if _, err := w.Packages.CreteRecord(depId); err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	}
	if err := w.Write(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
Пример #5
0
func addResource(s *settings.Settings, resourceType, name string, data interface{}) {
	w, err := workspace.ReadWorkspace(s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	r := scaffolding.Resource{
		Type: resourceType,
		Name: name,
		Data: data,
	}

	scaff, err := scaffolding.ReadScaffolding(w, s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if err := scaff.AddResource(r); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
Пример #6
0
func AddModuleCommand(s *settings.Settings, args []string) {
	if len(args) < 1 {
		fmt.Println("Module destination path is required")
		os.Exit(1)
	}
	if len(args) < 2 {
		fmt.Println("Module url is required")
		os.Exit(1)
	}

	dest := args[0]
	depId := args[1]

	w, err := workspace.ReadWorkspace(s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if _, err1 := w.Packages.Get(depId); err1 != nil {
		var err2 error
		if depId, err2 = w.Packages.CreteRecord(depId); err2 != nil {
			fmt.Println(err1)
			fmt.Println(err2)
			os.Exit(1)
		}
		if err2 = w.Write(); err2 != nil {
			fmt.Println(err1)
			fmt.Println(err2)
			os.Exit(1)
		}
		if err2 = w.Packages.UpdateRepo(depId); err2 != nil {
			fmt.Println(err1)
			fmt.Println(err2)
			os.Exit(1)
		}
	}

	scaff, err := scaffolding.ReadScaffolding(w, s.Workspace)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	m, err := scaff.AddModule(depId, dest)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if err := scaff.BuildSubModule(m); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if err := scaff.Write(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Println("Module added")
}