Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BuildCmd = &cobra.Command{ Use: "build", Short: "builds the project", Long: `builds the project based on instructions defined in bsf.hcl. Build occurs in a sandboxed environment where only current directory is available. It is recommended to check in the files in version control system(ex: Git) before building. `, Run: func(cmd *cobra.Command, args []string) { sc, fh, err := binit.GetBSFInitializers() if err != nil { fmt.Println(styles.ErrorStyle.Render("error: ", err.Error())) os.Exit(1) } err = generate.Generate(fh, sc) if err != nil { fmt.Println(styles.ErrorStyle.Render("error: ", err.Error())) os.Exit(1) } if output == "" { output = "bsf-result" } err = bgit.Add("bsf/") if err != nil { if _, ok := err.(*bgit.ErrFileNotAddedToVersionControl); ok { fmt.Println(styles.ErrorStyle.Render(err.Error() + "\n Please ensure all necessary files are added/committed in your version control system")) fmt.Println(styles.HintStyle.Render("hint: run git add . ")) os.Exit(1) } fmt.Println(styles.ErrorStyle.Render("error: ", err.Error())) os.Exit(1) } err = bgit.Ignore(output + "/") if err != nil { fmt.Println(styles.ErrorStyle.Render("error: ", err.Error())) os.Exit(1) } symlink, err := getSymLink() if err != nil { fmt.Println(styles.ErrorStyle.Render("error fetching symlink: ", err.Error())) os.Exit(1) } err = nixcmd.Build(output+"/result", "bsf/.") if err != nil { if isNoFileError(err.Error()) { fmt.Println(styles.ErrorStyle.Render(err.Error() + "\n Please ensure all necessary files are added/committed in your version control system")) fmt.Println(styles.HintStyle.Render("hint: run git add . ")) os.Exit(1) } fmt.Println(styles.ErrorStyle.Render("error: ", err.Error())) os.Exit(1) } fmt.Println(styles.HighlightStyle.Render("Generating artifacts...")) lockData, err := os.ReadFile("bsf.lock") if err != nil { fmt.Println(styles.ErrorStyle.Render("error:", err.Error())) os.Exit(1) } lockFile := &hcl2nix.LockFile{} err = json.Unmarshal(lockData, lockFile) if err != nil { fmt.Println(styles.ErrorStyle.Render("error:", err.Error())) os.Exit(1) } appDetails, graph, err := nixcmd.GetRuntimeClosureGraph(lockFile.App.Name, output, symlink) if err != nil { fmt.Println(styles.ErrorStyle.Render("error:", err.Error())) os.Exit(1) } err = GenerateArtifcats(output, symlink, lockFile, appDetails, graph, runtime.GOOS, runtime.GOARCH) if err != nil { fmt.Println(styles.ErrorStyle.Render("error:", err.Error())) os.Exit(1) } fmt.Println(styles.SucessStyle.Render(fmt.Sprintf("Build completed successfully, please check the %s directory", output))) }, }
BuildCmd represents the build command
Functions ¶
func GenerateArtifcats ¶
func GenerateArtifcats(output string, symlink string, lockFile *hcl2nix.LockFile, appDetails *nixcmd.App, graph *gographviz.Graph, tos, tarch string) error
GenerateArtifcats generates remaining artifacts after build
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.