// +build mage package main import ( "fmt" "github.com/magefile/mage/mg" "github.com/magefile/mage/sh" "gitlab.com/dananglin/cv/helpers" ) const ( aspellPersonalWordlist string = "./.aspell/.aspell.en.pws" cvJsonDataFile string = "./data/cv.json" cvOutputDir string = "./__output" cvTemplateDir string = "./template/tex/" cvOutputFileName string = "cv.tex" dockerfile string = "./docker/Dockerfile" ) // Default sets the default target. var Default = Pdf // SpellCheck checks the CV JSON file for spelling errors. If there are any // misspelt words found the function returns a list of those words in an error. // Any error found while gathering the list is returned. // This function depends on the aspell program. func SpellCheck() error { return helpers.SpellCheck(cvJsonDataFile, aspellPersonalWordlist) } // Tex takes the CV data file and generates the output tex file from // template. func Tex() error { fmt.Println("Generating the tex file...") mg.Deps(Clean) return helpers.CreateCVTex(cvJsonDataFile, cvTemplateDir, cvOutputDir, cvOutputFileName) } // Pdf takes the output tex file generated by the Tex target and // generates the output PDF file. func Pdf() error { mg.Deps(Tex) pathArg := "--path=" + cvOutputDir fmt.Println("Generating the PDF file...") return sh.Run("mtxrun", pathArg, "--script", "context", "cv.tex") } // Image builds the CV builder docker image. func Image() error { image := helpers.ImageName() return sh.Run("docker", "build", "-f", dockerfile, "-t", image, ".") } // PublishImage publishes the CV builder docker image // to the docker registry. func PublishImage() error { mg.Deps(Image) image := helpers.ImageName() return sh.Run("docker", "push", image) } // Clean removes the directory where the output files // are generated. func Clean() error { if err := sh.Rm(cvOutputDir); err != nil { return err } return nil }