mirror of
https://github.com/go-i2p/go-gh-page.git
synced 2025-06-08 10:31:43 -04:00
add generator CI
This commit is contained in:
2
Makefile
Normal file
2
Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fmt:
|
||||||
|
find . -name '*.go' -exec gofumpt -w -s -extra {} \;
|
@ -93,7 +93,7 @@ func main() {
|
|||||||
repoURL := fmt.Sprintf("https://%s/%s/%s.git", *githost, owner, repo)
|
repoURL := fmt.Sprintf("https://%s/%s/%s.git", *githost, owner, repo)
|
||||||
|
|
||||||
// Create output directory if it doesn't exist
|
// Create output directory if it doesn't exist
|
||||||
if err := os.MkdirAll(*outputFlag, 0755); err != nil {
|
if err := os.MkdirAll(*outputFlag, 0o755); err != nil {
|
||||||
log.Fatalf("Failed to create output directory: %v", err)
|
log.Fatalf("Failed to create output directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ func main() {
|
|||||||
defer os.RemoveAll(tempDir) // Clean up when done
|
defer os.RemoveAll(tempDir) // Clean up when done
|
||||||
} else {
|
} else {
|
||||||
// Ensure the specified work directory exists
|
// Ensure the specified work directory exists
|
||||||
if err := os.MkdirAll(workDir, 0755); err != nil {
|
if err := os.MkdirAll(workDir, 0o755); err != nil {
|
||||||
log.Fatalf("Failed to create working directory: %v", err)
|
log.Fatalf("Failed to create working directory: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func (g *Generator) GenerateSite() (*GenerationResult, error) {
|
|||||||
|
|
||||||
// Create docs directory
|
// Create docs directory
|
||||||
docsDir := filepath.Join(g.outputDir, "docs")
|
docsDir := filepath.Join(g.outputDir, "docs")
|
||||||
if err := os.MkdirAll(docsDir, 0755); err != nil {
|
if err := os.MkdirAll(docsDir, 0o755); err != nil {
|
||||||
return nil, fmt.Errorf("failed to create docs directory: %w", err)
|
return nil, fmt.Errorf("failed to create docs directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ func (g *Generator) GenerateSite() (*GenerationResult, error) {
|
|||||||
|
|
||||||
// Create image directory if needed
|
// Create image directory if needed
|
||||||
imagesDir := filepath.Join(g.outputDir, "images")
|
imagesDir := filepath.Join(g.outputDir, "images")
|
||||||
if err := os.MkdirAll(imagesDir, 0755); err != nil {
|
if err := os.MkdirAll(imagesDir, 0o755); err != nil {
|
||||||
return nil, fmt.Errorf("failed to create images directory: %w", err)
|
return nil, fmt.Errorf("failed to create images directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ func (g *Generator) generateMainPage(docsPages []utils.DocPage) error {
|
|||||||
|
|
||||||
// Write to file
|
// Write to file
|
||||||
outputPath := filepath.Join(g.outputDir, "index.html")
|
outputPath := filepath.Join(g.outputDir, "index.html")
|
||||||
if err := os.WriteFile(outputPath, buf.Bytes(), 0644); err != nil {
|
if err := os.WriteFile(outputPath, buf.Bytes(), 0o644); err != nil {
|
||||||
return fmt.Errorf("failed to write index.html: %w", err)
|
return fmt.Errorf("failed to write index.html: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,12 +288,12 @@ func (g *Generator) generateDocPage(path, content string, docsPages []utils.DocP
|
|||||||
|
|
||||||
// Ensure output directory exists
|
// Ensure output directory exists
|
||||||
outPath := filepath.Join(g.outputDir, outputPath)
|
outPath := filepath.Join(g.outputDir, outputPath)
|
||||||
if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(outPath), 0o755); err != nil {
|
||||||
return fmt.Errorf("failed to create directory for %s: %w", outPath, err)
|
return fmt.Errorf("failed to create directory for %s: %w", outPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to file
|
// Write to file
|
||||||
if err := os.WriteFile(outPath, buf.Bytes(), 0644); err != nil {
|
if err := os.WriteFile(outPath, buf.Bytes(), 0o644); err != nil {
|
||||||
return fmt.Errorf("failed to write %s: %w", outPath, err)
|
return fmt.Errorf("failed to write %s: %w", outPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ func copyFile(src, dst string) error {
|
|||||||
func GenerateRootStyle(outputDir string) error {
|
func GenerateRootStyle(outputDir string) error {
|
||||||
// write the templates.StyleTemplate to the root of the output directory
|
// write the templates.StyleTemplate to the root of the output directory
|
||||||
stylePath := filepath.Join(outputDir, "style.css")
|
stylePath := filepath.Join(outputDir, "style.css")
|
||||||
if err := os.WriteFile(stylePath, []byte(templates.StyleTemplate), 0644); err != nil {
|
if err := os.WriteFile(stylePath, []byte(templates.StyleTemplate), 0o644); err != nil {
|
||||||
return fmt.Errorf("failed to write style.css: %w", err)
|
return fmt.Errorf("failed to write style.css: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user