From 39b264a7f979d4df90b13f2a9681611031d77313 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 14 Apr 2025 13:48:19 +0000 Subject: [PATCH] refactor: split up package boundaries --- .../main.go => contributors/contributors.go} | 35 ----------------- scripts/contributors/main.go | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 35 deletions(-) rename scripts/{validate-contributor-readmes/main.go => contributors/contributors.go} (92%) create mode 100644 scripts/contributors/main.go diff --git a/scripts/validate-contributor-readmes/main.go b/scripts/contributors/contributors.go similarity index 92% rename from scripts/validate-contributor-readmes/main.go rename to scripts/contributors/contributors.go index d83a7c8b..671d3710 100644 --- a/scripts/validate-contributor-readmes/main.go +++ b/scripts/contributors/contributors.go @@ -1,15 +1,9 @@ -// This package is for validating all contributors within the main Registry -// directory. It validates that it has nothing but sub-directories, and that -// each sub-directory has a README.md file. Each of those files must then -// describe a specific contributor. The contents of these files will be parsed -// by the Registry site build step, to be displayed in the Registry site's UI. package main import ( "bufio" "errors" "fmt" - "log" "net/url" "os" "path" @@ -449,32 +443,3 @@ func validateRelativeUrls( errors: problems, } } - -func main() { - log.Println("Starting README validation") - allReadmeFiles, err := aggregateContributorReadmeFiles() - if err != nil { - log.Panic(err) - } - - log.Printf("Processing %d README files\n", len(allReadmeFiles)) - contributors, err := parseContributorFiles(allReadmeFiles) - if err != nil { - log.Panic(err) - } - log.Printf( - "Processed %d README files as valid contributor profiles", - len(contributors), - ) - - err = validateRelativeUrls(contributors) - if err != nil { - log.Panic(err) - } - log.Println("All relative URLs for READMEs are valid") - - log.Printf( - "Processed all READMEs in the %q directory\n", - rootRegistryPath, - ) -} diff --git a/scripts/contributors/main.go b/scripts/contributors/main.go new file mode 100644 index 00000000..90913185 --- /dev/null +++ b/scripts/contributors/main.go @@ -0,0 +1,39 @@ +// This package is for validating all contributors within the main Registry +// directory. It validates that it has nothing but sub-directories, and that +// each sub-directory has a README.md file. Each of those files must then +// describe a specific contributor. The contents of these files will be parsed +// by the Registry site build step, to be displayed in the Registry site's UI. +package main + +import ( + "log" +) + +func main() { + log.Println("Starting README validation") + allReadmeFiles, err := aggregateContributorReadmeFiles() + if err != nil { + log.Panic(err) + } + + log.Printf("Processing %d README files\n", len(allReadmeFiles)) + contributors, err := parseContributorFiles(allReadmeFiles) + log.Printf( + "Processed %d README files as valid contributor profiles", + len(contributors), + ) + if err != nil { + log.Panic(err) + } + + err = validateRelativeUrls(contributors) + if err != nil { + log.Panic(err) + } + log.Println("All relative URLs for READMEs are valid") + + log.Printf( + "Processed all READMEs in the %q directory\n", + rootRegistryPath, + ) +}