diff --git a/.gitignore b/.gitignore index 7fb94a8..0b7c9da 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ # vendor/ dist/ -generators/gola/out/ +src/generators/gola/out/ # go-task intermediate files like checksums # diff --git a/generators/gola/content-parser.go b/src/generators/gola/content-parser.go similarity index 100% rename from generators/gola/content-parser.go rename to src/generators/gola/content-parser.go diff --git a/generators/gola/gen/main.go b/src/generators/gola/gen/main.go similarity index 96% rename from generators/gola/gen/main.go rename to src/generators/gola/gen/main.go index a3e2d4b..a5e81ea 100644 --- a/generators/gola/gen/main.go +++ b/src/generators/gola/gen/main.go @@ -8,7 +8,7 @@ import ( "path/filepath" "github.com/samber/lo" - "github.com/snivilised/cobrass/generators/gola" + "github.com/snivilised/cobrass/src/generators/gola" nef "github.com/snivilised/nefilim" ) @@ -24,7 +24,7 @@ var ( writeFlag = flag.Bool("write", false, "write generated code?") signFlag = flag.Bool("sign", false, "show signature of existing code only") - testPath = filepath.Join("generators", "gola", "out", "assistant") + testPath = filepath.Join("src", "generators", "gola", "out", "assistant") sourcePath = filepath.Join("src", "assistant") ) diff --git a/generators/gola/gola-defs.go b/src/generators/gola/gola-defs.go similarity index 93% rename from generators/gola/gola-defs.go rename to src/generators/gola/gola-defs.go index cfd5be3..7b7708e 100644 --- a/generators/gola/gola-defs.go +++ b/src/generators/gola/gola-defs.go @@ -3,7 +3,7 @@ package gola import ( "bytes" - "github.com/snivilised/cobrass/generators/gola/internal/collections" + "github.com/snivilised/cobrass/src/generators/gola/internal/collections" ) type executionInfo struct { diff --git a/generators/gola/gola-suite_test.go b/src/generators/gola/gola-suite_test.go similarity index 100% rename from generators/gola/gola-suite_test.go rename to src/generators/gola/gola-suite_test.go diff --git a/generators/gola/gomega-matchers_test.go b/src/generators/gola/gomega-matchers_test.go similarity index 98% rename from generators/gola/gomega-matchers_test.go rename to src/generators/gola/gomega-matchers_test.go index fc1f9c4..61333c2 100644 --- a/generators/gola/gomega-matchers_test.go +++ b/src/generators/gola/gomega-matchers_test.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/samber/lo" - "github.com/snivilised/cobrass/generators/gola" + "github.com/snivilised/cobrass/src/generators/gola" nef "github.com/snivilised/nefilim" . "github.com/onsi/gomega/types" //nolint:revive // gomega ok diff --git a/generators/gola/hyper-gen_test.go b/src/generators/gola/hyper-gen_test.go similarity index 98% rename from generators/gola/hyper-gen_test.go rename to src/generators/gola/hyper-gen_test.go index aa64910..b3a0dde 100644 --- a/generators/gola/hyper-gen_test.go +++ b/src/generators/gola/hyper-gen_test.go @@ -92,7 +92,7 @@ var _ = Describe("HyperGen", Ordered, func() { BeforeAll(func() { repo = Repo("../..") - testPath = filepath.Join("generators", "gola", "out", "assistant") + testPath = filepath.Join("src", "generators", "gola", "out", "assistant") sourcePath = filepath.Join("src", "assistant") _ = testPath _ = sourcePath diff --git a/generators/gola/internal/collections/sorted-keys-map.go b/src/generators/gola/internal/collections/sorted-keys-map.go similarity index 100% rename from generators/gola/internal/collections/sorted-keys-map.go rename to src/generators/gola/internal/collections/sorted-keys-map.go diff --git a/generators/gola/mem-fs_test.go b/src/generators/gola/mem-fs_test.go similarity index 97% rename from generators/gola/mem-fs_test.go rename to src/generators/gola/mem-fs_test.go index d25d540..14a12e2 100644 --- a/generators/gola/mem-fs_test.go +++ b/src/generators/gola/mem-fs_test.go @@ -7,6 +7,7 @@ import ( "testing/fstest" "github.com/samber/lo" + "github.com/snivilised/cobrass/src/internal/lab" nef "github.com/snivilised/nefilim" ) @@ -43,7 +44,7 @@ func (f *TestMemFS) Create(name string) (*os.File, error) { } file := &fstest.MapFile{ - Mode: Perms.File, + Mode: lab.Perms.File, } f.MapFS[name] = file diff --git a/generators/gola/operator.go b/src/generators/gola/operator.go similarity index 100% rename from generators/gola/operator.go rename to src/generators/gola/operator.go diff --git a/generators/gola/signature.GO-HASH.txt b/src/generators/gola/signature.GO-HASH.txt similarity index 100% rename from generators/gola/signature.GO-HASH.txt rename to src/generators/gola/signature.GO-HASH.txt diff --git a/generators/gola/signature_test.go b/src/generators/gola/signature_test.go similarity index 92% rename from generators/gola/signature_test.go rename to src/generators/gola/signature_test.go index c6b16ff..d658687 100644 --- a/generators/gola/signature_test.go +++ b/src/generators/gola/signature_test.go @@ -3,38 +3,28 @@ package gola_test import ( _ "embed" "fmt" - "io/fs" "os" "path/filepath" . "github.com/onsi/ginkgo/v2" //nolint:revive // ok . "github.com/onsi/gomega" //nolint:revive // ok - "github.com/snivilised/cobrass/generators/gola" + "github.com/snivilised/cobrass/src/generators/gola" + "github.com/snivilised/cobrass/src/internal/lab" nef "github.com/snivilised/nefilim" ) -var ( - Perms = struct { - File fs.FileMode - Dir fs.FileMode - }{ - File: 0o666, - Dir: 0o777, - } -) - type setupFile struct { path string data []byte } func setup(fS nef.UniversalFS, directoryPath string, files ...setupFile) { - if e := fS.MakeDirAll(directoryPath, Perms.Dir); e != nil { + if e := fS.MakeDirAll(directoryPath, lab.Perms.Dir); e != nil { Fail(fmt.Sprintf("%q, path: %q", e.Error(), directoryPath)) } for _, f := range files { - if e := fS.WriteFile(f.path, f.data, Perms.File); e != nil { + if e := fS.WriteFile(f.path, f.data, lab.Perms.File); e != nil { Fail(fmt.Sprintf("%q, path: %q", e.Error(), f.path)) } } @@ -59,8 +49,8 @@ var _ = Describe("Signature", Ordered, func() { BeforeAll(func() { repo = Repo("../..") - testPath = filepath.Join("generators", "gola", "out", "assistant") - sourcePath = filepath.Join("src", "assistant") + testPath = filepath.Join("src", "generators", "gola", "out", "assistant") + sourcePath = filepath.Join("assistant") }) Context("sign", func() { diff --git a/generators/gola/source-code-container.go b/src/generators/gola/source-code-container.go similarity index 98% rename from generators/gola/source-code-container.go rename to src/generators/gola/source-code-container.go index 8c4dcf9..1fbad5e 100644 --- a/generators/gola/source-code-container.go +++ b/src/generators/gola/source-code-container.go @@ -7,7 +7,7 @@ import ( "text/template" "github.com/samber/lo" - "github.com/snivilised/cobrass/generators/gola/internal/collections" + "github.com/snivilised/cobrass/src/generators/gola/internal/collections" nef "github.com/snivilised/nefilim" ) diff --git a/generators/gola/source-code-data.go b/src/generators/gola/source-code-data.go similarity index 100% rename from generators/gola/source-code-data.go rename to src/generators/gola/source-code-data.go diff --git a/generators/gola/source-code-data_test.go b/src/generators/gola/source-code-data_test.go similarity index 90% rename from generators/gola/source-code-data_test.go rename to src/generators/gola/source-code-data_test.go index c2d4b2e..161097d 100644 --- a/generators/gola/source-code-data_test.go +++ b/src/generators/gola/source-code-data_test.go @@ -8,7 +8,7 @@ import ( . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok . "github.com/onsi/gomega" //nolint:revive // gomega ok - "github.com/snivilised/cobrass/generators/gola" + "github.com/snivilised/cobrass/src/generators/gola" nef "github.com/snivilised/nefilim" ) @@ -30,7 +30,7 @@ var _ = Describe("SourceCodeData", Ordered, func() { BeforeAll(func() { repo = Repo("../..") - testPath = filepath.Join("generators", "gola", "out", "assistant") + testPath = filepath.Join("src", "generators", "gola", "out", "assistant") sourcePath = filepath.Join("src", "assistant") fS = nef.NewUniversalABS() diff --git a/generators/gola/source-code-generator.go b/src/generators/gola/source-code-generator.go similarity index 95% rename from generators/gola/source-code-generator.go rename to src/generators/gola/source-code-generator.go index c4e5de6..2f1fc52 100644 --- a/generators/gola/source-code-generator.go +++ b/src/generators/gola/source-code-generator.go @@ -3,10 +3,10 @@ package gola import ( _ "embed" "fmt" - "io/fs" "path" "github.com/samber/lo" + "github.com/snivilised/cobrass/src/internal/lab" nef "github.com/snivilised/nefilim" ) @@ -14,14 +14,6 @@ var ( noData = struct{}{} //go:embed signature.GO-HASH.txt RegisteredHash string - - Perms = struct { - File fs.FileMode - Dir fs.FileMode - }{ - File: 0o666, //nolint:mnd // ok (pedantic) - Dir: 0o777, //nolint:mnd // ok (pedantic) - } ) type SourceCodeGenerator struct { @@ -166,7 +158,7 @@ func (g *SourceCodeGenerator) flush(outputPath string, yield *generatedYield) er if err := g.fS.MakeDirAll( directory, - Perms.Dir, + lab.Perms.Dir, ); err != nil { return fmt.Errorf("failed to ensure parent directory '%v' exists (%v)", directory, err) } @@ -174,7 +166,7 @@ func (g *SourceCodeGenerator) flush(outputPath string, yield *generatedYield) er if err := g.fS.WriteFile( outputPath, yield.buffer.Bytes(), - Perms.File, + lab.Perms.File, ); err != nil { return fmt.Errorf("failed to write generated code to '%v' (%v)", outputPath, err) } diff --git a/generators/gola/source-code-generator_test.go b/src/generators/gola/source-code-generator_test.go similarity index 86% rename from generators/gola/source-code-generator_test.go rename to src/generators/gola/source-code-generator_test.go index 3c0dbc3..9cda34d 100644 --- a/generators/gola/source-code-generator_test.go +++ b/src/generators/gola/source-code-generator_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok . "github.com/onsi/gomega" //nolint:revive // gomega ok - "github.com/snivilised/cobrass/generators/gola" + "github.com/snivilised/cobrass/src/generators/gola" nef "github.com/snivilised/nefilim" ) @@ -18,7 +18,7 @@ var _ = Describe("SourceCodeGenerator", Ordered, func() { BeforeAll(func() { repo = Repo("../..") - testPath = filepath.Join("generators", "gola", "out", "assistant") + testPath = filepath.Join("src", "generators", "gola", "out", "assistant") fS = NewTestMemFS() }) diff --git a/generators/gola/templates/option-validator-auto/generate-slice.go.tmpl b/src/generators/gola/templates/option-validator-auto/generate-slice.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto/generate-slice.go.tmpl rename to src/generators/gola/templates/option-validator-auto/generate-slice.go.tmpl diff --git a/generators/gola/templates/option-validator-auto/option-validator-auto-body.go.tmpl b/src/generators/gola/templates/option-validator-auto/option-validator-auto-body.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto/option-validator-auto-body.go.tmpl rename to src/generators/gola/templates/option-validator-auto/option-validator-auto-body.go.tmpl diff --git a/generators/gola/templates/option-validator-auto/option-validator-auto-footer.go.tmpl b/src/generators/gola/templates/option-validator-auto/option-validator-auto-footer.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto/option-validator-auto-footer.go.tmpl rename to src/generators/gola/templates/option-validator-auto/option-validator-auto-footer.go.tmpl diff --git a/generators/gola/templates/option-validator-auto/option-validator-auto-header.go.tmpl b/src/generators/gola/templates/option-validator-auto/option-validator-auto-header.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto/option-validator-auto-header.go.tmpl rename to src/generators/gola/templates/option-validator-auto/option-validator-auto-header.go.tmpl diff --git a/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-body.go.tmpl b/src/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-body.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto_test/option-validator-auto_test-body.go.tmpl rename to src/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-body.go.tmpl diff --git a/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-footer.go.tmpl b/src/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-footer.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto_test/option-validator-auto_test-footer.go.tmpl rename to src/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-footer.go.tmpl diff --git a/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-header.go.tmpl b/src/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-header.go.tmpl similarity index 100% rename from generators/gola/templates/option-validator-auto_test/option-validator-auto_test-header.go.tmpl rename to src/generators/gola/templates/option-validator-auto_test/option-validator-auto_test-header.go.tmpl diff --git a/generators/gola/templates/param-set-auto/param-set-auto-body.go.tmpl b/src/generators/gola/templates/param-set-auto/param-set-auto-body.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-auto/param-set-auto-body.go.tmpl rename to src/generators/gola/templates/param-set-auto/param-set-auto-body.go.tmpl diff --git a/generators/gola/templates/param-set-auto/param-set-auto-footer.go.tmpl b/src/generators/gola/templates/param-set-auto/param-set-auto-footer.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-auto/param-set-auto-footer.go.tmpl rename to src/generators/gola/templates/param-set-auto/param-set-auto-footer.go.tmpl diff --git a/generators/gola/templates/param-set-auto/param-set-auto-header.go.tmpl b/src/generators/gola/templates/param-set-auto/param-set-auto-header.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-auto/param-set-auto-header.go.tmpl rename to src/generators/gola/templates/param-set-auto/param-set-auto-header.go.tmpl diff --git a/generators/gola/templates/param-set-auto_test/param-set-auto_test-body.go.tmpl b/src/generators/gola/templates/param-set-auto_test/param-set-auto_test-body.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-auto_test/param-set-auto_test-body.go.tmpl rename to src/generators/gola/templates/param-set-auto_test/param-set-auto_test-body.go.tmpl diff --git a/generators/gola/templates/param-set-auto_test/param-set-auto_test-footer.go.tmpl b/src/generators/gola/templates/param-set-auto_test/param-set-auto_test-footer.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-auto_test/param-set-auto_test-footer.go.tmpl rename to src/generators/gola/templates/param-set-auto_test/param-set-auto_test-footer.go.tmpl diff --git a/generators/gola/templates/param-set-auto_test/param-set-auto_test-header.go.tmpl b/src/generators/gola/templates/param-set-auto_test/param-set-auto_test-header.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-auto_test/param-set-auto_test-header.go.tmpl rename to src/generators/gola/templates/param-set-auto_test/param-set-auto_test-header.go.tmpl diff --git a/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-body.go.tmpl b/src/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-body.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-body.go.tmpl rename to src/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-body.go.tmpl diff --git a/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-footer.go.tmpl b/src/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-footer.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-footer.go.tmpl rename to src/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-footer.go.tmpl diff --git a/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-header.go.tmpl b/src/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-header.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-header.go.tmpl rename to src/generators/gola/templates/param-set-binder-helpers-auto/param-set-binder-helpers-auto-header.go.tmpl diff --git a/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-body.go.tmpl b/src/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-body.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-body.go.tmpl rename to src/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-body.go.tmpl diff --git a/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-footer.go.tmpl b/src/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-footer.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-footer.go.tmpl rename to src/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-footer.go.tmpl diff --git a/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-header.go.tmpl b/src/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-header.go.tmpl similarity index 100% rename from generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-header.go.tmpl rename to src/generators/gola/templates/param-set-binder-helpers-auto_test/param-set-binder-helpers-auto_test-header.go.tmpl diff --git a/generators/gola/type-spec.go b/src/generators/gola/type-spec.go similarity index 100% rename from generators/gola/type-spec.go rename to src/generators/gola/type-spec.go diff --git a/generators/ps/generate-option-validators.ps1 b/src/generators/ps/generate-option-validators.ps1 similarity index 100% rename from generators/ps/generate-option-validators.ps1 rename to src/generators/ps/generate-option-validators.ps1 diff --git a/generators/signature.OUTPUT.txt b/src/generators/signature.OUTPUT.txt similarity index 100% rename from generators/signature.OUTPUT.txt rename to src/generators/signature.OUTPUT.txt diff --git a/generators/signature.PS-HASH.txt b/src/generators/signature.PS-HASH.txt similarity index 100% rename from generators/signature.PS-HASH.txt rename to src/generators/signature.PS-HASH.txt diff --git a/src/internal/lab/test-utilities.go b/src/internal/lab/test-utilities.go index 8ff597e..3a198ab 100644 --- a/src/internal/lab/test-utilities.go +++ b/src/internal/lab/test-utilities.go @@ -1,11 +1,22 @@ package lab import ( + "io/fs" "path/filepath" "runtime" "strings" ) +var ( + Perms = struct { + File fs.FileMode + Dir fs.FileMode + }{ + File: 0o666, //nolint:mnd // ok (pedantic) + Dir: 0o777, //nolint:mnd // ok (pedantic) + } +) + func Path(parent, relative string) string { segments := strings.Split(relative, "/") return filepath.Join(append([]string{parent}, segments...)...)